rygel r624 - in trunk/src: plugins/dvb plugins/tracker rygel



Author: zeeshanak
Date: Thu Feb 19 17:17:41 2009
New Revision: 624
URL: http://svn.gnome.org/viewvc/rygel?rev=624&view=rev

Log:
Allow multiple URIs to original content in MediaItem.

All the other properties (resolution, number of channels, frame rate etc
etc) still need to be exactly the same for each item.

Modified:
   trunk/src/plugins/dvb/rygel-dvb-channel.vala
   trunk/src/plugins/tracker/rygel-tracker-image-item.vala
   trunk/src/plugins/tracker/rygel-tracker-music-item.vala
   trunk/src/plugins/tracker/rygel-tracker-video-item.vala
   trunk/src/rygel/rygel-didl-lite-writer.vala
   trunk/src/rygel/rygel-http-request.vala
   trunk/src/rygel/rygel-media-item.vala

Modified: trunk/src/plugins/dvb/rygel-dvb-channel.vala
==============================================================================
--- trunk/src/plugins/dvb/rygel-dvb-channel.vala	(original)
+++ trunk/src/plugins/dvb/rygel-dvb-channel.vala	Thu Feb 19 17:17:41 2009
@@ -62,7 +62,8 @@
         }
 
         this.mime_type = "video/mpeg";
-        this.uri = this.channel_list.GetChannelURL (cid);
+        string uri = this.channel_list.GetChannelURL (cid);
+        this.uris.add (uri);
     }
 }
 

Modified: trunk/src/plugins/tracker/rygel-tracker-image-item.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-image-item.vala	(original)
+++ trunk/src/plugins/tracker/rygel-tracker-image-item.vala	Thu Feb 19 17:17:41 2009
@@ -94,7 +94,7 @@
         this.mime_type = values[Metadata.MIME];
         this.author = values[Metadata.CREATOR];
         this.album = values[Metadata.ALBUM];
-        this.uri = Filename.to_uri (path, null);
+        this.uris.add (Filename.to_uri (path, null));
     }
 }
 

Modified: trunk/src/plugins/tracker/rygel-tracker-music-item.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-music-item.vala	(original)
+++ trunk/src/plugins/tracker/rygel-tracker-music-item.vala	Thu Feb 19 17:17:41 2009
@@ -90,7 +90,7 @@
         this.mime_type = values[Metadata.MIME];
         this.author = values[Metadata.ARTIST];
         this.album = values[Metadata.ALBUM];
-        this.uri = Filename.to_uri (path, null);
+        this.uris.add (Filename.to_uri (path, null));
     }
 }
 

Modified: trunk/src/plugins/tracker/rygel-tracker-video-item.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-video-item.vala	(original)
+++ trunk/src/plugins/tracker/rygel-tracker-video-item.vala	Thu Feb 19 17:17:41 2009
@@ -81,7 +81,7 @@
         this.date = this.seconds_to_iso8601 (values[Metadata.DATE]);
         this.mime_type = values[Metadata.MIME];
         this.author = values[Metadata.AUTHOR];
-        this.uri = Filename.to_uri (path, null);
+        this.uris.add (Filename.to_uri (path, null));
     }
 }
 

Modified: trunk/src/rygel/rygel-didl-lite-writer.vala
==============================================================================
--- trunk/src/rygel/rygel-didl-lite-writer.vala	(original)
+++ trunk/src/rygel/rygel-didl-lite-writer.vala	Thu Feb 19 17:17:41 2009
@@ -108,16 +108,16 @@
         }
 
         /* Add resource data */
-        DIDLLiteResource res = this.get_original_res (item);
+        var res_list = this.get_original_res_list (item);
 
         /* Now get the transcoded/proxy URIs */
