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);
}
}
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;
}
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]);
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);
}
}
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 ();
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);
}
}
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);
}
}
return;
}
- if (item.res.size > 0) {
+ if (item.size > 0) {
this.handle_interactive_item (msg, item, seek);
} else {
this.handle_streaming_item (msg, item);
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;
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) {
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);
}
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,
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];
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) {
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,
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 {
}
/* 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 */
}
/* Add the original res in the end */
- if (this.res.uri != null) {
+ if (res.uri != null) {
didl_writer.add_res (res);
}
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;
+ }
}