From 8d6e72a2999e022a5724ff7117ae52ed506d72a3 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 25 Mar 2014 15:21:03 -0400 Subject: [PATCH] v4l2: Move capture eos handling in _process() Now that we might be copying out buffer (e.g. downstream don't support video meta bug we need it) we need to move the EOS handling inside the process method. --- sys/v4l2/gstv4l2bufferpool.c | 21 ++++++++++++++++++--- sys/v4l2/gstv4l2videodec.c | 4 ---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 89aa4b4912..99e679c31d 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -1441,14 +1441,24 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf) { GstBuffer *tmp; - if (buf->pool == bpool) - /* nothing, data was inside the buffer when we did _acquire() */ - goto done; + if (buf->pool == bpool) { + if (gst_buffer_get_size (buf) == 0) + goto eos; + else + /* nothing, data was inside the buffer when we did _acquire() */ + goto done; + } /* buffer not from our pool, grab a frame and copy it into the target */ if ((ret = gst_v4l2_buffer_pool_dqbuf (pool, &tmp)) != GST_FLOW_OK) goto done; + /* An empty buffer on capture indicates the end of stream */ + if (gst_buffer_get_size (tmp) == 0) { + gst_buffer_unref (tmp); + goto eos; + } + if (!gst_v4l2_object_copy (obj, buf, tmp)) goto copy_failed; @@ -1556,6 +1566,11 @@ start_failed: GST_ERROR_OBJECT (obj->element, "failed to start streaming"); return GST_FLOW_ERROR; } +eos: + { + GST_DEBUG_OBJECT (obj->element, "end of stream reached"); + return GST_FLOW_EOS; + } } diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c index 56a116e216..866ce6790d 100644 --- a/sys/v4l2/gstv4l2videodec.c +++ b/sys/v4l2/gstv4l2videodec.c @@ -393,10 +393,6 @@ gst_v4l2_video_dec_loop (GstVideoDecoder * decoder) if (ret != GST_FLOW_OK) goto beach; - /* Check if buffer isn't the last one */ - if (gst_buffer_get_size (buffer) == 0) - goto beach; - GST_LOG_OBJECT (decoder, "Process output buffer"); ret = gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL (self->