rtpmpvpay: Fix RTP buffer allocation in rtpmpvpay
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 29 Aug 2013 11:15:15 +0000 (13:15 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 29 Aug 2013 11:15:15 +0000 (13:15 +0200)
RTP buffer allocation should not be done with padding for the specific MPEG2
header as the padding is done at the end of the buffer and the last byte is
the size of the padding.

https://bugzilla.gnome.org/show_bug.cgi?id=706970

gst/rtp/gstrtpmpvpay.c

index 87c511d..0751bcd 100644 (file)
@@ -180,14 +180,16 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
     GstRTPBuffer rtp = { NULL };
     GstBuffer *paybuf;
 
-    packet_len = gst_rtp_buffer_calc_packet_len (avail, 4, 0);
+    packet_len = gst_rtp_buffer_calc_packet_len (avail + 4, 0, 0);
 
     towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (rtpmpvpay));
 
-    payload_len = gst_rtp_buffer_calc_payload_len (towrite, 4, 0);
+    payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
 
     outbuf = gst_rtp_buffer_new_allocate (4, 0, 0);
 
+    payload_len -= 4;
+
     gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
     payload = gst_rtp_buffer_get_payload (&rtp);