rtp: Fix allocations to support source-info property
authorSebastian Dröge <sebastian@centricular.com>
Mon, 28 Sep 2020 15:25:21 +0000 (18:25 +0300)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 28 Sep 2020 15:27:17 +0000 (15:27 +0000)
Use gst_rtp_base_payload_allocate_output_buffer() instead of
gst_rtp_buffer_new_allocate() in order to allocate RTP buffer with
correct number of CSRCs according to the meta.

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

14 files changed:
gst/rtp/gstrtpdvpay.c
gst/rtp/gstrtph261pay.c
gst/rtp/gstrtph263pay.c
gst/rtp/gstrtph263ppay.c
gst/rtp/gstrtph264pay.c
gst/rtp/gstrtph265pay.c
gst/rtp/gstrtpj2kpay.c
gst/rtp/gstrtpjpegpay.c
gst/rtp/gstrtpklvpay.c
gst/rtp/gstrtpmp4vpay.c
gst/rtp/gstrtpmpvpay.c
gst/rtp/gstrtptheorapay.c
gst/rtp/gstrtpvp8pay.c
gst/rtp/gstrtpvp9pay.c

index 540d685..3600251 100644 (file)
@@ -332,7 +332,9 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
   while (size >= 80) {
     /* Allocate a new buffer, set the timestamp */
     if (outbuf == NULL) {
-      outbuf = gst_rtp_buffer_new_allocate (max_payload_size, 0, 0);
+      outbuf =
+          gst_rtp_base_payload_allocate_output_buffer (basepayload,
+          max_payload_size, 0, 0);
       GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (buffer);
 
       if (!gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp)) {
index 9b8c0d9..fadc2c9 100644 (file)
@@ -813,8 +813,9 @@ gst_rtp_h261_pay_fragment_push (GstRtpH261Pay * pay, GstBuffer * buffer,
 
   nbytes = bitrange_to_bytes (start, end);
 
-  outbuf = gst_rtp_buffer_new_allocate (nbytes +
-      GST_RTP_H261_PAYLOAD_HEADER_LEN, 0, 0);
+  outbuf =
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD (pay),
+      nbytes + GST_RTP_H261_PAYLOAD_HEADER_LEN, 0, 0);
   gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
   payload = gst_rtp_buffer_get_payload (&rtp);
   header = (GstRtpH261PayHeader *) payload;
index a8def87..9c296a9 100644 (file)
@@ -1355,7 +1355,9 @@ gst_rtp_h263_pay_A_fragment_push (GstRtpH263Pay * rtph263pay,
 
   pack->gobn = context->gobs[first]->gobn;
   pack->mode = GST_RTP_H263_PAYLOAD_HEADER_MODE_A;
-  pack->outbuf = gst_rtp_buffer_new_allocate (pack->mode, 0, 0);
+  pack->outbuf =
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+      (rtph263pay), pack->mode, 0, 0);
 
   GST_DEBUG_OBJECT (rtph263pay, "Sending len:%d data to push function",
       pack->payload_len);
@@ -1412,7 +1414,9 @@ gst_rtp_h263_pay_B_fragment_push (GstRtpH263Pay * rtph263pay,
   }
 
   pack->payload_len = pack->payload_end - pack->payload_start + 1;
-  pack->outbuf = gst_rtp_buffer_new_allocate (pack->mode, 0, 0);
+  pack->outbuf =
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+      (rtph263pay), pack->mode, 0, 0);
 
   return gst_rtp_h263_pay_push (rtph263pay, context, pack);
 }
@@ -1637,7 +1641,8 @@ gst_rtp_h263_send_entire_frame (GstRtpH263Pay * rtph263pay,
       rtph263pay->available_data);
 
   pack->outbuf =
-      gst_rtp_buffer_new_allocate (GST_RTP_H263_PAYLOAD_HEADER_MODE_A, 0, 0);
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+      (rtph263pay), GST_RTP_H263_PAYLOAD_HEADER_MODE_A, 0, 0);
 
   return gst_rtp_h263_pay_push (rtph263pay, context, pack);
 }
index 3b1ee05..bb45455 100644 (file)
@@ -732,7 +732,9 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
     if (next_gop > 0)
       towrite = MIN (next_gop, towrite);
 
-    outbuf = gst_rtp_buffer_new_allocate (header_len, 0, 0);
+    outbuf =
+        gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+        (rtph263ppay), header_len, 0, 0);
 
     gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
     /* last fragment gets the marker bit set */
index 6735328..52e92a5 100644 (file)
@@ -1060,7 +1060,7 @@ gst_rtp_h264_pay_payload_nal_fragment (GstRTPBasePayload * basepayload,
     /* use buffer lists
      * create buffer without payload containing only the RTP header
      * (memory block at index 0) */
-    outbuf = gst_rtp_buffer_new_allocate (2, 0, 0);
+    outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 2, 0, 0);
 
     gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
@@ -1122,7 +1122,7 @@ gst_rtp_h264_pay_payload_nal_single (GstRTPBasePayload * basepayload,
 
   /* create buffer without payload containing only the RTP header
    * (memory block at index 0) */
-  outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+  outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 0, 0, 0);
 
   gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
