playbin2, uridecodebin: add "source-setup" signal
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 22 Feb 2011 12:56:48 +0000 (12:56 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Thu, 24 Feb 2011 16:53:01 +0000 (16:53 +0000)
Add "source-setup" signal for convenience and discoverability. No need
to figure out "notify::source", look up the notify callback signature,
then do an g_object_get() to get the source element..

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

gst/playback/gstplaybin2.c
gst/playback/gsturidecodebin.c

index 2f2a42e..30aa716 100644 (file)
@@ -509,6 +509,7 @@ enum
   SIGNAL_GET_VIDEO_PAD,
   SIGNAL_GET_AUDIO_PAD,
   SIGNAL_GET_TEXT_PAD,
+  SIGNAL_SOURCE_SETUP,
   LAST_SIGNAL
 };
 
@@ -911,6 +912,24 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
       gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
 
   /**
+   * GstPlayBin2::source-setup:
+   * @playbin: a #GstPlayBin2
+   * @source: source element
+   *
+   * This signal is emitted after the source element has been created, so
+   * it can be configured by setting additional properties (e.g. set a
+   * proxy server for an http source, or set the device and read speed for
+   * an audio cd source). This is functionally equivalent to connecting to
+   * the notify::source signal, but more convenient.
+   *
+   * Since: 0.10.33
+   */
+  gst_play_bin_signals[SIGNAL_SOURCE_SETUP] =
+      g_signal_new ("source-setup", G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+      gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
+
+  /**
    * GstPlayBin2::get-video-tags
    * @playbin: a #GstPlayBin2
    * @stream: a video stream number
@@ -3121,6 +3140,9 @@ notify_source_cb (GstElement * uridecodebin, GParamSpec * pspec,
   GST_OBJECT_UNLOCK (playbin);
 
   g_object_notify (G_OBJECT (playbin), "source");
+
+  g_signal_emit (playbin, gst_play_bin_signals[SIGNAL_SOURCE_SETUP],
+      0, playbin->source);
 }
 
 /* must be called with the group lock */
index af2d3dd..f4551e3 100644 (file)
@@ -149,6 +149,7 @@ enum
   SIGNAL_AUTOPLUG_SELECT,
   SIGNAL_DRAINED,
   SIGNAL_AUTOPLUG_SORT,
+  SIGNAL_SOURCE_SETUP,
   LAST_SIGNAL
 };
 
@@ -618,6 +619,24 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
       G_STRUCT_OFFSET (GstURIDecodeBinClass, drained), NULL, NULL,
       gst_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE);
 
+  /**
+   * GstURIDecodeBin::source-setup:
+   * @bin: the uridecodebin.
+   * @source: source element
+   *
+   * This signal is emitted after the source element has been created, so
+   * it can be configured by setting additional properties (e.g. set a
+   * proxy server for an http source, or set the device and read speed for
+   * an audio cd source). This is functionally equivalent to connecting to
+   * the notify::source signal, but more convenient.
+   *
+   * Since: 0.10.33
+   */
+  gst_uri_decode_bin_signals[SIGNAL_SOURCE_SETUP] =
+      g_signal_new ("source-setup", G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+      gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
+
   gstelement_class->query = GST_DEBUG_FUNCPTR (gst_uri_decode_bin_query);
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_uri_decode_bin_change_state);
@@ -1877,6 +1896,9 @@ setup_source (GstURIDecodeBin * decoder)
   /* notify of the new source used */
   g_object_notify (G_OBJECT (decoder), "source");
 
+  g_signal_emit (decoder, gst_uri_decode_bin_signals[SIGNAL_SOURCE_SETUP],
+      0, decoder->source);
+
   /* remove the old decoders now, if any */
   remove_decoders (decoder, FALSE);