Each media object gets a weak ref to it's parent container.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Mon, 16 Feb 2009 17:32:54 +0000 (17:32 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Mon, 16 Feb 2009 17:32:54 +0000 (17:32 +0000)
svn path=/trunk/; revision=605

17 files changed:
src/plugins/dvb/rygel-dvb-channel-group.vala
src/plugins/dvb/rygel-dvb-channel.vala
src/plugins/dvb/rygel-dvb-root-container.vala
src/plugins/test/rygel-test-audio-item.vala
src/plugins/test/rygel-test-item.vala
src/plugins/test/rygel-test-root-container.vala
src/plugins/test/rygel-test-video-item.vala
src/plugins/tracker/rygel-tracker-category.vala
src/plugins/tracker/rygel-tracker-image-category.vala
src/plugins/tracker/rygel-tracker-item.vala
src/plugins/tracker/rygel-tracker-music-category.vala
src/plugins/tracker/rygel-tracker-root-container.vala
src/plugins/tracker/rygel-tracker-video-category.vala
src/rygel/rygel-didl-lite-writer.vala
src/rygel/rygel-media-container.vala
src/rygel/rygel-media-item.vala
src/rygel/rygel-media-object.vala

index c9c79e1..f999c41 100644 (file)
@@ -45,10 +45,10 @@ public class Rygel.DVBChannelGroup : MediaContainer {
 
     public DVBChannelGroup (uint                gid,
                             string              title,
-                            string              parent_id,
+                            MediaContainer      parent,
                             dynamic DBus.Object channel_list) {
         base (GID_PREFIX + gid.to_string (), // UPnP ID
-              parent_id,
+              parent,
               title,
               0);
         this.gid = gid;
@@ -140,7 +140,7 @@ public class Rygel.DVBChannelGroup : MediaContainer {
             // Create Channels
             try {
                 var channel = new DVBChannel (channel_id,
-                                              this.id,
+                                              this,
                                               channel_list);
                 this.channels.add (channel);
             } catch (GLib.Error error) {
index 185c3e7..5271a93 100644 (file)
@@ -35,12 +35,12 @@ public class Rygel.DVBChannel : MediaItem {
     private uint cid; /* The DVB Daemon Channel ID */
 
     public DVBChannel (uint                cid,
-                       string              parent_id,
+                       MediaContainer      parent,
                        dynamic DBus.Object channel_list) throws GLib.Error {
-        string id = parent_id + ":" + cid.to_string (); /* UPnP ID */
+        string id = parent.id + ":" + cid.to_string (); /* UPnP ID */
 
         base (id,
-              parent_id,
+              parent,
               "Unknown",        /* Title Unknown at this point */
               "Unknown");       /* UPnP Class Unknown at this point */
 
index b4f5b95..9b308a6 100644 (file)
@@ -130,7 +130,7 @@ public class Rygel.DVBRootContainer : MediaContainer {
             // Create ChannelGroup for each registered device group
             this.groups.add (new DVBChannelGroup (group_id,
                                                   group_name,
-                                                  this.id,
+                                                  this,
                                                   channel_list));
         }
 
index bc7bc7b..6dc7c99 100644 (file)
@@ -33,11 +33,11 @@ using Gst;
 public class Rygel.TestAudioItem : Rygel.TestItem {
     const string TEST_MIMETYPE = "audio/x-wav";
 
-    public TestAudioItem (string id,
-                          string parent_id,
-                          string title) {
+    public TestAudioItem (string         id,
+                          MediaContainer parent,
+                          string         title) {
         base (id,
-              parent_id,
+              parent,
               title,
               TEST_MIMETYPE,
               MediaItem.AUDIO_CLASS);
index 7171153..2281675 100644 (file)
@@ -32,12 +32,12 @@ using Gst;
 public abstract class Rygel.TestItem : Rygel.MediaItem {
     const string TEST_AUTHOR = "Zeeshan Ali (Khattak)";
 
-    public TestItem (string id,
-                     string parent_id,
-                     string title,
-                     string mime,
-                     string upnp_class) {
-        base (id, parent_id, title, upnp_class);
+    public TestItem (string         id,
+                     MediaContainer parent,
+                     string         title,
+                     string         mime,
+                     string         upnp_class) {
+        base (id, parent, title, upnp_class);
 
         this.mime_type = mime;
         this.author = TEST_AUTHOR;
index fe11552..bf067b4 100644 (file)
@@ -38,10 +38,10 @@ public class Rygel.TestRootContainer : MediaContainer {
 
         this.items = new ArrayList<MediaItem> ();
         this.items.add (new TestAudioItem ("sinewave",
-                                           this.id,
+                                           this,
                                            "Sine Wave"));
         this.items.add (new TestVideoItem ("smtpe",
-                                           this.id,
+                                           this,
                                            "SMTPE"));
 
         // Now we know how many top-level items we have
index 9cc517a..2744683 100644 (file)
@@ -33,11 +33,11 @@ using Gst;
 public class Rygel.TestVideoItem : Rygel.TestItem {
     const string TEST_MIMETYPE = "video/mpeg";
 
-    public TestVideoItem (string id,
-                          string parent_id,
-                          string title) {
+    public TestVideoItem (string         id,
+                          MediaContainer parent,
+                          string         title) {
         base (id,
-              parent_id,
+              parent,
               title,
               TEST_MIMETYPE,
               MediaItem.VIDEO_CLASS);
index db113ed..184ac5d 100644 (file)
@@ -50,12 +50,12 @@ public abstract class Rygel.TrackerCategory : MediaContainer {
 
     Gee.List<AsyncResult> results;
 
-    public TrackerCategory (string id,
-                            string parent_id,
-                            string title,
-                            string category,
-                            string child_class) {
-        base (id, parent_id, title, 0);
+    public TrackerCategory (string         id,
+                            MediaContainer parent,
+                            string         title,
+                            string         category,
+                            string         child_class) {
+        base (id, parent, title, 0);
 
         this.category = category;
         this.child_class = child_class;
index 31b0045..a801874 100644 (file)
@@ -27,10 +27,10 @@ using Rygel;
  * Represents Tracker Image category.
  */
 public class Rygel.TrackerImageCategory : Rygel.TrackerCategory {
-    public TrackerImageCategory (string id,
-                                 string parent_id,
-                                 string title) {
-        base (id, parent_id, title, "Images", MediaItem.IMAGE_CLASS);
+    public TrackerImageCategory (string         id,
+                                 MediaContainer parent,
+                                 string         title) {
+        base (id, parent, title, "Images", MediaItem.IMAGE_CLASS);
     }
 
     protected override string[] get_metadata_keys () {
index 5c20cba..9ea3e22 100644 (file)
@@ -35,7 +35,7 @@ public abstract class Rygel.TrackerItem : MediaItem {
                         string          path,
                         TrackerCategory parent,
                         string[]        metadata) {
-        base (id, parent.id, "", parent.child_class);
+        base (id, parent, "", parent.child_class);
 
         this.path = path;
 
index b283a77..4aecaa9 100644 (file)
@@ -27,10 +27,10 @@ using Rygel;
  * Represents Tracker Music category.
  */
 public class Rygel.TrackerMusicCategory : Rygel.TrackerCategory {
-    public TrackerMusicCategory (string id,
-                                 string parent_id,
-                                 string title) {
-        base (id, parent_id, title, "Music", MediaItem.MUSIC_CLASS);
+    public TrackerMusicCategory (string         id,
+                                 MediaContainer parent,
+                                 string         title) {
+        base (id, parent, title, "Music", MediaItem.MUSIC_CLASS);
     }
 
     protected override string[] get_metadata_keys () {
index c5a2b10..62037f0 100644 (file)
@@ -40,15 +40,15 @@ public class Rygel.TrackerRootContainer : MediaContainer {
         this.categories = new ArrayList<TrackerCategory> ();
         this.categories.add
                         (new TrackerImageCategory ("16",
-                                                   this.id,
+                                                   this,
                                                    "All Images"));
         this.categories.add
                         (new TrackerMusicCategory ("14",
-                                                   this.id,
+                                                   this,
                                                    "All Music"));
         this.categories.add
                         (new TrackerVideoCategory ("15",
-                                                   this.id,
+                                                   this,
                                                    "All Videos"));
 
         // Now we know how many top-level containers we have
index 13f483d..4ea7b28 100644 (file)
@@ -27,10 +27,10 @@ using Rygel;
  * Represents Tracker Video category.
  */
 public class Rygel.TrackerVideoCategory : Rygel.TrackerCategory {
-    public TrackerVideoCategory (string id,
-                                 string parent_id,
-                                 string title) {
-        base (id, parent_id, title, "Videos", MediaItem.VIDEO_CLASS);
+    public TrackerVideoCategory (string         id,
+                                 MediaContainer parent,
+                                 string         title) {
+        base (id, parent, title, "Videos", MediaItem.VIDEO_CLASS);
     }
 
     protected override string[] get_metadata_keys () {
index 154e254..bd2ed45 100644 (file)
@@ -52,7 +52,7 @@ public class Rygel.DIDLLiteWriter : GUPnP.DIDLLiteWriter {
 
     private void serialize_item (MediaItem item) throws Error {
         this.start_item (item.id,
-                                item.parent_id,
+                                item.parent.id,
                                 null,
                                 false);
 
@@ -127,7 +127,7 @@ public class Rygel.DIDLLiteWriter : GUPnP.DIDLLiteWriter {
 
     private void serialize_container (MediaContainer container) throws Error {
         this.start_container (container.id,
-                              container.parent_id,
+                              container.parent.id,
                               (int) container.child_count,
                               false,
                               false);
index 76d32a6..a44182c 100644 (file)
@@ -32,12 +32,12 @@ public abstract class Rygel.MediaContainer : MediaObject {
     public uint child_count;
     public uint32 update_id;
 
-    public MediaContainer (string id,
-                           string parent_id,
-                           string title,
-                           uint   child_count) {
+    public MediaContainer (string          id,
+                           MediaContainer? parent,
+                           string          title,
+                           uint            child_count) {
         this.id = id;
-        this.parent_id = parent_id;
+        this.parent = parent;
         this.title = title;
         this.child_count = child_count;
         this.update_id = uint32.MAX; // undefined for non-root containers
@@ -45,7 +45,7 @@ public abstract class Rygel.MediaContainer : MediaObject {
 
     public MediaContainer.root (string title,
                                 uint   child_count) {
-        this ("0", "-1", title, child_count);
+        this ("0", null, title, child_count);
         this.update_id = 0;
     }
 
index 58fd12f..6e7f09e 100644 (file)
@@ -55,12 +55,12 @@ public class Rygel.MediaItem : MediaObject {
     public int height = -1;
     public int color_depth = -1;
 
-    public MediaItem (string id,
-                      string parent_id,
-                      string title,
-                      string upnp_class) {
+    public MediaItem (string         id,
+                      MediaContainer parent,
+                      string         title,
+                      string         upnp_class) {
         this.id = id;
-        this.parent_id = parent_id;
+        this.parent = parent;
         this.title = title;
         this.upnp_class = upnp_class;
     }
index b82ee64..719b9e1 100644 (file)
@@ -27,6 +27,7 @@ using GUPnP;
  */
 public abstract class Rygel.MediaObject : GLib.Object {
     public string id;
-    public string parent_id;
     public string title;
+
+    public unowned MediaContainer parent;
 }