OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/formats/mp2t/ts_section_cets_pssh.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "media/base/bit_reader.h" | |
9 #include "media/formats/mp2t/mp2t_common.h" | |
10 | |
11 namespace media { | |
12 namespace mp2t { | |
13 | |
14 TsSectionCetsPssh::TsSectionCetsPssh( | |
15 const RegisterPsshBoxesCb& register_pssh_boxes_cb) | |
16 : register_pssh_boxes_cb_(register_pssh_boxes_cb) {} | |
17 | |
18 TsSectionCetsPssh::~TsSectionCetsPssh() {} | |
19 | |
20 bool TsSectionCetsPssh::Parse(bool payload_unit_start_indicator, | |
21 const uint8_t* buf, | |
22 int size) { | |
23 DCHECK(buf); | |
24 // TODO(dougsteed). This initial implementation requires the entire CETS-PSSH | |
25 // to fit in one TS packet, so we know that the box length will fit in one | |
26 // byte. | |
27 BitReader bit_reader(buf, size); | |
28 bool md5_flag; | |
29 RCHECK(bit_reader.ReadFlag(&md5_flag) && !md5_flag); | |
30 RCHECK(bit_reader.SkipBits(31)); | |
31 int box_length_bits = bit_reader.bits_available(); | |
32 std::string pssh; | |
33 RCHECK(bit_reader.ReadString(box_length_bits, &pssh)); | |
34 // Now check that the first 4 bytes are of the form {0x00, 0x00, 0x00, X}, | |
35 // where X is the box length in bytes. | |
36 RCHECK(pssh[0] == 0x00 && pssh[1] == 0x00 && pssh[2] == 0x00); | |
37 uint8_t declared_box_bytes = static_cast<uint8_t>(pssh[3]); | |
38 RCHECK(declared_box_bytes <= box_length_bits * 8); | |
39 pssh.resize(declared_box_bytes); | |
40 register_pssh_boxes_cb_.Run(std::vector<uint8_t>(pssh.begin(), pssh.end())); | |
41 return true; | |
42 } | |
43 | |
44 void TsSectionCetsPssh::Flush() {} | |
ddorwin
2016/04/12 00:40:48
ditto
dougsteed
2016/05/08 23:18:45
Done.
| |
45 | |
46 void TsSectionCetsPssh::Reset() {} | |
47 | |
48 } // namespace mp2t | |
49 } // namespace media | |
OLD | NEW |