Commit abef66c9 authored by Alicia Boya García's avatar Alicia Boya García
Browse files

decodebin3: Avoid duplicate streams

Elements emitting stream collections do so by not only posting the
GST_MESSAGE_STREAM_COLLECTION, but also then pushing a
GST_EVENT_STREAM_COLLECTION through each srcpad.

The latter is how decodebin3 detects stream collections itself, as
the GST_MESSAGE_STREAM_COLLECTION may be posted before the source
element is added to the pipeline and therefore missed.

But it should be noted: when the source has two srcpads the stream
collection event is received twice!

When decodebin3 receives several stream collections it reacts by
creating a new one combining all the streams... But the code doing so
did not take into account the case mentioned before, where both
collections are actually the same and have the same streams. This patch
fixes that.
parent ece392e9
Pipeline #94585 failed with stages
in 6 minutes and 15 seconds
......@@ -1217,6 +1217,14 @@ sort_streams (GstStream * sa, GstStream * sb)
return ret;
static gint
compare_stream_by_id (const void *_stream, const void *_stream_id)
const GstStream *stream = (const GstStream *) _stream;
const gchar *stream_id = (const gchar *) _stream_id;
return g_strcmp0 (stream->stream_id, stream_id);
/* Call with INPUT_LOCK taken */
static GstStreamCollection *
get_merged_collection (GstDecodebin3 * dbin)
......@@ -1230,9 +1238,11 @@ get_merged_collection (GstDecodebin3 * dbin)
/* First check if we need to do a merge or just return the only collection */
res = dbin->main_input->collection;
/* Look for an existing collection that is different than the one we are
* merging with. */
for (tmp = dbin->other_inputs; tmp; tmp = tmp->next) {
DecodebinInput *input = (DecodebinInput *) tmp->data;
if (input->collection) {
if (input->collection && input->collection != res) {
if (res) {
needs_merge = TRUE;
......@@ -1269,6 +1279,8 @@ get_merged_collection (GstDecodebin3 * dbin)
for (i = 0; i < nb_stream; i++) {
GstStream *stream =
gst_stream_collection_get_stream (input->collection, i);
if (!g_list_find_custom (unsorted_streams, stream->stream_id,
unsorted_streams = g_list_append (unsorted_streams, stream);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment