rtponviftimestamp: make sure to set E and T bits on last buffer of lists

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5173>
This commit is contained in:
Mathieu Duponchelle 2024-02-16 18:08:36 +01:00 committed by GStreamer Marge Bot
parent b88d69b722
commit 0631a59803
2 changed files with 8 additions and 5 deletions

View file

@ -560,7 +560,7 @@ get_utc_from_offset (GstRtpOnvifTimestamp * self, GstBuffer * buf)
} }
static gboolean static gboolean
handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf) handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf, gboolean last)
{ {
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
guint8 *data; guint8 *data;
@ -669,7 +669,7 @@ handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf)
} }
/* Set E if this the last buffer of a contiguous section of recording */ /* Set E if this the last buffer of a contiguous section of recording */
if (self->set_e_bit) { if (last && self->set_e_bit) {
GST_DEBUG_OBJECT (self, "set E flag"); GST_DEBUG_OBJECT (self, "set E flag");
field |= (1 << 6); field |= (1 << 6);
self->set_e_bit = FALSE; self->set_e_bit = FALSE;
@ -683,7 +683,7 @@ handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf)
} }
/* Set T if we have received EOS */ /* Set T if we have received EOS */
if (self->set_t_bit) { if (last && self->set_t_bit) {
GST_DEBUG_OBJECT (self, "set T flag"); GST_DEBUG_OBJECT (self, "set T flag");
field |= (1 << 4); field |= (1 << 4);
self->set_t_bit = FALSE; self->set_t_bit = FALSE;
@ -705,7 +705,7 @@ done:
static GstFlowReturn static GstFlowReturn
handle_and_push_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf) handle_and_push_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf)
{ {
if (!handle_buffer (self, buf)) { if (!handle_buffer (self, buf, TRUE)) {
gst_buffer_unref (buf); gst_buffer_unref (buf);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -736,13 +736,15 @@ gst_rtp_onvif_timestamp_chain (GstPad * pad, GstObject * parent,
static gboolean static gboolean
do_handle_buffer (GstBuffer ** buffer, guint idx, GstRtpOnvifTimestamp * self) do_handle_buffer (GstBuffer ** buffer, guint idx, GstRtpOnvifTimestamp * self)
{ {
return handle_buffer (self, *buffer); return handle_buffer (self, *buffer, idx + 1 == self->current_list_size);
} }
/* @buf: (transfer full) */ /* @buf: (transfer full) */
static GstFlowReturn static GstFlowReturn
handle_and_push_buffer_list (GstRtpOnvifTimestamp * self, GstBufferList * list) handle_and_push_buffer_list (GstRtpOnvifTimestamp * self, GstBufferList * list)
{ {
self->current_list_size = gst_buffer_list_length (list);
if (!gst_buffer_list_foreach (list, (GstBufferListFunc) do_handle_buffer, if (!gst_buffer_list_foreach (list, (GstBufferListFunc) do_handle_buffer,
self)) { self)) {
gst_buffer_list_unref (list); gst_buffer_list_unref (list);

View file

@ -73,6 +73,7 @@ struct _GstRtpOnvifTimestamp {
GQueue *event_queue; GQueue *event_queue;
GstBuffer *buffer; GstBuffer *buffer;
GstBufferList *list; GstBufferList *list;
guint current_list_size;
}; };
struct _GstRtpOnvifTimestampClass { struct _GstRtpOnvifTimestampClass {