[rygel] core: Properly replace @ADDRESS@ template



commit 1ee2a14775d9640e7713f8bca4366b95e10a616e
Author: Jens Georg <mail jensge org>
Date:   Sat Jan 28 14:41:54 2012 +0100

    core: Properly replace @ADDRESS@ template
    
    Replacing of the template was forgotten for proxy urls and transcoded
    resources while moving the functionality from external plugin to core.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663826

 src/rygel/rygel-http-identity-handler.vala  |    3 ++-
 src/rygel/rygel-http-transcode-handler.vala |    3 ++-
 src/rygel/rygel-media-item.vala             |   14 ++++++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/rygel/rygel-http-identity-handler.vala b/src/rygel/rygel-http-identity-handler.vala
index 00dc465..0a451ac 100644
--- a/src/rygel/rygel-http-identity-handler.vala
+++ b/src/rygel/rygel-http-identity-handler.vala
@@ -81,7 +81,8 @@ internal class Rygel.HTTPIdentityHandler : Rygel.HTTPGetHandler {
         } else if (request.thumbnail != null) {
             src = GstUtils.create_source_for_uri (request.thumbnail.uri);
         } else {
-            src = request.item.create_stream_source ();
+            src = request.item.create_stream_source
+                                        (request.http_server.context.host_ip);
         }
 
         if (src == null) {
diff --git a/src/rygel/rygel-http-transcode-handler.vala b/src/rygel/rygel-http-transcode-handler.vala
index b1122fc..18ab87a 100644
--- a/src/rygel/rygel-http-transcode-handler.vala
+++ b/src/rygel/rygel-http-transcode-handler.vala
@@ -51,7 +51,8 @@ internal class Rygel.HTTPTranscodeHandler : HTTPGetHandler {
     public override HTTPResponse render_body (HTTPGet request)
                                               throws HTTPRequestError {
         var item = request.item;
-        var src = item.create_stream_source ();
+        var src = item.create_stream_source
+                                        (request.http_server.context.host_ip);
         if (src == null) {
             throw new HTTPRequestError.NOT_FOUND (_("Not found"));
         }
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 44eb68f..2e0584e 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -98,11 +98,21 @@ public abstract class Rygel.MediaItem : MediaObject {
 
     // Live media items need to provide a nice working implementation of this
     // method if they can/do not provide a valid URI
-    public virtual Element? create_stream_source () {
+    public virtual Element? create_stream_source (string? host_ip = null) {
         dynamic Element src = null;
 
         if (this.uris.size != 0) {
-            src = GstUtils.create_source_for_uri (this.uris.get (0));
+            string translated_uri = this.uris.get (0);
+            if (host_ip != null) {
+                try {
+                    translated_uri = this.address_regex.replace_literal
+                                        (this.uris.get (0), -1, 0, host_ip);
+                } catch (Error error) {
+                    assert_not_reached ();
+                }
+            }
+
+            src = GstUtils.create_source_for_uri (translated_uri);
         }
 
         return src;



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