v4l2: Move capture eos handling in _process()
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 25 Mar 2014 19:21:03 +0000 (15:21 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 8 May 2014 19:56:35 +0000 (15:56 -0400)
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
sys/v4l2/gstv4l2videodec.c

index 89aa4b4..99e679c 100644 (file)
@@ -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;
+  }
 }
 
 
index 56a116e..866ce67 100644 (file)
@@ -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->