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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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/webm/webm_crypto_helpers.h"
6
7 #include "base/logging.h"
8 #include "base/sys_byteorder.h"
9 #include "media/base/decrypt_config.h"
10 #include "media/webm/webm_constants.h"
11
12 namespace media {
13
14 std::string GenerateWebMCounterBlock(const uint8* iv, int iv_size) {
15 std::string counter_block(reinterpret_cast<const char*>(iv), iv_size);
16 counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0);
17 return counter_block;
18 }
19
20 scoped_ptr<DecryptConfig> WebMCreateDecryptConfig(
21 const uint8* data, int data_size,
22 const uint8* key_id, int key_id_size) {
23 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
24 << "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
25 << data_size;
26 uint8 signal_byte = data[0];
27 int frame_offset = sizeof(signal_byte);
28
29 // Setting the DecryptConfig object of the buffer while leaving the
30 // initialization vector empty will tell the decryptor that the frame is
31 // unencrypted.
32 std::string counter_block;
33
34 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
35 // IVs are only present on encrypted frames.
36 CHECK(data_size >= kWebMSignalByteSize + kWebMIvSize)
ddorwin 2013/03/10 21:29:39 same
fgalligan1 2013/03/12 00:42:42 ditto
37 << "Got an encrypted block with not enough data "
38 << data_size;
39 counter_block = GenerateWebMCounterBlock(data + frame_offset, kWebMIvSize);
40 frame_offset += kWebMIvSize;
41 }
42
43 scoped_ptr<DecryptConfig> config(new DecryptConfig(
44 std::string(reinterpret_cast<const char*>(key_id), key_id_size),
45 counter_block,
46 frame_offset,
47 std::vector<SubsampleEntry>()));
48 return config.Pass();
49 }
50
51 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698