playbin: add "element-setup" signal

Allows configuration of plugged elements.

https://bugzilla.gnome.org/show_bug.cgi?id=578933
This commit is contained in:
Tim-Philipp Müller 2016-05-14 11:28:01 +01:00
parent 7c5ee9d3ef
commit 7c2cabd407

View file

@ -603,6 +603,7 @@ enum
SIGNAL_GET_AUDIO_PAD, SIGNAL_GET_AUDIO_PAD,
SIGNAL_GET_TEXT_PAD, SIGNAL_GET_TEXT_PAD,
SIGNAL_SOURCE_SETUP, SIGNAL_SOURCE_SETUP,
SIGNAL_ELEMENT_SETUP,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -622,6 +623,8 @@ static GstStateChangeReturn gst_play_bin_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
static void gst_play_bin_handle_message (GstBin * bin, GstMessage * message); static void gst_play_bin_handle_message (GstBin * bin, GstMessage * message);
static void gst_play_bin_deep_element_added (GstBin * playbin, GstBin * sub_bin,
GstElement * child);
static gboolean gst_play_bin_query (GstElement * element, GstQuery * query); static gboolean gst_play_bin_query (GstElement * element, GstQuery * query);
static void gst_play_bin_set_context (GstElement * element, static void gst_play_bin_set_context (GstElement * element,
GstContext * context); GstContext * context);
@ -1177,6 +1180,27 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
G_SIGNAL_RUN_LAST, 0, NULL, NULL, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_ELEMENT); g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
/**
* GstPlayBin::element-setup:
* @playbin: a #GstPlayBin
* @element: an element that was added to the playbin hierarchy
*
* This signal is emitted when a new element is added to playbin or any of
* its sub-bins. This signal can be used to configure elements, e.g. to set
* properties on decoders. This is functionally equivalent to connecting to
* the deep-element-added signal, but more convenient.
*
* This signal is usually emitted from the context of a GStreamer streaming
* thread, so might be called at the same time as code running in the main
* application thread.
*
* Since: 1.10
*/
gst_play_bin_signals[SIGNAL_ELEMENT_SETUP] =
g_signal_new ("element-setup", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
/** /**
* GstPlayBin::get-video-tags * GstPlayBin::get-video-tags
* @playbin: a #GstPlayBin * @playbin: a #GstPlayBin
@ -1321,6 +1345,8 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
gstbin_klass->handle_message = gstbin_klass->handle_message =
GST_DEBUG_FUNCPTR (gst_play_bin_handle_message); GST_DEBUG_FUNCPTR (gst_play_bin_handle_message);
gstbin_klass->deep_element_added =
GST_DEBUG_FUNCPTR (gst_play_bin_deep_element_added);
} }
static void static void
@ -3009,6 +3035,18 @@ gst_play_bin_handle_message (GstBin * bin, GstMessage * msg)
GST_BIN_CLASS (parent_class)->handle_message (bin, msg); GST_BIN_CLASS (parent_class)->handle_message (bin, msg);
} }
static void
gst_play_bin_deep_element_added (GstBin * playbin, GstBin * sub_bin,
GstElement * child)
{
GST_LOG_OBJECT (playbin, "element %" GST_PTR_FORMAT " was added to "
"%" GST_PTR_FORMAT, child, sub_bin);
g_signal_emit (playbin, gst_play_bin_signals[SIGNAL_ELEMENT_SETUP], 0, child);
GST_BIN_CLASS (parent_class)->deep_element_added (playbin, sub_bin, child);
}
static void static void
combiner_active_pad_changed (GObject * combiner, GParamSpec * pspec, combiner_active_pad_changed (GObject * combiner, GParamSpec * pspec,
GstPlayBin * playbin) GstPlayBin * playbin)