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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/message_loop/message_loop_proxy.h" | 17 #include "base/message_loop/message_loop_proxy.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/sys_byteorder.h" |
19 #include "jni/MediaDrmBridge_jni.h" | 20 #include "jni/MediaDrmBridge_jni.h" |
20 | 21 |
21 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 22 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
22 | 23 |
23 using base::android::AttachCurrentThread; | 24 using base::android::AttachCurrentThread; |
24 using base::android::ConvertUTF8ToJavaString; | 25 using base::android::ConvertUTF8ToJavaString; |
25 using base::android::ConvertJavaStringToUTF8; | 26 using base::android::ConvertJavaStringToUTF8; |
26 using base::android::JavaByteArrayToByteVector; | 27 using base::android::JavaByteArrayToByteVector; |
27 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
28 | 29 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 return false; | 270 return false; |
270 | 271 |
271 scoped_ptr<MediaDrmBridge> media_drm_bridge = | 272 scoped_ptr<MediaDrmBridge> media_drm_bridge = |
272 MediaDrmBridge::CreateSessionless(key_system); | 273 MediaDrmBridge::CreateSessionless(key_system); |
273 if (!media_drm_bridge) | 274 if (!media_drm_bridge) |
274 return false; | 275 return false; |
275 | 276 |
276 return media_drm_bridge->SetSecurityLevel(security_level); | 277 return media_drm_bridge->SetSecurityLevel(security_level); |
277 } | 278 } |
278 | 279 |
279 // static | 280 static void AddKeySystemUuidMapping(JNIEnv* env, jclass clazz, |
280 void MediaDrmBridge::AddKeySystemUuidMapping(const std::string& key_system, | 281 jstring j_key_system, |
281 const std::vector<uint8>& uuid) { | 282 jobject j_buffer) { |
| 283 std::string key_system = ConvertJavaStringToUTF8(env, j_key_system); |
| 284 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(j_buffer)); |
| 285 UUID uuid(buffer, buffer + 16); |
282 g_key_system_uuid_manager.Get().AddMapping(key_system, uuid); | 286 g_key_system_uuid_manager.Get().AddMapping(key_system, uuid); |
283 } | 287 } |
284 | 288 |
285 // static | 289 // static |
286 std::vector<std::string> MediaDrmBridge::GetPlatformKeySystemNames() { | 290 std::vector<std::string> MediaDrmBridge::GetPlatformKeySystemNames() { |
287 return g_key_system_uuid_manager.Get().GetPlatformKeySystemNames(); | 291 return g_key_system_uuid_manager.Get().GetPlatformKeySystemNames(); |
288 } | 292 } |
289 | 293 |
290 // static | 294 // static |
291 bool MediaDrmBridge::IsKeySystemSupported(const std::string& key_system) { | 295 bool MediaDrmBridge::IsKeySystemSupported(const std::string& key_system) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 JNIEnv* env = AttachCurrentThread(); | 563 JNIEnv* env = AttachCurrentThread(); |
560 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); | 564 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); |
561 } | 565 } |
562 | 566 |
563 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( | 567 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( |
564 JNIEnv* env, jobject, bool success) { | 568 JNIEnv* env, jobject, bool success) { |
565 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 569 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
566 } | 570 } |
567 | 571 |
568 } // namespace media | 572 } // namespace media |
OLD | NEW |