index 3793ad6..81e2bce 100644 (file)
@@ -1131,7 +1131,7 @@ gst_rtp_h265_pay_payload_nal_single (GstRTPBasePayload * basepayload,
   /* use buffer lists
    * create buffer without payload containing only the RTP header
    * (memory block at index 0) */
-  outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+  outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 0, 0, 0);
 
   gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
@@ -1206,7 +1206,7 @@ gst_rtp_h265_pay_payload_nal_fragment (GstRTPBasePayload * basepayload,
     /* use buffer lists
      * create buffer without payload containing only the RTP header
      * (memory block at index 0), and with space for PayloadHdr and FU header */
-    outbuf = gst_rtp_buffer_new_allocate (3, 0, 0);
+    outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 3, 0, 0);
 
     gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
index 9ead8a2..41d1fad 100644 (file)
@@ -440,7 +440,9 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
       data_size = payload_size - GST_RTP_J2K_HEADER_SIZE;
 
       /* make buffer for header */
-      outbuf = gst_rtp_buffer_new_allocate (GST_RTP_J2K_HEADER_SIZE, 0, 0);
+      outbuf =
+          gst_rtp_base_payload_allocate_output_buffer (basepayload,
+          GST_RTP_J2K_HEADER_SIZE, 0, 0);
 
       GST_BUFFER_PTS (outbuf) = timestamp;
 
index 31f8efa..b79ecc6 100644 (file)
@@ -885,7 +885,9 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
     if (dri_found)
       header_size += sizeof (restart_marker_header);
 
-    outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
+    outbuf =
+        gst_rtp_base_payload_allocate_output_buffer (basepayload, header_size,
+        0, 0);
 
     gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
index f24d29f..779d6a7 100644 (file)
@@ -147,7 +147,7 @@ gst_rtp_klv_pay_handle_buffer (GstRTPBasePayload * basepayload, GstBuffer * buf)
     bytes_left = map.size - offset;
     payload_size = MIN (bytes_left, max_payload_size);
 
-    outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+    outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 0, 0, 0);
 
     if (payload_size == bytes_left) {
       GST_LOG_OBJECT (pay, "last packet of KLV unit");
index 2980339..30c679d 100644 (file)
@@ -278,7 +278,9 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
 
     /* create buffer without payload. The payload will be put
      * in next buffer instead. Both buffers will be merged */
-    outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+    outbuf =
+        gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+        (rtpmp4vpay), 0, 0, 0);
 
     /* Take buffer with the payload from the adapter */
     outbuf_data = gst_adapter_take_buffer_fast (rtpmp4vpay->adapter,
index eb73af2..24ad3c7 100644 (file)
@@ -204,7 +204,9 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
 
     payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
 
-    outbuf = gst_rtp_buffer_new_allocate (4, 0, 0);
+    outbuf =
+        gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+        (rtpmpvpay), 4, 0, 0);
 
     payload_len -= 4;
 
index 61fb90b..136ce7d 100644 (file)
@@ -281,8 +281,8 @@ gst_rtp_theora_pay_init_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
 
   /* new packet allocate max packet size */
   rtptheorapay->packet =
-      gst_rtp_buffer_new_allocate_len (GST_RTP_BASE_PAYLOAD_MTU
-      (rtptheorapay), 0, 0);
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD
+      (rtptheorapay), GST_RTP_BASE_PAYLOAD_MTU (rtptheorapay), 0, 0);
   gst_rtp_theora_pay_reset_packet (rtptheorapay, TDT);
 
   GST_BUFFER_PTS (rtptheorapay->packet) = timestamp;
index e3c8b34..d286029 100644 (file)
@@ -385,9 +385,9 @@ gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid,
   guint8 *p;
   GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
 
-  out = gst_rtp_base_payload_allocate_output_buffer (
-      GST_RTP_BASE_PAYLOAD_CAST (self), gst_rtp_vp8_calc_header_len (self),
-      0, 0);
+  out =
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD_CAST
+      (self), gst_rtp_vp8_calc_header_len (self), 0, 0);
   gst_rtp_buffer_map (out, GST_MAP_READWRITE, &rtpbuffer);
   p = gst_rtp_buffer_get_payload (&rtpbuffer);
   /* X=0,R=0,N=0,S=start,PartID=partid */
index ce79c64..6ec4251 100644 (file)
@@ -386,7 +386,9 @@ gst_rtp_vp9_create_header_buffer (GstRtpVP9Pay * self,
   guint off = 1;
   guint hdrlen = gst_rtp_vp9_calc_header_len (self, start);
 
-  out = gst_rtp_buffer_new_allocate (hdrlen, 0, 0);
+  out =
+      gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD (self),
+      hdrlen, 0, 0);
   gst_rtp_buffer_map (out, GST_MAP_READWRITE, &rtpbuffer);
   p = gst_rtp_buffer_get_payload (&rtpbuffer);
   p[0] = 0x0;