[rygel] engine-gst: Use GES for time seeking during transcoding



commit 0c932b68f5f9930f5773a76e5266279d883f59e5
Author: Jens Georg <mail jensge org>
Date:   Sun May 3 18:50:42 2020 +0200

    engine-gst: Use GES for time seeking during transcoding
    
    Fixes #157

 meson.build                                        |  3 +-
 .../gstreamer/rygel-gst-data-source.vala           |  8 ++--
 .../gstreamer/rygel-gst-media-engine.vala          |  1 +
 .../rygel-gst-transcoding-data-source.vala         | 46 ++++++++++++++++------
 4 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/meson.build b/meson.build
index 007eda1b..5a3f8867 100644
--- a/meson.build
+++ b/meson.build
@@ -93,6 +93,7 @@ gstreamer_base = dependency('gstreamer-base-1.0', version : '>= 1.0', disabler:
 gstreamer_audio = dependency('gstreamer-audio-1.0', version : '>= 1.0', disabler: true, required: 
get_option('gstreamer'))
 gstreamer_video = dependency('gstreamer-video-1.0', version : '>= 1.0', disabler: true, required: 
get_option('gstreamer'))
 gstreamer_tag = dependency('gstreamer-tag-1.0', version : '>= 1.0', disabler: true, required: 
get_option('gstreamer'))
+gstreamer_es = dependency('gst-editing-services-1.0', version : '>= 1.16', disabler: true, required : 
get_option('gstreamer'))
 gupnp_dlna_gst = dependency('gupnp-dlna-gst-2.0', version: '>= 0.9.4', disabler: true, required: 
get_option('gstreamer'))
 
 gdk_pixbuf = dependency('gdk-pixbuf-2.0')
@@ -121,7 +122,7 @@ renderer_gst_deps = common_deps + [gstreamer, gstreamer_audio]
 server_deps = common_deps + [gssdp, gupnp_av, soup, mediaart, gmodule, libxml]
 db_deps = common_deps + [gupnp_av, gio, sqlite, unistring]
 media_engine_gst_dep = [gee, gupnp_av, libxml, gio, gstreamer, gstreamer_pbu,
-                        gstreamer_base, gupnp_dlna, math]
+                        gstreamer_base, gupnp_dlna, math, gstreamer_es]
 ruih_deps = common_deps
 rygel_deps = common_deps
 
diff --git a/src/media-engines/gstreamer/rygel-gst-data-source.vala 
b/src/media-engines/gstreamer/rygel-gst-data-source.vala
index b16562d2..ca177173 100644
--- a/src/media-engines/gstreamer/rygel-gst-data-source.vala
+++ b/src/media-engines/gstreamer/rygel-gst-data-source.vala
@@ -36,8 +36,10 @@ internal class Rygel.GstDataSource : Rygel.DataSource, GLib.Object {
     private HTTPSeekRequest seek = null;
     private GstSink sink;
     private uint bus_watch_id;
+    string uri = null;
 
     public GstDataSource (string uri, MediaResource ? resource) throws Error {
+        this.uri = uri;
         this.res = resource;
         this.src = GstUtils.create_source_for_uri (uri);
         if (this.src == null) {
@@ -61,8 +63,8 @@ internal class Rygel.GstDataSource : Rygel.DataSource, GLib.Object {
         this.src = element;
     }
 
-    public HTTPSeekRequest? get_seek_request () {
-        return this.seek;
+    public string get_uri () {
+        return this.uri;
     }
 
     public virtual Gee.List<HTTPResponseElement>? preroll
@@ -284,7 +286,7 @@ internal class Rygel.GstDataSource : Rygel.DataSource, GLib.Object {
         return ret;
     }
 
-    private bool perform_seek () {
+    public virtual bool perform_seek () {
         var stop_type = Gst.SeekType.NONE;
         Format format;
         var flags = SeekFlags.FLUSH;
diff --git a/src/media-engines/gstreamer/rygel-gst-media-engine.vala 
b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
index f21fa5fb..4883c642 100644
--- a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
+++ b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
@@ -35,6 +35,7 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
         unowned string[] args = null;
 
         Gst.init (ref args);
+        GES.init ();
         Gst.preset_set_app_dir (BuildConfig.PRESET_DIR);
 
         /* Get the possible DLNA profiles
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 bd9451d5..8bd21927 100644
--- a/src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala
+++ b/src/media-engines/gstreamer/rygel-gst-transcoding-data-source.vala
@@ -43,22 +43,44 @@ internal class Rygel.TranscodingGstDataSource : Rygel.GstDataSource {
                                          throws Error {
         var bin = (Gst.Bin) this.src;
 
-        this.decoder = GstUtils.create_element (DECODE_BIN, DECODE_BIN);
-        debug ("%s using the following encoding profile:",
-                this.get_class ().get_type ().name ());
-                GstUtils.dump_encoding_profile (encoder.profile);
-
-        bin.add_many (orig_source.src, decoder);
-
-        orig_source.src.link (decoder);
-
-        decoder.autoplug_continue.connect (this.on_decode_autoplug_continue);
-        decoder.pad_added.connect (this.on_decoder_pad_added);
-        decoder.no_more_pads.connect (this.on_no_more_pads);
+        if (seek_request == null || seek_request is HTTPByteSeekRequest) {
+            this.decoder = GstUtils.create_element (DECODE_BIN, DECODE_BIN);
+            debug ("%s using the following encoding profile:",
+                    this.get_class ().get_type ().name ());
+                    GstUtils.dump_encoding_profile (encoder.profile);
+
+            bin.add_many (orig_source.src, decoder);
+            orig_source.src.link (decoder);
+            orig_source.src.sync_state_with_parent ();
+            decoder.sync_state_with_parent ();
+
+            decoder.autoplug_continue.connect (this.on_decode_autoplug_continue);
+            decoder.pad_added.connect (this.on_decoder_pad_added);
+            decoder.no_more_pads.connect (this.on_no_more_pads);
+        } else {
+            var time_seek = (HTTPTimeSeekRequest) seek_request;
+
+            var timeline = new GES.Timeline.audio_video ();
+            var layer = timeline.append_layer ();
+            var clip = new GES.UriClip (this.orig_source.get_uri ());
+            clip.in_point = time_seek.start_time * Gst.USECOND;
+            clip.duration = time_seek.range_duration * Gst.USECOND;
+            layer.add_clip (clip);
+            timeline.commit ();
+            var gessrc = GstUtils.create_element ("gessrc", "gessrc");
+            bin.add (gessrc);
+            gessrc.pad_added.connect (this.on_decoder_pad_added);
+            gessrc.no_more_pads.connect (this.on_no_more_pads);
+            gessrc.set ("timeline", timeline, null);
+        }
 
         return base.preroll (seek_request, playspeed_request);
     }
 
+    public override bool perform_seek () {
+        return true;
+    }
+
     private Gst.Pad? get_compatible_sink_pad (Pad pad, Caps caps) {
         var sinkpad = this.encoder.get_compatible_pad (pad, null);
 


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