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

Side by Side Diff: media/cdm/aes_decryptor.cc

Issue 1199643002: Have GetKeyIds() return the key IDs from the first matching 'pssh' box (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 5 years, 6 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
« no previous file with comments | « no previous file | media/cdm/cenc_utils.h » ('j') | media/cdm/cenc_utils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/cdm/aes_decryptor.h" 5 #include "media/cdm/aes_decryptor.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "crypto/encryptor.h" 13 #include "crypto/encryptor.h"
14 #include "crypto/symmetric_key.h" 14 #include "crypto/symmetric_key.h"
15 #include "media/base/audio_decoder_config.h" 15 #include "media/base/audio_decoder_config.h"
16 #include "media/base/cdm_key_information.h" 16 #include "media/base/cdm_key_information.h"
17 #include "media/base/cdm_promise.h" 17 #include "media/base/cdm_promise.h"
18 #include "media/base/decoder_buffer.h" 18 #include "media/base/decoder_buffer.h"
19 #include "media/base/decrypt_config.h" 19 #include "media/base/decrypt_config.h"
20 #include "media/base/video_decoder_config.h" 20 #include "media/base/video_decoder_config.h"
21 #include "media/base/video_frame.h" 21 #include "media/base/video_frame.h"
22 #include "media/cdm/json_web_key.h" 22 #include "media/cdm/json_web_key.h"
23 23
24 #if defined(USE_PROPRIETARY_CODECS) 24 #if defined(USE_PROPRIETARY_CODECS)
25 #include "media/cdm/cenc_utils.h" 25 #include "media/cdm/cenc_utils.h"
26 #endif 26 #endif
27 27
28 namespace media { 28 namespace media {
29 29
30 #if defined(USE_PROPRIETARY_CODECS)
31 // CENC SystemID for the Common System.
32 // https://w3c.github.io/encrypted-media/cenc-format.html#common-system
33 const uint8_t kCencCommonSystemId[] = {0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2,
34 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e,
35 0x52, 0xe2, 0xfb, 0x4b};
36 #endif
37
30 // Keeps track of the session IDs and DecryptionKeys. The keys are ordered by 38 // Keeps track of the session IDs and DecryptionKeys. The keys are ordered by
31 // insertion time (last insertion is first). It takes ownership of the 39 // insertion time (last insertion is first). It takes ownership of the
32 // DecryptionKeys. 40 // DecryptionKeys.
33 class AesDecryptor::SessionIdDecryptionKeyMap { 41 class AesDecryptor::SessionIdDecryptionKeyMap {
34 // Use a std::list to actually hold the data. Insertion is always done 42 // Use a std::list to actually hold the data. Insertion is always done
35 // at the front, so the "latest" decryption key is always the first one 43 // at the front, so the "latest" decryption key is always the first one
36 // in the list. 44 // in the list.
37 typedef std::list<std::pair<std::string, DecryptionKey*> > KeyList; 45 typedef std::list<std::pair<std::string, DecryptionKey*> > KeyList;
38 46
39 public: 47 public:
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // when prefixed EME is removed (http://crbug.com/249976). 276 // when prefixed EME is removed (http://crbug.com/249976).
269 if (!init_data.empty()) { 277 if (!init_data.empty()) {
270 std::vector<std::vector<uint8_t>> keys; 278 std::vector<std::vector<uint8_t>> keys;
271 switch (init_data_type) { 279 switch (init_data_type) {
272 case EmeInitDataType::WEBM: 280 case EmeInitDataType::WEBM:
273 // |init_data| is simply the key needed. 281 // |init_data| is simply the key needed.
274 keys.push_back(init_data); 282 keys.push_back(init_data);
275 break; 283 break;
276 case EmeInitDataType::CENC: 284 case EmeInitDataType::CENC:
277 #if defined(USE_PROPRIETARY_CODECS) 285 #if defined(USE_PROPRIETARY_CODECS)
286 {
278 // |init_data| is a set of 0 or more concatenated 'pssh' boxes. 287 // |init_data| is a set of 0 or more concatenated 'pssh' boxes.
279 if (!GetKeyIdsForCommonSystemId(init_data, &keys)) { 288 std::vector<uint8_t> common_system_id(
289 kCencCommonSystemId,
290 kCencCommonSystemId + arraysize(kCencCommonSystemId));
291 if (!GetKeyIdsFromPsshBoxes(init_data, common_system_id, &keys)) {
280 promise->reject(NOT_SUPPORTED_ERROR, 0, 292 promise->reject(NOT_SUPPORTED_ERROR, 0,
281 "No supported PSSH box found."); 293 "No supported PSSH box found.");
282 return; 294 return;
283 } 295 }
284 break; 296 } break;
285 #else 297 #else
286 promise->reject(NOT_SUPPORTED_ERROR, 0, 298 promise->reject(NOT_SUPPORTED_ERROR, 0,
287 "Initialization data type CENC is not supported."); 299 "Initialization data type CENC is not supported.");
288 return; 300 return;
289 #endif 301 #endif
290 case EmeInitDataType::KEYIDS: { 302 case EmeInitDataType::KEYIDS: {
291 std::string init_data_string(init_data.begin(), init_data.end()); 303 std::string init_data_string(init_data.begin(), init_data.end());
292 std::string error_message; 304 std::string error_message;
293 if (!ExtractKeyIdsFromKeyIdsInitData(init_data_string, &keys, 305 if (!ExtractKeyIdsFromKeyIdsInitData(init_data_string, &keys,
294 &error_message)) { 306 &error_message)) {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 bool AesDecryptor::DecryptionKey::Init() { 616 bool AesDecryptor::DecryptionKey::Init() {
605 CHECK(!secret_.empty()); 617 CHECK(!secret_.empty());
606 decryption_key_.reset(crypto::SymmetricKey::Import( 618 decryption_key_.reset(crypto::SymmetricKey::Import(
607 crypto::SymmetricKey::AES, secret_)); 619 crypto::SymmetricKey::AES, secret_));
608 if (!decryption_key_) 620 if (!decryption_key_)
609 return false; 621 return false;
610 return true; 622 return true;
611 } 623 }
612 624
613 } // namespace media 625 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/cdm/cenc_utils.h » ('j') | media/cdm/cenc_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698