From c5304751ab02bd5b295c89f99f2d38b2274b7929 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 17 Jun 2023 07:15:23 -0400 Subject: [PATCH] uridecodebin: Handle non dynamic sources with several source pads Part-of: --- .../testsuites/validate.testslist | 1 + ...n_source_with_several_srcpads.validatetest | 4 ++ .../gst/playback/gsturidecodebin.c | 53 ++++++++++--------- 3 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 subprojects/gst-integration-testsuites/testsuites/validate/uridecodebin/uridecodebin_source_with_several_srcpads.validatetest diff --git a/subprojects/gst-integration-testsuites/testsuites/validate.testslist b/subprojects/gst-integration-testsuites/testsuites/validate.testslist index 69f6613ee1..3a50625a94 100644 --- a/subprojects/gst-integration-testsuites/testsuites/validate.testslist +++ b/subprojects/gst-integration-testsuites/testsuites/validate.testslist @@ -955,3 +955,4 @@ validate.test.rtp.h264.payloader_nego_profile validate.test.rtp.rtpsession_recv_simple validate.test.rtp.rtpsession_send_simple validate.test.scaletempo.playbin_audio_filter.fast_forward +validate.test.uridecodebin.uridecodebin_source_with_several_srcpads diff --git a/subprojects/gst-integration-testsuites/testsuites/validate/uridecodebin/uridecodebin_source_with_several_srcpads.validatetest b/subprojects/gst-integration-testsuites/testsuites/validate/uridecodebin/uridecodebin_source_with_several_srcpads.validatetest new file mode 100644 index 0000000000..6426d99cf2 --- /dev/null +++ b/subprojects/gst-integration-testsuites/testsuites/validate/uridecodebin/uridecodebin_source_with_several_srcpads.validatetest @@ -0,0 +1,4 @@ +meta, + args = { + "uridecodebin uri=\"ges:+track video +track audio +test-clip blue d=1.0\" name=d ! fakesink d. ! fakesink", + }, diff --git a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c index ead0e78673..27ec4f3c40 100644 --- a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c +++ b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c @@ -2185,7 +2185,7 @@ remove_source (GstURIDecodeBin * bin) } /* is called when a dynamic source element created a new pad. */ -static void +static gboolean source_new_pad (GstElement * element, GstPad * pad, GstURIDecodeBin * bin) { GstElement *decoder; @@ -2208,7 +2208,7 @@ source_new_pad (GstElement * element, GstPad * pad, GstURIDecodeBin * bin) GST_URI_DECODE_BIN_UNLOCK (bin); gst_caps_unref (rawcaps); expose_decoded_pad (element, pad, bin); - return; + return TRUE; } gst_caps_unref (rawcaps); @@ -2228,14 +2228,14 @@ source_new_pad (GstElement * element, GstPad * pad, GstURIDecodeBin * bin) gst_element_sync_state_with_parent (decoder); GST_URI_DECODE_BIN_UNLOCK (bin); - return; + return TRUE; /* ERRORS */ no_decodebin: { /* error was posted */ GST_URI_DECODE_BIN_UNLOCK (bin); - return; + return FALSE; } could_not_link: { @@ -2244,7 +2244,7 @@ could_not_link: (NULL), ("Can't link source to decoder element")); GST_URI_DECODE_BIN_UNLOCK (bin); do_async_done (bin); - return; + return FALSE; } } @@ -2265,12 +2265,27 @@ is_live_source (GstElement * source) return is_live; } +typedef struct +{ + GstURIDecodeBin *decoder; + gboolean res; +} ExposeSourceData; + +static gboolean +expose_source_pad (GstElement * element, GstPad * pad, ExposeSourceData * data) +{ + data->res |= source_new_pad (element, pad, data->decoder); + + return TRUE; +} + /* construct and run the source and decoder elements until we found * all the streams or until a preroll queue has been filled. */ static gboolean setup_source (GstURIDecodeBin * decoder) { + gboolean res = TRUE; gboolean is_raw, have_out, is_dynamic; GstElement *source; @@ -2355,20 +2370,19 @@ setup_source (GstURIDecodeBin * decoder) if (!setup_streaming (decoder)) goto streaming_failed; } else { - GstElement *dec_elem; + ExposeSourceData data = { decoder, FALSE }; - /* no streaming source, we can link now */ - GST_DEBUG_OBJECT (decoder, "Plugging decodebin to source"); + GST_DEBUG_OBJECT (decoder, "Expose %" GST_PTR_FORMAT " srcpads", + decoder->source); - dec_elem = make_decoder (decoder); - if (!dec_elem) - goto no_decoder; + /* error message is posted if expose_source_pad fails */ + gst_element_foreach_src_pad (decoder->source, + (GstElementForeachPadFunc) expose_source_pad, &data); - if (!gst_element_link_pads (decoder->source, NULL, dec_elem, "sink")) - goto could_not_link; + res = data.res; } } - return TRUE; + return res; /* ERRORS */ no_source: @@ -2388,22 +2402,11 @@ invalid_source: (_("Source element is invalid.")), (NULL)); return FALSE; } -no_decoder: - { - /* message was posted */ - return FALSE; - } streaming_failed: { /* message was posted */ return FALSE; } -could_not_link: - { - GST_ELEMENT_ERROR (decoder, CORE, NEGOTIATION, - (NULL), ("Can't link source to decoder element")); - return FALSE; - } } static void