OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/base/android/media_drm_bridge.h" | 5 #include "media/base/android/media_drm_bridge.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/android/build_info.h" | 11 #include "base/android/build_info.h" |
12 #include "base/android/jni_array.h" | 12 #include "base/android/jni_array.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
17 #include "base/feature_list.h" | 17 #include "base/feature_list.h" |
18 #include "base/location.h" | 18 #include "base/location.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/sys_byteorder.h" | 24 #include "base/sys_byteorder.h" |
25 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
27 #include "jni/MediaDrmBridge_jni.h" | 27 #include "jni/MediaDrmBridge_jni.h" |
28 #include "media/base/android/media_client_android.h" | |
29 #include "media/base/android/media_codec_util.h" | 28 #include "media/base/android/media_codec_util.h" |
| 29 #include "media/base/android/media_drm_bridge_client.h" |
30 #include "media/base/android/media_drm_bridge_delegate.h" | 30 #include "media/base/android/media_drm_bridge_delegate.h" |
31 #include "media/base/cdm_key_information.h" | 31 #include "media/base/cdm_key_information.h" |
32 #include "media/base/media_switches.h" | 32 #include "media/base/media_switches.h" |
33 #include "media/base/provision_fetcher.h" | 33 #include "media/base/provision_fetcher.h" |
34 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 34 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
35 | 35 |
36 using base::android::AttachCurrentThread; | 36 using base::android::AttachCurrentThread; |
37 using base::android::ConvertUTF8ToJavaString; | 37 using base::android::ConvertUTF8ToJavaString; |
38 using base::android::ConvertJavaStringToUTF8; | 38 using base::android::ConvertJavaStringToUTF8; |
39 using base::android::JavaByteArrayToByteVector; | 39 using base::android::JavaByteArrayToByteVector; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return CdmKeyInformation::INTERNAL_ERROR; | 126 return CdmKeyInformation::INTERNAL_ERROR; |
127 } | 127 } |
128 | 128 |
129 class KeySystemManager { | 129 class KeySystemManager { |
130 public: | 130 public: |
131 KeySystemManager(); | 131 KeySystemManager(); |
132 UUID GetUUID(const std::string& key_system); | 132 UUID GetUUID(const std::string& key_system); |
133 std::vector<std::string> GetPlatformKeySystemNames(); | 133 std::vector<std::string> GetPlatformKeySystemNames(); |
134 | 134 |
135 private: | 135 private: |
136 using KeySystemUuidMap = MediaClientAndroid::KeySystemUuidMap; | 136 using KeySystemUuidMap = MediaDrmBridgeClient::KeySystemUuidMap; |
137 | 137 |
138 KeySystemUuidMap key_system_uuid_map_; | 138 KeySystemUuidMap key_system_uuid_map_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(KeySystemManager); | 140 DISALLOW_COPY_AND_ASSIGN(KeySystemManager); |
141 }; | 141 }; |
142 | 142 |
143 KeySystemManager::KeySystemManager() { | 143 KeySystemManager::KeySystemManager() { |
144 // Widevine is always supported in Android. | 144 // Widevine is always supported in Android. |
145 key_system_uuid_map_[kWidevineKeySystem] = | 145 key_system_uuid_map_[kWidevineKeySystem] = |
146 UUID(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); | 146 UUID(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); |
147 MediaClientAndroid* client = GetMediaClientAndroid(); | 147 MediaDrmBridgeClient* client = GetMediaDrmBridgeClient(); |
148 if (client) | 148 if (client) |
149 client->AddKeySystemUUIDMappings(&key_system_uuid_map_); | 149 client->AddKeySystemUUIDMappings(&key_system_uuid_map_); |
150 } | 150 } |
151 | 151 |
152 UUID KeySystemManager::GetUUID(const std::string& key_system) { | 152 UUID KeySystemManager::GetUUID(const std::string& key_system) { |
153 KeySystemUuidMap::iterator it = key_system_uuid_map_.find(key_system); | 153 KeySystemUuidMap::iterator it = key_system_uuid_map_.find(key_system); |
154 if (it == key_system_uuid_map_.end()) | 154 if (it == key_system_uuid_map_.end()) |
155 return UUID(); | 155 return UUID(); |
156 return it->second; | 156 return it->second; |
157 } | 157 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; | 393 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; |
394 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, | 394 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, |
395 "Only the temporary session type is supported."); | 395 "Only the temporary session type is supported."); |
396 return; | 396 return; |
397 } | 397 } |
398 | 398 |
399 JNIEnv* env = AttachCurrentThread(); | 399 JNIEnv* env = AttachCurrentThread(); |
400 ScopedJavaLocalRef<jbyteArray> j_init_data; | 400 ScopedJavaLocalRef<jbyteArray> j_init_data; |
401 ScopedJavaLocalRef<jobjectArray> j_optional_parameters; | 401 ScopedJavaLocalRef<jobjectArray> j_optional_parameters; |
402 | 402 |
403 MediaClientAndroid* client = GetMediaClientAndroid(); | 403 MediaDrmBridgeClient* client = GetMediaDrmBridgeClient(); |
404 if (client) { | 404 if (client) { |
405 MediaDrmBridgeDelegate* delegate = | 405 MediaDrmBridgeDelegate* delegate = |
406 client->GetMediaDrmBridgeDelegate(scheme_uuid_); | 406 client->GetMediaDrmBridgeDelegate(scheme_uuid_); |
407 if (delegate) { | 407 if (delegate) { |
408 std::vector<uint8_t> init_data_from_delegate; | 408 std::vector<uint8_t> init_data_from_delegate; |
409 std::vector<std::string> optional_parameters_from_delegate; | 409 std::vector<std::string> optional_parameters_from_delegate; |
410 if (!delegate->OnCreateSession(init_data_type, init_data, | 410 if (!delegate->OnCreateSession(init_data_type, init_data, |
411 &init_data_from_delegate, | 411 &init_data_from_delegate, |
412 &optional_parameters_from_delegate)) { | 412 &optional_parameters_from_delegate)) { |
413 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0, | 413 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0, |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 910 } |
911 | 911 |
912 void MediaDrmBridge::OnHasAdditionalUsableKey() { | 912 void MediaDrmBridge::OnHasAdditionalUsableKey() { |
913 DCHECK(task_runner_->BelongsToCurrentThread()); | 913 DCHECK(task_runner_->BelongsToCurrentThread()); |
914 DVLOG(1) << __func__; | 914 DVLOG(1) << __func__; |
915 | 915 |
916 player_tracker_.NotifyNewKey(); | 916 player_tracker_.NotifyNewKey(); |
917 } | 917 } |
918 | 918 |
919 } // namespace media | 919 } // namespace media |
OLD | NEW |