[rygel/wip/media-engine: 9/13] server: Remove GStreamer from TimeSeek



commit 277202a257c7c48ab3fa193593a084e75dc4fd17
Author: Jens Georg <jensg openismus org>
Date:   Tue Sep 11 14:55:50 2012 +0200

    server: Remove GStreamer from TimeSeek

 src/librygel-server/rygel-gst-data-source.vala |    9 +++++-
 src/librygel-server/rygel-http-time-seek.vala  |   20 +++++++-------
 tests/Makefile.am                              |    8 +++++-
 tests/rygel-environment-test.vala              |   31 ++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 13 deletions(-)
---
diff --git a/src/librygel-server/rygel-gst-data-source.vala b/src/librygel-server/rygel-gst-data-source.vala
index 90d8fc2..41cf91a 100644
--- a/src/librygel-server/rygel-gst-data-source.vala
+++ b/src/librygel-server/rygel-gst-data-source.vala
@@ -198,13 +198,18 @@ public class Rygel.GstDataSource : Rygel.DataSource, GLib.Object {
         var stop_type = Gst.SeekType.NONE;
         Format format;
         var flags = SeekFlags.FLUSH;
+        int64 start, stop;
 
         if (this.seek is HTTPTimeSeek) {
             format = Format.TIME;
             flags |= SeekFlags.KEY_UNIT;
+            start = (this.seek.start) * Gst.USECOND;
+            stop = (this.seek.stop) * Gst.USECOND;
         } else {
             format = Format.BYTES;
             flags |= SeekFlags.ACCURATE;
+            start = this.seek.start;
+            stop = this.seek.stop;
         }
 
         if (this.seek.stop > 0) {
@@ -215,9 +220,9 @@ public class Rygel.GstDataSource : Rygel.DataSource, GLib.Object {
                                  format,
                                  flags,
                                  Gst.SeekType.SET,
-                                 this.seek.start,
+                                 start,
                                  stop_type,
-                                 this.seek.stop + 1)) {
+                                 stop + 1)) {
             warning (_("Failed to seek to offsets %lld:%lld"),
                      this.seek.start,
                      this.seek.stop);
diff --git a/src/librygel-server/rygel-http-time-seek.vala b/src/librygel-server/rygel-http-time-seek.vala
index 8597977..00cdbea 100644
--- a/src/librygel-server/rygel-http-time-seek.vala
+++ b/src/librygel-server/rygel-http-time-seek.vala
@@ -1,8 +1,10 @@
 /*
  * Copyright (C) 2009 Nokia Corporation.
+ * Copyright (C) 2012 Intel Corporation.
  *
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  *                               <zeeshan ali nokia com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -21,15 +23,13 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using Gst;
-
 internal class Rygel.HTTPTimeSeek : Rygel.HTTPSeek {
     public HTTPTimeSeek (HTTPGet request) throws HTTPSeekError {
         string range;
         string[] range_tokens;
         int64 start = 0;
-        int64 duration = (request.item as AudioItem).duration * SECOND;
-        int64 stop = duration - MSECOND;
+        int64 duration = (request.item as AudioItem).duration * TimeSpan.SECOND;
+        int64 stop = duration - TimeSpan.MILLISECOND;
         int64 parsed_value = 0;
         bool parsing_start = true;
 
@@ -85,7 +85,7 @@ internal class Rygel.HTTPTimeSeek : Rygel.HTTPSeek {
             }
         }
 
-        base (request.msg, start, stop, MSECOND, duration);
+        base (request.msg, start, stop, TimeSpan.MILLISECOND, duration);
     }
 
     public static bool needed (HTTPGet request) {
@@ -104,9 +104,9 @@ internal class Rygel.HTTPTimeSeek : Rygel.HTTPSeek {
 
     public override void add_response_headers () {
         // TimeSeekRange.dlna.org: npt=START_TIME-END_TIME/DURATION
-        double start = (double) this.start / SECOND;
-        double stop = (double) this.stop / SECOND;
-        double total = (double) this.total_length / SECOND;
+        double start = (double) this.start / TimeSpan.SECOND;
+        double stop = (double) this.stop / TimeSpan.SECOND;
+        double total = (double) this.total_length / TimeSpan.SECOND;
 
         var start_str = new char[double.DTOSTR_BUF_SIZE];
         var stop_str = new char[double.DTOSTR_BUF_SIZE];
@@ -123,7 +123,7 @@ internal class Rygel.HTTPTimeSeek : Rygel.HTTPSeek {
     private static bool parse_seconds (string    range_token,
                                        ref int64 value) {
         if (range_token[0].isdigit ()) {
-            value = (int64) (double.parse (range_token) * SECOND);
+            value = (int64) (double.parse (range_token) * TimeSpan.SECOND);
         } else {
             return false;
         }
@@ -150,7 +150,7 @@ internal class Rygel.HTTPTimeSeek : Rygel.HTTPSeek {
         foreach (string time in time_tokens) {
             if (time[0].isdigit ()) {
                 seconds_sum += (int64) ((double.parse (time) *
-                                         SECOND) * time_factor);
+                                         TimeSpan.SECOND) * time_factor);
             } else {
                 return false;
             }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc431e2..990d19c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -44,7 +44,8 @@ check_PROGRAMS = rygel-http-item-uri-test \
 		 rygel-item-creator-test \
 		 rygel-playbin-renderer-test \
 		 rygel-user-config-test \
-		 rygel-regression
+		 rygel-regression \
+		 rygel-environment-test
 
 TESTS = $(check_PROGRAMS)
 
@@ -154,6 +155,11 @@ rygel_regression_LDADD = \
 	$(top_builddir)/src/librygel-server/librygel-server-1.0.la \
 	$(top_builddir)/src/librygel-core/librygel-core-1.0.la
 
+rygel_environment_test_SOURCES = rygel-environment-test.vala
+rygel_environment_test_CFLAGS = $(AM_CFLAGS)
+rygel_environment_test_LDADD = $(LDADD)
+rygel_environment_test_VALAFLAGS = $(AM_VALAFLAGS) --pkg gstreamer-0.10
+
 if ALWAYS_TEST
 all-local: check
 endif
diff --git a/tests/rygel-environment-test.vala b/tests/rygel-environment-test.vala
new file mode 100644
index 0000000..41a67e1
--- /dev/null
+++ b/tests/rygel-environment-test.vala
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+public class EnvironmentTest {
+    public static int main (string[] args) {
+        // Check that the base of TimeSpan is a micro-second
+        // Otherwise rygel-gst-data-source.vala needs adaption
+        assert (TimeSpan.SECOND * Gst.USECOND == Gst.SECOND);
+
+        return 0;
+    }
+}



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