playbin: add "element-setup" signal
authorTim-Philipp Müller <tim@centricular.com>
Sat, 14 May 2016 10:28:01 +0000 (11:28 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 16 May 2016 08:23:45 +0000 (09:23 +0100)
Allows configuration of plugged elements.

https://bugzilla.gnome.org/show_bug.cgi?id=578933

gst/playback/gstplaybin2.c

index b4b7478..e939fa6 100644 (file)
@@ -603,6 +603,7 @@ enum
   SIGNAL_GET_AUDIO_PAD,
   SIGNAL_GET_TEXT_PAD,
   SIGNAL_SOURCE_SETUP,
+  SIGNAL_ELEMENT_SETUP,
   LAST_SIGNAL
 };
 
@@ -622,6 +623,8 @@ static GstStateChangeReturn gst_play_bin_change_state (GstElement * element,
     GstStateChange transition);
 
 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 void gst_play_bin_set_context (GstElement * element,
     GstContext * context);
@@ -1178,6 +1181,27 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
       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
    * @playbin: a #GstPlayBin
    * @stream: a video stream number
@@ -1321,6 +1345,8 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
 
   gstbin_klass->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
@@ -3010,6 +3036,18 @@ gst_play_bin_handle_message (GstBin * bin, GstMessage * 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
 combiner_active_pad_changed (GObject * combiner, GParamSpec * pspec,
     GstPlayBin * playbin)
 {