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 jlong uuid_msb, jlong uuid_lsb) { |
283 std::string key_system = ConvertJavaStringToUTF8(env, j_key_system); | |
284 // MSB (byte) should be positioned at the first element. | |
285 uuid_msb = base::HostToNet64(uuid_msb); | |
286 uuid_lsb = base::HostToNet64(uuid_lsb); | |
287 std::vector<uint8> uuid; | |
288 uuid.insert(uuid.end(), reinterpret_cast<uint8*>(&uuid_msb), | |
289 reinterpret_cast<uint8*>(&uuid_msb + 1)); | |
290 uuid.insert(uuid.end(), reinterpret_cast<uint8*>(&uuid_lsb), | |
291 reinterpret_cast<uint8*>(&uuid_lsb + 1)); | |
xhwang
2014/06/16 15:58:32
nit: Can you convert the UUID to an array or vecto
ycheo (away)
2014/06/16 21:42:11
In UUID, there is no method to return an array or
xhwang
2014/06/16 21:46:50
Yes, I saw that, so you have to do some kind of co
ycheo (away)
2014/06/16 23:40:36
Done.
| |
282 g_key_system_uuid_manager.Get().AddMapping(key_system, uuid); | 292 g_key_system_uuid_manager.Get().AddMapping(key_system, uuid); |
283 } | 293 } |
284 | 294 |
285 // static | 295 // static |
286 std::vector<std::string> MediaDrmBridge::GetPlatformKeySystemNames() { | 296 std::vector<std::string> MediaDrmBridge::GetPlatformKeySystemNames() { |
287 return g_key_system_uuid_manager.Get().GetPlatformKeySystemNames(); | 297 return g_key_system_uuid_manager.Get().GetPlatformKeySystemNames(); |
288 } | 298 } |
289 | 299 |
290 // static | 300 // static |
291 bool MediaDrmBridge::IsKeySystemSupported(const std::string& key_system) { | 301 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(); | 569 JNIEnv* env = AttachCurrentThread(); |
560 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); | 570 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); |
561 } | 571 } |
562 | 572 |
563 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( | 573 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( |
564 JNIEnv* env, jobject, bool success) { | 574 JNIEnv* env, jobject, bool success) { |
565 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 575 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
566 } | 576 } |
567 | 577 |
568 } // namespace media | 578 } // namespace media |
OLD | NEW |