OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/base/android/android_cdm_factory.h" | 5 #include "media/base/android/android_cdm_factory.h" |
6 | 6 |
7 #include "base/feature_list.h" | |
7 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
8 #include "media/base/android/media_drm_bridge.h" | 9 #include "media/base/android/media_drm_bridge.h" |
9 #include "media/base/bind_to_current_loop.h" | 10 #include "media/base/bind_to_current_loop.h" |
10 #include "media/base/cdm_config.h" | 11 #include "media/base/cdm_config.h" |
12 #include "media/base/key_system_names.h" | |
11 #include "media/base/key_systems.h" | 13 #include "media/base/key_systems.h" |
14 #include "media/base/media_switches.h" | |
15 #include "media/cdm/aes_decryptor.h" | |
12 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 16 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
13 #include "url/gurl.h" | 17 #include "url/gurl.h" |
14 | 18 |
15 namespace media { | 19 namespace media { |
16 | 20 |
17 AndroidCdmFactory::AndroidCdmFactory(const CreateFetcherCB& create_fetcher_cb) | 21 AndroidCdmFactory::AndroidCdmFactory(const CreateFetcherCB& create_fetcher_cb) |
18 : create_fetcher_cb_(create_fetcher_cb) {} | 22 : create_fetcher_cb_(create_fetcher_cb) {} |
19 | 23 |
20 AndroidCdmFactory::~AndroidCdmFactory() {} | 24 AndroidCdmFactory::~AndroidCdmFactory() {} |
21 | 25 |
22 void AndroidCdmFactory::Create( | 26 void AndroidCdmFactory::Create( |
23 const std::string& key_system, | 27 const std::string& key_system, |
24 const GURL& security_origin, | 28 const GURL& security_origin, |
25 const CdmConfig& cdm_config, | 29 const CdmConfig& cdm_config, |
26 const SessionMessageCB& session_message_cb, | 30 const SessionMessageCB& session_message_cb, |
27 const SessionClosedCB& session_closed_cb, | 31 const SessionClosedCB& session_closed_cb, |
28 const SessionKeysChangeCB& session_keys_change_cb, | 32 const SessionKeysChangeCB& session_keys_change_cb, |
29 const SessionExpirationUpdateCB& session_expiration_update_cb, | 33 const SessionExpirationUpdateCB& session_expiration_update_cb, |
30 const CdmCreatedCB& cdm_created_cb) { | 34 const CdmCreatedCB& cdm_created_cb) { |
31 // Bound |cdm_created_cb| so we always fire it asynchronously. | 35 // Bound |cdm_created_cb| so we always fire it asynchronously. |
32 CdmCreatedCB bound_cdm_created_cb = BindToCurrentLoop(cdm_created_cb); | 36 CdmCreatedCB bound_cdm_created_cb = BindToCurrentLoop(cdm_created_cb); |
33 | 37 |
34 if (!security_origin.is_valid()) { | 38 if (!security_origin.is_valid()) { |
35 bound_cdm_created_cb.Run(nullptr, "Invalid origin."); | 39 bound_cdm_created_cb.Run(nullptr, "Invalid origin."); |
36 return; | 40 return; |
37 } | 41 } |
38 | 42 |
43 // Create AesDecryptor here to support External Clear Key key system. | |
44 // This is used for testing. | |
45 if (base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting) && | |
ddorwin
2016/09/16 19:40:07
nit: This order seems strange.
xhwang
2016/09/16 20:02:16
I see your point. What I am thinking is "if ECK is
| |
46 IsExternalClearKey(key_system)) { | |
47 scoped_refptr<MediaKeys> cdm( | |
48 new AesDecryptor(security_origin, session_message_cb, session_closed_cb, | |
49 session_keys_change_cb)); | |
50 bound_cdm_created_cb.Run(cdm, ""); | |
51 return; | |
52 } | |
53 | |
39 std::string error_message; | 54 std::string error_message; |
40 | 55 |
41 if (!MediaDrmBridge::IsKeySystemSupported(key_system)) { | 56 if (!MediaDrmBridge::IsKeySystemSupported(key_system)) { |
42 error_message = "Key system not supported unexpectedly: " + key_system; | 57 error_message = "Key system not supported unexpectedly: " + key_system; |
43 NOTREACHED() << error_message; | 58 NOTREACHED() << error_message; |
44 bound_cdm_created_cb.Run(nullptr, error_message); | 59 bound_cdm_created_cb.Run(nullptr, error_message); |
45 return; | 60 return; |
46 } | 61 } |
47 | 62 |
48 MediaDrmBridge::SecurityLevel security_level = | 63 MediaDrmBridge::SecurityLevel security_level = |
(...skipping 22 matching lines...) Expand all Loading... | |
71 LOG(ERROR) << error_message; | 86 LOG(ERROR) << error_message; |
72 bound_cdm_created_cb.Run(nullptr, error_message); | 87 bound_cdm_created_cb.Run(nullptr, error_message); |
73 return; | 88 return; |
74 } | 89 } |
75 | 90 |
76 // Success! | 91 // Success! |
77 bound_cdm_created_cb.Run(cdm, ""); | 92 bound_cdm_created_cb.Run(cdm, ""); |
78 } | 93 } |
79 | 94 |
80 } // namespace media | 95 } // namespace media |
OLD | NEW |