omxh264enc: send codec data downstream
authorGuillaume Desmottes <guillaume.desmottes@collabora.com>
Thu, 16 May 2019 08:38:49 +0000 (10:38 +0200)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sun, 22 Dec 2019 05:43:40 +0000 (05:43 +0000)
We are operating in stream-format=byte-stream so the codec data buffer
is meant to be part of the buffer flow.

The base class will push it when a key frame is requested (as we stored
it with gst_video_encoder_set_headers()) but we still have to push it
right away as part of the normal buffer flow.

Also set the HEADER flag on this buffer.

omx/gstomxh264enc.c

index f050e80..94963e1 100644 (file)
@@ -863,22 +863,27 @@ gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc * enc, GstOMXPort * port,
      */
     GstBuffer *hdrs;
     GstMapInfo map = GST_MAP_INFO_INIT;
+    GstFlowReturn flow_ret;
 
     GST_DEBUG_OBJECT (self, "got codecconfig in byte-stream format");
 
     hdrs = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen);
+    GST_BUFFER_FLAG_SET (hdrs, GST_BUFFER_FLAG_HEADER);
 
     gst_buffer_map (hdrs, &map, GST_MAP_WRITE);
     memcpy (map.data,
         buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
         buf->omx_buf->nFilledLen);
     gst_buffer_unmap (hdrs, &map);
-    self->headers = g_list_append (self->headers, hdrs);
+    self->headers = g_list_append (self->headers, gst_buffer_ref (hdrs));
+    frame->output_buffer = hdrs;
+    flow_ret =
+        gst_video_encoder_finish_subframe (GST_VIDEO_ENCODER (self), frame);
 
     if (frame)
       gst_video_codec_frame_unref (frame);
 
-    return GST_FLOW_OK;
+    return flow_ret;
   } else if (self->headers) {
     gst_video_encoder_set_headers (GST_VIDEO_ENCODER (self), self->headers);
     self->headers = NULL;