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

Side by Side Diff: media/webm/webm_crypt_helpers.cc

Issue 10829470: Support for parsing encrypted WebM streams by src. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bug with playing latest encrypted WebM. Addressing comments. Created 8 years, 3 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) 2012 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_crypt_helpers.h"
xhwang 2012/08/29 05:08:14 How about rename this to "webm_crypto_helpers.h",
ddorwin 2012/09/01 16:46:41 Agreed. Is there a reason you chose "crypt"?
fgalligan1 2013/03/09 01:10:59 Done.
fgalligan1 2013/03/09 01:10:59 Done.
6
7 #include "base/logging.h"
ddorwin 2012/09/01 16:46:41 Not needed?
8 #include "base/sys_byteorder.h"
9 #include "media/base/decrypt_config.h"
10 #include "media/crypto/decryptor_helpers.h"
11 #include "media/webm/webm_constants.h"
12
13 namespace media {
14
15 scoped_refptr<DecoderBuffer> WebMCopyBufferCheckIfEncrypted(
ddorwin 2012/09/01 16:46:41 This function does not "check if encrypted". So, i
fgalligan1 2013/03/09 01:10:59 Renamed.
16 const uint8* data, int data_size,
17 const uint8* key_id, int key_id_size) {
18 scoped_refptr<DecoderBuffer> encrypted_buffer = DecoderBuffer::CopyFrom(
19 data + kWebMHmacSize, data_size - kWebMHmacSize);
ddorwin 2012/09/01 16:46:41 line breaks and alignment seem questionable.
fgalligan1 2013/03/09 01:10:59 Removed.
20 CHECK(encrypted_buffer);
21
22 uint8 signal_byte = data[kWebMHmacSize];
23 int data_offset = sizeof(signal_byte);
ddorwin 2012/09/01 16:46:41 const int kDataOffset? "data_offset" is not direct
fgalligan1 2013/03/09 01:10:59 Changed to frame_offset.
24
25 // Setting the DecryptConfig object of the buffer while leaving the
26 // initialization vector empty will tell the decryptor that the frame is
27 // unencrypted but integrity should still be checked.
28 std::string counter_block_str;
29
30 if (signal_byte & kWebMFlagEncryptedFrame) {
31 uint64 network_iv;
ddorwin 2012/09/01 16:46:41 Might comment "IV is only present for encrypted fr
fgalligan1 2013/03/09 01:10:59 Done.
32 memcpy(&network_iv, data + kWebMHmacSize + data_offset, sizeof(network_iv));
33 const uint64 iv = base::NetToHost64(network_iv);
34 counter_block_str =
35 GenerateCounterBlock(iv);
ddorwin 2012/09/01 16:46:41 on same line as above
36 data_offset += sizeof(iv);
37 }
38
39 encrypted_buffer->SetDecryptConfig(
40 scoped_ptr<DecryptConfig>(new DecryptConfig(
41 std::string(reinterpret_cast<const char*>(key_id), key_id_size),
42 counter_block_str,
43 std::string(reinterpret_cast<const char*>(data), kWebMHmacSize),
44 data_offset,
45 std::vector<SubsampleEntry>())));
46 return encrypted_buffer;
47 }
48
49 } // media
xhwang 2012/08/29 05:08:14 // namespace media
fgalligan1 2013/03/09 01:10:59 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698