From 972f7ea71f078648b0a895d07a1d1f16490eb3fa Mon Sep 17 00:00:00 2001 From: Jesper Larsen Date: Sat, 8 Feb 2014 13:08:02 +0100 Subject: [PATCH] mpegts: Fix some packetizing bugs - Length of NIT stream descriptors was not detected correct - Reserved bits was not set according to EN 300 468, ISO/IEC 13818-1 - Also set output data size if the section was previously packetized https://bugzilla.gnome.org/show_bug.cgi?id=723892 --- gst-libs/gst/mpegts/gst-dvb-section.c | 4 ++-- gst-libs/gst/mpegts/gstmpegtssection.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/mpegts/gst-dvb-section.c b/gst-libs/gst/mpegts/gst-dvb-section.c index cd0a493f0a..652cf1dcee 100644 --- a/gst-libs/gst/mpegts/gst-dvb-section.c +++ b/gst-libs/gst/mpegts/gst-dvb-section.c @@ -685,7 +685,7 @@ _packetize_nit (GstMpegTsSection * section) loop_length += 6; if (stream->descriptors) { for (j = 0; j < stream->descriptors->len; j++) { - descriptor = g_ptr_array_index (stream->descriptors, i); + descriptor = g_ptr_array_index (stream->descriptors, j); loop_length += descriptor->length + 2; } } @@ -734,7 +734,7 @@ _packetize_nit (GstMpegTsSection * section) _packetize_descriptor_array (stream->descriptors, &data); /* Go back and update the descriptor length */ - GST_WRITE_UINT16_BE (pos, data - pos - 2); + GST_WRITE_UINT16_BE (pos, (data - pos - 2) | 0xF000); } } diff --git a/gst-libs/gst/mpegts/gstmpegtssection.c b/gst-libs/gst/mpegts/gstmpegtssection.c index 1c95c0149f..6b17ec09dc 100644 --- a/gst-libs/gst/mpegts/gstmpegtssection.c +++ b/gst-libs/gst/mpegts/gstmpegtssection.c @@ -1087,7 +1087,14 @@ _packetize_common_section (GstMpegTsSection * section, gsize length) /* section_syntax_indicator - 1 bit reserved - 3 bit section_length - 12 bit uimsbf */ - GST_WRITE_UINT16_BE (data, (section->section_length - 3) | 0x7000); + if (section->section_type == (GST_MPEGTS_SECTION_PAT || + GST_MPEGTS_SECTION_PMT || + GST_MPEGTS_SECTION_CAT || GST_MPEGTS_SECTION_TSDT)) { + /* Tables from ISO/IEC 13818-1 has a '0' bit + * after the section_syntax_indicator */ + GST_WRITE_UINT16_BE (data, (section->section_length - 3) | 0x3000); + } else + GST_WRITE_UINT16_BE (data, (section->section_length - 3) | 0x7000); if (!section->short_section) *data |= 0x80; @@ -1206,8 +1213,10 @@ gst_mpegts_section_packetize (GstMpegTsSection * section, gsize * output_size) g_return_val_if_fail (section->packetizer != NULL, NULL); /* Section data has already been packetized */ - if (section->data) + if (section->data) { + *output_size = section->section_length; return section->data; + } if (!section->packetizer (section)) return NULL;