avtpsink: Accept buffers that fall out of segment
authorEderson de Souza <ederson.desouza@intel.com>
Fri, 3 Apr 2020 17:41:31 +0000 (10:41 -0700)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 2 May 2020 17:42:15 +0000 (17:42 +0000)
Proper calculate running time for buffers that are out of current
segment and try to honor them.

A typical case is for AVTP packets coming from avtpcvfpay element, as
those may have DTS that falls out of segment (which is about PTS).

By using gst_segment_to_running_time_full(), avtpsink can properly
calculate when to transmit those buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1004>

ext/avtp/gstavtpsink.c

index 5f469dd..a825049 100644 (file)
@@ -374,12 +374,17 @@ gst_avtp_sink_render (GstBaseSink * basesink, GstBuffer * buffer)
   if (G_LIKELY (basesink->sync)) {
     GstClockTime base_time, running_time;
     struct cmsghdr *cmsg = CMSG_FIRSTHDR (avtpsink->msg);
+    gint ret;
 
     g_assert (GST_BUFFER_DTS_OR_PTS (buffer) != GST_CLOCK_TIME_NONE);
 
+    ret = gst_segment_to_running_time_full (&basesink->segment,
+        basesink->segment.format, GST_BUFFER_DTS_OR_PTS (buffer),
+        &running_time);
+    if (ret == -1)
+      running_time = -running_time;
+
     base_time = gst_element_get_base_time (GST_ELEMENT (avtpsink));
-    running_time = gst_segment_to_running_time (&basesink->segment,
-        basesink->segment.format, GST_BUFFER_DTS_OR_PTS (buffer));
     running_time = gst_avtp_sink_adjust_time (basesink, running_time);
     *(__u64 *) CMSG_DATA (cmsg) = UTC_TO_TAI (base_time + running_time);
   }