From ec11b228a44a6d21c0fa593549010534b6a7f568 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Sat, 5 Jul 2014 06:21:48 +0000 Subject: [PATCH] rtph264pay: don't add trailing zeros to PPS/SPS This would happen if input is byte-stream with four-byte sync markers instead of three-byte ones. The code that scans for sync markers will place the start of the NALU on the third-last byte of the NALU sync marker, which means that any additional zeros may be counted as belonging to the previous NALU instead of being part of the next sync marker. Fix that so we don't send SPS/PPS with trailing zeros in this case. https://bugzilla.gnome.org/show_bug.cgi?id=732758 --- gst/rtp/gstrtph264pay.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c index 0135b4ca41..73f080a7b7 100644 --- a/gst/rtp/gstrtph264pay.c +++ b/gst/rtp/gstrtph264pay.c @@ -701,6 +701,10 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader, if (SPS_TYPE_ID == type || PPS_TYPE_ID == type) { GstBuffer *nal; + /* trailing 0x0 are not part of the SPS/PPS */ + while (size > 0 && data[size - 1] == 0x0) + size--; + /* encode the entire SPS NAL in base64 */ GST_DEBUG ("Found %s %x %x %x Len=%u", type == SPS_TYPE_ID ? "SPS" : "PPS", (header >> 7), (header >> 5) & 3, type, size);