[rygel] core,gst-renderer: Simplify MediaRenderer implementations



commit 7615c143d29fff2c414c8803c93e26353aaffff8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sun Aug 1 04:47:24 2010 +0300

    core,gst-renderer: Simplify MediaRenderer implementations
    
    We no longer require plugins to provide AVTransport and RenderingControl
    services but instead they need to always subclass Plugin class and
    implement it's 'get_player' method.

 src/plugins/gst-renderer/Makefile.am               |    2 -
 .../rygel-gst-renderer-av-transport.vala           |   28 --------------------
 .../gst-renderer/rygel-gst-renderer-plugin.vala    |   19 +++++++++----
 .../rygel-gst-renderer-rendering-control.vala      |   25 -----------------
 src/rygel/rygel-av-transport.vala                  |    9 +++---
 src/rygel/rygel-media-renderer-plugin.vala         |   16 ++++++-----
 6 files changed, 27 insertions(+), 72 deletions(-)
---
diff --git a/src/plugins/gst-renderer/Makefile.am b/src/plugins/gst-renderer/Makefile.am
index c62eaaa..aefe2df 100644
--- a/src/plugins/gst-renderer/Makefile.am
+++ b/src/plugins/gst-renderer/Makefile.am
@@ -18,8 +18,6 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 	    -include config.h
 
 librygel_gst_renderer_la_SOURCES = rygel-gst-renderer-connection-manager.vala \
-				   rygel-gst-renderer-rendering-control.vala \
-				   rygel-gst-renderer-av-transport.vala \
 				   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-plugin.vala b/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala
index 6ab913c..5bdb1e8 100644
--- a/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala
+++ b/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala
@@ -26,13 +26,20 @@ using Rygel;
 using Gee;
 
 public void module_init (PluginLoader loader) {
-    var plugin = new MediaRendererPlugin (
-                                        "GstRenderer",
-                                        _("GStreamer Renderer"),
-                                        typeof (GstRenderer.ConnectionManager),
-                                        typeof (GstRenderer.AVTransport),
-                                        typeof (GstRenderer.RenderingControl));
+    var plugin = new GstRenderer.Plugin ();
 
     loader.add_plugin (plugin);
 }
 
+public class Rygel.GstRenderer.Plugin : Rygel.MediaRendererPlugin {
+    public Plugin () {
+        base ("GstRenderer",
+              _("GStreamer Renderer"),
+              typeof (GstRenderer.ConnectionManager));
+    }
+
+    public override Rygel.Player? get_player () {
+        return GstRenderer.Player.get_default ();
+    }
+}
+
diff --git a/src/rygel/rygel-av-transport.vala b/src/rygel/rygel-av-transport.vala
index 1109007..5085fd3 100644
--- a/src/rygel/rygel-av-transport.vala
+++ b/src/rygel/rygel-av-transport.vala
@@ -136,7 +136,7 @@ public class Rygel.AVTransport : Service {
 
     public override void constructed () {
         this.changelog = new ChangeLog (this, LAST_CHANGE_NS);
-        this.player = this.create_player ();
+        this.player = this.get_player ();
 
         query_variable["LastChange"].connect (this.query_last_change_cb);
 
@@ -160,9 +160,10 @@ public class Rygel.AVTransport : Service {
         this.player.notify["duration"].connect (this.notify_duration_cb);
     }
 
-    // Public abstract methods derived classes need to implement
-    public virtual Player? create_player () {
-        return null;
+    private Player get_player () {
+        var plugin = this.root_device.resource_factory as MediaRendererPlugin;
+
+        return plugin.get_player ();
     }
 
     private void query_last_change_cb (Service        service,
diff --git a/src/rygel/rygel-media-renderer-plugin.vala b/src/rygel/rygel-media-renderer-plugin.vala
index f1ed39d..2c6eaf3 100644
--- a/src/rygel/rygel-media-renderer-plugin.vala
+++ b/src/rygel/rygel-media-renderer-plugin.vala
@@ -29,8 +29,6 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
     public MediaRendererPlugin (string  name,
                                 string? title,
                                 Type    connection_manager_type,
-                                Type    av_transport_type,
-                                Type    rendering_control_type,
                                 string? description = null) {
         base (MEDIA_RENDERER_DESC_PATH, name, title, description);
 
@@ -40,17 +38,21 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
                                          connection_manager_type);
         this.add_resource (resource);
 
-        resource = new ResourceInfo (Rygel.AVTransport.UPNP_ID,
-                                     Rygel.AVTransport.UPNP_TYPE,
-                                     Rygel.AVTransport.DESCRIPTION_PATH,
-                                     av_transport_type);
+        resource = new ResourceInfo (AVTransport.UPNP_ID,
+                                     AVTransport.UPNP_TYPE,
+                                     AVTransport.DESCRIPTION_PATH,
+                                     typeof (AVTransport));
         this.add_resource (resource);
 
         resource = new ResourceInfo (RenderingControl.UPNP_ID,
                                      RenderingControl.UPNP_TYPE,
                                      RenderingControl.DESCRIPTION_PATH,
-                                     rendering_control_type);
+                                     typeof (RenderingControl));
         this.add_resource (resource);
     }
+
+    public virtual Player? get_player () {
+        return null;
+    }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]