From bf4ea6193efa778c4fb5317ac84edf8d33fcd654 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Sun, 1 Aug 2010 05:22:54 +0300 Subject: [PATCH] core,gst-renderer: Add SinkConnectionManager to core This now makes it possible for MediaRenderer plugins to not have to provide ConnectionManager implementation. Instead Player implementation in plugins needs to provide list of supported protocols and mime_types. --- src/plugins/gst-renderer/Makefile.am | 3 +- .../rygel-gst-renderer-connection-manager.vala | 68 ---------------------- .../gst-renderer/rygel-gst-renderer-player.vala | 36 ++++++++++++ .../gst-renderer/rygel-gst-renderer-plugin.vala | 4 +- src/rygel/Makefile.am | 1 + src/rygel/rygel-media-renderer-plugin.vala | 3 +- src/rygel/rygel-player.vala | 2 + src/rygel/rygel-sink-connection-manager.vala | 47 +++++++++++++++ 8 files changed, 89 insertions(+), 75 deletions(-) delete mode 100644 src/plugins/gst-renderer/rygel-gst-renderer-connection-manager.vala create mode 100644 src/rygel/rygel-sink-connection-manager.vala diff --git a/src/plugins/gst-renderer/Makefile.am b/src/plugins/gst-renderer/Makefile.am index aefe2df..b943da9 100644 --- a/src/plugins/gst-renderer/Makefile.am +++ b/src/plugins/gst-renderer/Makefile.am @@ -17,8 +17,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \ -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(shareddir)"' \ -include config.h -librygel_gst_renderer_la_SOURCES = rygel-gst-renderer-connection-manager.vala \ - rygel-gst-renderer-player.vala \ +librygel_gst_renderer_la_SOURCES = rygel-gst-renderer-player.vala \ rygel-gst-renderer-plugin.vala \ rygel-gst-renderer-time.vala diff --git a/src/plugins/gst-renderer/rygel-gst-renderer-connection-manager.vala b/src/plugins/gst-renderer/rygel-gst-renderer-connection-manager.vala deleted file mode 100644 index a66f104..0000000 --- a/src/plugins/gst-renderer/rygel-gst-renderer-connection-manager.vala +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2008 OpenedHand Ltd. - * Copyright (C) 2009 Nokia Corporation. - * - * Author: Jorn Baayen - * Zeeshan Ali (Khattak) - * - * - * 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. - */ - -using GUPnP; - -public class Rygel.GstRenderer.ConnectionManager : Rygel.ConnectionManager { - private string[] protocols = { "http-get", "rtsp" }; - private string[] mime_types = { "audio/mpeg", - "application/ogg", - "audio/x-vorbis", - "audio/x-vorbis+ogg", - "audio/x-ms-wma", - "audio/x-ms-asf", - "audio/x-flac", - "audio/x-mod", - "audio/x-wav", - "audio/x-ac3", - "audio/x-m4a", - "video/x-theora", - "video/x-dirac", - "video/x-wmv", - "video/x-wma", - "video/x-msvideo", - "video/x-3ivx", - "video/x-3ivx", - "video/x-matroska", - "video/mpeg", - "video/mp4", - "video/x-ms-asf", - "video/x-xvid", - "video/x-ms-wmv", - "audio/L16;rate=44100;channels=2", - "audio/L16;rate=44100;channels=1" }; - - public override void constructed () { - base.constructed (); - - foreach (var protocol in this.protocols) { - foreach (var mime_type in this.mime_types) { - if (this.mime_types[0] != mime_type) { - this.sink_protocol_info += ","; - } - - this.sink_protocol_info += protocol + ":*:" + mime_type + ":*"; - } - } - } -} diff --git a/src/plugins/gst-renderer/rygel-gst-renderer-player.vala b/src/plugins/gst-renderer/rygel-gst-renderer-player.vala index 40ff145..fcc1d6e 100644 --- a/src/plugins/gst-renderer/rygel-gst-renderer-player.vala +++ b/src/plugins/gst-renderer/rygel-gst-renderer-player.vala @@ -24,6 +24,34 @@ using Gst; public class Rygel.GstRenderer.Player : GLib.Object, Rygel.Player { + private const string[] protocols = { "http-get", "rtsp" }; + private const string[] mime_types = { + "audio/mpeg", + "application/ogg", + "audio/x-vorbis", + "audio/x-vorbis+ogg", + "audio/x-ms-wma", + "audio/x-ms-asf", + "audio/x-flac", + "audio/x-mod", + "audio/x-wav", + "audio/x-ac3", + "audio/x-m4a", + "video/x-theora", + "video/x-dirac", + "video/x-wmv", + "video/x-wma", + "video/x-msvideo", + "video/x-3ivx", + "video/x-3ivx", + "video/x-matroska", + "video/mpeg", + "video/mp4", + "video/x-ms-asf", + "video/x-xvid", + "video/x-ms-wmv", + "audio/L16;rate=44100;channels=2", + "audio/L16;rate=44100;channels=1" }; private static Player player; private dynamic Element playbin; @@ -130,6 +158,14 @@ public class Rygel.GstRenderer.Player : GLib.Object, Rygel.Player { -1); } + public string[] get_protocols () { + return protocols; + } + + public string[] get_mime_types () { + return mime_types; + } + private bool bus_handler (Gst.Bus bus, Message message) { if (message.type == MessageType.EOS) { diff --git a/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala b/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala index 5bdb1e8..9417b41 100644 --- a/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala +++ b/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala @@ -33,9 +33,7 @@ public void module_init (PluginLoader loader) { public class Rygel.GstRenderer.Plugin : Rygel.MediaRendererPlugin { public Plugin () { - base ("GstRenderer", - _("GStreamer Renderer"), - typeof (GstRenderer.ConnectionManager)); + base ("GstRenderer", _("GStreamer Renderer")); } public override Rygel.Player? get_player () { diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am index 55d1da0..f6c6905 100644 --- a/src/rygel/Makefile.am +++ b/src/rygel/Makefile.am @@ -52,6 +52,7 @@ VAPI_SOURCE_FILES = rygel-configuration.vala \ rygel-content-directory.vala \ rygel-connection-manager.vala \ rygel-source-connection-manager.vala \ + rygel-sink-connection-manager.vala \ rygel-av-transport.vala \ rygel-rendering-control.vala \ rygel-transcode-manager.vala \ diff --git a/src/rygel/rygel-media-renderer-plugin.vala b/src/rygel/rygel-media-renderer-plugin.vala index 2c6eaf3..82b535a 100644 --- a/src/rygel/rygel-media-renderer-plugin.vala +++ b/src/rygel/rygel-media-renderer-plugin.vala @@ -28,14 +28,13 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin { public MediaRendererPlugin (string name, string? title, - Type connection_manager_type, string? description = null) { base (MEDIA_RENDERER_DESC_PATH, name, title, description); var resource = new ResourceInfo (ConnectionManager.UPNP_ID, ConnectionManager.UPNP_TYPE, ConnectionManager.DESCRIPTION_PATH, - connection_manager_type); + typeof (SinkConnectionManager)); this.add_resource (resource); resource = new ResourceInfo (AVTransport.UPNP_ID, diff --git a/src/rygel/rygel-player.vala b/src/rygel/rygel-player.vala index 1033e45..56afa33 100644 --- a/src/rygel/rygel-player.vala +++ b/src/rygel/rygel-player.vala @@ -29,4 +29,6 @@ public interface Rygel.Player : GLib.Object { public abstract string position { owned get; } public abstract bool seek (string time); + public abstract string[] get_protocols (); + public abstract string[] get_mime_types (); } diff --git a/src/rygel/rygel-sink-connection-manager.vala b/src/rygel/rygel-sink-connection-manager.vala new file mode 100644 index 0000000..239d273 --- /dev/null +++ b/src/rygel/rygel-sink-connection-manager.vala @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2008 OpenedHand Ltd. + * Copyright (C) 2009 Nokia Corporation. + * + * Author: Jorn Baayen + * Zeeshan Ali (Khattak) + * + * + * 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. + */ + +using GUPnP; + +public class Rygel.SinkConnectionManager : Rygel.ConnectionManager { + private Player player; + + public override void constructed () { + base.constructed (); + + var plugin = this.root_device.resource_factory as MediaRendererPlugin; + this.player = plugin.get_player (); + + foreach (var protocol in this.player.get_protocols ()) { + var mime_types = this.player.get_mime_types (); + + foreach (var mime_type in mime_types) { + if (mime_types[0] != mime_type) { + this.sink_protocol_info += ","; + } + + this.sink_protocol_info += protocol + ":*:" + mime_type + ":*"; + } + } + } +} -- 2.7.4