core: Expose transcode formats in the ProtocolInfo
authorJames Henstridge <james@jamesh.id.au>
Tue, 28 Jul 2009 11:02:39 +0000 (19:02 +0800)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 28 Jul 2009 21:18:44 +0000 (00:18 +0300)
Some media players (e.g. certain Sony Bravia models) won't talk to media
servers that don't advertise a DLNA profile they understand, so this is
necessary to talk to such devices.

src/rygel/rygel-connection-manager.vala
src/rygel/rygel-root-device.vala
src/rygel/rygel-transcode-manager.vala

index 384f3c9..91e7a0b 100644 (file)
@@ -34,14 +34,37 @@ public class Rygel.ConnectionManager : Service {
                     "urn:schemas-upnp-org:service:ConnectionManager:2";
     public const string DESCRIPTION_PATH = "xml/ConnectionManager.xml";
 
-    protected string source_protocol_info;
     protected string sink_protocol_info;
     protected string connection_ids;
 
+    private TranscodeManager? get_transcode_manager () {
+        var root_device = (Rygel.RootDevice) this.root_device;
+
+        // Find the ContentDirectory service attached to this root device.
+        foreach (var service in root_device.services) {
+            if (service.get_type().is_a (typeof (Rygel.ContentDirectory))) {
+                var content_directory = (Rygel.ContentDirectory) service;
+                return (TranscodeManager) content_directory.http_server;
+            }
+        }
+        return null;
+    }
+
+    protected string source_protocol_info {
+        owned get {
+            string protocol_info = "http-get:*:*:*";
+            TranscodeManager tm = get_transcode_manager ();
+
+            if (tm != null) {
+                protocol_info += tm.get_transcoder_protocol_info ();
+            }
+            return protocol_info;
+        }
+    }
+
     public override void constructed () {
         this.sink_protocol_info   = "";
         this.connection_ids       = "0";
-        this.source_protocol_info = "http-get:*:*:*";
 
         this.query_variable["SourceProtocolInfo"] +=
                         this.query_source_protocol_info_cb;
index 4e70dc5..080ee1b 100644 (file)
@@ -29,7 +29,7 @@ using Gee;
  * Represents a Root device.
  */
 public class Rygel.RootDevice: GUPnP.RootDevice {
-    private ArrayList<ServiceInfo> services;   /* Services we implement */
+    internal ArrayList<ServiceInfo> services;   /* Services we implement */
 
     public RootDevice (GUPnP.Context context,
                        Plugin        plugin,
index 1063647..126bea5 100644 (file)
@@ -98,5 +98,15 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
 
         return transcoder;
     }
+
+    public string get_transcoder_protocol_info () {
+        string protocol_info = "";
+
+        foreach (var transcoder in this.transcoders) {
+            protocol_info += ",http-get:*:%s:DLNA.ORG_PN=%s".printf (
+                transcoder.mime_type, transcoder.dlna_profile);
+        }
+        return protocol_info;
+    }
 }