Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: media/formats/mp2t/ts_section_pmt.cc

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: move some gn defs Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/mp2t/ts_section_pmt.h" 5 #include "media/formats/mp2t/ts_section_pmt.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string>
ddorwin 2016/04/12 00:40:48 unused?
dougsteed 2016/05/08 23:18:45 Done.
8 9
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "media/base/bit_reader.h" 11 #include "media/base/bit_reader.h"
11 #include "media/formats/mp2t/mp2t_common.h" 12 #include "media/formats/mp2t/mp2t_common.h"
12 13
13 namespace media { 14 namespace media {
14 namespace mp2t { 15 namespace mp2t {
15 16
16 TsSectionPmt::TsSectionPmt(const RegisterPesCb& register_pes_cb) 17 TsSectionPmt::TsSectionPmt(const RegisterPesCb& register_pes_cb)
17 : register_pes_cb_(register_pes_cb) { 18 : register_pes_cb_(register_pes_cb) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 // Read the program info descriptor. 74 // Read the program info descriptor.
74 // TODO(damienv): check wether any of the descriptors could be useful. 75 // TODO(damienv): check wether any of the descriptors could be useful.
75 // Defined in section 2.6 of ISO-13818. 76 // Defined in section 2.6 of ISO-13818.
76 RCHECK(bit_reader->SkipBits(8 * program_info_length)); 77 RCHECK(bit_reader->SkipBits(8 * program_info_length));
77 78
78 // Read the ES description table. 79 // Read the ES description table.
79 // The end of the PID map if 4 bytes away from the end of the section 80 // The end of the PID map if 4 bytes away from the end of the section
80 // (4 bytes = size of the CRC). 81 // (4 bytes = size of the CRC).
81 int pid_map_end_marker = section_start_marker - section_length + 4; 82 int pid_map_end_marker = section_start_marker - section_length + 4;
82 std::map<int, int> pid_map; 83 using PidMapValue = std::pair<int, Descriptors>;
84 using PidMapElement = std::pair<int, PidMapValue>;
85 std::map<int, PidMapValue> pid_map;
83 while (bit_reader->bits_available() > 8 * pid_map_end_marker) { 86 while (bit_reader->bits_available() > 8 * pid_map_end_marker) {
84 int stream_type; 87 int stream_type;
85 int reserved; 88 int reserved;
86 int pid_es; 89 int pid_es;
87 int es_info_length; 90 int es_info_length;
88 RCHECK(bit_reader->ReadBits(8, &stream_type)); 91 RCHECK(bit_reader->ReadBits(8, &stream_type));
89 RCHECK(bit_reader->ReadBits(3, &reserved)); 92 RCHECK(bit_reader->ReadBits(3, &reserved));
90 RCHECK(bit_reader->ReadBits(13, &pid_es)); 93 RCHECK(bit_reader->ReadBits(13, &pid_es));
91 RCHECK(bit_reader->ReadBits(4, &reserved)); 94 RCHECK(bit_reader->ReadBits(4, &reserved));
92 RCHECK(bit_reader->ReadBits(12, &es_info_length)); 95 RCHECK(bit_reader->ReadBits(12, &es_info_length));
93 96
97 Descriptors descriptors;
98 RCHECK(descriptors.Read(bit_reader, es_info_length));
99
94 // Do not register the PID right away. 100 // Do not register the PID right away.
95 // Wait for the end of the section to be fully parsed 101 // Wait for the end of the section to be fully parsed
96 // to make sure there is no error. 102 // to make sure there is no error.
97 pid_map.insert(std::pair<int, int>(pid_es, stream_type)); 103 PidMapValue stream_info(stream_type, descriptors);
98 104 pid_map.insert(PidMapElement(pid_es, stream_info));
99 // Read the ES info descriptors.
100 // TODO(damienv): check wether any of the descriptors could be useful.
101 // Defined in section 2.6 of ISO-13818.
102 RCHECK(bit_reader->SkipBits(8 * es_info_length));
103 } 105 }
104 106
105 // Read the CRC. 107 // Read the CRC.
106 int crc32; 108 int crc32;
107 RCHECK(bit_reader->ReadBits(32, &crc32)); 109 RCHECK(bit_reader->ReadBits(32, &crc32));
108 110
109 // Once the PMT has been proved to be correct, register the PIDs. 111 // Once the PMT has been proved to be correct, register the PIDs.
110 for (std::map<int, int>::iterator it = pid_map.begin(); 112 for (const auto& it : pid_map)
111 it != pid_map.end(); ++it) 113 register_pes_cb_.Run(it.first, it.second.first, it.second.second);
112 register_pes_cb_.Run(it->first, it->second);
113 114
114 return true; 115 return true;
115 } 116 }
116 117
117 void TsSectionPmt::ResetPsiSection() { 118 void TsSectionPmt::ResetPsiSection() {
118 } 119 }
119 120
120 } // namespace mp2t 121 } // namespace mp2t
121 } // namespace media 122 } // namespace media
122 123
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698