[rygel] core: Refactor HTTPSeek.add_response_headers
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: Refactor HTTPSeek.add_response_headers
- Date: Thu, 1 Oct 2009 22:12:43 +0000 (UTC)
commit 43f00a17ef9cc0103a9ce03b973dbf600a8ae0d7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Oct 2 00:37:32 2009 +0300
core: Refactor HTTPSeek.add_response_headers
src/rygel/rygel-http-seek.vala | 52 ++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 23 deletions(-)
---
diff --git a/src/rygel/rygel-http-seek.vala b/src/rygel/rygel-http-seek.vala
index 98c2e67..fd6977a 100644
--- a/src/rygel/rygel-http-seek.vala
+++ b/src/rygel/rygel-http-seek.vala
@@ -31,6 +31,7 @@ internal errordomain Rygel.HTTPSeekError {
internal class Rygel.HTTPSeek : GLib.Object {
public Format format { get; private set; }
+ // These are either number of bytes or microseconds
public int64 start { get; private set; }
public int64 stop { get; private set; }
@@ -143,38 +144,43 @@ internal class Rygel.HTTPSeek : GLib.Object {
}
public void add_response_header (Soup.Message msg, int64 length=-1) {
+ string header;
string value;
+ double start = 0;
+ double stop;
if (this.format == Format.TIME) {
- // TimeSeekRange.dlna.org: npt=START_TIME-END_TIME
- value = "npt=%g-".printf ((double) this.start / SECOND);
- if (this.stop > 0) {
- value += "%g".printf ((double) this.stop / SECOND);
- }
-
- msg.response_headers.append ("TimeSeekRange.dlna.org", value);
+ // TimeSeekRange.dlna.org: npt=START_TIME-END_TIME/DURATION
+ header = "TimeSeekRange.dlna.org";
+ value = "npt=";
+ start = (double) this.start / SECOND;
+ stop = (double) this.stop / SECOND;
} else {
// Content-Range: bytes START_BYTE-STOP_BYTE/TOTAL_LENGTH
- value = "bytes " + this.start.to_string () + "-";
- var end_point = this.stop;
-
- if (length > 0) {
- if (end_point >= 0) {
- end_point = int64.max (end_point, length - 1);
- } else {
- end_point = length - 1;
- }
- }
+ header = "Content-Range";
+ value = "bytes ";
+ start = (double) this.start;
+ stop = (double) this.stop;
+ }
- if (end_point >= 0) {
- value += end_point.to_string();
+ if (length > 0) {
+ if (stop >= 0.0) {
+ stop = double.max (stop, (double) length - 1);
+ } else {
+ stop = (double) length - 1;
}
+ }
- if (length > 0) {
- value += "/" + length.to_string();
- }
+ value += start.to_string () + "-";
+
+ if (stop >= 0.0) {
+ value += stop.to_string();
+ }
- msg.response_headers.append ("Content-Range", value);
+ if (length > 0) {
+ value += "/" + length.to_string();
}
+
+ msg.response_headers.append (header, value);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]