[rygel/wip/didl-s: 17/35] wip: Add DIDL_S resource to container
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/didl-s: 17/35] wip: Add DIDL_S resource to container
- Date: Wed, 21 Nov 2012 16:56:41 +0000 (UTC)
commit e1debdd46197d2fe8ad40329f2f48ffb4489c3a4
Author: Jens Georg <jensg openismus com>
Date: Fri Nov 2 17:15:26 2012 +0100
wip: Add DIDL_S resource to container
src/librygel-server/rygel-audio-item.vala | 10 +-
src/librygel-server/rygel-http-get-handler.vala | 3 +-
.../rygel-http-identity-handler.vala | 14 ++--
src/librygel-server/rygel-http-item-uri.vala | 83 ++++++++++----------
.../rygel-http-playlist-handler.vala | 22 ++++-
src/librygel-server/rygel-http-server.vala | 8 +-
.../rygel-http-transcode-handler.vala | 9 +-
src/librygel-server/rygel-image-item.vala | 4 +-
src/librygel-server/rygel-media-container.vala | 39 +++++++++
src/librygel-server/rygel-media-item.vala | 15 ++--
src/librygel-server/rygel-media-object.vala | 11 +++
src/librygel-server/rygel-music-item.vala | 1 +
src/librygel-server/rygel-transcode-manager.vala | 3 +-
src/librygel-server/rygel-transcoder.vala | 3 +-
src/librygel-server/rygel-video-item.vala | 11 ++-
src/librygel-server/rygel-visual-item.vala | 5 +-
16 files changed, 162 insertions(+), 79 deletions(-)
---
diff --git a/src/librygel-server/rygel-audio-item.vala b/src/librygel-server/rygel-audio-item.vala
index 33fec7e..24b34a1 100644
--- a/src/librygel-server/rygel-audio-item.vala
+++ b/src/librygel-server/rygel-audio-item.vala
@@ -49,12 +49,12 @@ public class Rygel.AudioItem : MediaItem {
}
internal override DIDLLiteResource add_resource
- (DIDLLiteItem didl_item,
- string? uri,
- string protocol,
- string? import_uri = null)
+ (DIDLLiteObject didl_object,
+ string? uri,
+ string protocol,
+ string? import_uri = null)
throws Error {
- var res = base.add_resource (didl_item, uri, protocol, import_uri);
+ var res = base.add_resource (didl_object, uri, protocol, import_uri);
res.duration = this.duration;
res.bitrate = this.bitrate;
diff --git a/src/librygel-server/rygel-http-get-handler.vala b/src/librygel-server/rygel-http-get-handler.vala
index cec9a09..df0603f 100644
--- a/src/librygel-server/rygel-http-get-handler.vala
+++ b/src/librygel-server/rygel-http-get-handler.vala
@@ -69,6 +69,7 @@ internal abstract class Rygel.HTTPGetHandler: GLib.Object {
(request.object as MediaItem,
-1,
0, // FIXME: offer first subtitle only?
+ null,
null);
request.msg.response_headers.append ("CaptionInfo.sec",
@@ -86,7 +87,7 @@ internal abstract class Rygel.HTTPGetHandler: GLib.Object {
public abstract HTTPResponse render_body (HTTPGet request)
throws HTTPRequestError;
- protected abstract DIDLLiteResource add_resource (DIDLLiteItem didl_item,
+ protected abstract DIDLLiteResource add_resource (DIDLLiteObject didl_object,
HTTPGet request)
throws Error;
diff --git a/src/librygel-server/rygel-http-identity-handler.vala b/src/librygel-server/rygel-http-identity-handler.vala
index bdf90a8..215a6ea 100644
--- a/src/librygel-server/rygel-http-identity-handler.vala
+++ b/src/librygel-server/rygel-http-identity-handler.vala
@@ -75,15 +75,17 @@ internal class Rygel.HTTPIdentityHandler : Rygel.HTTPGetHandler {
size > 0;
}
- protected override DIDLLiteResource add_resource (DIDLLiteItem didl_item,
- HTTPGet request)
- throws Error {
+ protected override DIDLLiteResource add_resource
+ (DIDLLiteObject didl_object,
+ HTTPGet request)
+ throws Error {
var protocol = request.http_server.get_protocol ();
if (request.thumbnail != null) {
- return request.thumbnail.add_resource (didl_item, protocol);
+ return request.thumbnail.add_resource (didl_object as DIDLLiteItem,
+ protocol);
} else {
- return (request.object as MediaItem).add_resource (didl_item, null, protocol);
+ return request.object.add_resource (didl_object, null, protocol);
}
}
@@ -116,6 +118,6 @@ internal class Rygel.HTTPIdentityHandler : Rygel.HTTPGetHandler {
return request.thumbnail.size;
}
- return request.item.size;
+ return (request.object as MediaItem).size;
}
}
diff --git a/src/librygel-server/rygel-http-item-uri.vala b/src/librygel-server/rygel-http-item-uri.vala
index fd96ca9..0c56210 100644
--- a/src/librygel-server/rygel-http-item-uri.vala
+++ b/src/librygel-server/rygel-http-item-uri.vala
@@ -48,68 +48,71 @@ internal class Rygel.HTTPItemURI : Object {
public static HashMap<string, string> mime_to_ext;
- public HTTPItemURI (MediaItem item,
+ public HTTPItemURI (MediaObject object,
HTTPServer http_server,
int thumbnail_index = -1,
int subtitle_index = -1,
string? transcode_target = null,
string? playlist_format = null) {
- this.item_id = item.id;
+ this.item_id = object.id;
this.thumbnail_index = thumbnail_index;
this.subtitle_index = subtitle_index;
this.transcode_target = transcode_target;
this.http_server = http_server;
- this.playlist_format = null;
+ this.playlist_format = playlist_format;
this.extension = "";
- if (thumbnail_index > -1) {
- if (item is VisualItem) {
- var thumbnails = (item as VisualItem).thumbnails;
-
- if (thumbnails.size > thumbnail_index) {
- this.extension = thumbnails[thumbnail_index].file_extension;
+ if (object is MediaItem) {
+ var item = object as MediaItem;
+ if (thumbnail_index > -1) {
+ if (item is VisualItem) {
+ var thumbnails = (item as VisualItem).thumbnails;
+
+ if (thumbnails.size > thumbnail_index) {
+ this.extension = thumbnails[thumbnail_index].file_extension;
+ }
+ } else if (item is MusicItem) {
+ var album_art = (item as MusicItem).album_art;
+
+ if (album_art != null) {
+ this.extension = album_art.file_extension;
+ }
}
- } else if (item is MusicItem) {
- var album_art = (item as MusicItem).album_art;
+ } else if (subtitle_index > -1) {
+ if (item is VideoItem) {
+ var subtitles = (item as VideoItem).subtitles;
- if (album_art != null) {
- this.extension = album_art.file_extension;
+ if (subtitles.size > subtitle_index) {
+ this.extension = subtitles[subtitle_index].caption_type;
+ }
}
- }
- } else if (subtitle_index > -1) {
- if (item is VideoItem) {
- var subtitles = (item as VideoItem).subtitles;
+ } else if (transcode_target != null) {
+ try {
+ var tc = this.http_server.get_transcoder (transcode_target);
- if (subtitles.size > subtitle_index) {
- this.extension = subtitles[subtitle_index].caption_type;
- }
+ this.extension = tc.extension;
+ } catch (Error error) {}
}
- } else if (transcode_target != null) {
- try {
- var tc = this.http_server.get_transcoder (transcode_target);
-
- this.extension = tc.extension;
- } catch (Error error) {}
- }
- if (this.extension == "") {
- string uri_extension = "";
+ if (this.extension == "") {
+ string uri_extension = "";
- foreach (string uri_string in item.uris) {
- string basename = Path.get_basename (uri_string);
- int dot_index = basename.last_index_of(".");
+ foreach (string uri_string in item.uris) {
+ string basename = Path.get_basename (uri_string);
+ int dot_index = basename.last_index_of(".");
- if (dot_index > -1) {
- uri_extension = basename.substring (dot_index + 1);
+ if (dot_index > -1) {
+ uri_extension = basename.substring (dot_index + 1);
- break;
+ break;
+ }
}
- }
- if (uri_extension == "") {
- this.extension = this.ext_from_mime_type (item.mime_type);
- } else {
- this.extension = uri_extension;
+ if (uri_extension == "") {
+ this.extension = this.ext_from_mime_type (item.mime_type);
+ } else {
+ this.extension = uri_extension;
+ }
}
}
}
diff --git a/src/librygel-server/rygel-http-playlist-handler.vala b/src/librygel-server/rygel-http-playlist-handler.vala
index 8ee31a1..e6487d4 100644
--- a/src/librygel-server/rygel-http-playlist-handler.vala
+++ b/src/librygel-server/rygel-http-playlist-handler.vala
@@ -94,6 +94,13 @@ internal class Rygel.HTTPPlaylistHandler : Rygel.HTTPGetHandler {
this.cancellable = cancellable;
}
+ public override void add_response_headers (HTTPGet request)
+ throws HTTPRequestError {
+ request.msg.response_headers.append ("Content-Type", "text/xml");
+
+ base.add_response_headers (request);
+ }
+
public override HTTPResponse render_body (HTTPGet request)
throws HTTPRequestError {
try {
@@ -108,9 +115,16 @@ internal class Rygel.HTTPPlaylistHandler : Rygel.HTTPGetHandler {
}
}
- protected override DIDLLiteResource add_resource (DIDLLiteItem didl_item,
- HTTPGet request) {
- // TODO: Implement
- return null as DIDLLiteResource;
+ protected override DIDLLiteResource add_resource
+ (DIDLLiteObject didl_object,
+ HTTPGet request) {
+ var protocol = request.http_server.get_protocol ();
+ debug ("=> Protocol of this http server is: %s", protocol);
+
+ try {
+ return request.object.add_resource (didl_object, null, protocol);
+ } catch (Error error) {
+ return null as DIDLLiteResource;
+ }
}
}
diff --git a/src/librygel-server/rygel-http-server.vala b/src/librygel-server/rygel-http-server.vala
index 1a76fec..f68e7ae 100644
--- a/src/librygel-server/rygel-http-server.vala
+++ b/src/librygel-server/rygel-http-server.vala
@@ -65,7 +65,7 @@ internal class Rygel.HTTPServer : Rygel.TranscodeManager, Rygel.StateMachine {
return;
}
- var uri = this.create_uri_for_item (item, -1, -1, null);
+ var uri = this.create_uri_for_item (item, -1, -1, null, null);
item.add_resource (didl_item, uri, this.get_protocol (), uri);
}
@@ -100,12 +100,14 @@ internal class Rygel.HTTPServer : Rygel.TranscodeManager, Rygel.StateMachine {
internal override string create_uri_for_item (MediaItem item,
int thumbnail_index,
int subtitle_index,
- string? transcode_target) {
+ string? transcode_target,
+ string? playlist_target) {
var uri = new HTTPItemURI (item,
this,
thumbnail_index,
subtitle_index,
- transcode_target);
+ transcode_target,
+ playlist_target);
return uri.to_string ();
}
diff --git a/src/librygel-server/rygel-http-transcode-handler.vala b/src/librygel-server/rygel-http-transcode-handler.vala
index 65e088a..da21a06 100644
--- a/src/librygel-server/rygel-http-transcode-handler.vala
+++ b/src/librygel-server/rygel-http-transcode-handler.vala
@@ -67,10 +67,11 @@ internal class Rygel.HTTPTranscodeHandler : HTTPGetHandler {
}
}
- protected override DIDLLiteResource add_resource (DIDLLiteItem didl_item,
- HTTPGet request)
- throws Error {
- return this.transcoder.add_resource (didl_item,
+ protected override DIDLLiteResource add_resource
+ (DIDLLiteObject didl_object,
+ HTTPGet request)
+ throws Error {
+ return this.transcoder.add_resource (didl_object as DIDLLiteItem,
request.object as MediaItem,
request.http_server);
}
diff --git a/src/librygel-server/rygel-image-item.vala b/src/librygel-server/rygel-image-item.vala
index 4566164..07b12be 100644
--- a/src/librygel-server/rygel-image-item.vala
+++ b/src/librygel-server/rygel-image-item.vala
@@ -86,12 +86,12 @@ public class Rygel.ImageItem : MediaItem, VisualItem {
}
internal override DIDLLiteResource add_resource
- (DIDLLiteItem didl_item,
+ (DIDLLiteObject didl_object,
string? uri,
string protocol,
string? import_uri = null)
throws Error {
- var res = base.add_resource (didl_item, uri, protocol, import_uri);
+ var res = base.add_resource (didl_object, uri, protocol, import_uri);
this.add_visual_props (res);
diff --git a/src/librygel-server/rygel-media-container.vala b/src/librygel-server/rygel-media-container.vala
index e4b6d11..3639d13 100644
--- a/src/librygel-server/rygel-media-container.vala
+++ b/src/librygel-server/rygel-media-container.vala
@@ -237,9 +237,48 @@ public abstract class Rygel.MediaContainer : MediaObject {
didl_container.restricted = true;
}
+ var uri = new HTTPItemURI (this,
+ http_server,
+ -1,
+ -1,
+ null,
+ "DIDL_S");
+ uri.extension = "xml";
+
+ this.add_resource (didl_container,
+ uri.to_string (),
+ http_server.get_protocol ());
+
return didl_container;
}
+ internal override DIDLLiteResource add_resource
+ (DIDLLiteObject didl_object,
+ string? uri,
+ string protocol,
+ string? import_uri = null)
+ throws Error {
+ var res = base.add_resource (didl_object,
+ uri,
+ protocol,
+ import_uri);
+
+ if (uri != null) {
+ res.uri = uri;
+ }
+
+ var protocol_info = new ProtocolInfo ();
+ protocol_info.mime_type = "text/xml";
+ protocol_info.dlna_profile = "DIDL_S";
+ protocol_info.protocol = protocol;
+ protocol_info.dlna_flags = DLNAFlags.DLNA_V15 |
+ DLNAFlags.CONNECTION_STALL |
+ DLNAFlags.BACKGROUND_TRANSFER_MODE;
+ res.protocol_info = protocol_info;
+
+ return res;
+ }
+
/**
* handler for container_updated signal on this container. We only forward
* it to the parent, hoping someone will get it from the root container
diff --git a/src/librygel-server/rygel-media-item.vala b/src/librygel-server/rygel-media-item.vala
index ab852d6..9677258 100644
--- a/src/librygel-server/rygel-media-item.vala
+++ b/src/librygel-server/rygel-media-item.vala
@@ -143,13 +143,16 @@ public abstract class Rygel.MediaItem : MediaObject {
(int) transcoder2.get_distance (this);
}
- internal virtual DIDLLiteResource add_resource
- (DIDLLiteItem didl_item,
- string? uri,
- string protocol,
- string? import_uri = null)
+ internal override DIDLLiteResource add_resource
+ (DIDLLiteObject didl_object,
+ string? uri,
+ string protocol,
+ string? import_uri = null)
throws Error {
- var res = didl_item.add_resource ();
+ var res = base.add_resource (didl_object,
+ uri,
+ protocol,
+ import_uri);
if (uri != null && !this.place_holder) {
res.uri = uri;
diff --git a/src/librygel-server/rygel-media-object.vala b/src/librygel-server/rygel-media-object.vala
index 45da38c..59d1a7f 100644
--- a/src/librygel-server/rygel-media-object.vala
+++ b/src/librygel-server/rygel-media-object.vala
@@ -220,6 +220,17 @@ public abstract class Rygel.MediaObject : GLib.Object {
}
}
+ internal virtual DIDLLiteResource add_resource
+ (DIDLLiteObject object,
+ string? uri,
+ string protocol,
+ string? import_uri = null)
+ throws Error {
+ var res = object.add_resource ();
+
+ return res;
+ }
+
protected int compare_int_props (int prop1, int prop2) {
return (prop1 - prop2).clamp (-1, 1);
}
diff --git a/src/librygel-server/rygel-music-item.vala b/src/librygel-server/rygel-music-item.vala
index a1acb0e..f51883c 100644
--- a/src/librygel-server/rygel-music-item.vala
+++ b/src/librygel-server/rygel-music-item.vala
@@ -158,6 +158,7 @@ public class Rygel.MusicItem : AudioItem {
didl_item.album_art = server.create_uri_for_item (this,
0,
-1,
+ null,
null);
}
}
diff --git a/src/librygel-server/rygel-transcode-manager.vala b/src/librygel-server/rygel-transcode-manager.vala
index 538f53d..8df32d3 100644
--- a/src/librygel-server/rygel-transcode-manager.vala
+++ b/src/librygel-server/rygel-transcode-manager.vala
@@ -44,7 +44,8 @@ public abstract class Rygel.TranscodeManager : GLib.Object {
public abstract string create_uri_for_item (MediaItem item,
int thumbnail_index,
int subtitle_index,
- string? transcode_target);
+ string? transcode_target,
+ string? playlist_target);
public void add_resources (DIDLLiteItem didl_item, MediaItem item)
throws Error {
diff --git a/src/librygel-server/rygel-transcoder.vala b/src/librygel-server/rygel-transcoder.vala
index 6427694..95488a4 100644
--- a/src/librygel-server/rygel-transcoder.vala
+++ b/src/librygel-server/rygel-transcoder.vala
@@ -58,7 +58,8 @@ public abstract class Rygel.Transcoder : GLib.Object {
var uri = manager.create_uri_for_item (item,
-1,
-1,
- this.dlna_profile);
+ this.dlna_profile,
+ null);
var res = item.add_resource (didl_item, uri, protocol);
res.size = -1;
diff --git a/src/librygel-server/rygel-video-item.vala b/src/librygel-server/rygel-video-item.vala
index 679b700..93f61a1 100644
--- a/src/librygel-server/rygel-video-item.vala
+++ b/src/librygel-server/rygel-video-item.vala
@@ -109,12 +109,12 @@ public class Rygel.VideoItem : AudioItem, VisualItem {
}
internal override DIDLLiteResource add_resource
- (DIDLLiteItem didl_item,
- string? uri,
- string protocol,
- string? import_uri = null)
+ (DIDLLiteObject didl_object,
+ string? uri,
+ string protocol,
+ string? import_uri = null)
throws Error {
- var res = base.add_resource (didl_item, uri, protocol, import_uri);
+ var res = base.add_resource (didl_object, uri, protocol, import_uri);
this.add_visual_props (res);
@@ -180,6 +180,7 @@ public class Rygel.VideoItem : AudioItem, VisualItem {
subtitle.uri = server.create_uri_for_item (this,
-1,
index,
+ null,
null);
subtitle.add_didl_node (didl_item);
diff --git a/src/librygel-server/rygel-visual-item.vala b/src/librygel-server/rygel-visual-item.vala
index 13bd8c5..82a792e 100644
--- a/src/librygel-server/rygel-visual-item.vala
+++ b/src/librygel-server/rygel-visual-item.vala
@@ -63,7 +63,9 @@ public interface Rygel.VisualItem : MediaItem {
try {
var thumb = thumbnailer.get_thumbnail (uri, this.mime_type);
this.thumbnails.add (thumb);
- } catch (Error err) {}
+ } catch (Error err) {
+ debug ("Failed to get thumbnail: %s", err.message);
+ }
}
}
@@ -96,6 +98,7 @@ public interface Rygel.VisualItem : MediaItem {
thumbnail.uri = server.create_uri_for_item (this,
index,
-1,
+ null,
null);
thumbnail.add_resource (didl_item, server.get_protocol ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]