[rygel] core, playbin: Generate basic meta-data on external URI change



commit 21464942a52ca2d26b42cebd7aaa794f4c741b28
Author: Jens Georg <mail jensge org>
Date:   Thu Jun 14 10:58:59 2012 +0200

    core,playbin: Generate basic meta-data on external URI change

 src/plugins/playbin/rygel-playbin-player.vala |   21 +++++++++++++++++++++
 src/rygel/rygel-av-transport.vala             |    7 ++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/playbin/rygel-playbin-player.vala b/src/plugins/playbin/rygel-playbin-player.vala
index a8f1f32..3ee329b 100644
--- a/src/plugins/playbin/rygel-playbin-player.vala
+++ b/src/plugins/playbin/rygel-playbin-player.vala
@@ -316,6 +316,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
                             // uri changed externally
                             this._uri = this.playbin.uri;
                             this.notify_property("uri");
+                            this.metadata = this.generate_basic_didl ();
                         }
                     }
                 }
@@ -382,4 +383,24 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
     private void on_uri_notify (ParamSpec pspec) {
         this.uri_update_hint = true;
     }
+
+    /**
+     * Generate basic DIDLLite information.
+     *
+     * This is used when the URI gets changed externally. DLNA requires that a
+     * minimum DIDLLite is always present if the URI is not empty.
+     */
+    private string generate_basic_didl () {
+        var writer = new DIDLLiteWriter (null);
+        var item = writer.add_item ();
+        item.id = "1";
+        item.parent_id = "-1";
+        item.upnp_class = "object.item";
+        var resource = item.add_resource ();
+        resource.uri = this._uri;
+        var file = File.new_for_uri (this.uri);
+        item.title = file.get_basename ();
+
+        return writer.get_string ();
+    }
 }
diff --git a/src/rygel/rygel-av-transport.vala b/src/rygel/rygel-av-transport.vala
index 6d929e2..5f346fe 100644
--- a/src/rygel/rygel-av-transport.vala
+++ b/src/rygel/rygel-av-transport.vala
@@ -76,7 +76,6 @@ internal class Rygel.AVTransport : Service {
         set {
             this._metadata = value;
             this.player.metadata = value;
-            this.changelog.log ("CurrentTrackMetadata", this.metadata);
         }
     }
 
@@ -162,6 +161,7 @@ internal class Rygel.AVTransport : Service {
         this.player.notify["playback-state"].connect (this.notify_state_cb);
         this.player.notify["duration"].connect (this.notify_duration_cb);
         this.player.notify["uri"].connect (this.notify_uri_cb);
+        this.player.notify["metadata"].connect (this.notify_meta_data_cb);
 
         this.session = new SessionAsync ();
     }
@@ -561,4 +561,9 @@ internal class Rygel.AVTransport : Service {
         this.changelog.log ("CurrentTrackURI", this.uri);
         this.changelog.log ("AVTransportURI", this.uri);
     }
+
+    private void notify_meta_data_cb (Object player, ParamSpec p) {
+        this._metadata = this.player.metadata;
+        this.changelog.log ("CurrentTrackMetadata", this.metadata);
+    }
 }



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