rtp*pay: Allocate using the base class for audio codecs

This is required to add RTP header extensions from the
meta automatically.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/674>
This commit is contained in:
Olivier Crête 2020-07-17 16:39:25 -04:00
parent adb044c9ed
commit 7effe918d1
14 changed files with 40 additions and 17 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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