appsrc: Clear is_eos flag when receiving the flush-stop event
authorKazunori Kobayashi <kkobayas@igel.co.jp>
Thu, 3 Dec 2015 02:53:05 +0000 (11:53 +0900)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 19 Dec 2015 10:35:39 +0000 (11:35 +0100)
The EOS event can be propagated to the downstream elements when
is_eos flag remains set even after leaving the flushing state.
This fix allows this element to normally restart the streaming
after receiving the flush event by clearing the is_eos flag.

https://bugzilla.gnome.org/show_bug.cgi?id=759110

gst-libs/gst/app/gstappsrc.c

index ae7ce10..4f15e77 100644 (file)
@@ -237,6 +237,7 @@ static gboolean gst_app_src_do_seek (GstBaseSrc * src, GstSegment * segment);
 static gboolean gst_app_src_is_seekable (GstBaseSrc * src);
 static gboolean gst_app_src_do_get_size (GstBaseSrc * src, guint64 * size);
 static gboolean gst_app_src_query (GstBaseSrc * src, GstQuery * query);
+static gboolean gst_app_src_event (GstBaseSrc * src, GstEvent * event);
 
 static GstFlowReturn gst_app_src_push_buffer_action (GstAppSrc * appsrc,
     GstBuffer * buffer);
@@ -528,6 +529,7 @@ gst_app_src_class_init (GstAppSrcClass * klass)
   basesrc_class->is_seekable = gst_app_src_is_seekable;
   basesrc_class->get_size = gst_app_src_do_get_size;
   basesrc_class->query = gst_app_src_query;
+  basesrc_class->event = gst_app_src_event;
 
   klass->push_buffer = gst_app_src_push_buffer_action;
   klass->push_sample = gst_app_src_push_sample_action;
@@ -1916,3 +1918,22 @@ gst_app_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
   iface->get_uri = gst_app_src_uri_get_uri;
   iface->set_uri = gst_app_src_uri_set_uri;
 }
+
+static gboolean
+gst_app_src_event (GstBaseSrc * src, GstEvent * event)
+{
+  GstAppSrc *appsrc = GST_APP_SRC_CAST (src);
+  GstAppSrcPrivate *priv = appsrc->priv;
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_FLUSH_STOP:
+      g_mutex_lock (&priv->mutex);
+      priv->is_eos = FALSE;
+      g_mutex_unlock (&priv->mutex);
+      break;
+    default:
+      break;
+  }
+
+  return GST_BASE_SRC_CLASS (parent_class)->event (src, event);
+}