rygel r482 - in trunk/src: plugins/dvb plugins/test plugins/tracker rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r482 - in trunk/src: plugins/dvb plugins/test plugins/tracker rygel
- Date: Wed, 28 Jan 2009 12:32:17 +0000 (UTC)
Author: zeeshanak
Date: Wed Jan 28 12:32:17 2009
New Revision: 482
URL: http://svn.gnome.org/viewvc/rygel?rev=482&view=rev
Log:
Duplicate common DIDLLiteResource fields in MediaItem.
This is to save typical plugin developer from the knowlege of
DIDLLiteResource. Next we need to make sure he doesn't need to know about
DIDL-Lite at all.
Modified:
trunk/src/plugins/dvb/rygel-dvb-channel.vala
trunk/src/plugins/test/rygel-test-item.vala
trunk/src/plugins/tracker/rygel-tracker-image-item.vala
trunk/src/plugins/tracker/rygel-tracker-music-item.vala
trunk/src/plugins/tracker/rygel-tracker-video-item.vala
trunk/src/rygel/rygel-http-server.vala
trunk/src/rygel/rygel-media-item.vala
Modified: trunk/src/plugins/dvb/rygel-dvb-channel.vala
==============================================================================
--- trunk/src/plugins/dvb/rygel-dvb-channel.vala (original)
+++ trunk/src/plugins/dvb/rygel-dvb-channel.vala Wed Jan 28 12:32:17 2009
@@ -63,8 +63,8 @@
this.upnp_class = "object.item.videoItem.videoBroadcast";
}
- this.res.mime_type = "video/mpeg";
- this.res.uri = this.channel_list.GetChannelURL (cid);
+ this.mime_type = "video/mpeg";
+ this.uri = this.channel_list.GetChannelURL (cid);
}
}
Modified: trunk/src/plugins/test/rygel-test-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-item.vala Wed Jan 28 12:32:17 2009
@@ -40,7 +40,7 @@
HTTPServer http_server) {
base (id, parent_id, title, upnp_class, http_server);
- this.res.mime_type = mime;
+ this.mime_type = mime;
this.author = TEST_AUTHOR;
}
Modified: trunk/src/plugins/tracker/rygel-tracker-image-item.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-image-item.vala (original)
+++ trunk/src/plugins/tracker/rygel-tracker-image-item.vala Wed Jan 28 12:32:17 2009
@@ -73,16 +73,16 @@
this.title = values[Metadata.FILE_NAME];
if (values[Metadata.SIZE] != "")
- this.res.size = values[Metadata.SIZE].to_int ();
+ this.size = values[Metadata.SIZE].to_int ();
if (values[Metadata.WIDTH] != "")
- this.res.width = values[Metadata.WIDTH].to_int ();
+ this.width = values[Metadata.WIDTH].to_int ();
if (values[Metadata.HEIGHT] != "")
- this.res.height = values[Metadata.HEIGHT].to_int ();
+ this.height = values[Metadata.HEIGHT].to_int ();
if (values[Metadata.SIZE] != "")
- this.res.size = values[Metadata.SIZE].to_int ();
+ this.size = values[Metadata.SIZE].to_int ();
if (values[Metadata.DATE] != "") {
this.date = seconds_to_iso8601 (values[Metadata.DATE]);
@@ -90,10 +90,10 @@
this.date = seconds_to_iso8601 (values[Metadata.IMAGE_DATE]);
}
- this.res.mime_type = values[Metadata.MIME];
+ this.mime_type = values[Metadata.MIME];
this.author = values[Metadata.CREATOR];
this.album = values[Metadata.ALBUM];
- this.res.uri = this.uri_from_path (path);
+ this.uri = this.uri_from_path (path);
}
}
Modified: trunk/src/plugins/tracker/rygel-tracker-music-item.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-music-item.vala (original)
+++ trunk/src/plugins/tracker/rygel-tracker-music-item.vala Wed Jan 28 12:32:17 2009
@@ -73,7 +73,7 @@
this.title = values[Metadata.FILE_NAME];
if (values[Metadata.SIZE] != "")
- this.res.size = values[Metadata.SIZE].to_int ();
+ this.size = values[Metadata.SIZE].to_int ();
if (values[Metadata.TRACK_NUM] != "")
this.track_number = values[Metadata.TRACK_NUM].to_int ();
@@ -86,10 +86,10 @@
this.date = seconds_to_iso8601 (values[Metadata.DATE_ADDED]);
}
- this.res.mime_type = values[Metadata.MIME];
+ this.mime_type = values[Metadata.MIME];
this.author = values[Metadata.ARTIST];
this.album = values[Metadata.ALBUM];
- this.res.uri = this.uri_from_path (path);
+ this.uri = this.uri_from_path (path);
}
}
Modified: trunk/src/plugins/tracker/rygel-tracker-video-item.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-video-item.vala (original)
+++ trunk/src/plugins/tracker/rygel-tracker-video-item.vala Wed Jan 28 12:32:17 2009
@@ -69,18 +69,18 @@
this.title = values[Metadata.FILE_NAME];
if (values[Metadata.SIZE] != "")
- this.res.size = values[Metadata.SIZE].to_int ();
+ this.size = values[Metadata.SIZE].to_int ();
if (values[Metadata.WIDTH] != "")
- this.res.width = values[Metadata.WIDTH].to_int ();
+ this.width = values[Metadata.WIDTH].to_int ();
if (values[Metadata.HEIGHT] != "")
- this.res.height = values[Metadata.HEIGHT].to_int ();
+ this.height = values[Metadata.HEIGHT].to_int ();
this.date = this.seconds_to_iso8601 (values[Metadata.DATE]);
- this.res.mime_type = values[Metadata.MIME];
+ this.mime_type = values[Metadata.MIME];
this.author = values[Metadata.AUTHOR];
- this.res.uri = this.uri_from_path (path);
+ this.uri = this.uri_from_path (path);
}
}
Modified: trunk/src/rygel/rygel-http-server.vala
==============================================================================
--- trunk/src/rygel/rygel-http-server.vala (original)
+++ trunk/src/rygel/rygel-http-server.vala Wed Jan 28 12:32:17 2009
@@ -158,7 +158,7 @@
return;
}
- if (item.res.size > 0) {
+ if (item.size > 0) {
this.handle_interactive_item (msg, item, seek);
} else {
this.handle_streaming_item (msg, item);
@@ -168,20 +168,16 @@
private void add_item_headers (Soup.Message msg,
MediaItem item,
Seek? seek) {
- if (item.res.mime_type != null) {
- msg.response_headers.append ("Content-Type", item.res.mime_type);
+ if (item.mime_type != null) {
+ msg.response_headers.append ("Content-Type", item.mime_type);
}
- if (item.res.size >= 0) {
+ if (item.size >= 0) {
msg.response_headers.append ("Content-Length",
- item.res.size.to_string ());
+ item.size.to_string ());
}
- if (DLNAOperation.RANGE in item.res.dlna_operation) {
- msg.response_headers.append ("Accept-Ranges", "bytes");
- }
-
- if (item.res.size > 0) {
+ if (item.size > 0) {
int64 first_byte;
int64 last_byte;
@@ -190,21 +186,22 @@
last_byte = seek.stop;
} else {
first_byte = 0;
- last_byte = item.res.size - 1;
+ last_byte = item.size - 1;
}
// Content-Range: bytes START_BYTE-STOP_BYTE/TOTAL_LENGTH
var content_range = "bytes " +
first_byte.to_string () + "-" +
last_byte.to_string () + "/" +
- item.res.size.to_string ();
+ item.size.to_string ();
msg.response_headers.append ("Content-Range", content_range);
+ msg.response_headers.append ("Accept-Ranges", "bytes");
}
}
private void handle_streaming_item (Soup.Message msg,
MediaItem item) {
- string uri = item.res.uri;
+ string uri = item.uri;
dynamic Element src = null;
if (uri != null) {
@@ -239,7 +236,7 @@
private void handle_interactive_item (Soup.Message msg,
MediaItem item,
Seek? seek) {
- string uri = item.res.uri;
+ string uri = item.uri;
if (uri == null) {
warning ("Requested item '%s' didn't provide a URI\n", item.id);
@@ -248,7 +245,7 @@
}
try {
- this.serve_uri (uri, msg, seek, item.res.size);
+ this.serve_uri (uri, msg, seek, item.size);
} catch (Error error) {
warning ("Error in attempting to serve %s: %s",
uri,
@@ -291,7 +288,7 @@
range);
}
- seek = new Seek (Format.BYTES, 0, item.res.size - 1);
+ seek = new Seek (Format.BYTES, 0, item.size - 1);
// Get first byte position
string first_byte = range_tokens[0];
@@ -311,16 +308,16 @@
range);
}
- if (item.res.size > 0) {
+ if (item.size > 0) {
// shouldn't go beyond actual length of media
- if (seek.start > item.res.size ||
- seek.length > item.res.size) {
+ if (seek.start > item.size ||
+ seek.length > item.size) {
throw new HTTPServerError.OUT_OF_RANGE (
"Range '%s' not setsifiable", range);
}
// No need to seek if whole stream is requested
- if (seek.start == 0 && seek.length == item.res.size) {
+ if (seek.start == 0 && seek.length == item.size) {
return null;
}
} else if (seek.start == 0) {
Modified: trunk/src/rygel/rygel-media-item.vala
==============================================================================
--- trunk/src/rygel/rygel-media-item.vala (original)
+++ trunk/src/rygel/rygel-media-item.vala Wed Jan 28 12:32:17 2009
@@ -42,10 +42,25 @@
public string date;
public string upnp_class;
- public DIDLLiteResource res;
-
+ // Resource info
+ public string uri;
+ public string mime_type;
+
+ public long size = -1; // Size in bytes
+ public long duration = -1; // Duration in seconds
+ public int bitrate = -1; // Bytes/second
+
+ // Audio/Music
+ public int sample_freq = -1;
+ public int bits_per_sample = -1;
+ public int n_audio_channels = -1;
public int track_number = -1;
+ // Image/Video
+ public int width = -1;
+ public int height = -1;
+ public int color_depth = -1;
+
protected Rygel.HTTPServer http_server;
public MediaItem (string id,
@@ -58,9 +73,6 @@
this.title = title;
this.upnp_class = upnp_class;
this.http_server = http_server;
-
- this.res = DIDLLiteResource ();
- this.res.reset ();
}
public override void serialize (DIDLLiteWriter didl_writer) throws Error {
@@ -121,23 +133,25 @@
}
/* Add resource data */
+ DIDLLiteResource res = this.get_original_res ();
+
/* Protocol info */
- if (this.res.uri != null) {
- string protocol = get_protocol_for_uri (this.res.uri);
- this.res.protocol = protocol;
+ if (res.uri != null) {
+ string protocol = get_protocol_for_uri (res.uri);
+ res.protocol = protocol;
}
- this.res.dlna_profile = "MP3"; /* FIXME */
+ res.dlna_profile = "MP3"; /* FIXME */
if (this.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
- this.res.dlna_flags |= DLNAFlags.INTERACTIVE_TRANSFER_MODE;
+ res.dlna_flags |= DLNAFlags.INTERACTIVE_TRANSFER_MODE;
} else {
- this.res.dlna_flags |= DLNAFlags.STREAMING_TRANSFER_MODE;
+ res.dlna_flags |= DLNAFlags.STREAMING_TRANSFER_MODE;
}
- if (this.res.size > 0) {
- this.res.dlna_operation = DLNAOperation.RANGE;
- this.res.dlna_flags |= DLNAFlags.BACKGROUND_TRANSFER_MODE;
+ if (res.size > 0) {
+ res.dlna_operation = DLNAOperation.RANGE;
+ res.dlna_flags |= DLNAFlags.BACKGROUND_TRANSFER_MODE;
}
/* Now get the transcoded/proxy URIs */
@@ -147,7 +161,7 @@
}
/* Add the original res in the end */
- if (this.res.uri != null) {
+ if (res.uri != null) {
didl_writer.add_res (res);
}
@@ -188,4 +202,26 @@
return resources;
}
+
+ private DIDLLiteResource get_original_res () {
+ DIDLLiteResource res = DIDLLiteResource ();
+ res.reset ();
+
+ res.uri = this.uri;
+ res.mime_type = this.mime_type;
+
+ res.size = this.size;
+ res.duration = this.duration;
+ res.bitrate = this.bitrate;
+
+ res.sample_freq = this.sample_freq;
+ res.bits_per_sample = this.bits_per_sample;
+ res.n_audio_channels = this.n_audio_channels;
+
+ res.width = this.width;
+ res.height = this.height;
+ res.color_depth = this.color_depth;
+
+ return res;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]