rtpvrawpay: preserve GST_BUFFER_FLAG_DISCONT on the first outputted buffer
authorAntonio Ospite <antonio.ospite@collabora.com>
Mon, 8 Apr 2019 09:35:34 +0000 (11:35 +0200)
committerSebastian Dröge <slomo@coaxion.net>
Tue, 9 Apr 2019 09:32:43 +0000 (09:32 +0000)
If the incoming frame buffer has GST_BUFFER_FLAG_DISCONT set this should
be preserved and set for the first output buffer too, like other
payloaders do.

Spotted with gst-validate-1.0 when adding integration tests for
rtpsession, a minimal test to reproduce the issue is:

$ gst-validate-1.0 videotestsrc num-buffers=1 ! rtpvrawpay ! identity ! fakesink
Starting pipeline
Pipeline started
   warning : Buffer didn't have expected DISCONT flag333 speed: 1.000000 />
             Detected on <identity0:sink>
             Detected on <identity0:src>
             Detected on <fakesink0:sink>
             Description : Buffers after SEGMENT and FLUSH must have a DISCONT flag

Issues found: 1

=======> Test PASSED (Return value: 0)

gst/rtp/gstrtpvrawpay.c

index 11bd360..fa43ac8 100644 (file)
@@ -282,6 +282,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
   gboolean use_buffer_lists;
   GstBufferList *list = NULL;
   GstRTPBuffer rtp = { NULL, };
+  gboolean discont;
 
   rtpvrawpay = GST_RTP_VRAW_PAY (payload);
 
@@ -290,6 +291,8 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
     return GST_FLOW_ERROR;
   }
 
+  discont = GST_BUFFER_IS_DISCONT (buffer);
+
   GST_LOG_OBJECT (rtpvrawpay, "new frame of %" G_GSIZE_FORMAT " bytes",
       gst_buffer_get_size (buffer));
 
@@ -352,6 +355,12 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
       left = gst_rtp_buffer_calc_payload_len (mtu, 0, 0);
       out = gst_rtp_buffer_new_allocate (left, 0, 0);
 
+      if (discont) {
+        GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DISCONT);
+        /* Only the first outputted buffer has the DISCONT flag */
+        discont = FALSE;
+      }
+
       if (field == 0) {
         GST_BUFFER_PTS (out) = GST_BUFFER_PTS (buffer);
       } else {