From 7effe918d1a79fb592d9888bcb4c49aeb73c0189 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 17 Jul 2020 16:39:25 -0400 Subject: [PATCH] rtp*pay: Allocate using the base class for audio codecs This is required to add RTP header extensions from the meta automatically. Part-of: --- gst/rtp/gstrtpac3pay.c | 4 +++- gst/rtp/gstrtpamrpay.c | 4 +++- gst/rtp/gstrtpceltpay.c | 4 +++- gst/rtp/gstrtpg723pay.c | 5 +++-- gst/rtp/gstrtpg729pay.c | 4 +++- gst/rtp/gstrtpgsmpay.c | 2 +- gst/rtp/gstrtpgstpay.c | 4 +++- gst/rtp/gstrtpmp2tpay.c | 4 +++- gst/rtp/gstrtpmp4apay.c | 3 ++- gst/rtp/gstrtpmp4gpay.c | 5 +++-- gst/rtp/gstrtpmpapay.c | 4 +++- gst/rtp/gstrtpsbcpay.c | 4 +++- gst/rtp/gstrtpspeexpay.c | 2 +- gst/rtp/gstrtpvorbispay.c | 8 ++++++-- 14 files changed, 40 insertions(+), 17 deletions(-) diff --git a/gst/rtp/gstrtpac3pay.c b/gst/rtp/gstrtpac3pay.c index 8c5c235..1fecced 100644 --- a/gst/rtp/gstrtpac3pay.c +++ b/gst/rtp/gstrtpac3pay.c @@ -274,7 +274,9 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay) payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0); /* create buffer to hold the payload */ - outbuf = gst_rtp_buffer_new_allocate (2, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpac3pay), 2, 0, 0); if (FT == 0) { /* check if it all fits */ diff --git a/gst/rtp/gstrtpamrpay.c b/gst/rtp/gstrtpamrpay.c index 7921d97..828a718 100644 --- a/gst/rtp/gstrtpamrpay.c +++ b/gst/rtp/gstrtpamrpay.c @@ -312,7 +312,9 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload, goto too_big; /* now alloc output buffer */ - outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (basepayload, payload_len, 0, + 0); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); diff --git a/gst/rtp/gstrtpceltpay.c b/gst/rtp/gstrtpceltpay.c index c498897..a29d23b 100644 --- a/gst/rtp/gstrtpceltpay.c +++ b/gst/rtp/gstrtpceltpay.c @@ -332,7 +332,9 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay) payload_len, GST_TIME_ARGS (rtpceltpay->qduration)); /* get a big enough packet for the sizes + payloads */ - outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpceltpay), payload_len, 0, 0); GST_BUFFER_DURATION (outbuf) = duration; diff --git a/gst/rtp/gstrtpg723pay.c b/gst/rtp/gstrtpg723pay.c index cb6dff5..18e294a 100644 --- a/gst/rtp/gstrtpg723pay.c +++ b/gst/rtp/gstrtpg723pay.c @@ -144,8 +144,9 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay) avail = gst_adapter_available (pay->adapter); - outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); - + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD (pay), + 0, 0, 0); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); GST_BUFFER_PTS (outbuf) = pay->timestamp; diff --git a/gst/rtp/gstrtpg729pay.c b/gst/rtp/gstrtpg729pay.c index 378fa64..7809780 100644 --- a/gst/rtp/gstrtpg729pay.c +++ b/gst/rtp/gstrtpg729pay.c @@ -167,7 +167,9 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay, GstBuffer * buf) payload_len, GST_TIME_ARGS (rtpg729pay->next_ts)); /* create buffer to hold the payload */ - outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpg729pay), 0, 0, 0); gst_rtp_buffer_map (outbuf, GST_MAP_READWRITE, &rtp); diff --git a/gst/rtp/gstrtpgsmpay.c b/gst/rtp/gstrtpgsmpay.c index aa239a8..25fa0fa 100644 --- a/gst/rtp/gstrtpgsmpay.c +++ b/gst/rtp/gstrtpgsmpay.c @@ -145,7 +145,7 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload, if (payload_len > GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay)) goto too_big; - outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); + outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 0, 0, 0); /* copy timestamp and duration */ GST_BUFFER_PTS (outbuf) = timestamp; diff --git a/gst/rtp/gstrtpgstpay.c b/gst/rtp/gstrtpgstpay.c index a0f42e3..15b281b 100644 --- a/gst/rtp/gstrtpgstpay.c +++ b/gst/rtp/gstrtpgstpay.c @@ -299,7 +299,9 @@ gst_rtp_gst_pay_create_from_adapter (GstRtpGSTPay * rtpgstpay, payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0); /* create buffer to hold the header */ - outbuf = gst_rtp_buffer_new_allocate (8, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpgstpay), 8, 0, 0); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); payload = gst_rtp_buffer_get_payload (&rtp); diff --git a/gst/rtp/gstrtpmp2tpay.c b/gst/rtp/gstrtpmp2tpay.c index 12f948e..8dac50b 100644 --- a/gst/rtp/gstrtpmp2tpay.c +++ b/gst/rtp/gstrtpmp2tpay.c @@ -152,7 +152,9 @@ gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay) break; /* create buffer to hold the payload */ - outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpmp2tpay), 0, 0, 0); /* get payload */ paybuf = gst_adapter_take_buffer_fast (rtpmp2tpay->adapter, payload_len); diff --git a/gst/rtp/gstrtpmp4apay.c b/gst/rtp/gstrtpmp4apay.c index 2f01b21..ab1eeb5 100644 --- a/gst/rtp/gstrtpmp4apay.c +++ b/gst/rtp/gstrtpmp4apay.c @@ -408,7 +408,8 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload, packet_len, payload_len); /* create buffer to hold the payload. */ - outbuf = gst_rtp_buffer_new_allocate (header_len, 0, 0); + outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, + header_len, 0, 0); /* copy payload */ gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); diff --git a/gst/rtp/gstrtpmp4gpay.c b/gst/rtp/gstrtpmp4gpay.c index 1f64b24..532e2de 100644 --- a/gst/rtp/gstrtpmp4gpay.c +++ b/gst/rtp/gstrtpmp4gpay.c @@ -487,8 +487,9 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay) packet_len, payload_len); /* create buffer to hold the payload, also make room for the 4 header bytes. */ - outbuf = gst_rtp_buffer_new_allocate (4, 0, 0); - + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpmp4gpay), 4, 0, 0); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); /* copy payload */ diff --git a/gst/rtp/gstrtpmpapay.c b/gst/rtp/gstrtpmpapay.c index 09fa8a8..62639f7 100644 --- a/gst/rtp/gstrtpmpapay.c +++ b/gst/rtp/gstrtpmpapay.c @@ -213,7 +213,9 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay) payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0); /* create buffer to hold the payload */ - outbuf = gst_rtp_buffer_new_allocate (4, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpmpapay), 4, 0, 0); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); diff --git a/gst/rtp/gstrtpsbcpay.c b/gst/rtp/gstrtpsbcpay.c index 1d2cbd4..f2cf849 100644 --- a/gst/rtp/gstrtpsbcpay.c +++ b/gst/rtp/gstrtpsbcpay.c @@ -198,7 +198,9 @@ gst_rtp_sbc_pay_flush_buffers (GstRtpSBCPay * sbcpay) if (payload_length == 0) /* Nothing to send */ return GST_FLOW_OK; - outbuf = gst_rtp_buffer_new_allocate (RTP_SBC_PAYLOAD_HEADER_SIZE, 0, 0); + outbuf = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (sbcpay), RTP_SBC_PAYLOAD_HEADER_SIZE, 0, 0); /* get payload */ gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); diff --git a/gst/rtp/gstrtpspeexpay.c b/gst/rtp/gstrtpspeexpay.c index 7816bd6..6f086b0 100644 --- a/gst/rtp/gstrtpspeexpay.c +++ b/gst/rtp/gstrtpspeexpay.c @@ -279,8 +279,8 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload, duration = GST_BUFFER_DURATION (buffer); /* FIXME, only one SPEEX frame per RTP packet for now */ + outbuf = gst_rtp_base_payload_allocate_output_buffer (basepayload, 0, 0, 0); - outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); /* FIXME, assert for now */ g_assert (gst_buffer_get_size (buffer) <= GST_RTP_BASE_PAYLOAD_MTU (rtpspeexpay)); diff --git a/gst/rtp/gstrtpvorbispay.c b/gst/rtp/gstrtpvorbispay.c index 9220f37..8a3c249 100644 --- a/gst/rtp/gstrtpvorbispay.c +++ b/gst/rtp/gstrtpvorbispay.c @@ -270,14 +270,18 @@ static void gst_rtp_vorbis_pay_init_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT, GstClockTime timestamp) { + guint len; + GST_LOG_OBJECT (rtpvorbispay, "starting new packet, VDT: %d", VDT); gst_rtp_vorbis_pay_clear_packet (rtpvorbispay); /* new packet allocate max packet size */ - rtpvorbispay->packet = - gst_rtp_buffer_new_allocate_len (GST_RTP_BASE_PAYLOAD_MTU + len = gst_rtp_buffer_calc_payload_len (GST_RTP_BASE_PAYLOAD_MTU (rtpvorbispay), 0, 0); + rtpvorbispay->packet = + gst_rtp_base_payload_allocate_output_buffer (GST_RTP_BASE_PAYLOAD + (rtpvorbispay), len, 0, 0); gst_rtp_vorbis_pay_reset_packet (rtpvorbispay, VDT); GST_BUFFER_PTS (rtpvorbispay->packet) = timestamp; -- 2.7.4