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

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: rebase Created 4 years 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
« no previous file with comments | « media/formats/mp2t/ts_section_pmt.h ('k') | media/formats/mpeg/adts_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 std::map<int, PidMapValue> pid_map;
83 while (bit_reader->bits_available() > 8 * pid_map_end_marker) { 84 while (bit_reader->bits_available() > 8 * pid_map_end_marker) {
84 int stream_type; 85 int stream_type;
85 int reserved; 86 int reserved;
86 int pid_es; 87 int pid_es;
87 int es_info_length; 88 int es_info_length;
88 RCHECK(bit_reader->ReadBits(8, &stream_type)); 89 RCHECK(bit_reader->ReadBits(8, &stream_type));
89 RCHECK(bit_reader->ReadBits(3, &reserved)); 90 RCHECK(bit_reader->ReadBits(3, &reserved));
90 RCHECK(bit_reader->ReadBits(13, &pid_es)); 91 RCHECK(bit_reader->ReadBits(13, &pid_es));
91 RCHECK(bit_reader->ReadBits(4, &reserved)); 92 RCHECK(bit_reader->ReadBits(4, &reserved));
92 RCHECK(bit_reader->ReadBits(12, &es_info_length)); 93 RCHECK(bit_reader->ReadBits(12, &es_info_length));
93 94
95 Descriptors descriptors;
96 RCHECK(descriptors.Read(bit_reader, es_info_length));
97
94 // Do not register the PID right away. 98 // Do not register the PID right away.
95 // Wait for the end of the section to be fully parsed 99 // Wait for the end of the section to be fully parsed
96 // to make sure there is no error. 100 // to make sure there is no error.
97 pid_map.insert(std::pair<int, int>(pid_es, stream_type)); 101 PidMapValue stream_info(stream_type, descriptors);
98 102 pid_map.insert(std::make_pair(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 } 103 }
104 104
105 // Read the CRC. 105 // Read the CRC.
106 int crc32; 106 int crc32;
107 RCHECK(bit_reader->ReadBits(32, &crc32)); 107 RCHECK(bit_reader->ReadBits(32, &crc32));
108 108
109 // Once the PMT has been proved to be correct, register the PIDs. 109 // Once the PMT has been proved to be correct, register the PIDs.
110 for (std::map<int, int>::iterator it = pid_map.begin(); 110 for (const auto& it : pid_map)
111 it != pid_map.end(); ++it) 111 register_pes_cb_.Run(it.first, it.second.first, it.second.second);
112 register_pes_cb_.Run(it->first, it->second);
113 112
114 return true; 113 return true;
115 } 114 }
116 115
117 void TsSectionPmt::ResetPsiSection() { 116 void TsSectionPmt::ResetPsiSection() {
118 } 117 }
119 118
120 } // namespace mp2t 119 } // namespace mp2t
121 } // namespace media 120 } // namespace media
122 121
OLDNEW
« no previous file with comments | « media/formats/mp2t/ts_section_pmt.h ('k') | media/formats/mpeg/adts_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698