-        var res_list = this.get_transcoded_resources (item, res);
-        foreach (DIDLLiteResource trans_res in res_list) {
+        var trans_res_list = this.get_transcoded_resources (item, res_list);
+        foreach (DIDLLiteResource trans_res in trans_res_list) {
             this.add_res (trans_res);
         }
 
-        /* Add the original res in the end */
-        if (res.uri != null) {
+        /* Add the original resources in the end */
+        foreach (DIDLLiteResource res in res_list) {
             this.add_res (res);
         }
 
@@ -162,18 +162,17 @@
 
     // FIXME: We only proxy URIs through our HTTP server for now
     private ArrayList<DIDLLiteResource?>? get_transcoded_resources
-                                            (MediaItem        item,
-                                             DIDLLiteResource orig_res) {
+                                (MediaItem                    item,
+                                 ArrayList<DIDLLiteResource?> orig_res_list) {
         var resources = new ArrayList<DIDLLiteResource?> ();
 
-        if (orig_res.protocol == "http-get")
+        if (http_res_present (orig_res_list)) {
             return resources;
+        }
 
-        // Copy the original res first
-        DIDLLiteResource res = orig_res;
-
-        // Then modify the URI and protocol
-        res.uri = this.http_server.create_http_uri_for_item (item);
+        // Create the HTTP URI
+        var uri = this.http_server.create_http_uri_for_item (item);
+        DIDLLiteResource res = create_res (item, uri);
         res.protocol = "http-get";
 
         resources.add (res);
@@ -181,11 +180,39 @@
         return resources;
     }
 
-    private DIDLLiteResource get_original_res (MediaItem item) throws Error {
+    private bool http_res_present (ArrayList<DIDLLiteResource?> res_list) {
+        bool present = false;
+
+        foreach (var res in res_list) {
+            if (res.protocol == "http-get") {
+                present = true;
+
+                break;
+            }
+        }
+
+        return present;
+    }
+
+    private ArrayList<DIDLLiteResource?> get_original_res_list (MediaItem item)
+                                                               throws Error {
+        var resources = new ArrayList<DIDLLiteResource?> ();
+
+        foreach (var uri in item.uris) {
+            DIDLLiteResource res = create_res (item, uri);
+
+            resources.add (res);
+        }
+
+        return resources;
+    }
+
+    private DIDLLiteResource create_res (MediaItem item, string uri)
+                                         throws Error {
         DIDLLiteResource res = DIDLLiteResource ();
         res.reset ();
 
-        res.uri = item.uri;
+        res.uri = uri;
         res.mime_type = item.mime_type;
 
         res.size = item.size;

Modified: trunk/src/rygel/rygel-http-request.vala
==============================================================================
--- trunk/src/rygel/rygel-http-request.vala	(original)
+++ trunk/src/rygel/rygel-http-request.vala	Thu Feb 19 17:17:41 2009
@@ -132,7 +132,11 @@
             return;
         }
 
-        string uri = this.item.uri;
+        // Just use the first URI available
+        string uri = null;
+        if (this.item.uris.size != 0) {
+            uri = this.item.uris.get (0);
+        }
 
         if (this.item.size > 0) {
             this.handle_interactive_item (uri);

Modified: trunk/src/rygel/rygel-media-item.vala
==============================================================================
--- trunk/src/rygel/rygel-media-item.vala	(original)
+++ trunk/src/rygel/rygel-media-item.vala	Thu Feb 19 17:17:41 2009
@@ -21,6 +21,7 @@
  */
 
 using GUPnP;
+using Gee;
 
 /**
  * Represents a media (Music, Video and Image) item.
@@ -37,7 +38,7 @@
     public string upnp_class;
 
     // Resource info
-    public string uri;
+    public ArrayList<string> uris;
     public string mime_type;
 
     public long size = -1;       // Size in bytes
@@ -63,6 +64,8 @@
         this.parent = parent;
         this.title = title;
         this.upnp_class = upnp_class;
+
+        this.uris = new ArrayList<string> ();
     }
 
     // Live media items need to provide a nice working implementation of this



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