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

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: ddorwin comments Created 4 years, 7 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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/bit_reader.h" 10 #include "media/base/bit_reader.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 // Read the program info descriptor. 73 // Read the program info descriptor.
74 // TODO(damienv): check wether any of the descriptors could be useful. 74 // TODO(damienv): check wether any of the descriptors could be useful.
75 // Defined in section 2.6 of ISO-13818. 75 // Defined in section 2.6 of ISO-13818.
76 RCHECK(bit_reader->SkipBits(8 * program_info_length)); 76 RCHECK(bit_reader->SkipBits(8 * program_info_length));
77 77
78 // Read the ES description table. 78 // Read the ES description table.
79 // The end of the PID map if 4 bytes away from the end of the section 79 // The end of the PID map if 4 bytes away from the end of the section
80 // (4 bytes = size of the CRC). 80 // (4 bytes = size of the CRC).
81 int pid_map_end_marker = section_start_marker - section_length + 4; 81 int pid_map_end_marker = section_start_marker - section_length + 4;
82 std::map<int, int> pid_map; 82 using PidMapValue = std::pair<int, Descriptors>;
83 using PidMapElement = std::pair<int, PidMapValue>;
84 std::map<int, PidMapValue> pid_map;
83 while (bit_reader->bits_available() > 8 * pid_map_end_marker) { 85 while (bit_reader->bits_available() > 8 * pid_map_end_marker) {
84 int stream_type; 86 int stream_type;
85 int reserved; 87 int reserved;
86 int pid_es; 88 int pid_es;
87 int es_info_length; 89 int es_info_length;
88 RCHECK(bit_reader->ReadBits(8, &stream_type)); 90 RCHECK(bit_reader->ReadBits(8, &stream_type));
89 RCHECK(bit_reader->ReadBits(3, &reserved)); 91 RCHECK(bit_reader->ReadBits(3, &reserved));
90 RCHECK(bit_reader->ReadBits(13, &pid_es)); 92 RCHECK(bit_reader->ReadBits(13, &pid_es));
91 RCHECK(bit_reader->ReadBits(4, &reserved)); 93 RCHECK(bit_reader->ReadBits(4, &reserved));
92 RCHECK(bit_reader->ReadBits(12, &es_info_length)); 94 RCHECK(bit_reader->ReadBits(12, &es_info_length));
93 95
96 Descriptors descriptors;
97 RCHECK(descriptors.Read(bit_reader, es_info_length));
98
94 // Do not register the PID right away. 99 // Do not register the PID right away.
95 // Wait for the end of the section to be fully parsed 100 // Wait for the end of the section to be fully parsed
96 // to make sure there is no error. 101 // to make sure there is no error.
97 pid_map.insert(std::pair<int, int>(pid_es, stream_type)); 102 PidMapValue stream_info(stream_type, descriptors);
98 103 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 } 104 }
104 105
105 // Read the CRC. 106 // Read the CRC.
106 int crc32; 107 int crc32;
107 RCHECK(bit_reader->ReadBits(32, &crc32)); 108 RCHECK(bit_reader->ReadBits(32, &crc32));
108 109
109 // Once the PMT has been proved to be correct, register the PIDs. 110 // Once the PMT has been proved to be correct, register the PIDs.
110 for (std::map<int, int>::iterator it = pid_map.begin(); 111 for (const auto& it : pid_map)
111 it != pid_map.end(); ++it) 112 register_pes_cb_.Run(it.first, it.second.first, it.second.second);
112 register_pes_cb_.Run(it->first, it->second);
113 113
114 return true; 114 return true;
115 } 115 }
116 116
117 void TsSectionPmt::ResetPsiSection() { 117 void TsSectionPmt::ResetPsiSection() {
118 } 118 }
119 119
120 } // namespace mp2t 120 } // namespace mp2t
121 } // namespace media 121 } // namespace media
122 122
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698