From 7013a5887402c6b8a0689bd0824d923a7573c16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Wed, 25 Sep 2019 10:45:28 +0200 Subject: [PATCH] videoencoder: Use video marker flag to signal end of frame This marker is optional, its name refer to RTP marker bit. This mark can be use to reduce latency in various use cases. With the split between finish_frame() and finish_subframe() we will now be able to identitfy the last subframe with no latency. In order to detail the use of GST_BUFFER_FLAG_MARKER in a video use case, the flag GST_VIDEO_BUFFER_FLAG_MARKER has been introduced with a proper documentation clarifying marker's role. --- gst-libs/gst/video/gstvideoencoder.c | 6 ++++++ gst-libs/gst/video/video-frame.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 12ed24bf48..822a09857d 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -2392,6 +2392,12 @@ gst_video_encoder_finish_frame (GstVideoEncoder * encoder, GST_BUFFER_DTS (frame->output_buffer) = frame->dts; GST_BUFFER_DURATION (frame->output_buffer) = frame->duration; + /* At this stage we have a full frame in subframe use case , + * let's mark it to enabled some latency optimization + * in some uses cases like RTP. */ + + GST_BUFFER_FLAG_SET (frame->output_buffer, GST_VIDEO_BUFFER_FLAG_MARKER); + GST_OBJECT_LOCK (encoder); /* update rate estimate */ priv->bytes += gst_buffer_get_size (frame->output_buffer); diff --git a/gst-libs/gst/video/video-frame.h b/gst-libs/gst/video/video-frame.h index eedf6b7be6..992d47beb3 100644 --- a/gst-libs/gst/video/video-frame.h +++ b/gst-libs/gst/video/video-frame.h @@ -176,6 +176,8 @@ gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFr * @GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD: The video frame has the bottom field only. This is * the same as GST_VIDEO_BUFFER_FLAG_ONEFIELD * (GST_VIDEO_BUFFER_FLAG_TFF flag unset) (Since: 1.16). + * @GST_VIDEO_BUFFER_FLAG_MARKER: The #GstBuffer contains the end of a video field or frame + * boundary such as the last subframe or packet (Since: 1.18). * @GST_VIDEO_BUFFER_FLAG_LAST: Offset to define more flags * * Additional video buffer flags. These flags can potentially be used on any @@ -197,6 +199,8 @@ typedef enum { GST_VIDEO_BUFFER_FLAG_ONEFIELD, GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD = GST_VIDEO_BUFFER_FLAG_ONEFIELD, + GST_VIDEO_BUFFER_FLAG_MARKER = GST_BUFFER_FLAG_MARKER, + GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8) } GstVideoBufferFlags;