tools: print "pad-added", "pad-removed" and "no-more-pads" signals for elements with sometimes pads

It's often not obvious to people that elements like e.g. uridecodebin
(or demuxers) automatically support the standard signals of the
GstElement class, so let's print the useful pad-related ones for
elements with sometimes pads.
This commit is contained in:
Tim-Philipp Müller 2011-02-28 14:56:23 +00:00
parent c7881a21b5
commit b923b7f901

View file

@ -880,13 +880,19 @@ print_pad_info (GstElement * element)
}
}
#if 0
static gint
compare_signal_names (GSignalQuery * a, GSignalQuery * b)
static gboolean
has_sometimes_template (GstElement * element)
{
return strcmp (a->signal_name, b->signal_name);
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
GList *l;
for (l = klass->padtemplates; l != NULL; l = l->next) {
if (GST_PAD_TEMPLATE (l->data)->presence == GST_PAD_SOMETIMES)
return TRUE;
}
return FALSE;
}
#endif
static void
print_signal_info (GstElement * element)
@ -901,6 +907,22 @@ print_signal_info (GstElement * element)
for (k = 0; k < 2; k++) {
found_signals = NULL;
/* For elements that have sometimes pads, also list a few useful GstElement
* signals. Put these first, so element-specific ones come later. */
if (k == 0 && has_sometimes_template (element)) {
query = g_new0 (GSignalQuery, 1);
g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
found_signals = g_slist_append (found_signals, query);
query = g_new0 (GSignalQuery, 1);
g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
found_signals = g_slist_append (found_signals, query);
query = g_new0 (GSignalQuery, 1);
g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
query);
found_signals = g_slist_append (found_signals, query);
}
for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
break;