Hi,

please find my preliminary patch attached.
> > 
> > Found a way to get the tags:
> > 
> >         n = tag_list.n_tags();
> >         for(i=0;i<n;i++) {
> >           tag = tag_list.nth_tag_name(i);
> >           ...
> > 
> > 
> > Now I would like to add them to the current meta data. How should
> > that 
> > be done?
> > 
> > regards,
> 
> Hi,
> 
> I will push my local branch later where I have a bit of code. The
> main 
> issue is to
> determine when to override the provided tags and when not to.
> _______________________________________________
> rygel-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/rygel-list
diff --git a/src/librygel-renderer-gst/rygel-playbin-player.vala b/src/librygel-renderer-gst/rygel-playbin-player.vala
index c5ed47a14..5b46152f6 100644
--- a/src/librygel-renderer-gst/rygel-playbin-player.vala
+++ b/src/librygel-renderer-gst/rygel-playbin-player.vala
@@ -187,6 +187,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
     private string transfer_mode = null;
 
     private bool uri_update_hint = false;
+    private bool metadata_update_hint = false;
     private string? _uri = null;
     public string? uri {
         owned get {
@@ -195,6 +196,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
 
         set {
             this._uri = value;
+            this.writer = null;
             this.playbin.set_state (State.READY);
             if (Player.has_dlna_src && value.has_prefix ("http")) {
                 debug ("Trying to use DLNA src element");
@@ -250,6 +252,11 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
         set {
             this._parsed_duration = 0;
             this._metadata = value;
+            if (value == "" && this._uri != "") {
+                this.metadata_update_hint = true;
+            } else {
+                this.metadata_update_hint = false;
+            }
         }
     }
 
@@ -513,6 +520,13 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
     private void bus_handler (Gst.Bus bus,
                               Message message) {
         switch (message.type) {
+        case MessageType.TAG: {
+            TagList? tags = null;
+            warning ("Got tags message from %s", message.src.get_name ());
+            message.parse_tag (out tags);
+            this.update_didl (tags);
+        }
+        break;
         case MessageType.DURATION_CHANGED:
             if (this.playbin.query_duration (Format.TIME, null)) {
                 this.notify_property ("duration");
@@ -607,6 +621,59 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
         this.uri_update_hint = true;
     }
 
+    private void update_didl (Gst.TagList? tags) {
+        // Nothing to do
+        if (tags == null) {
+            return;
+        }
+
+        // Nothing to update
+        if (!this.metadata_update_hint) {
+            return;
+        }
+
+        // Init didl-lite item
+        this.generate_basic_didl ();
+
+        tags.@foreach ((list, tag) => {
+            warning ("Found tag %s", tag);
+            if (tag == Tags.ALBUM) {
+                string album;
+                list.get_string (Tags.ALBUM, out album);
+                this.didl_item.set_album (album);
+            }
+
+            if (tag == Tags.TITLE) {
+                string title;
+                list.get_string (Tags.TITLE, out title);
+                this.didl_item.title = title;
+            }
+
+            if (tag == Tags.ARTIST) {
+                string artist;
+                var found = false;
+                list.get_string (Tags.ARTIST, out artist);
+                var contributors = this.didl_item.get_artists ();
+                foreach (var contributor in contributors) {
+                    if (contributor.role == "artist" &&
+                        contributor.name == artist) {
+                        found = true;
+                    }
+                }
+
+                if (!found) {
+                    var contributor = this.didl_item.add_artist ();
+                    contributor.name = artist;
+                }
+            }
+        });
+
+        this.metadata = this.generate_basic_didl ();
+    }
+
+    private DIDLLiteWriter writer = null;
+    private DIDLLiteItem didl_item = null;
+
     /**
      * Generate basic DIDLLite information.
      *
@@ -614,17 +681,19 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
      * 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 ();
+        if (this.writer == null) {
+            this.writer = new DIDLLiteWriter (null);
+            this.didl_item = writer.add_item ();
+            this.didl_item.id = "1";
+            this.didl_item.parent_id = "-1";
+
+            var resource = this.didl_item.add_resource ();
+            resource.uri = this._uri;
+            var file = File.new_for_uri (this.uri);
+            this.didl_item.title = file.get_basename ();
+        }
+
+        return this.writer.get_string ();
     }
 
     private void setup_playbin () {
_______________________________________________
rygel-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/rygel-list

Reply via email to