From bbf226d9d6ab19cb21d50bc5264dd3b750070ce4 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Tue, 10 Jun 2014 12:59:53 -0300 Subject: [PATCH] appsrc: add send_event handler for flushing Adds a send_event handling for allowing appsrc to flush its internal data, allowing users to flush the pipeline without setting it to null. https://bugzilla.gnome.org/show_bug.cgi?id=724231 --- gst-libs/gst/app/gstappsrc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index a3be7741f7..d529bfd3fa 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -214,6 +214,8 @@ static void gst_app_src_set_property (GObject * object, guint prop_id, static void gst_app_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static gboolean gst_app_src_send_event (GstElement * element, GstEvent * event); + static void gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min, gboolean do_max, guint64 max); @@ -479,6 +481,8 @@ gst_app_src_class_init (GstAppSrcClass * klass) gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_app_src_template)); + element_class->send_event = gst_app_src_send_event; + basesrc_class->negotiate = gst_app_src_negotiate; basesrc_class->get_caps = gst_app_src_internal_get_caps; basesrc_class->create = gst_app_src_create; @@ -700,6 +704,23 @@ gst_app_src_get_property (GObject * object, guint prop_id, GValue * value, } } +static gboolean +gst_app_src_send_event (GstElement * element, GstEvent * event) +{ + GstAppSrc *appsrc = GST_APP_SRC_CAST (element); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_FLUSH_STOP: + gst_app_src_flush_queued (appsrc); + break; + default: + break; + } + + return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, send_event, (element, + event), FALSE); +} + static gboolean gst_app_src_unlock (GstBaseSrc * bsrc) {