transcodebin: Accept more than one stream
authorPhilippe Normand <philn@igalia.com>
Sun, 25 Oct 2020 18:04:05 +0000 (18:04 +0000)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 29 Oct 2020 13:30:07 +0000 (13:30 +0000)
Look-up the stream matching the given ID also after building the stream list
from the received collection. Without this change the transcoder would discard
the second incoming stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1151>

gst/transcode/gsttranscodebin.c

index 8730a54..169e966 100644 (file)
@@ -524,16 +524,18 @@ select_stream_cb (GstElement * decodebin,
 {
   gint i;
   gboolean transcode_stream = FALSE;
+  guint len = 0;
 
   GST_OBJECT_LOCK (self);
-  if (self->transcoding_streams->len) {
-    GST_OBJECT_UNLOCK (self);
+  len = self->transcoding_streams->len;
+  GST_OBJECT_UNLOCK (self);
 
+  if (len) {
     transcode_stream =
         find_stream (self, gst_stream_get_stream_id (stream), NULL) != NULL;
-    goto done;
+    if (transcode_stream)
+      goto done;
   }
-  GST_OBJECT_UNLOCK (self);
 
   for (i = 0; i < gst_stream_collection_get_size (collection); i++) {
     GstStream *tmpstream = gst_stream_collection_get_stream (collection, i);
@@ -555,6 +557,15 @@ select_stream_cb (GstElement * decodebin,
     }
   }
 
+  GST_OBJECT_LOCK (self);
+  len = self->transcoding_streams->len;
+  GST_OBJECT_UNLOCK (self);
+
+  if (len) {
+    transcode_stream =
+        find_stream (self, gst_stream_get_stream_id (stream), NULL) != NULL;
+  }
+
 done:
   if (!transcode_stream)
     GST_INFO_OBJECT (self, "Discarding stream: %" GST_PTR_FORMAT, stream);