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

Side by Side Diff: media/formats/webm/webm_crypto_helpers.cc

Issue 1874413003: Convert media/formats to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/webm/webm_crypto_helpers.h" 5 #include "media/formats/webm/webm_crypto_helpers.h"
6 6
7 #include <memory>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
9 #include "media/base/decrypt_config.h" 11 #include "media/base/decrypt_config.h"
10 #include "media/formats/webm/webm_constants.h" 12 #include "media/formats/webm/webm_constants.h"
11 13
12 namespace media { 14 namespace media {
13 namespace { 15 namespace {
14 16
15 // Generates a 16 byte CTR counter block. The CTR counter block format is a 17 // Generates a 16 byte CTR counter block. The CTR counter block format is a
16 // CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV. 18 // CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV.
17 // |iv_size| is the size of |iv| in btyes. Returns a string of 19 // |iv_size| is the size of |iv| in btyes. Returns a string of
18 // kDecryptionKeySize bytes. 20 // kDecryptionKeySize bytes.
19 std::string GenerateWebMCounterBlock(const uint8_t* iv, int iv_size) { 21 std::string GenerateWebMCounterBlock(const uint8_t* iv, int iv_size) {
20 std::string counter_block(reinterpret_cast<const char*>(iv), iv_size); 22 std::string counter_block(reinterpret_cast<const char*>(iv), iv_size);
21 counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0); 23 counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0);
22 return counter_block; 24 return counter_block;
23 } 25 }
24 26
25 } // namespace anonymous 27 } // namespace anonymous
26 28
27 bool WebMCreateDecryptConfig(const uint8_t* data, 29 bool WebMCreateDecryptConfig(const uint8_t* data,
28 int data_size, 30 int data_size,
29 const uint8_t* key_id, 31 const uint8_t* key_id,
30 int key_id_size, 32 int key_id_size,
31 scoped_ptr<DecryptConfig>* decrypt_config, 33 std::unique_ptr<DecryptConfig>* decrypt_config,
32 int* data_offset) { 34 int* data_offset) {
33 if (data_size < kWebMSignalByteSize) { 35 if (data_size < kWebMSignalByteSize) {
34 DVLOG(1) << "Got a block from an encrypted stream with no data."; 36 DVLOG(1) << "Got a block from an encrypted stream with no data.";
35 return false; 37 return false;
36 } 38 }
37 39
38 uint8_t signal_byte = data[0]; 40 uint8_t signal_byte = data[0];
39 int frame_offset = sizeof(signal_byte); 41 int frame_offset = sizeof(signal_byte);
40 42
41 // Setting the DecryptConfig object of the buffer while leaving the 43 // Setting the DecryptConfig object of the buffer while leaving the
(...skipping 13 matching lines...) Expand all
55 decrypt_config->reset(new DecryptConfig( 57 decrypt_config->reset(new DecryptConfig(
56 std::string(reinterpret_cast<const char*>(key_id), key_id_size), 58 std::string(reinterpret_cast<const char*>(key_id), key_id_size),
57 counter_block, 59 counter_block,
58 std::vector<SubsampleEntry>())); 60 std::vector<SubsampleEntry>()));
59 *data_offset = frame_offset; 61 *data_offset = frame_offset;
60 62
61 return true; 63 return true;
62 } 64 }
63 65
64 } // namespace media 66 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698