[rygel] core: Custom GStreamer sink for HTTP streaming



commit 803a19582014d6f00bd814675a2be64aa57e7818
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Mar 22 16:11:38 2011 +0200

    core: Custom GStreamer sink for HTTP streaming

 src/rygel/Makefile.am                  |    1 +
 src/rygel/rygel-http-gst-response.vala |   11 +-----
 src/rygel/rygel-http-gst-sink.vala     |   56 ++++++++++++++++++++++++++++++++
 tests/Makefile.am                      |    1 +
 4 files changed, 60 insertions(+), 9 deletions(-)
---
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am
index 19a126c..4313a68 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -54,6 +54,7 @@ VAPI_SOURCE_FILES = \
 	rygel-http-response.vala \
 	rygel-http-gst-response.vala \
 	rygel-http-seekable-response.vala \
+	rygel-http-gst-sink.vala \
 	rygel-resource-info.vala \
 	rygel-icon-info.vala \
 	rygel-plugin.vala \
diff --git a/src/rygel/rygel-http-gst-response.vala b/src/rygel/rygel-http-gst-response.vala
index 48ae55e..07f149a 100644
--- a/src/rygel/rygel-http-gst-response.vala
+++ b/src/rygel/rygel-http-gst-response.vala
@@ -25,7 +25,6 @@
 using Gst;
 
 internal class Rygel.HTTPGstResponse : Rygel.HTTPResponse {
-    private const string SINK_NAME = "fakesink";
     // High and low threshold for number of buffered chunks
     private const uint MAX_BUFFERED_CHUNKS = 32;
     private const uint MIN_BUFFERED_CHUNKS = 4;
@@ -89,14 +88,8 @@ internal class Rygel.HTTPGstResponse : Rygel.HTTPResponse {
 
     private void prepare_pipeline (string name,
                                    Element src) throws Error {
-        dynamic Element sink = ElementFactory.make ("fakesink", SINK_NAME);
+        var sink = new HTTPGstSink ();
 
-        if (sink == null) {
-            // 'fakesink' should not be translated
-            throw new GstError.MISSING_PLUGIN (_("Plugin 'fakesink' missing"));
-        }
-
-        sink.signal_handoffs = true;
         sink.handoff.connect (this.on_new_buffer);
 
         this.pipeline = new Pipeline (name);
@@ -125,7 +118,7 @@ internal class Rygel.HTTPGstResponse : Rygel.HTTPResponse {
                                 Pad     src_pad) {
         var caps = src_pad.get_caps ();
 
-        var sink = this.pipeline.get_by_name (SINK_NAME);
+        var sink = this.pipeline.get_by_name (HTTPGstSink.NAME);
         Pad sink_pad;
 
         dynamic Element depay = GstUtils.get_rtp_depayloader (caps);
diff --git a/src/rygel/rygel-http-gst-sink.vala b/src/rygel/rygel-http-gst-sink.vala
new file mode 100644
index 0000000..5e8ac0b
--- /dev/null
+++ b/src/rygel/rygel-http-gst-sink.vala
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 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 Gst;
+
+internal class Rygel.HTTPGstSink : BaseSink {
+    public const string NAME = "http-gst-sink";
+    public const string PAD_NAME = "sink";
+
+    public signal void handoff (Buffer buffer, Pad pad);
+
+    static construct {
+        var caps = new Caps.any ();
+        var template = new PadTemplate (PAD_NAME,
+                                        PadDirection.SINK,
+                                        PadPresence.ALWAYS,
+                                        caps);
+        add_pad_template (template);
+    }
+
+    public HTTPGstSink () {
+        this.sync = false;
+        this.name = NAME;
+    }
+
+    public override FlowReturn preroll (Buffer buffer) {
+        return render (buffer);
+    }
+
+    public override FlowReturn render (Buffer buffer) {
+        this.handoff (buffer, this.sinkpad);
+
+        return FlowReturn.OK;
+    }
+}
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0577d8e..16792d9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -44,6 +44,7 @@ rygel_http_gst_response_test_SOURCES = rygel-http-gst-response-test.vala \
                                    rygel-http-response_gst-response.vala \
                                    rygel-http-response-test_gst-response.vala \
 				   rygel-state-machine_gst-response.vala \
+				   rygel-http-gst-sink.vala \
 				   rygel-gst-utils.vala
 
 rygel_http_seekable_response_test_SOURCES = \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]