diff options
author | Jens Georg <jensg@openismus.com> | 2012-09-27 14:44:59 +0200 |
---|---|---|
committer | Jens Georg <jensg@openismus.com> | 2012-10-05 17:33:28 +0200 |
commit | 8a921d181288059cc4715f3c2267d6ff4826c0f9 (patch) | |
tree | 4acb9cbf99c7ffa344cf8bdd929adcc2c6280691 /src | |
parent | 92b120e9d44126c96d298e33d7bc9f0f3f35b013 (diff) | |
download | rygel-8a921d181288059cc4715f3c2267d6ff4826c0f9.tar.gz |
renderer: Remove GStreamer references
Change API to be more like libserver. Extract Playbin-specific implementation
into an additional library.
Diffstat (limited to 'src')
18 files changed, 180 insertions, 27 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e18dcf31..754e42d4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,7 @@ -SUBDIRS = librygel-core librygel-renderer librygel-server rygel media-engines plugins +SUBDIRS = librygel-core librygel-renderer librygel-server librygel-renderer-gst + +SUBDIRS += rygel media-engines plugins + if BUILD_UI SUBDIRS += ui endif diff --git a/src/librygel-renderer-gst/Makefile.am b/src/librygel-renderer-gst/Makefile.am new file mode 100644 index 00000000..7a85651f --- /dev/null +++ b/src/librygel-renderer-gst/Makefile.am @@ -0,0 +1,34 @@ +include ../../common.am +include $(srcdir)/filelist.am + +librygel_renderer_includedir=$(includedir)/rygel-1.0 +librygel_renderer_include_HEADERS = rygel-renderer-gst.h + +lib_LTLIBRARIES = librygel-renderer-gst-1.0.la + +LIBRYGEL_RENDERER_GST_VERSION=0:0:0 + +librygel_renderer_gst_1_0_la_SOURCES = \ + $(LIBRYGEL_RENDERER_GST_VAPI_SOURCE_FILES) \ + $(LIBRYGEL_RENDERER_GST_NONVAPI_SOURCE_FILES) + +AM_CFLAGS += -DG_LOG_DOMAIN=\"Rygel\" \ + $(LIBGSTREAMER_CFLAGS) + +librygel_renderer_gst_1_0_la_VALAFLAGS = \ + -H rygel-renderer-gst.h --library=rygel-renderer-gst-1.0 \ + $(LIBRYGEL_RENDERER_GST_VALAFLAGS_PKG) \ + $(RYGEL_COMMON_RENDERER_PLUGIN_VALAFLAGS) +librygel_renderer_gst_1_0_la_LIBADD = \ + $(RYGEL_COMMON_RENDERER_LIBS) \ + $(LIBGSTREAMER_LIBS) \ + $(LIBGUPNP_AV_LIBS) +librygel_renderer_gst_1_0_la_LDFLAGS = -version-info $(LIBRYGEL_RENDERER_GST_VERSION) + +rygel-renderer-gst.h rygel-renderer-gst-1.0.vapi: \ + librygel_renderer_gst_1_0_la_vala.stamp + +vapidir = $(VAPIDIR) +vapi_DATA = rygel-renderer-gst-1.0.vapi rygel-renderer-gst-1.0.deps + +EXTRA_DIST=rygel-renderer-gst.h rygel-renderer-gst-1.0.vapi rygel-renderer-gst-1.0.deps diff --git a/src/librygel-renderer-gst/filelist.am b/src/librygel-renderer-gst/filelist.am new file mode 100644 index 00000000..c6fcc9d0 --- /dev/null +++ b/src/librygel-renderer-gst/filelist.am @@ -0,0 +1,8 @@ +LIBRYGEL_RENDERER_GST_VAPI_SOURCE_FILES = \ + rygel-playbin-player.vala \ + rygel-playbin-plugin.vala \ + rygel-playbin-renderer.vala + +LIBRYGEL_RENDERER_GST_NONVAPI_SOURCE_FILES = + +LIBRYGEL_RENDERER_GST_VALAFLAGS_PKG = --pkg gstreamer-0.10 diff --git a/src/librygel-renderer/rygel-gst-utils.vala b/src/librygel-renderer-gst/rygel-gst-utils.vala index ff512ae1..ff512ae1 100644 --- a/src/librygel-renderer/rygel-gst-utils.vala +++ b/src/librygel-renderer-gst/rygel-gst-utils.vala diff --git a/src/librygel-renderer/rygel-playbin-player.vala b/src/librygel-renderer-gst/rygel-playbin-player.vala index 43c069b3..5f3a2c41 100644 --- a/src/librygel-renderer/rygel-playbin-player.vala +++ b/src/librygel-renderer-gst/rygel-playbin-player.vala @@ -233,7 +233,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer { int64 dur; if (this.playbin.query_duration (ref format, out dur)) { - return dur; + return dur / Gst.USECOND; } else { return 0; } @@ -246,7 +246,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer { int64 pos; if (this.playbin.query_position (ref format, out pos)) { - return pos; + return pos / Gst.USECOND; } else { return 0; } @@ -275,12 +275,12 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer { return player; } - public bool seek (ClockTime time) { + public bool seek (int64 time) { return this.playbin.seek (1.0, Format.TIME, SeekFlags.FLUSH, Gst.SeekType.SET, - (int64) time, + time * Gst.USECOND, Gst.SeekType.NONE, -1); } diff --git a/src/librygel-renderer/rygel-playbin-plugin.vala b/src/librygel-renderer-gst/rygel-playbin-plugin.vala index ce556afa..ce556afa 100644 --- a/src/librygel-renderer/rygel-playbin-plugin.vala +++ b/src/librygel-renderer-gst/rygel-playbin-plugin.vala diff --git a/src/librygel-renderer/rygel-playbin-renderer.vala b/src/librygel-renderer-gst/rygel-playbin-renderer.vala index 62bba08c..62bba08c 100644 --- a/src/librygel-renderer/rygel-playbin-renderer.vala +++ b/src/librygel-renderer-gst/rygel-playbin-renderer.vala diff --git a/src/librygel-renderer-gst/rygel-renderer-gst-1.0.deps b/src/librygel-renderer-gst/rygel-renderer-gst-1.0.deps new file mode 100644 index 00000000..83c39ae9 --- /dev/null +++ b/src/librygel-renderer-gst/rygel-renderer-gst-1.0.deps @@ -0,0 +1,2 @@ +rygel-renderer-1.0 +gstreamer-0.10 diff --git a/src/librygel-renderer/Makefile.am b/src/librygel-renderer/Makefile.am index 11528227..4637e62f 100644 --- a/src/librygel-renderer/Makefile.am +++ b/src/librygel-renderer/Makefile.am @@ -12,9 +12,7 @@ librygel_renderer_1_0_la_SOURCES = \ $(LIBRYGEL_RENDERER_VAPI_SOURCE_FILES) \ $(LIBRYGEL_RENDERER_NONVAPI_SOURCE_FILES) -librygel_renderer_1_0_la_CFLAGS = \ - $(AM_CFLAGS) \ - $(LIBGSTREAMER_CFLAGS) +AM_CFLAGS += -DG_LOG_DOMAIN=\"Rygel\" librygel_renderer_1_0_la_VALAFLAGS = \ -H rygel-renderer.h --library=rygel-renderer-1.0 \ diff --git a/src/librygel-renderer/filelist.am b/src/librygel-renderer/filelist.am index 3209f51e..5048e791 100644 --- a/src/librygel-renderer/filelist.am +++ b/src/librygel-renderer/filelist.am @@ -1,16 +1,14 @@ LIBRYGEL_RENDERER_VAPI_SOURCE_FILES = \ - rygel-playbin-player.vala \ - rygel-playbin-plugin.vala \ rygel-media-renderer-plugin.vala \ rygel-media-player.vala \ - rygel-playbin-renderer.vala + rygel-media-renderer.vala LIBRYGEL_RENDERER_NONVAPI_SOURCE_FILES = \ rygel-av-transport.vala \ rygel-rendering-control.vala \ rygel-sink-connection-manager.vala \ + rygel-time-utils.vala \ rygel-changelog.vala \ - rygel-gst-utils.vala \ rygel-volume.vala -LIBRYGEL_RENDERER_VALAFLAGS_PKG = --pkg gstreamer-0.10 +LIBRYGEL_RENDERER_VALAFLAGS_PKG = diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala index 3f5e6767..28b57e4b 100644 --- a/src/librygel-renderer/rygel-av-transport.vala +++ b/src/librygel-renderer/rygel-av-transport.vala @@ -522,7 +522,7 @@ internal class Rygel.AVTransport : Service { case "REL_TIME": debug ("Seeking to %s.", target); - if (!this.player.seek (GstUtils.time_from_string (target))) { + if (!this.player.seek (TimeUtils.time_from_string (target))) { action.return_error (710, _("Seek mode not supported")); return; diff --git a/src/librygel-renderer/rygel-media-player.vala b/src/librygel-renderer/rygel-media-player.vala index 26cc0711..6017caad 100644 --- a/src/librygel-renderer/rygel-media-player.vala +++ b/src/librygel-renderer/rygel-media-player.vala @@ -22,8 +22,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -using Gst; - /** * Interface for mapping AVTransport:2 methods to the specific implementation. * @@ -33,23 +31,27 @@ public interface Rygel.MediaPlayer : GLib.Object { public abstract string playback_state { owned get; set; } public abstract string? uri { owned get; set; } public abstract double volume { get; set; } + + /// Duration of the current media in microseconds public abstract int64 duration { get; } public abstract string? metadata { owned get; set; } public abstract string? mime_type { owned get; set; } public abstract string? content_features { owned get; set; } public string duration_as_str { owned get { - return GstUtils.time_to_string ((ClockTime) this.duration); + return TimeUtils.time_to_string (duration); } } + + /// Position in the current media in microseconds public abstract int64 position { get; } public string position_as_str { owned get { - return GstUtils.time_to_string ((ClockTime) this.position); + return TimeUtils.time_to_string (position); } } - public abstract bool seek (ClockTime time); + public abstract bool seek (int64 time); public abstract string[] get_protocols (); public abstract string[] get_mime_types (); } diff --git a/src/librygel-renderer/rygel-media-renderer.vala b/src/librygel-renderer/rygel-media-renderer.vala new file mode 100644 index 00000000..2d87604f --- /dev/null +++ b/src/librygel-renderer/rygel-media-renderer.vala @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2012 Openismus GmbH. + * Copyright (C) 2012 Intel Corporation. + * + * Author: Jens Georg <jensg@openismus.com> + * + * 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. + */ + +internal class Plugin : Rygel.MediaRendererPlugin { + private Rygel.MediaPlayer player; + + public Plugin (Rygel.MediaPlayer root_container) { + base ("LibRygelRenderer", _("LibRygelRenderer")); + } + + public override Rygel.MediaPlayer? get_player () { + return this.player; + } +} + +/** + * This class may be used to implement in-process UPnP-AV media renderers. + * + * Call rygel_media_device_add_interface() on the RygelMediaServer to allow it + * to serve media via that network interface. + * + * See the standalone-renderer.c example. + */ +public class Rygel.MediaRenderer : MediaDevice { + + /** + * Create a MediaRenderer to serve the media in the RygelMediaContainer. + * For instance, you might use a RygelSimpleContainer. Alternatively, + * you might use your own RygelMediaContainer implementation. + * + * Assuming that the RygelMediaContainer is correctly implemented, + * the RygelMediaServer will respond appropriately to changes in the + * RygelMediaContainer. + */ + public MediaRenderer (string title, MediaPlayer player) { + base (); + this.plugin = new global::Plugin (player); + this.plugin.title = title; + } +} diff --git a/src/librygel-renderer/rygel-renderer-1.0.deps b/src/librygel-renderer/rygel-renderer-1.0.deps index a3892454..b06cbab1 100644 --- a/src/librygel-renderer/rygel-renderer-1.0.deps +++ b/src/librygel-renderer/rygel-renderer-1.0.deps @@ -1,2 +1 @@ -gstreamer-0.10 rygel-core-1.0 diff --git a/src/librygel-renderer/rygel-time-utils.vala b/src/librygel-renderer/rygel-time-utils.vala new file mode 100644 index 00000000..aeffc0f0 --- /dev/null +++ b/src/librygel-renderer/rygel-time-utils.vala @@ -0,0 +1,45 @@ +/* + * 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. + * + * 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. + */ + +internal abstract class Rygel.TimeUtils { + public static int64 time_from_string (string str) { + uint64 hours, minutes, seconds; + + str.scanf ("%llu:%2llu:%2llu%*s", out hours, out minutes, out seconds); + + return (int64)(hours * 3600 + minutes * 60 + seconds) * TimeSpan.SECOND; + } + + public static string time_to_string (int64 time) { + uint64 hours, minutes, seconds; + + hours = time / TimeSpan.SECOND / 3600; + seconds = time / TimeSpan.SECOND % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + return "%llu:%.2llu:%.2llu".printf (hours, minutes, seconds); + } +} diff --git a/src/librygel-server/rygel-media-server.vala b/src/librygel-server/rygel-media-server.vala index f48e48ab..00e88da0 100644 --- a/src/librygel-server/rygel-media-server.vala +++ b/src/librygel-server/rygel-media-server.vala @@ -47,5 +47,6 @@ public class Rygel.MediaServer : MediaDevice { public MediaServer (string title, MediaContainer root_container) { base (); this.plugin = new global::Plugin (root_container); + this.plugin.title = title; } } diff --git a/src/plugins/mpris/rygel-mpris-player.vala b/src/plugins/mpris/rygel-mpris-player.vala index 9935e099..80e95693 100644 --- a/src/plugins/mpris/rygel-mpris-player.vala +++ b/src/plugins/mpris/rygel-mpris-player.vala @@ -103,7 +103,7 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer { int64 dur = 0; if (val != null) { - dur = (int64) val * 1000; + dur = (int64) val; } return dur; @@ -112,7 +112,7 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer { public int64 position { get { - return this.actual_player.position * 1000; + return this.actual_player.position; } } @@ -124,11 +124,11 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer { actual_player.g_properties_changed.connect (this.on_properties_changed); } - public bool seek (Gst.ClockTime time) { + public bool seek (int64 time) { var ret = false; try { - this.actual_player.seek ((int64) (time / 1000)); + this.actual_player.seek (time); ret = true; } catch (Error error) {} diff --git a/src/plugins/playbin/Makefile.am b/src/plugins/playbin/Makefile.am index 3a533005..476263b6 100644 --- a/src/plugins/playbin/Makefile.am +++ b/src/plugins/playbin/Makefile.am @@ -3,10 +3,15 @@ include ../../../common.am plugin_LTLIBRARIES = librygel-playbin.la AM_CFLAGS += -DG_LOG_DOMAIN='"Playbin"' \ + -I$(top_srcdir)/src/librygel-renderer-gst \ $(LIBGSTREAMER_CFLAGS) librygel_playbin_la_SOURCES = rygel-module.vala -librygel_playbin_la_CFLAGS = $(AM_CFLAGS) -librygel_playbin_la_VALAFLAGS = $(RYGEL_COMMON_RENDERER_PLUGIN_VALAFLAGS) -librygel_playbin_la_LIBADD = $(RYGEL_COMMON_RENDERER_LIBS) +librygel_playbin_la_VALAFLAGS = \ + --pkg rygel-renderer-gst-1.0 \ + --vapidir $(top_srcdir)/src/librygel-renderer-gst \ + $(RYGEL_COMMON_RENDERER_PLUGIN_VALAFLAGS) +librygel_playbin_la_LIBADD = \ + $(top_builddir)/src/librygel-renderer-gst/librygel-renderer-gst-1.0.la \ + $(RYGEL_COMMON_RENDERER_LIBS) librygel_playbin_la_LDFLAGS = $(RYGEL_PLUGIN_LINKER_FLAGS) |