playbin2, uridecodebin: add "source-setup" signal

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
This commit is contained in:
Tim-Philipp Müller 2011-02-22 12:56:48 +00:00
parent 461d9f2f2c
commit c48c193b56
2 changed files with 44 additions and 0 deletions

View file

@ -509,6 +509,7 @@ enum
SIGNAL_GET_VIDEO_PAD,
SIGNAL_GET_AUDIO_PAD,
SIGNAL_GET_TEXT_PAD,
SIGNAL_SOURCE_SETUP,
LAST_SIGNAL
};
@ -910,6 +911,24 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
G_STRUCT_OFFSET (GstPlayBinClass, text_tags_changed), NULL, NULL,
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
@ -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 */

View 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);