5 #include "packager/media/formats/mp2t/ts_section_pmt.h" 9 #include "packager/base/logging.h" 10 #include "packager/media/base/bit_reader.h" 11 #include "packager/media/formats/mp2t/mp2t_common.h" 17 TsSectionPmt::TsSectionPmt(
const RegisterPesCb& register_pes_cb)
18 : register_pes_cb_(register_pes_cb) {
21 TsSectionPmt::~TsSectionPmt() {
24 bool TsSectionPmt::ParsePsiSection(BitReader* bit_reader) {
27 int section_syntax_indicator;
33 int current_next_indicator;
35 int last_section_number;
36 RCHECK(bit_reader->ReadBits(8, &table_id));
37 RCHECK(bit_reader->ReadBits(1, §ion_syntax_indicator));
38 RCHECK(bit_reader->ReadBits(1, &dummy_zero));
39 RCHECK(bit_reader->ReadBits(2, &reserved));
40 RCHECK(bit_reader->ReadBits(12, §ion_length));
41 int section_start_marker =
static_cast<int>(bit_reader->bits_available()) / 8;
43 RCHECK(bit_reader->ReadBits(16, &program_number));
44 RCHECK(bit_reader->ReadBits(2, &reserved));
45 RCHECK(bit_reader->ReadBits(5, &version_number));
46 RCHECK(bit_reader->ReadBits(1, ¤t_next_indicator));
47 RCHECK(bit_reader->ReadBits(8, §ion_number));
48 RCHECK(bit_reader->ReadBits(8, &last_section_number));
54 RCHECK(table_id == 0x2);
55 RCHECK(section_syntax_indicator);
57 RCHECK(section_length <= 1021);
58 RCHECK(section_number == 0);
59 RCHECK(last_section_number == 0);
63 int program_info_length;
64 RCHECK(bit_reader->ReadBits(3, &reserved));
65 RCHECK(bit_reader->ReadBits(13, &pcr_pid));
66 RCHECK(bit_reader->ReadBits(4, &reserved));
67 RCHECK(bit_reader->ReadBits(12, &program_info_length));
68 RCHECK(program_info_length < 1024);
72 RCHECK(bit_reader->SkipBits(8 * program_info_length));
77 int pid_map_end_marker = section_start_marker - section_length + 4;
78 std::map<int, int> pid_map;
79 while (static_cast<int>(bit_reader->bits_available()) >
80 8 * pid_map_end_marker) {
85 RCHECK(bit_reader->ReadBits(8, &stream_type));
86 RCHECK(bit_reader->ReadBits(3, &reserved));
87 RCHECK(bit_reader->ReadBits(13, &pid_es));
88 RCHECK(bit_reader->ReadBits(4, &reserved));
89 RCHECK(bit_reader->ReadBits(12, &es_info_length));
94 pid_map.insert(std::pair<int, int>(pid_es, stream_type));
98 RCHECK(bit_reader->SkipBits(8 * es_info_length));
103 RCHECK(bit_reader->ReadBits(32, &crc32));
106 for (std::map<int, int>::iterator it = pid_map.begin();
107 it != pid_map.end(); ++it)
108 register_pes_cb_.Run(it->first, it->second);
113 void TsSectionPmt::ResetPsiSection() {
All the methods that are virtual are virtual for mocking.