| Index: media/formats/mp2t/ts_section_cets_pssh.cc
|
| diff --git a/media/formats/mp2t/ts_section_cets_pssh.cc b/media/formats/mp2t/ts_section_cets_pssh.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..042146f54116e88b37069f76242da0da3fd1ce7e
|
| --- /dev/null
|
| +++ b/media/formats/mp2t/ts_section_cets_pssh.cc
|
| @@ -0,0 +1,49 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "media/formats/mp2t/ts_section_cets_pssh.h"
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/logging.h"
|
| +#include "media/base/bit_reader.h"
|
| +#include "media/formats/mp2t/mp2t_common.h"
|
| +
|
| +namespace media {
|
| +namespace mp2t {
|
| +
|
| +TsSectionCetsPssh::TsSectionCetsPssh(
|
| + const RegisterPsshBoxesCb& register_pssh_boxes_cb)
|
| + : register_pssh_boxes_cb_(register_pssh_boxes_cb) {}
|
| +
|
| +TsSectionCetsPssh::~TsSectionCetsPssh() {}
|
| +
|
| +bool TsSectionCetsPssh::Parse(bool payload_unit_start_indicator,
|
| + const uint8* buf,
|
| + int size) {
|
| + // TODO(dougsteed). This initial implementation requires the entire CETS-PSSH
|
| + // to fit in one TS packet, so we know that the box length will fit in one
|
| + // byte.
|
| + BitReader bit_reader(buf, size);
|
| + bool md5_flag;
|
| + RCHECK(bit_reader.ReadFlag(&md5_flag) && !md5_flag);
|
| + RCHECK(bit_reader.SkipBits(31));
|
| + int box_length_bits = bit_reader.bits_available();
|
| + std::string pssh;
|
| + RCHECK(bit_reader.ReadString(box_length_bits, &pssh));
|
| + // Now check that the first 4 bytes are of the form {0x00, 0x00, 0x00, X},
|
| + // where X is the box length in bytes.
|
| + RCHECK(pssh[0] == 0x00 && pssh[1] == 0x00 && pssh[2] == 0x00);
|
| + uint8 declared_box_bytes = static_cast<uint8>(pssh[3]);
|
| + RCHECK(declared_box_bytes <= box_length_bits * 8);
|
| + pssh.resize(declared_box_bytes);
|
| + register_pssh_boxes_cb_.Run(std::vector<uint8>(pssh.begin(), pssh.end()));
|
| + return true;
|
| +}
|
| +
|
| +void TsSectionCetsPssh::Flush() {}
|
| +
|
| +void TsSectionCetsPssh::Reset() {}
|
| +
|
| +} // namespace mp2t
|
| +} // namespace media
|
|
|