From f95dde512c32dc31665de6c392daa88cf3b4fd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 28 Sep 2020 18:25:21 +0300 Subject: [PATCH] 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: --- gst/rtp/gstrtpdvpay.c | 4 +++- gst/rtp/gstrtph261pay.c | 5 +++-- gst/rtp/gstrtph263pay.c | 11 ++++++++--- gst/rtp/gstrtph263ppay.c | 4 +++- gst/rtp/gstrtph264pay.c | 4 ++-- gst/rtp/gstrtph265pay.c | 4 ++-- gst/rtp/gstrtpj2kpay.c | 4 +++- gst/rtp/gstrtpjpegpay.c | 4 +++- gst/rtp/gstrtpklvpay.c | 2 +- gst/rtp/gstrtpmp4vpay.c | 4 +++- gst/rtp/gstrtpmpvpay.c | 4 +++- gst/rtp/gstrtptheorapay.c | 4 ++-- gst/rtp/gstrtpvp8pay.c | 6 +++--- gst/rtp/gstrtpvp9pay.c | 4 +++- 14 files changed, 42 insertions(+), 22 deletions(-) diff --git a/gst/rtp/gstrtpdvpay.c b/gst/rtp/gstrtpdvpay.c index 540d685662..3600251ce9 100644 --- a/gst/rtp/gstrtpdvpay.c +++ b/gst/rtp/gstrtpdvpay.c @@ -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)) { diff --git a/gst/rtp/gstrtph261pay.c b/gst/rtp/gstrtph261pay.c index 9b8c0d9226..fadc2c99e7 100644 --- a/gst/rtp/gstrtph261pay.c +++ b/gst/rtp/gstrtph261pay.c @@ -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; diff --git a/gst/rtp/gstrtph263pay.c b/gst/rtp/gstrtph263pay.c index a8def87aab..9c296a9173 100644 --- a/gst/rtp/gstrtph263pay.c +++ b/gst/rtp/gstrtph263pay.c @@ -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); } diff --git a/gst/rtp/gstrtph263ppay.c b/gst/rtp/gstrtph263ppay.c index 3b1ee0512e..bb454558b3 100644 --- a/gst/rtp/gstrtph263ppay.c +++ b/gst/rtp/gstrtph263ppay.c @@ -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 */ diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c index 67353283eb..52e92a5fc6 100644 --- a/gst/rtp/gstrtph264pay.c +++ b/gst/rtp/gstrtph264pay.c @@ -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); diff --git a/gst/rtp/gstrtph265pay.c b/gst/rtp/gstrtph265pay.c index 3793ad613c..81e2bce0b2 100644 --- a/gst/rtp/gstrtph265pay.c +++ b/gst/rtp/gstrtph265pay.c @@ -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); diff --git a/gst/rtp/gstrtpj2kpay.c b/gst/rtp/gstrtpj2kpay.c index 9ead8a21a6..41d1fadca5 100644 --- a/gst/rtp/gstrtpj2kpay.c +++ b/gst/rtp/gstrtpj2kpay.c @@ -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; diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c index 31f8efa384..b79ecc606f 100644 --- a/gst/rtp/gstrtpjpegpay.c +++ b/gst/rtp/gstrtpjpegpay.c @@ -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); diff --git a/gst/rtp/gstrtpklvpay.c b/gst/rtp/gstrtpklvpay.c index f24d29f3c6..779d6a70eb 100644 --- a/gst/rtp/gstrtpklvpay.c +++ b/gst/rtp/gstrtpklvpay.c @@ -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"); diff --git a/gst/rtp/gstrtpmp4vpay.c b/gst/rtp/gstrtpmp4vpay.c index 29803392ad..30c679d4a8 100644 --- a/gst/rtp/gstrtpmp4vpay.c +++ b/gst/rtp/gstrtpmp4vpay.c @@ -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, diff --git a/gst/rtp/gstrtpmpvpay.c b/gst/rtp/gstrtpmpvpay.c index eb73af25e8..24ad3c72c3 100644 --- a/gst/rtp/gstrtpmpvpay.c +++ b/gst/rtp/gstrtpmpvpay.c @@ -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; diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c index 61fb90bc6c..136ce7d6d2 100644 --- a/gst/rtp/gstrtptheorapay.c +++ b/gst/rtp/gstrtptheorapay.c @@ -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; diff --git a/gst/rtp/gstrtpvp8pay.c b/gst/rtp/gstrtpvp8pay.c index e3c8b34837..d286029b72 100644 --- a/gst/rtp/gstrtpvp8pay.c +++ b/gst/rtp/gstrtpvp8pay.c @@ -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 */ diff --git a/gst/rtp/gstrtpvp9pay.c b/gst/rtp/gstrtpvp9pay.c index ce79c64632..6ec4251503 100644 --- a/gst/rtp/gstrtpvp9pay.c +++ b/gst/rtp/gstrtpvp9pay.c @@ -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;