[rygel] server: Move knowledge of supported profiles



commit 27b8eb1e0048f493510f0831aace70006a87a1df
Author: Jens Georg <jensg openismus com>
Date:   Fri Aug 9 13:17:24 2013 +0200

    server: Move knowledge of supported profiles
    
    Query the supported profiles (all, upload) from the MediaServerPlugin,
    provide a default implementation that does return everything from the
    profiles supported by the MediaEngine.
    
    Note: This is done via properties in this slightly complicated manner to not
    break ABI this late in the cycle. Ideally it should be abstract/virtual
    properties or abstract/virtual functions.

 src/librygel-server/rygel-content-directory.vala   |    4 +-
 src/librygel-server/rygel-media-server-plugin.vala |   54 ++++++++++++++++++++
 src/librygel-server/rygel-object-creator.vala      |    3 +-
 .../rygel-source-connection-manager.vala           |    4 +-
 4 files changed, 60 insertions(+), 5 deletions(-)
---
diff --git a/src/librygel-server/rygel-content-directory.vala 
b/src/librygel-server/rygel-content-directory.vala
index 48ec050..1812a96 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -774,8 +774,8 @@ internal class Rygel.ContentDirectory: Service {
             return;
         }
 
-        unowned GLib.List<DLNAProfile> profiles = MediaEngine.get_default ().
-                                        get_dlna_profiles ();
+        var plugin = this.root_device.resource_factory as MediaServerPlugin;
+        unowned GLib.List<DLNAProfile> profiles = plugin.upload_profiles;
         var requested_profiles = upload_profiles.split (",");
         var builder = new StringBuilder ();
         foreach (var profile in profiles) {
diff --git a/src/librygel-server/rygel-media-server-plugin.vala 
b/src/librygel-server/rygel-media-server-plugin.vala
index 1ee13d2..6e58f43 100644
--- a/src/librygel-server/rygel-media-server-plugin.vala
+++ b/src/librygel-server/rygel-media-server-plugin.vala
@@ -40,6 +40,60 @@ public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
 
     public MediaContainer root_container { get; construct; }
 
+    private GLib.List<DLNAProfile> _upload_profiles;
+
+    /**
+     * The list of DLNA profiles the MediaServer in this plugin will accept
+     * files as upload.
+     *
+     * Can be a subset of :supported_profiles. If set to %NULL, it will be
+     * reset to :supported_profiles.
+     */
+    public unowned GLib.List<DLNAProfile> upload_profiles {
+        get {
+            if (_upload_profiles == null) {
+                return _supported_profiles;
+            }
+
+            return _upload_profiles;
+        }
+
+        construct set {
+            _upload_profiles = null;
+            foreach (var profile in value) {
+                _upload_profiles.append (profile);
+            }
+        }
+    }
+
+    private GLib.List<DLNAProfile> _supported_profiles;
+
+    /**
+     * The list of DLNA profiles the MediaServer in this plugin will be able
+     * to serve.
+     *
+     * If it does not accept all formats it can serve for uploading,
+     * :upload_profiles needs to be set to the supported subset.
+     *
+     * By default it will be the supported profiles of the #RygelMediaEngine.
+     */
+    public unowned GLib.List<DLNAProfile> supported_profiles {
+        get {
+            if (_supported_profiles == null) {
+                return MediaEngine.get_default ().get_dlna_profiles ();
+            }
+
+            return _supported_profiles;
+        }
+
+        construct set {
+            _supported_profiles = null;
+            foreach (var profile in value) {
+                _supported_profiles.append (profile);
+            }
+        }
+    }
+
     /**
      * Create an instance of the plugin.
      * The plugin's service will have the same title as its root container.
diff --git a/src/librygel-server/rygel-object-creator.vala b/src/librygel-server/rygel-object-creator.vala
index 58b193c..6e1fe25 100644
--- a/src/librygel-server/rygel-object-creator.vala
+++ b/src/librygel-server/rygel-object-creator.vala
@@ -786,7 +786,8 @@ internal class Rygel.ObjectCreator: GLib.Object, Rygel.StateMachine {
     private bool is_profile_valid (string profile) {
         unowned GLib.List<DLNAProfile> profiles, result;
 
-        profiles = MediaEngine.get_default ().get_dlna_profiles ();
+        var plugin = this.content_dir.root_device.resource_factory as MediaServerPlugin;
+        profiles = plugin.upload_profiles;
         var p = new DLNAProfile (profile, "");
 
         result = profiles.find_custom (p, DLNAProfile.compare_by_name);
diff --git a/src/librygel-server/rygel-source-connection-manager.vala 
b/src/librygel-server/rygel-source-connection-manager.vala
index 77031bd..4c23884 100644
--- a/src/librygel-server/rygel-source-connection-manager.vala
+++ b/src/librygel-server/rygel-source-connection-manager.vala
@@ -51,8 +51,8 @@ internal class Rygel.SourceConnectionManager : Rygel.ConnectionManager {
         var server = this.get_http_server ();
         var protocol_infos = server.get_protocol_info ();
 
-        unowned GLib.List<DLNAProfile> profiles = MediaEngine.get_default ().
-                                                              get_dlna_profiles ();
+        var plugin = this.root_device.resource_factory as MediaServerPlugin;
+        unowned GLib.List<DLNAProfile> profiles = plugin.supported_profiles;
 
         var protocol = server.get_protocol ();
 


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