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
This commit is contained in:
Jesper Larsen 2014-02-08 13:08:02 +01:00 committed by Sebastian Dröge
parent 3e6c1967c9
commit 972f7ea71f
2 changed files with 13 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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;