From 3af36ed8fe22296e2051698c5241b5f2a5de5a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 1 Jul 2015 15:40:25 +0200 Subject: [PATCH] rtpac3pay: Attach the payload to the output buffer instead of copying it Might also want to produce buffer lists here if needed. --- gst/rtp/gstrtpac3pay.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gst/rtp/gstrtpac3pay.c b/gst/rtp/gstrtpac3pay.c index c63d734a26..4464150a2d 100644 --- a/gst/rtp/gstrtpac3pay.c +++ b/gst/rtp/gstrtpac3pay.c @@ -260,6 +260,7 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay) guint payload_len; guint packet_len; GstRTPBuffer rtp = { NULL, }; + GstBuffer *payload_buffer; /* this will be the total length of the packet */ packet_len = gst_rtp_buffer_calc_packet_len (2 + avail, 0, 0); @@ -271,7 +272,7 @@ 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 (payload_len, 0, 0); + outbuf = gst_rtp_buffer_new_allocate (2, 0, 0); if (FT == 0) { /* check if it all fits */ @@ -314,14 +315,16 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay) payload[1] = NF; payload_len -= 2; - gst_adapter_copy (rtpac3pay->adapter, &payload[2], 0, payload_len); - gst_adapter_flush (rtpac3pay->adapter, payload_len); - - avail -= payload_len; - if (avail == 0) + if (avail == payload_len) gst_rtp_buffer_set_marker (&rtp, TRUE); gst_rtp_buffer_unmap (&rtp); + payload_buffer = + gst_adapter_take_buffer_fast (rtpac3pay->adapter, payload_len); + outbuf = gst_buffer_append (outbuf, payload_buffer); + + avail -= payload_len; + GST_BUFFER_PTS (outbuf) = rtpac3pay->first_ts; GST_BUFFER_DURATION (outbuf) = rtpac3pay->duration;