[rygel] core,playbin: Time represented as int64
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,playbin: Time represented as int64
- Date: Thu, 26 Aug 2010 13:38:08 +0000 (UTC)
commit 27d1bf7fa8616ec2714c21b5733b177ff763661f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Aug 26 15:10:00 2010 +0300
core,playbin: Time represented as int64
Player interface now deals with all time values in nano-seconds as int64.
We should be simply using Gst.ClockTime but that is unfortunately not a
registered type so we can't use that as GObject property. :(
src/plugins/playbin/Makefile.am | 3 +-
src/plugins/playbin/rygel-playbin-player.vala | 21 +++++------
src/plugins/playbin/rygel-playbin-time.vala | 49 -------------------------
src/rygel/rygel-av-transport.vala | 22 +++++++-----
src/rygel/rygel-gst-utils.vala | 20 ++++++++++
src/rygel/rygel-media-player.vala | 18 ++++++++--
6 files changed, 59 insertions(+), 74 deletions(-)
---
diff --git a/src/plugins/playbin/Makefile.am b/src/plugins/playbin/Makefile.am
index f8e59d6..74d0abc 100644
--- a/src/plugins/playbin/Makefile.am
+++ b/src/plugins/playbin/Makefile.am
@@ -18,8 +18,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
-include config.h
librygel_playbin_la_SOURCES = rygel-playbin-player.vala \
- rygel-playbin-plugin.vala \
- rygel-playbin-time.vala
+ rygel-playbin-plugin.vala
librygel_playbin_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
--vapidir=$(srcdir) \
diff --git a/src/plugins/playbin/rygel-playbin-player.vala b/src/plugins/playbin/rygel-playbin-player.vala
index a02c41a..d706eae 100644
--- a/src/plugins/playbin/rygel-playbin-player.vala
+++ b/src/plugins/playbin/rygel-playbin-player.vala
@@ -104,28 +104,28 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
}
}
- public string duration {
- owned get {
+ public int64 duration {
+ get {
var format = Format.TIME;
int64 dur;
if (this.playbin.query_duration (ref format, out dur)) {
- return Time.to_string ((ClockTime) dur);
+ return dur;
} else {
- return "00:00:00";
+ return 0;
}
}
}
- public string position {
- owned get {
+ public int64 position {
+ get {
var format = Format.TIME;
int64 pos;
if (this.playbin.query_position (ref format, out pos)) {
- return Time.to_string ((ClockTime) pos);
+ return pos;
} else {
- return "00:00:00";
+ return 0;
}
}
}
@@ -147,13 +147,12 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
return player;
}
- public bool seek (string time) {
- debug (_("Seeking to %s."), time);
+ public bool seek (ClockTime time) {
return this.playbin.seek (1.0,
Format.TIME,
SeekFlags.FLUSH,
Gst.SeekType.SET,
- Time.from_string (time),
+ time,
Gst.SeekType.NONE,
-1);
}
diff --git a/src/rygel/rygel-av-transport.vala b/src/rygel/rygel-av-transport.vala
index 8243f1d..45f54cd 100644
--- a/src/rygel/rygel-av-transport.vala
+++ b/src/rygel/rygel-av-transport.vala
@@ -185,8 +185,8 @@ internal class Rygel.AVTransport : Service {
log.log ("PossibleRecordQualityMode", "NOT_IMPLEMENTED");
log.log ("NumberOfTracks", this.n_tracks.to_string ());
log.log ("CurrentTrack", this.track.to_string ());
- log.log ("CurrentTrackDuration", this.player.duration);
- log.log ("CurrentMediaDuration", this.player.duration);
+ log.log ("CurrentTrackDuration", this.player.duration_as_str);
+ log.log ("CurrentMediaDuration", this.player.duration_as_str);
log.log ("CurrentTrackMetadata", this.metadata);
log.log ("CurrentTrackURI", this.uri);
log.log ("AVTransportURI", this.uri);
@@ -242,7 +242,7 @@ internal class Rygel.AVTransport : Service {
this.n_tracks,
"MediaDuration",
typeof (string),
- this.player.duration,
+ this.player.duration_as_str,
"CurrentURI",
typeof (string),
this.uri,
@@ -298,7 +298,7 @@ internal class Rygel.AVTransport : Service {
this.track,
"TrackDuration",
typeof (string),
- this.player.duration,
+ this.player.duration_as_str,
"TrackMetaData",
typeof (string),
this.metadata,
@@ -307,10 +307,10 @@ internal class Rygel.AVTransport : Service {
this.uri,
"RelTime",
typeof (string),
- this.player.position,
+ this.player.position_as_str,
"AbsTime",
typeof (string),
- this.player.position,
+ this.player.position_as_str,
"RelCount",
typeof (int),
int.MAX,
@@ -411,7 +411,9 @@ internal class Rygel.AVTransport : Service {
switch (unit) {
case "ABS_TIME":
case "REL_TIME":
- if (!this.player.seek (target)) {
+ debug (_("Seeking to %s."), target);
+
+ if (!this.player.seek (GstUtils.time_from_string (target))) {
action.return_error (710, _("Seek mode not supported"));
return;
@@ -440,7 +442,9 @@ internal class Rygel.AVTransport : Service {
}
private void notify_duration_cb (Object player, ParamSpec p) {
- this.changelog.log ("CurrentTrackDuration", this.player.duration);
- this.changelog.log ("CurrentMediaDuration", this.player.duration);
+ this.changelog.log ("CurrentTrackDuration",
+ this.player.duration_as_str);
+ this.changelog.log ("CurrentMediaDuration",
+ this.player.duration_as_str);
}
}
diff --git a/src/rygel/rygel-gst-utils.vala b/src/rygel/rygel-gst-utils.vala
index 1260f49..fa41500 100644
--- a/src/rygel/rygel-gst-utils.vala
+++ b/src/rygel/rygel-gst-utils.vala
@@ -47,6 +47,26 @@ internal abstract class Rygel.GstUtils {
dest.post_message (msg);
}
+ public static ClockTime time_from_string (string str) {
+ uint64 hours, minutes, seconds;
+
+ str.scanf ("%llu:%2llu:%2llu%*s", out hours, out minutes, out seconds);
+
+ return (ClockTime) ((hours * 3600 + minutes * 60 + seconds) *
+ Gst.SECOND);
+ }
+
+ public static string time_to_string (ClockTime time) {
+ uint64 hours, minutes, seconds;
+
+ hours = time / Gst.SECOND / 3600;
+ seconds = time / Gst.SECOND % 3600;
+ minutes = seconds / 60;
+ seconds = seconds % 60;
+
+ return "%llu:%.2llu:%.2llu".printf (hours, minutes, seconds);
+ }
+
public static dynamic Element? get_rtp_depayloader (Caps caps) {
if (!need_rtp_depayloader (caps)) {
return null;
diff --git a/src/rygel/rygel-media-player.vala b/src/rygel/rygel-media-player.vala
index a378854..4476b2f 100644
--- a/src/rygel/rygel-media-player.vala
+++ b/src/rygel/rygel-media-player.vala
@@ -21,14 +21,26 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+using Gst;
+
public interface Rygel.MediaPlayer : GLib.Object {
public abstract string playback_state { get; set; }
public abstract string uri { get; set; }
public abstract double volume { get; set; }
- public abstract string duration { owned get; }
- public abstract string position { owned get; }
+ public abstract int64 duration { get; }
+ public string duration_as_str {
+ owned get {
+ return GstUtils.time_to_string ((ClockTime) this.duration);
+ }
+ }
+ public abstract int64 position { get; }
+ public string position_as_str {
+ owned get {
+ return GstUtils.time_to_string ((ClockTime) this.position);
+ }
+ }
- public abstract bool seek (string time);
+ public abstract bool seek (ClockTime time);
public abstract string[] get_protocols ();
public abstract string[] get_mime_types ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]