[rygel] core,external: Move '@ADDRESS@' substitution to core
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,external: Move '@ADDRESS@' substitution to core
- Date: Thu, 23 Dec 2010 15:25:16 +0000 (UTC)
commit d36c76f8c1c3c0eb06f53ffcce2d11314e4993f5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Dec 23 17:08:51 2010 +0200
core,external: Move '@ADDRESS@' substitution to core
.../external/rygel-external-album-art-factory.vala | 2 +-
.../external/rygel-external-item-factory.vala | 2 +-
.../external/rygel-external-thumbnail-factory.vala | 2 +-
src/rygel/rygel-media-item.vala | 16 +++++++++++++++-
src/rygel/rygel-music-item.vala | 8 ++++++++
5 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/external/rygel-external-album-art-factory.vala b/src/plugins/external/rygel-external-album-art-factory.vala
index 60917cd..95fd55c 100644
--- a/src/plugins/external/rygel-external-album-art-factory.vala
+++ b/src/plugins/external/rygel-external-album-art-factory.vala
@@ -52,7 +52,7 @@ public class Rygel.External.AlbumArtFactory {
value = props.lookup ("URLs");
var uris = (string[]) value;
if (uris != null && uris[0] != null) {
- thumbnail.uri = uris[0].replace ("@ADDRESS@", host_ip);
+ thumbnail.uri = uris[0];
}
value = props.lookup ("Size");
diff --git a/src/plugins/external/rygel-external-item-factory.vala b/src/plugins/external/rygel-external-item-factory.vala
index 85e53a8..7b684ae 100644
--- a/src/plugins/external/rygel-external-item-factory.vala
+++ b/src/plugins/external/rygel-external-item-factory.vala
@@ -152,7 +152,7 @@ public class Rygel.External.ItemFactory {
var uris = (string[]) props.lookup ("URLs");
if (uris != null) {
for (var i = 0; uris[i] != null; i++) {
- item.add_uri (uris[i].replace ("@ADDRESS@", host_ip));
+ item.add_uri (uris[i]);
}
}
diff --git a/src/plugins/external/rygel-external-thumbnail-factory.vala b/src/plugins/external/rygel-external-thumbnail-factory.vala
index 37ab093..c8f8da2 100644
--- a/src/plugins/external/rygel-external-thumbnail-factory.vala
+++ b/src/plugins/external/rygel-external-thumbnail-factory.vala
@@ -56,7 +56,7 @@ public class Rygel.External.ThumbnailFactory {
var value = props.lookup ("URLs");
var uris = (string[]) value;
if (uris != null && uris[0] != null) {
- thumbnail.uri = uris[0].replace ("@ADDRESS@", host_ip);
+ thumbnail.uri = uris[0];
}
value = props.lookup ("Size");
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 9411a31..a0f81cf 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -78,6 +78,8 @@ public abstract class Rygel.MediaItem : MediaObject {
}
}
+ protected Regex address_regex;
+
public MediaItem (string id,
MediaContainer parent,
string title,
@@ -86,6 +88,12 @@ public abstract class Rygel.MediaItem : MediaObject {
this.parent = parent;
this.title = title;
this.upnp_class = upnp_class;
+
+ try {
+ this.address_regex = new Regex (Regex.escape_string ("@ADDRESS@"));
+ } catch (GLib.RegexError err) {
+ assert_not_reached ();
+ }
}
// Live media items need to provide a nice working implementation of this
@@ -208,11 +216,17 @@ public abstract class Rygel.MediaItem : MediaObject {
*/
this.add_proxy_resources (http_server, didl_item);
if (!this.place_holder) {
+ var host_ip = http_server.context.host_ip;
+
// then original URIs
bool internal_allowed;
internal_allowed = http_server.context.interface == "lo" ||
- http_server.context.host_ip == "127.0.0.1";
+ host_ip == "127.0.0.1";
this.add_resources (didl_item, internal_allowed);
+
+ foreach (var res in didl_item.get_resources ()) {
+ res.uri = this.address_regex.replace_literal (res.uri, -1, 0, host_ip);
+ }
}
return didl_item;
diff --git a/src/rygel/rygel-music-item.vala b/src/rygel/rygel-music-item.vala
index 7437998..97d6949 100644
--- a/src/rygel/rygel-music-item.vala
+++ b/src/rygel/rygel-music-item.vala
@@ -112,6 +112,14 @@ public class Rygel.MusicItem : AudioItem {
didl_item.genre = this.genre;
}
+ if (didl_item.album_art != null) {
+ didl_item.album_art = this.address_regex.replace_literal
+ (didl_item.album_art,
+ -1,
+ 0,
+ http_server.context.host_ip);
+ }
+
return didl_item;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]