rtpmpvpay: Create buffer lists instead of pushing each buffer individually
authorSebastian Dröge <sebastian@centricular.com>
Fri, 3 Jul 2015 10:14:47 +0000 (12:14 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 3 Jul 2015 10:15:10 +0000 (12:15 +0200)
gst/rtp/gstrtpmpvpay.c

index 75ae678..9bec042 100644 (file)
@@ -160,12 +160,15 @@ gst_rtp_mpv_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event)
   return ret;
 }
 
+#define RTP_HEADER_LEN 12
+
 static GstFlowReturn
 gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
 {
-  GstBuffer *outbuf;
   GstFlowReturn ret;
   guint avail;
+  GstBufferList *list;
+  GstBuffer *outbuf;
 
   guint8 *payload;
 
@@ -173,6 +176,10 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
 
   ret = GST_FLOW_OK;
 
+  list =
+      gst_buffer_list_new_sized (avail / (GST_RTP_BASE_PAYLOAD_MTU (rtpmpvpay) -
+          RTP_HEADER_LEN) + 1);
+
   while (avail > 0) {
     guint towrite;
     guint packet_len;
@@ -217,10 +224,11 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
     outbuf = gst_buffer_append (outbuf, paybuf);
 
     GST_BUFFER_PTS (outbuf) = rtpmpvpay->first_ts;
-
-    ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpmpvpay), outbuf);
+    gst_buffer_list_add (list, outbuf);
   }
 
+  ret = gst_rtp_base_payload_push_list (GST_RTP_BASE_PAYLOAD (rtpmpvpay), list);
+
   return ret;
 }