[rygel] core: Support byte-seek if size is known



commit cccc0c1d502a299154fe850c36391dad94c3c17e
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Jan 21 17:28:30 2011 +0200

    core: Support byte-seek if size is known
    
    We now support byte-seek for all streams where size of content is known.

 src/rygel/rygel-http-gst-response.vala  |    9 ++++++++-
 src/rygel/rygel-media-item.vala         |    5 ++++-
 tests/rygel-http-gst-response-test.vala |    2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-http-gst-response.vala b/src/rygel/rygel-http-gst-response.vala
index 8c494da..379d098 100644
--- a/src/rygel/rygel-http-gst-response.vala
+++ b/src/rygel/rygel-http-gst-response.vala
@@ -195,6 +195,13 @@ internal class Rygel.HTTPGstResponse : Rygel.HTTPResponse {
 
     private bool perform_seek () {
         Gst.SeekType stop_type;
+        Format format;
+
+        if (this.seek is HTTPTimeSeek) {
+            format = Format.TIME;
+        } else {
+            format = Format.BYTES;
+        }
 
         if (this.seek.stop > 0) {
             stop_type = Gst.SeekType.SET;
@@ -203,7 +210,7 @@ internal class Rygel.HTTPGstResponse : Rygel.HTTPResponse {
         }
 
         if (!this.pipeline.seek (1.0,
-                                 Format.TIME,
+                                 format,
                                  SeekFlags.FLUSH,
                                  Gst.SeekType.SET,
                                  this.seek.start,
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 4f9fd40..b0e0002 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -253,12 +253,15 @@ public abstract class Rygel.MediaItem : MediaObject {
         protocol_info.dlna_flags = DLNAFlags.DLNA_V15 |
                                    DLNAFlags.CONNECTION_STALL;
 
+        if (this.size > 0) {
+            protocol_info.dlna_operation = DLNAOperation.RANGE;
+        }
+
         if (this.streamable ()) {
             protocol_info.dlna_flags |= DLNAFlags.STREAMING_TRANSFER_MODE;
         }
 
         if (!this.should_stream ()) {
-            protocol_info.dlna_operation = DLNAOperation.RANGE;
             protocol_info.dlna_flags |= DLNAFlags.BACKGROUND_TRANSFER_MODE;
         }
 
diff --git a/tests/rygel-http-gst-response-test.vala b/tests/rygel-http-gst-response-test.vala
index 85e33cb..3315d11 100644
--- a/tests/rygel-http-gst-response-test.vala
+++ b/tests/rygel-http-gst-response-test.vala
@@ -132,6 +132,8 @@ internal abstract class Rygel.HTTPSeek : GLib.Object {
     public int64 total_length;
 }
 
+internal class Rygel.HTTPTimeSeek : Rygel.HTTPSeek {}
+
 public errordomain Rygel.HTTPRequestError {
     NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND
 }



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