[rygel] server, engines: Fix @ADDRESS@ replacement



commit e7b55f496a7a2a0379c4c48cab5fc85b06d2b3e2
Author: Jens Georg <mail jensge org>
Date:   Mon Jan 14 13:29:48 2019 +0100

    server, engines: Fix @ADDRESS@ replacement
    
    Before creating proxy or transcoding uris, replace patterns in the
    original URI
    
    Fixes #89

 src/librygel-server/rygel-media-engine.vala             | 3 ++-
 src/librygel-server/rygel-media-file-item.vala          | 2 +-
 src/media-engines/gstreamer/rygel-gst-media-engine.vala | 5 ++++-
 src/media-engines/simple/rygel-simple-media-engine.vala | 7 +++++--
 4 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/librygel-server/rygel-media-engine.vala b/src/librygel-server/rygel-media-engine.vala
index bf8e8e3f..4cac4b1c 100644
--- a/src/librygel-server/rygel-media-engine.vala
+++ b/src/librygel-server/rygel-media-engine.vala
@@ -128,7 +128,8 @@ public abstract class Rygel.MediaEngine : GLib.Object {
      * @return A #DataSource representing the given item resource
      */
     public abstract DataSource? create_data_source_for_resource (MediaObject item,
-                                                                 MediaResource resource)
+                                                                 MediaResource resource,
+                                                                 HashTable<string, string> replacements)
           throws Error;
 
     /**
diff --git a/src/librygel-server/rygel-media-file-item.vala b/src/librygel-server/rygel-media-file-item.vala
index aac729f9..1fed1aaa 100644
--- a/src/librygel-server/rygel-media-file-item.vala
+++ b/src/librygel-server/rygel-media-file-item.vala
@@ -129,7 +129,7 @@ public abstract class Rygel.MediaFileItem : MediaItem {
                                          MediaResource resource)
                                          throws Error {
         return MediaEngine.get_default ().create_data_source_for_resource
-                                        (this, resource);
+                                        (this, resource, request.http_server.replacements);
     }
 
     internal override DIDLLiteObject? serialize (Serializer serializer,
diff --git a/src/media-engines/gstreamer/rygel-gst-media-engine.vala 
b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
index bb50f912..f21fa5fb 100644
--- a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
+++ b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
@@ -198,7 +198,8 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
 
     public override DataSource? create_data_source_for_resource
                                         (MediaObject   object,
-                                         MediaResource resource)
+                                         MediaResource resource,
+                                         HashTable<string, string> replacements)
                                         throws Error {
         if (!(object is MediaFileItem)) {
             warning ("Can only process file-based MediaObjects (MediaFileItems)");
@@ -210,6 +211,8 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
         // For MediaFileItems, the primary URI refers directly to the content
         var source_uri = item.get_primary_uri ();
         debug ("creating data source for %s", source_uri);
+        source_uri = MediaObject.apply_replacements (replacements, source_uri);
+        debug ("source_uri after applying replacements: %s", source_uri);
 
         var data_source = new GstDataSource (source_uri, resource);
         debug ("MediaResource %s, profile %s, mime_type %s",
diff --git a/src/media-engines/simple/rygel-simple-media-engine.vala 
b/src/media-engines/simple/rygel-simple-media-engine.vala
index a52a2bce..645e1a3e 100644
--- a/src/media-engines/simple/rygel-simple-media-engine.vala
+++ b/src/media-engines/simple/rygel-simple-media-engine.vala
@@ -92,7 +92,8 @@ internal class Rygel.SimpleMediaEngine : MediaEngine {
 
     public override DataSource? create_data_source_for_resource
                                         (MediaObject object,
-                                         MediaResource resource)
+                                         MediaResource resource,
+                                         HashTable<string, string> replacements)
                                         throws Error {
         if (!(object is MediaFileItem)) {
             warning (_("Can only process file-based MediaObjects (MediaFileItems)"));
@@ -101,7 +102,9 @@ internal class Rygel.SimpleMediaEngine : MediaEngine {
         }
 
         // For MediaFileItems, the primary URI referrs to the local content file
-        return new SimpleDataSource (this.pool, object.get_primary_uri ());
+        var source_uri = MediaObject.apply_replacements (replacements,
+                                                         object.get_primary_uri ());
+        return new SimpleDataSource (this.pool, source_uri);
     }
 
     public override DataSource? create_data_source_for_uri (string uri) {


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