diff --git a/gst/playback/gstdecodebin3.c b/gst/playback/gstdecodebin3.c index 1f18f4e12d4154c6a5f2ecae6e1120cd14a86fd2..9a076c645741ac8709081bc4c0de8b34a95c1b0a 100644 --- a/gst/playback/gstdecodebin3.c +++ b/gst/playback/gstdecodebin3.c @@ -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; break; @@ -1269,7 +1279,9 @@ get_merged_collection (GstDecodebin3 * dbin) for (i = 0; i < nb_stream; i++) { GstStream *stream = gst_stream_collection_get_stream (input->collection, i); - unsorted_streams = g_list_append (unsorted_streams, stream); + if (!g_list_find_custom (unsorted_streams, stream->stream_id, + compare_stream_by_id)) + unsorted_streams = g_list_append (unsorted_streams, stream); } } }