rtpbasedepay: when setting discont flag make sure rtpbuffer is current
authorTim-Philipp Müller <tim@centricular.com>
Fri, 11 Dec 2015 11:01:53 +0000 (11:01 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 11 Dec 2015 11:06:35 +0000 (11:06 +0000)
Depayloaders will look at rtpbuffer->buffer for the discont flag.
When we set the discont flag on a buffer in the rtp base depayloader
and we have to make the buffer writable, make sure the rtpbuffer
actually contains the newly-flagged buffer, not the original input
buffer. This was introduced with the addition of the process_rtp_packet
vfunc, but would only trigger if the input buffer wasn't flagged
already and was not writable already.

gst-libs/gst/rtp/gstrtpbasedepayload.c

index a790c0f..0eb8b89 100644 (file)
@@ -426,11 +426,21 @@ gst_rtp_base_depayload_handle_buffer (GstRTPBaseDepayload * filter,
   if (G_UNLIKELY (discont)) {
     priv->discont = TRUE;
     if (!buf_discont) {
+      gpointer old_inbuf = in;
+
       /* we detected a seqnum discont but the buffer was not flagged with a discont,
        * set the discont flag so that the subclass can throw away old data. */
       GST_LOG_OBJECT (filter, "mark DISCONT on input buffer");
       in = gst_buffer_make_writable (in);
       GST_BUFFER_FLAG_SET (in, GST_BUFFER_FLAG_DISCONT);
+      /* depayloaders will check flag on rtpbuffer->buffer, so if the input
+       * buffer was not writable already we need to remap to make our
+       * newly-flagged buffer current on the rtpbuffer */
+      if (in != old_inbuf) {
+        gst_rtp_buffer_unmap (&rtp);
+        if (G_UNLIKELY (!gst_rtp_buffer_map (in, GST_MAP_READ, &rtp)))
+          goto invalid_buffer;
+      }
     }
   }