diff options
author | Jens Georg <mail@jensge.org> | 2022-05-12 19:00:04 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-05-12 19:00:04 +0200 |
commit | 7207b28eda6b37d78608dced13de06f32caa9f60 (patch) | |
tree | 012f75612ea45b35eebae004dd8a69ccacda8405 | |
parent | 66360a77b90eeb15c1adf927421aa75a711fb89d (diff) | |
download | rygel-7207b28eda6b37d78608dced13de06f32caa9f60.tar.gz |
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
-rw-r--r-- | src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala | 30 |
1 files changed, 30 insertions, 0 deletions
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 8bd21927..082ea8f9 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 (); + } + } } } |