rtp: Fix allocations to support source-info property

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>
This commit is contained in:
Sebastian Dröge 2020-09-28 18:25:21 +03:00 committed by GStreamer Merge Bot
parent d494be9916
commit f95dde512c
14 changed files with 42 additions and 22 deletions

View 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)) {

View 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;

View 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);
}

View 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 */

View 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);

View 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);

View 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;

View 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);

View 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");

View 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,

View 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;

View 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;

View 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 */

View 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;