[rygel] core: Add HTTPTranscodeHandler
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: Add HTTPTranscodeHandler
- Date: Tue, 1 Sep 2009 22:39:28 +0000 (UTC)
commit 72a3ca5008f079bac620a6ff6e19bc24c12c56b3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Sep 1 16:04:51 2009 +0300
core: Add HTTPTranscodeHandler
Move HTTPRequestHandler implementation from Transcoder to a new class,
HTTPTranscodeHandler. This is to keep the HTTP protocol implementation
as separate as possible so that later we can easily add more protocol
handlers (e.g RTSP).
src/rygel/Makefile.am | 1 +
src/rygel/rygel-http-request.vala | 8 ++--
src/rygel/rygel-http-transcode-handler.vala | 62 +++++++++++++++++++++++++++
src/rygel/rygel-transcoder.vala | 27 +-----------
4 files changed, 68 insertions(+), 30 deletions(-)
---
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am
index fa29b50..3eb3da9 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -53,6 +53,7 @@ VAPI_SOURCE_FILES = rygel-configuration.vala \
rygel-http-request.vala \
rygel-http-request-handler.vala \
rygel-identity-request-handler.vala \
+ rygel-http-transcode-handler.vala \
rygel-seek.vala \
rygel-http-response.vala \
rygel-live-response.vala \
diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala
index 481f25b..61d21ff 100644
--- a/src/rygel/rygel-http-request.vala
+++ b/src/rygel/rygel-http-request.vala
@@ -80,10 +80,10 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
if (this.query != null) {
this.item_id = this.query.lookup ("itemid");
- var transcode_target = this.query.lookup ("transcode");
- if (transcode_target != null) {
- this.request_handler = this.http_server.get_transcoder (
- transcode_target);
+ var target = this.query.lookup ("transcode");
+ if (target != null) {
+ var transcoder = this.http_server.get_transcoder (target);
+ this.request_handler = new HTTPTranscodeHandler (transcoder);
}
}
diff --git a/src/rygel/rygel-http-transcode-handler.vala b/src/rygel/rygel-http-transcode-handler.vala
new file mode 100644
index 0000000..3596e7a
--- /dev/null
+++ b/src/rygel/rygel-http-transcode-handler.vala
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * <zeeshan ali nokia com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+using Rygel;
+using Gst;
+
+/**
+ * The handler for HTTP transcoding requests.
+ */
+internal class Rygel.HTTPTranscodeHandler : GLib.Object, HTTPRequestHandler {
+ private Transcoder transcoder;
+
+ public HTTPTranscodeHandler (Transcoder transcoder) {
+ this.transcoder = transcoder;
+ }
+
+ public virtual void add_response_headers (HTTPRequest request)
+ throws HTTPRequestError {
+ request.msg.response_headers.append ("Content-Type",
+ this.transcoder.mime_type);
+ if (request.time_range != null) {
+ request.time_range.add_response_header (request.msg);
+ }
+ }
+
+ public virtual HTTPResponse render_body (HTTPRequest request)
+ throws HTTPRequestError {
+ var item = request.item;
+ var src = item.create_stream_source ();
+ if (src == null) {
+ throw new HTTPRequestError.NOT_FOUND ("Not found");
+ }
+
+ src = this.transcoder.create_source (item, src);
+
+ return new LiveResponse (request.server,
+ request.msg,
+ "RygelLiveResponse",
+ src,
+ request.time_range);
+ }
+}
+
diff --git a/src/rygel/rygel-transcoder.vala b/src/rygel/rygel-transcoder.vala
index 593e9bd..f826ba7 100644
--- a/src/rygel/rygel-transcoder.vala
+++ b/src/rygel/rygel-transcoder.vala
@@ -29,7 +29,7 @@ using Gee;
* The base Transcoder class. Each implementation derives from it and must
* at least implement create_source method.
*/
-internal abstract class Rygel.Transcoder : GLib.Object, HTTPRequestHandler {
+internal abstract class Rygel.Transcoder : GLib.Object {
public string mime_type { get; protected set; }
public string dlna_profile { get; protected set; }
@@ -103,30 +103,5 @@ internal abstract class Rygel.Transcoder : GLib.Object, HTTPRequestHandler {
return g_content_type_is_a (content_type1, content_type2);
}
-
- public virtual void add_response_headers (HTTPRequest request)
- throws HTTPRequestError {
- request.msg.response_headers.append ("Content-Type", this.mime_type);
- if (request.time_range != null) {
- request.time_range.add_response_header(request.msg);
- }
- }
-
- public virtual HTTPResponse render_body (HTTPRequest request)
- throws HTTPRequestError {
- var item = request.item;
- var src = item.create_stream_source ();
- if (src == null) {
- throw new HTTPRequestError.NOT_FOUND ("Not found");
- }
-
- src = this.create_source (item, src);
-
- return new LiveResponse (request.server,
- request.msg,
- "RygelLiveResponse",
- src,
- request.time_range);
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]