diff --git a/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.c b/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.c index ef02cd7e5e..0a489bb4fd 100644 --- a/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.c +++ b/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.c @@ -560,7 +560,7 @@ get_utc_from_offset (GstRtpOnvifTimestamp * self, GstBuffer * buf) } static gboolean -handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf) +handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf, gboolean last) { GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; 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 */ - if (self->set_e_bit) { + if (last && self->set_e_bit) { GST_DEBUG_OBJECT (self, "set E flag"); field |= (1 << 6); self->set_e_bit = FALSE; @@ -683,7 +683,7 @@ handle_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf) } /* 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"); field |= (1 << 4); self->set_t_bit = FALSE; @@ -705,7 +705,7 @@ done: static GstFlowReturn handle_and_push_buffer (GstRtpOnvifTimestamp * self, GstBuffer * buf) { - if (!handle_buffer (self, buf)) { + if (!handle_buffer (self, buf, TRUE)) { gst_buffer_unref (buf); return GST_FLOW_ERROR; } @@ -736,13 +736,15 @@ gst_rtp_onvif_timestamp_chain (GstPad * pad, GstObject * parent, static gboolean 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) */ static GstFlowReturn 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, self)) { gst_buffer_list_unref (list); diff --git a/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.h b/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.h index 5cbc5f5846..f74a111cdd 100644 --- a/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.h +++ b/subprojects/gst-plugins-bad/gst/onvif/gstrtponviftimestamp.h @@ -73,6 +73,7 @@ struct _GstRtpOnvifTimestamp { GQueue *event_queue; GstBuffer *buffer; GstBufferList *list; + guint current_list_size; }; struct _GstRtpOnvifTimestampClass {