gst-inspect: print ranks with offsets from names

This commit is contained in:
David Schleef 2010-06-11 16:12:33 -07:00
parent 171815c922
commit ad9f5e11d0

View file

@ -172,32 +172,44 @@ print_event_masks (const GstEventMask * masks)
#endif #endif
static const char * static const char *
get_rank_name (gint rank) get_rank_name (char *s, gint rank)
{ {
switch (rank) { static const int ranks[4] = {
case GST_RANK_NONE: GST_RANK_NONE, GST_RANK_MARGINAL, GST_RANK_SECONDARY, GST_RANK_PRIMARY
return "none"; };
case GST_RANK_MARGINAL: static const char *rank_names[4] = { "none", "marginal", "secondary",
return "marginal"; "primary"
case GST_RANK_SECONDARY: };
return "secondary"; int i;
case GST_RANK_PRIMARY: int best_i;
return "primary";
default: best_i = 0;
return "unknown"; for (i = 0; i < 4; i++) {
if (rank == ranks[i])
return rank_names[i];
if (abs (rank - ranks[i]) < abs (rank - ranks[best_i])) {
best_i = i;
} }
} }
sprintf (s, "%s %c %d", rank_names[best_i],
(rank - ranks[best_i] > 0) ? '+' : '-', abs (ranks[best_i] - rank));
return s;
}
static void static void
print_factory_details_info (GstElementFactory * factory) print_factory_details_info (GstElementFactory * factory)
{ {
char s[20];
n_print ("Factory Details:\n"); n_print ("Factory Details:\n");
n_print (" Long name:\t%s\n", factory->details.longname); n_print (" Long name:\t%s\n", factory->details.longname);
n_print (" Class:\t%s\n", factory->details.klass); n_print (" Class:\t%s\n", factory->details.klass);
n_print (" Description:\t%s\n", factory->details.description); n_print (" Description:\t%s\n", factory->details.description);
n_print (" Author(s):\t%s\n", factory->details.author); n_print (" Author(s):\t%s\n", factory->details.author);
n_print (" Rank:\t\t%s (%d)\n", n_print (" Rank:\t\t%s (%d)\n",
get_rank_name (GST_PLUGIN_FEATURE (factory)->rank), get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank),
GST_PLUGIN_FEATURE (factory)->rank); GST_PLUGIN_FEATURE (factory)->rank);
n_print ("\n"); n_print ("\n");
} }