OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cdm/renderer/android_key_systems.h" | 5 #include "components/cdm/renderer/android_key_systems.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/command_line.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "components/cdm/common/cdm_messages_android.h" | 12 #include "components/cdm/common/cdm_messages_android.h" |
12 #include "components/cdm/renderer/widevine_key_systems.h" | 13 #include "components/cdm/renderer/widevine_key_systems.h" |
13 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
14 #include "media/base/eme_constants.h" | 15 #include "media/base/eme_constants.h" |
| 16 #include "media/base/media_switches.h" |
15 | 17 |
16 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
17 | 19 |
| 20 using media::EmeRobustness; |
18 using media::KeySystemInfo; | 21 using media::KeySystemInfo; |
19 using media::SupportedCodecs; | 22 using media::SupportedCodecs; |
20 | 23 |
21 namespace cdm { | 24 namespace cdm { |
22 | 25 |
23 static SupportedKeySystemResponse QueryKeySystemSupport( | 26 static SupportedKeySystemResponse QueryKeySystemSupport( |
24 const std::string& key_system) { | 27 const std::string& key_system) { |
25 SupportedKeySystemRequest request; | 28 SupportedKeySystemRequest request; |
26 SupportedKeySystemResponse response; | 29 SupportedKeySystemResponse response; |
27 | 30 |
28 request.key_system = key_system; | 31 request.key_system = key_system; |
29 request.codecs = media::EME_CODEC_ALL; | 32 request.codecs = media::EME_CODEC_ALL; |
30 content::RenderThread::Get()->Send( | 33 content::RenderThread::Get()->Send( |
31 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); | 34 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); |
32 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) | 35 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) |
33 << "unrecognized codec"; | 36 << "unrecognized codec"; |
34 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) | 37 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) |
35 << "unrecognized codec"; | 38 << "unrecognized codec"; |
36 return response; | 39 return response; |
37 } | 40 } |
38 | 41 |
39 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { | 42 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
40 SupportedKeySystemResponse response = QueryKeySystemSupport( | 43 SupportedKeySystemResponse response = QueryKeySystemSupport( |
41 kWidevineKeySystem); | 44 kWidevineKeySystem); |
42 if (response.compositing_codecs != media::EME_CODEC_NONE) { | 45 |
| 46 // When creating the WIDEVINE key system, BrowserCdmFactoryAndroid configures |
| 47 // the CDM's security level based on the --mediadrm-enable-non-compositing |
| 48 // flag (L1 if the flag is enabled, L3 otherwise). Therefore the supported |
| 49 // codec/robustenss combinations depend on that flag. |
| 50 // TODO(sandersd): For unprefixed, set the security level based on the |
| 51 // requested robustness instead of the flag. http://crbug.com/467779 |
| 52 SupportedCodecs codecs = response.compositing_codecs; |
| 53 EmeRobustness max_audio_robustness = EmeRobustness::SW_SECURE_CRYPTO; |
| 54 EmeRobustness max_video_robustness = EmeRobustness::SW_SECURE_CRYPTO; |
| 55 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 56 switches::kMediaDrmEnableNonCompositing)) { |
| 57 codecs = response.non_compositing_codecs; |
| 58 max_audio_robustness = EmeRobustness::HW_SECURE_CRYPTO; |
| 59 max_video_robustness = EmeRobustness::HW_SECURE_ALL; |
| 60 } |
| 61 if (codecs != media::EME_CODEC_NONE) { |
43 AddWidevineWithCodecs( | 62 AddWidevineWithCodecs( |
44 WIDEVINE, | 63 WIDEVINE, |
45 static_cast<SupportedCodecs>(response.compositing_codecs), | 64 codecs, |
46 media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent license. | 65 max_audio_robustness, |
47 media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message. | 66 max_video_robustness, |
| 67 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license. |
| 68 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message. |
48 media::EME_FEATURE_NOT_SUPPORTED, // Persistent state. | 69 media::EME_FEATURE_NOT_SUPPORTED, // Persistent state. |
49 media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier. | 70 media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier. |
50 concrete_key_systems); | 71 concrete_key_systems); |
51 } | 72 } |
52 | 73 |
| 74 // For compatibility with the prefixed API, register a separate L1 key system. |
| 75 // When creating the WIDEVINE_HR_NON_COMPOSITING key system, |
| 76 // BrowserCdmFactoryAndroid does not configure the CDM's security level (that |
| 77 // is, leaves it as L1); therefore only secure codecs are supported. |
| 78 // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976 |
53 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { | 79 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { |
54 // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976 | |
55 AddWidevineWithCodecs( | 80 AddWidevineWithCodecs( |
56 WIDEVINE_HR_NON_COMPOSITING, | 81 WIDEVINE_HR_NON_COMPOSITING, |
57 static_cast<SupportedCodecs>(response.non_compositing_codecs), | 82 response.non_compositing_codecs, |
58 media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent license. | 83 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. |
59 media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message. | 84 EmeRobustness::HW_SECURE_ALL, // Max video robustness. |
| 85 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license. |
| 86 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message. |
60 media::EME_FEATURE_NOT_SUPPORTED, // Persistent state. | 87 media::EME_FEATURE_NOT_SUPPORTED, // Persistent state. |
61 media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier. | 88 media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier. |
62 concrete_key_systems); | 89 concrete_key_systems); |
63 } | 90 } |
64 } | 91 } |
65 | 92 |
66 void AddAndroidPlatformKeySystems( | 93 void AddAndroidPlatformKeySystems( |
67 std::vector<KeySystemInfo>* concrete_key_systems) { | 94 std::vector<KeySystemInfo>* concrete_key_systems) { |
68 std::vector<std::string> key_system_names; | 95 std::vector<std::string> key_system_names; |
69 content::RenderThread::Get()->Send( | 96 content::RenderThread::Get()->Send( |
70 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); | 97 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); |
71 | 98 |
72 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); | 99 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); |
73 it != key_system_names.end(); ++it) { | 100 it != key_system_names.end(); ++it) { |
74 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); | 101 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); |
75 if (response.compositing_codecs != media::EME_CODEC_NONE) { | 102 if (response.compositing_codecs != media::EME_CODEC_NONE) { |
76 KeySystemInfo info; | 103 KeySystemInfo info; |
77 info.key_system = *it; | 104 info.key_system = *it; |
78 info.supported_codecs = response.compositing_codecs; | 105 info.supported_codecs = response.compositing_codecs; |
79 // Here we assume that support for a container implies support for the | 106 // Here we assume that support for a container implies support for the |
80 // associated initialization data type. KeySystems handles validating | 107 // associated initialization data type. KeySystems handles validating |
81 // |init_data_type| x |container| pairings. | 108 // |init_data_type| x |container| pairings. |
82 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) | 109 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) |
83 info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_WEBM; | 110 info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_WEBM; |
84 #if defined(USE_PROPRIETARY_CODECS) | 111 #if defined(USE_PROPRIETARY_CODECS) |
85 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) | 112 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) |
86 info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_CENC; | 113 info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_CENC; |
87 #endif // defined(USE_PROPRIETARY_CODECS) | 114 #endif // defined(USE_PROPRIETARY_CODECS) |
| 115 info.max_audio_robustness = EmeRobustness::EMPTY; |
| 116 info.max_video_robustness = EmeRobustness::EMPTY; |
88 // Assume the worst case (from a user point of view). | 117 // Assume the worst case (from a user point of view). |
89 info.persistent_license_support = media::EME_SESSION_TYPE_NOT_SUPPORTED; | 118 info.persistent_license_support = media::EME_SESSION_TYPE_NOT_SUPPORTED; |
90 info.persistent_release_message_support = | 119 info.persistent_release_message_support = |
91 media::EME_SESSION_TYPE_NOT_SUPPORTED; | 120 media::EME_SESSION_TYPE_NOT_SUPPORTED; |
92 info.persistent_state_support = media::EME_FEATURE_ALWAYS_ENABLED; | 121 info.persistent_state_support = media::EME_FEATURE_ALWAYS_ENABLED; |
93 info.distinctive_identifier_support = media::EME_FEATURE_ALWAYS_ENABLED; | 122 info.distinctive_identifier_support = media::EME_FEATURE_ALWAYS_ENABLED; |
94 concrete_key_systems->push_back(info); | 123 concrete_key_systems->push_back(info); |
95 } | 124 } |
96 } | 125 } |
97 } | 126 } |
98 | 127 |
99 } // namespace cdm | 128 } // namespace cdm |
OLD | NEW |