summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2014-06-18 08:10:03 +0100
committerTim-Philipp Müller <tim@centricular.com>2014-06-18 14:54:58 +0100
commit6c9e2194d2ed52628ca9a3385e73b1d846372d81 (patch)
tree41891ddef8410f3dd209debbf7cec223e16c2b01
parent01ee993d8deaf82d2a275255a531150ec5cafcee (diff)
downloadgstreamer-plugins-good-6c9e2194d2ed52628ca9a3385e73b1d846372d81.tar.gz
rtpgstpay: pre-allocate buffer list of the right size
To avoid re-allocs.
-rw-r--r--gst/rtp/gstrtpgstpay.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gst/rtp/gstrtpgstpay.c b/gst/rtp/gstrtpgstpay.c
index 016cefe90..c0a9d94d9 100644
--- a/gst/rtp/gstrtpgstpay.c
+++ b/gst/rtp/gstrtpgstpay.c
@@ -257,12 +257,13 @@ gst_rtp_gst_pay_change_state (GstElement * element, GstStateChange transition)
return ret;
}
+#define RTP_HEADER_LEN 12
static gboolean
gst_rtp_gst_pay_create_from_adapter (GstRtpGSTPay * rtpgstpay,
GstClockTime timestamp)
{
- guint avail;
+ guint avail, mtu;
guint frag_offset;
GstBufferList *list;
@@ -270,7 +271,9 @@ gst_rtp_gst_pay_create_from_adapter (GstRtpGSTPay * rtpgstpay,
if (avail == 0)
return FALSE;
- list = gst_buffer_list_new ();
+ mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpgstpay);
+
+ list = gst_buffer_list_new_sized ((avail / (mtu - (RTP_HEADER_LEN + 8))) + 1);
frag_offset = 0;
while (avail) {
@@ -287,7 +290,7 @@ gst_rtp_gst_pay_create_from_adapter (GstRtpGSTPay * rtpgstpay,
packet_len = gst_rtp_buffer_calc_packet_len (8 + avail, 0, 0);
/* fill one MTU or all available bytes */
- towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (rtpgstpay));
+ towrite = MIN (packet_len, mtu);
/* this is the payload length */
payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);