[rygel/wip/media-engine: 9/15] server: Remove GStreamer from TimeSeek
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/media-engine: 9/15] server: Remove GStreamer from TimeSeek
- Date: Fri, 28 Sep 2012 16:49:25 +0000 (UTC)
commit e070211d32f1cb4575ed871c923993d0ea4a281c
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 ++++++++++++++++++++++++
tests/rygel-http-time-seek-test.vala | 18 +++++++-------
5 files changed, 64 insertions(+), 22 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 6c7086a..65486de 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)
@@ -156,6 +157,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;
+ }
+}
diff --git a/tests/rygel-http-time-seek-test.vala b/tests/rygel-http-time-seek-test.vala
index b184364..3e7283b 100644
--- a/tests/rygel-http-time-seek-test.vala
+++ b/tests/rygel-http-time-seek-test.vala
@@ -21,8 +21,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using Gst;
-
private errordomain Rygel.TestError {
SKIP
}
@@ -167,7 +165,9 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
Subtitle? subtitle) throws HTTPSeekError {
var request = new HTTPGet (thumbnail, subtitle);
var audio_item = request.item as AudioItem;
- this.test_seek (request, 0, audio_item.duration * SECOND - MSECOND);
+ this.test_seek (request,
+ 0,
+ audio_item.duration * TimeSpan.SECOND - TimeSpan.MILLISECOND);
}
private void test_start_only_seek (Thumbnail? thumbnail,
@@ -189,8 +189,8 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
var audio_item = request.item as AudioItem;
this.test_seek (request,
- 128 * SECOND,
- audio_item.duration * SECOND - MSECOND);
+ 128 * TimeSpan.SECOND,
+ audio_item.duration * TimeSpan.SECOND - TimeSpan.MILLISECOND);
}
private void test_stop_only_seek (Thumbnail? thumbnail,
@@ -213,7 +213,7 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
break;
}
- this.test_seek (request, 0, 128 * SECOND);
+ this.test_seek (request, 0, 128 * TimeSpan.SECOND);
}
private void test_start_stop_seek (Thumbnail? thumbnail,
@@ -248,7 +248,7 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
}
- this.test_seek (request, 128 * SECOND, 256 * SECOND);
+ this.test_seek (request, 128 * TimeSpan.SECOND, 256 * TimeSpan.SECOND);
}
private void test_seek (HTTPGet request,
@@ -262,10 +262,10 @@ private class Rygel.HTTPTimeSeekTest : GLib.Object {
assert (seek != null);
assert (seek.start == start);
assert (seek.stop == stop);
- assert (seek.length == seek.stop + MSECOND - seek.start);
+ assert (seek.length == seek.stop + TimeSpan.MILLISECOND - seek.start);
var audio_item = request.item as AudioItem;
- assert (seek.total_length == audio_item.duration * SECOND);
+ assert (seek.total_length == audio_item.duration * TimeSpan.SECOND);
var header = request.msg.response_headers.get_one
("TimeSeekRange.dlna.org");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]