From 6a699b6c40cd6da3be5e669909093caab7cd174e Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 28 Jan 2014 00:19:07 +1100 Subject: [PATCH] decodebin: make it possible to register multiple handlers for autoplug-select Change the way autoplug-select is accumulated so that it's possible to have multiple handlers. The handlers keep getting called as long as they keep returning GST_AUTOPLUG_SELECT_TRY. One practical example of when this is needed is when hooking into playbin's uridecodebin, which is perhaps not very elegant but the only way to influence which streams playbin autoplugs/exposes. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=723096 --- gst/playback/gstdecodebin2.c | 15 ++++++++++++--- gst/playback/gsturidecodebin.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 01f20fcdd9..2695e95e3b 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -611,6 +611,13 @@ _gst_select_accumulator (GSignalInvocationHint * ihint, if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP)) g_value_set_enum (return_accu, res); + /* Call the next handler in the chain (if any) when the current callback + * returns TRY. This makes it possible to register separate autoplug-select + * handlers that implement different TRY/EXPOSE/SKIP strategies. + */ + if (res == GST_AUTOPLUG_SELECT_TRY) + return TRUE; + return FALSE; } @@ -778,9 +785,11 @@ gst_decode_bin_class_init (GstDecodeBinClass * klass) * next factory. * * - * Only the signal handler that is connected first will ever by invoked. - * Don't connect signal handlers with the #G_CONNECT_AFTER flag to this - * signal, they will never be invoked! + * The signal handler will not be invoked if any of the previously + * registered signal handlers (if any) return a value other than + * GST_AUTOPLUG_SELECT_TRY. Which also means that if you return + * GST_AUTOPLUG_SELECT_TRY from one signal handler, handlers that get + * registered next (again, if any) can override that decision. * * * Returns: a #GST_TYPE_AUTOPLUG_SELECT_RESULT that indicates the required diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index 0cd8b9cdbb..744127e7c3 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -272,6 +272,13 @@ _gst_select_accumulator (GSignalInvocationHint * ihint, if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP)) g_value_set_enum (return_accu, res); + /* Call the next handler in the chain (if any) when the current callback + * returns TRY. This makes it possible to register separate autoplug-select + * handlers that implement different TRY/EXPOSE/SKIP strategies. + */ + if (res == GST_AUTOPLUG_SELECT_TRY) + return TRUE; + return FALSE; } @@ -622,9 +629,11 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass) * next factory. * * - * Only the signal handler that is connected first will ever by invoked. - * Don't connect signal handlers with the #G_CONNECT_AFTER flag to this - * signal, they will never be invoked! + * The signal handler will not be invoked if any of the previously + * registered signal handlers (if any) return a value other than + * GST_AUTOPLUG_SELECT_TRY. Which also means that if you return + * GST_AUTOPLUG_SELECT_TRY from one signal handler, handlers that get + * registered next (again, if any) can override that decision. * * * Returns: a #GST_TYPE_AUTOPLUG_SELECT_RESULT that indicates the required