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);
}
}
--- /dev/null
+/*
+ * 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);
+ }
+}
+
* 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; }
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);
- }
}