[rygel/wip/cablelabs-integration: 26/27] wip: Serialize thumbnails using resources
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/cablelabs-integration: 26/27] wip: Serialize thumbnails using resources
- Date: Fri, 5 Dec 2014 20:26:32 +0000 (UTC)
commit 4015f6167c213e2b5f82e0927e20d968dc3e8704
Author: Jens Georg <mail jensge org>
Date: Sat Nov 29 14:51:04 2014 +0100
wip: Serialize thumbnails using resources
src/librygel-server/rygel-image-item.vala | 14 +++++---
src/librygel-server/rygel-thumbnail.vala | 25 +++++++++++++++
src/librygel-server/rygel-video-item.vala | 2 -
src/librygel-server/rygel-visual-item.vala | 47 ++++++++++++++++++++-------
4 files changed, 68 insertions(+), 20 deletions(-)
---
diff --git a/src/librygel-server/rygel-image-item.vala b/src/librygel-server/rygel-image-item.vala
index 219dac3..4f7e8a4 100644
--- a/src/librygel-server/rygel-image-item.vala
+++ b/src/librygel-server/rygel-image-item.vala
@@ -92,7 +92,7 @@ public class Rygel.ImageItem : MediaFileItem, VisualItem {
throws Error {
base.add_resources (didl_item, allow_internal);
- this.add_thumbnail_resources (didl_item, allow_internal);
+// this.add_thumbnail_resources (didl_item, allow_internal);
}
internal override DIDLLiteResource add_resource
@@ -112,11 +112,6 @@ public class Rygel.ImageItem : MediaFileItem, VisualItem {
DIDLLiteItem didl_item)
throws Error {
base.add_proxy_resources (server, didl_item);
-
- if (!this.place_holder) {
- // Thumbnails comes in the end
- this.add_thumbnail_proxy_resources (server, didl_item);
- }
}
protected override ProtocolInfo get_protocol_info (string? uri,
@@ -127,4 +122,11 @@ public class Rygel.ImageItem : MediaFileItem, VisualItem {
return protocol_info;
}
+
+ internal override void add_additional_resources (HTTPServer server) {
+ base.add_additional_resources (server);
+
+ this.add_thumbnail_resources (server);
+ }
+
}
diff --git a/src/librygel-server/rygel-thumbnail.vala b/src/librygel-server/rygel-thumbnail.vala
index 42ed920..655c941 100644
--- a/src/librygel-server/rygel-thumbnail.vala
+++ b/src/librygel-server/rygel-thumbnail.vala
@@ -77,4 +77,29 @@ public class Rygel.Thumbnail : Rygel.IconInfo {
return protocol_info;
}
+
+ internal virtual MediaResource get_resource (string protocol, int index) {
+ var name = "%s_thumbnail_%02d".printf (protocol, index);
+ MediaResource res = new MediaResource (name);
+
+ res.size = this.size;
+ res.width = this.width;
+ res.height = this.height;
+ res.color_depth = this.depth;
+ res.mime_type = this.mime_type;
+ res.dlna_profile = this.dlna_profile;
+ res.protocol = protocol;
+ // Note: These represent best-case. The MediaServer/HTTPServer can dial these back
+ res.dlna_flags |= DLNAFlags.INTERACTIVE_TRANSFER_MODE |
+ DLNAFlags.BACKGROUND_TRANSFER_MODE |
+ DLNAFlags.CONNECTION_STALL |
+ DLNAFlags.DLNA_V15;
+ res.dlna_operation = DLNAOperation.RANGE;
+ res.dlna_conversion = DLNAConversion.TRANSCODED;
+ res.extension = this.file_extension;
+
+ res.uri = this.uri;
+
+ return res;
+ }
}
diff --git a/src/librygel-server/rygel-video-item.vala b/src/librygel-server/rygel-video-item.vala
index c9d3a16..0583415 100644
--- a/src/librygel-server/rygel-video-item.vala
+++ b/src/librygel-server/rygel-video-item.vala
@@ -113,8 +113,6 @@ public class Rygel.VideoItem : AudioItem, VisualItem {
}
base.add_resources (didl_item, allow_internal);
-
- this.add_thumbnail_resources (didl_item, allow_internal);
}
internal override DIDLLiteResource add_resource
diff --git a/src/librygel-server/rygel-visual-item.vala b/src/librygel-server/rygel-visual-item.vala
index 2ab8897..bf8464b 100644
--- a/src/librygel-server/rygel-visual-item.vala
+++ b/src/librygel-server/rygel-visual-item.vala
@@ -71,18 +71,6 @@ public interface Rygel.VisualItem : MediaFileItem {
}
}
- internal void add_thumbnail_resources (DIDLLiteItem didl_item,
- bool allow_internal)
- throws Error {
- foreach (var thumbnail in this.thumbnails) {
- var protocol = this.get_protocol_for_uri (thumbnail.uri);
-
- if (allow_internal || protocol != "internal") {
- thumbnail.add_resource (didl_item, protocol);
- }
- }
- }
-
internal void add_visual_props (DIDLLiteResource res) {
res.width = this.width;
res.height = this.height;
@@ -109,4 +97,39 @@ public interface Rygel.VisualItem : MediaFileItem {
}
}
}
+
+ internal void add_thumbnail_resources (HTTPServer http_server) {
+ for (var i = 0; i < this.thumbnails.size; i++) {
+ if (!this.place_holder) {
+ var thumbnail = this.thumbnails.get (i);
+ // Add the defined thumbnail uri unconditionally
+ // (it will be filtered out if the request is remote)
+ string protocol;
+ try {
+ protocol = this.get_protocol_for_uri (thumbnail.uri);
+ } catch (Error e) {
+ message ("Could not determine protocol for " + thumbnail.uri);
+ continue;
+ }
+
+ var thumb_res = thumbnail.get_resource (protocol, i);
+ thumb_res.uri = thumbnail.uri;
+ this.get_resource_list ().add (thumb_res);
+ if (http_server.need_proxy (thumbnail.uri)) {
+ var http_thumb_res = thumbnail.get_resource
+ (http_server.get_protocol (), i);
+
+ var index = this.thumbnails.index_of (thumbnail);
+ // Make a http uri for the thumbnail
+ http_thumb_res.uri = http_server.create_uri_for_object
+ (this,
+ index,
+ -1,
+ null,
+ null);
+ this.get_resource_list ().add (http_thumb_res);
+ }
+ }
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]