summaryrefslogtreecommitdiff
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 11:57:16 +0200
commit9f485d884cf2ecc1f336ecafacc52b332e072ffe (patch)
tree9fcaf74999a9b13afd8d89eedc5f1bc98f2a3ac4
parentf1c8c133e5f727f7d9e5d1c09455c3329c0d57e5 (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
-rw-r--r--gst/rtp/gstrtpmp2tdepay.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gst/rtp/gstrtpmp2tdepay.c b/gst/rtp/gstrtpmp2tdepay.c
index 609bfba1e..1cef95b90 100644
--- a/gst/rtp/gstrtpmp2tdepay.c
+++ b/gst/rtp/gstrtpmp2tdepay.c
@@ -156,7 +156,7 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
GstRtpMP2TDepay *rtpmp2tdepay;
GstBuffer *outbuf;
- gint payload_len;
+ gint payload_len, leftover;
rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
@@ -165,9 +165,26 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes))
goto empty_packet;
+ 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;
+ }
+
outbuf =
gst_rtp_buffer_get_payload_subbuffer (buf, rtpmp2tdepay->skip_first_bytes,
- -1);
+ payload_len);
if (outbuf)
GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %d",