renderer: Fix GetCurrentConnectionInfo's p-i
authorJens Georg <jensg@openismus.com>
Tue, 1 Oct 2013 10:27:51 +0000 (12:27 +0200)
committerJens Georg <mail@jensge.org>
Sun, 24 Nov 2013 10:07:09 +0000 (11:07 +0100)
We need to supply a proper protocol info in GetCurrentConnectionInfo if we
have one. This is even required by UPnP.

(Partially) fixes DLNA CTT 7.3.53.2

https://bugzilla.gnome.org/show_bug.cgi?id=706986

src/librygel-core/rygel-connection-manager.vala
src/librygel-renderer/rygel-media-player.vala
src/librygel-renderer/rygel-sink-connection-manager.vala

index b9a4108..3ecd2a5 100644 (file)
@@ -64,6 +64,10 @@ public class Rygel.ConnectionManager : Service {
                                         (this.get_current_connection_info_cb);
     }
 
+    public virtual string get_current_protocol_info () {
+        return "";
+    }
+
     private void query_source_protocol_info_cb (Service   cm,
                                                 string    var,
                                                 ref Value val) {
@@ -138,7 +142,7 @@ public class Rygel.ConnectionManager : Service {
                         this.av_transport_id,
                     "ProtocolInfo",
                         typeof (string),
-                        "",
+                        this.get_current_protocol_info (),
                     "PeerConnectionManager",
                         typeof (string),
                         "",
index 1efcf05..da9adb4 100644 (file)
@@ -139,4 +139,33 @@ public interface Rygel.MediaPlayer : GLib.Object {
 
          return double.parse (rational[0]) / double.parse (rational[1]);
     }
+    
+    /// Return the protocol info of the current track's meta-data
+    public string protocol_info {
+        owned get {
+            if (this.metadata == null || this.uri == null) {
+                return "";
+            }
+
+            // Parse meta-data
+            var p = new GUPnP.DIDLLiteParser ();
+            GUPnP.DIDLLiteObject item = null;
+
+            p.item_available.connect ( (object) => { item = object; });
+            try {
+                p.parse_didl (this.metadata);
+            } catch (Error error) {
+                return "";
+            }
+
+            var resources = item.get_resources ();
+            foreach (var resource in resources) {
+                if (resource.uri == this.uri) {
+                    return resource.protocol_info.to_string ();
+                }
+            }
+
+            return "";
+        }
+    }
 }
index beb30c0..f443738 100644 (file)
@@ -34,4 +34,11 @@ internal class Rygel.SinkConnectionManager : Rygel.ConnectionManager {
         var plugin = this.root_device.resource_factory as MediaRendererPlugin;
         this.sink_protocol_info = plugin.get_protocol_info ();
     }
+
+    public override string get_current_protocol_info () {
+        var plugin = this.root_device.resource_factory as MediaRendererPlugin;
+        var player = plugin.get_player ();
+
+        return player.protocol_info;
+    }
 }