summaryrefslogtreecommitdiff
path: root/gst/rtp/gstrtpmp2tdepay.c
diff options
context:
space:
mode:
authorEdward Hervey <edward.hervey@collabora.co.uk>2012-05-26 11:57:16 +0200
committerEdward Hervey <edward.hervey@collabora.co.uk>2012-05-26 12:04:54 +0200
commit923be8a85b1cae4e509e2cc095e90780cf095578 (patch)
tree29f9e404dddb79fd5196479d4bf6b4357d85dab6 /gst/rtp/gstrtpmp2tdepay.c
parent5b3d3b0885eee6dc6e10e0fc39ac1c85c7b73e2d (diff)
rtpmp2tdepay: Only output integral mpeg-ts packets
From RFC 2250 2. Encapsulation of MPEG System and Transport Streams ... For MPEG2 Transport Streams the RTP payload will contain an integral number of MPEG transport packets. To avoid end system inefficiencies, data from multiple small MTS packets (normally fixed in size at 188 bytes) are aggregated into a single RTP packet. The number of transport packets contained is computed by dividing RTP payload length by the length of an MTS packet (188). .... Since it needs to contain "an integral number of MPEG transport packets", a simple fix is to check that's the case, and strip off any leftover data. Fixes #676799 Conflicts: gst/rtp/gstrtpmp2tdepay.c
Diffstat (limited to 'gst/rtp/gstrtpmp2tdepay.c')
-rw-r--r--gst/rtp/gstrtpmp2tdepay.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gst/rtp/gstrtpmp2tdepay.c b/gst/rtp/gstrtpmp2tdepay.c
index acb4d52a8..39699e58d 100644
--- a/gst/rtp/gstrtpmp2tdepay.c
+++ b/gst/rtp/gstrtpmp2tdepay.c
@@ -150,7 +150,7 @@ gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpMP2TDepay *rtpmp2tdepay;
GstBuffer *outbuf;
- gint payload_len;
+ gint payload_len, leftover;
GstRTPBuffer rtp = { NULL };
rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
@@ -161,11 +161,28 @@ gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes))
goto empty_packet;
- outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp,
- rtpmp2tdepay->skip_first_bytes, -1);
+ payload_len -= rtpmp2tdepay->skip_first_bytes;
+
+ /* RFC 2250
+ *
+ * 2. Encapsulation of MPEG System and Transport Streams
+ *
+ * For MPEG2 Transport Streams the RTP payload will contain an integral
+ * number of MPEG transport packets.
+ */
+ leftover = payload_len % 188;
+ if (G_UNLIKELY (leftover)) {
+ GST_WARNING ("We don't have an integral number of buffers (leftover: %d)",
+ leftover);
+
+ payload_len -= leftover;
+ }
- gst_rtp_buffer_unmap (&rtp);
+ outbuf =
+ gst_rtp_buffer_get_payload_subbuffer (&rtp,
+ rtpmp2tdepay->skip_first_bytes, payload_len);
+ gst_rtp_buffer_unmap (&rtp);
if (outbuf)
GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %"
G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));