summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorOlivier Crete <olivier.crete@collabora.co.uk>2008-04-02 22:46:12 +0000
committerEdward Hervey <bilboed@bilboed.com>2009-02-17 19:29:03 +0100
commit9b1a57442e7b4d875d66e6d37fe95bdf81f1d3bb (patch)
tree45130872899e723df5b2387fcfa2ce08ed950c52 /gst
parent59d6b57d52a836967c0904284f4fea2cd63d31d8 (diff)
downloadgst-plugins-bad-9b1a57442e7b4d875d66e6d37fe95bdf81f1d3bb.tar.gz
gst-plugins-bad-9b1a57442e7b4d875d66e6d37fe95bdf81f1d3bb.tar.bz2
gst-plugins-bad-9b1a57442e7b4d875d66e6d37fe95bdf81f1d3bb.zip
[MOVED FROM GST-P-FARSIGHT] Import adder src event handling
20080402224612-3e2dc-21a682b18fe18782bf7fa48983c13c1ad86dc5a1.gz
Diffstat (limited to 'gst')
-rw-r--r--gst/liveadder/liveadder.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/gst/liveadder/liveadder.c b/gst/liveadder/liveadder.c
index 808fdca8..36e52808 100644
--- a/gst/liveadder/liveadder.c
+++ b/gst/liveadder/liveadder.c
@@ -115,6 +115,8 @@ static GstCaps *
gst_live_adder_sink_getcaps (GstPad * pad);
static gboolean
gst_live_adder_src_activate_push (GstPad * pad, gboolean active);
+static gboolean
+gst_live_adder_src_event (GstPad * pad, GstEvent * event);
static void
gst_live_adder_loop (gpointer data);
@@ -222,6 +224,8 @@ gst_live_adder_init (GstLiveAdder * adder, GstLiveAdderClass *klass)
GST_DEBUG_FUNCPTR (gst_live_adder_setcaps));
gst_pad_set_query_function (adder->srcpad,
GST_DEBUG_FUNCPTR (gst_live_adder_query));
+ gst_pad_set_event_function (adder->srcpad,
+ GST_DEBUG_FUNCPTR (gst_live_adder_src_event));
gst_pad_set_activatepush_function (adder->srcpad,
GST_DEBUG_FUNCPTR (gst_live_adder_src_activate_push));
gst_element_add_pad (GST_ELEMENT (adder), adder->srcpad);
@@ -680,6 +684,87 @@ gst_live_adder_query (GstPad * pad, GstQuery * query)
return res;
}
+static gboolean
+forward_event_func (GstPad * pad, GValue * ret, GstEvent * event)
+{
+ gst_event_ref (event);
+ GST_LOG_OBJECT (pad, "About to send event %s", GST_EVENT_TYPE_NAME (event));
+ if (!gst_pad_push_event (pad, event)) {
+ g_value_set_boolean (ret, FALSE);
+ GST_WARNING_OBJECT (pad, "Sending event %p (%s) failed.",
+ event, GST_EVENT_TYPE_NAME (event));
+ } else {
+ GST_LOG_OBJECT (pad, "Sent event %p (%s).",
+ event, GST_EVENT_TYPE_NAME (event));
+ }
+ gst_object_unref (pad);
+ return TRUE;
+}
+
+/* forwards the event to all sinkpads, takes ownership of the
+ * event
+ *
+ * Returns: TRUE if the event could be forwarded on all
+ * sinkpads.
+ */
+static gboolean
+forward_event (GstLiveAdder * adder, GstEvent * event)
+{
+ gboolean ret;
+ GstIterator *it;
+ GValue vret = { 0 };
+
+ GST_LOG_OBJECT (adder, "Forwarding event %p (%s)", event,
+ GST_EVENT_TYPE_NAME (event));
+
+ ret = TRUE;
+
+ g_value_init (&vret, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&vret, TRUE);
+ it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (adder));
+ gst_iterator_fold (it, (GstIteratorFoldFunction) forward_event_func, &vret,
+ event);
+ gst_iterator_free (it);
+ gst_event_unref (event);
+
+ ret = g_value_get_boolean (&vret);
+
+ return ret;
+}
+
+
+static gboolean
+gst_live_adder_src_event (GstPad * pad, GstEvent * event)
+{
+ GstLiveAdder *adder;
+ gboolean result;
+
+ adder = GST_LIVE_ADDER (gst_pad_get_parent (pad));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_QOS:
+ /* QoS might be tricky */
+ result = FALSE;
+ break;
+ case GST_EVENT_SEEK:
+ /* I'm not certain how to handle seeks yet */
+ result = FALSE;
+ break;
+ case GST_EVENT_NAVIGATION:
+ /* navigation is rather pointless. */
+ result = FALSE;
+ break;
+ default:
+ /* just forward the rest for now */
+ result = forward_event (adder, event);
+ break;
+
+ }
+ gst_object_unref (adder);
+
+ return result;
+}
+
static guint
gst_live_adder_length_from_duration (GstLiveAdder *adder, GstClockTime duration)
{