core,gst-renderer: Add SinkConnectionManager to core
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sun, 1 Aug 2010 02:22:54 +0000 (05:22 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sun, 1 Aug 2010 16:44:36 +0000 (19:44 +0300)
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
src/plugins/gst-renderer/rygel-gst-renderer-connection-manager.vala [deleted file]
src/plugins/gst-renderer/rygel-gst-renderer-player.vala
src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala
src/rygel/Makefile.am
src/rygel/rygel-media-renderer-plugin.vala
src/rygel/rygel-player.vala
src/rygel/rygel-sink-connection-manager.vala [new file with mode: 0644]

index aefe2df..b943da9 100644 (file)
@@ -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 (file)
index a66f104..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2008 OpenedHand Ltd.
- * Copyright (C) 2009 Nokia Corporation.
- *
- * Author: Jorn Baayen <jorn@openedhand.com>
- *         Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
- *                               <zeeshan.ali@nokia.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.
- */
-
-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 + ":*";
-            }
-        }
-    }
-}
index 40ff145..fcc1d6e 100644 (file)
 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) {
index 5bdb1e8..9417b41 100644 (file)
@@ -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 () {
index 55d1da0..f6c6905 100644 (file)
@@ -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 \
index 2c6eaf3..82b535a 100644 (file)
@@ -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,
index 1033e45..56afa33 100644 (file)
@@ -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 (file)
index 0000000..239d273
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 OpenedHand Ltd.
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Author: Jorn Baayen <jorn@openedhand.com>
+ *         Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
+ *                               <zeeshan.ali@nokia.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.
+ */
+
+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 + ":*";
+            }
+        }
+    }
+}