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