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

Unified Diff: media/webm/webm_crypto_helpers.cc

Issue 10829470: Support for parsing encrypted WebM streams by src. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase code. Add support for audio. Created 7 years, 9 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/webm/webm_crypto_helpers.cc
diff --git a/media/webm/webm_crypto_helpers.cc b/media/webm/webm_crypto_helpers.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a7a1413558362d6893ab2321d6584c691472680
--- /dev/null
+++ b/media/webm/webm_crypto_helpers.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2013 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/webm/webm_crypto_helpers.h"
+
+#include "base/logging.h"
+#include "base/sys_byteorder.h"
+#include "media/base/decrypt_config.h"
+#include "media/webm/webm_constants.h"
+
+namespace media {
+
+std::string GenerateWebMCounterBlock(const uint8* iv, int iv_size) {
+ std::string counter_block(reinterpret_cast<const char*>(iv), iv_size);
+ counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0);
+ return counter_block;
+}
+
+scoped_ptr<DecryptConfig> WebMCreateDecryptConfig(
+ const uint8* data, int data_size,
+ const uint8* key_id, int key_id_size) {
+ CHECK(data_size >= kWebMSignalByteSize)
ddorwin 2013/03/10 21:29:39 Is this a programming or media error?
fgalligan1 2013/03/12 00:42:42 Could be either I guess. But most likely a media e
+ << "Got an encrypted block with not enough data "
ddorwin 2013/03/10 21:29:39 I assume this is included in the prod binary. Shou
fgalligan1 2013/03/12 00:42:42 I copied this from media source. Should I change i
ddorwin 2013/03/12 04:40:06 It's only non-D CHECK strings that (might) remain
+ << data_size;
+ uint8 signal_byte = data[0];
+ int frame_offset = sizeof(signal_byte);
+
+ // Setting the DecryptConfig object of the buffer while leaving the
+ // initialization vector empty will tell the decryptor that the frame is
+ // unencrypted.
+ std::string counter_block;
+
+ if (signal_byte & kWebMFlagEncryptedFrame) {
ddorwin 2013/03/10 21:29:39 Should we DLOG_IF(unsupported bits set) somewhere?
fgalligan1 2013/03/12 00:42:42 I changed this up to return a NULL scoped_ptr so w
+ // IVs are only present on encrypted frames.
+ CHECK(data_size >= kWebMSignalByteSize + kWebMIvSize)
ddorwin 2013/03/10 21:29:39 same
fgalligan1 2013/03/12 00:42:42 ditto
+ << "Got an encrypted block with not enough data "
+ << data_size;
+ counter_block = GenerateWebMCounterBlock(data + frame_offset, kWebMIvSize);
+ frame_offset += kWebMIvSize;
+ }
+
+ scoped_ptr<DecryptConfig> config(new DecryptConfig(
+ std::string(reinterpret_cast<const char*>(key_id), key_id_size),
+ counter_block,
+ frame_offset,
+ std::vector<SubsampleEntry>()));
+ return config.Pass();
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698