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

Unified Diff: media/formats/mp2t/ts_section_cets_pssh.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 side-by-side diff with in-line comments
Download patch
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..38da070e91aa8f1aeb9cd1661bf7aab2244c30c0
--- /dev/null
+++ b/media/formats/mp2t/ts_section_cets_pssh.cc
@@ -0,0 +1,56 @@
+// 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/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_t* buf,
+ int size) {
+ DCHECK(buf);
+ // ignore if doesn't contain PUSI.
ddorwin 2016/05/18 20:06:51 nit: Capital 'I'.
dougsteed 2016/05/26 02:33:15 Done.
+ if (!payload_unit_start_indicator)
+ return false;
+ // 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_t declared_box_bytes = static_cast<uint8_t>(pssh[3]);
+ RCHECK(declared_box_bytes <= box_length_bits * 8);
+ pssh.resize(declared_box_bytes);
+ register_pssh_boxes_cb_.Run(std::vector<uint8_t>(pssh.begin(), pssh.end()));
+ return true;
+}
+
+void TsSectionCetsPssh::Flush() {
+ // no pending state.
ddorwin 2016/05/18 20:06:51 ditto
dougsteed 2016/05/26 02:33:15 Done.
+}
+
+void TsSectionCetsPssh::Reset() {
+ // no state to clean up.
+}
+
+} // namespace mp2t
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698