[rygel] engine-gst: Plug unused pads in encodebin



commit 7207b28eda6b37d78608dced13de06f32caa9f60
Author: Jens Georg <mail jensge org>
Date:   Thu May 12 19:00:04 2022 +0200

    engine-gst: Plug unused pads in encodebin
    
    Use silence for audio and black screen for video if we try to transcode
    something where the other is missing
    
    Fixes lock-up in transcoding pipeline if there the source material does
    not have any audio

 .../rygel-gst-transcoding-data-source.vala         | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala 
b/src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala
index 8bd21927b..082ea8f97 100644
--- a/src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala
+++ b/src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala
@@ -138,5 +138,35 @@ internal class Rygel.TranscodingGstDataSource : Rygel.GstDataSource {
             var bus = bin.get_bus ();
             bus.post (message);
         }
+
+        // Check if we have any unlinked sink pads in the encoder...
+        var pad_iterator = this.encoder.iterate_pads ();
+        bool done = false;
+        while (!done) {
+            GLib.Value val;
+            var res = pad_iterator.next (out val);
+            if (res == Gst.IteratorResult.DONE || res == Gst.IteratorResult.ERROR) {
+                done = true;
+            }
+            else if (res == Gst.IteratorResult.OK) {
+                var p = (Gst.Pad) val;
+                if (!p.is_linked ()) {
+                    dynamic Gst.Element src = null;
+                    if (p.name.has_prefix ("audio")) {
+                        src = Gst.ElementFactory.make ("audiotestsrc", null);
+                        src.wave = 4;
+                    } else if (p.name.has_prefix ("video")) {
+                        src = Gst.ElementFactory.make ("videotestsrc", null);
+                        src.pattern = 2;
+                    }
+
+                    ((Gst.Bin)this.encoder.get_parent ()).add (src);
+                    src.link_pads ("src", this.encoder, p.name);
+                    src.sync_state_with_parent ();
+                }
+            } else if (res == Gst.IteratorResult.RESYNC) {
+                pad_iterator.resync ();
+            }
+        }
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]