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/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "components/cdm/common/cdm_messages_android.h" | 12 #include "components/cdm/common/cdm_messages_android.h" |
13 #include "components/cdm/renderer/widevine_key_systems.h" | 13 #include "components/cdm/renderer/widevine_key_systems.h" |
14 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
15 #include "media/base/eme_constants.h" | 15 #include "media/base/eme_constants.h" |
16 #include "media/base/media_switches.h" | 16 #include "media/base/media_switches.h" |
17 | 17 |
18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
19 | 19 |
20 using media::EmeFeatureSupport; | |
20 using media::EmeRobustness; | 21 using media::EmeRobustness; |
22 using media::EmeSessionTypeSupport; | |
21 using media::KeySystemInfo; | 23 using media::KeySystemInfo; |
22 using media::SupportedCodecs; | 24 using media::SupportedCodecs; |
23 | 25 |
24 namespace cdm { | 26 namespace cdm { |
25 | 27 |
26 static SupportedKeySystemResponse QueryKeySystemSupport( | 28 static SupportedKeySystemResponse QueryKeySystemSupport( |
27 const std::string& key_system) { | 29 const std::string& key_system) { |
28 SupportedKeySystemRequest request; | 30 SupportedKeySystemRequest request; |
29 SupportedKeySystemResponse response; | 31 SupportedKeySystemResponse response; |
30 | 32 |
31 request.key_system = key_system; | 33 request.key_system = key_system; |
32 request.codecs = media::EME_CODEC_ALL; | 34 request.codecs = media::EME_CODEC_ALL; |
33 content::RenderThread::Get()->Send( | 35 content::RenderThread::Get()->Send( |
34 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); | 36 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); |
35 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) | 37 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) |
36 << "unrecognized codec"; | 38 << "unrecognized codec"; |
37 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) | 39 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) |
38 << "unrecognized codec"; | 40 << "unrecognized codec"; |
39 return response; | 41 return response; |
40 } | 42 } |
41 | 43 |
42 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems, | 44 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
43 bool is_non_compositing_supported) { | |
44 SupportedKeySystemResponse response = QueryKeySystemSupport( | 45 SupportedKeySystemResponse response = QueryKeySystemSupport( |
45 kWidevineKeySystem); | 46 kWidevineKeySystem); |
46 | 47 |
47 // When creating the WIDEVINE key system, BrowserCdmFactoryAndroid configures | 48 // Since we do not control the implementation of the MediaDrm API on Android, |
ddorwin
2015/05/01 20:39:11
This seems to be in the wrong place. Or at least t
sandersd (OOO until July 31)
2015/05/01 21:57:01
Done.
| |
48 // the CDM's security level based on a pref. Therefore the supported | 49 // we assume that it can and will make use of persistence even though no |
49 // codec/robustenss combinations depend on that pref, represented by | 50 // persistence-based features are supported. |
50 // |bool is_non_compositing_supported|. | 51 if (response.compositing_codecs != media::EME_CODEC_NONE) { |
51 // TODO(sandersd): For unprefixed, set the security level based on the | |
52 // requested robustness instead of the flag. http://crbug.com/467779 | |
53 // We should also stop using the term "non_compositing." | |
54 SupportedCodecs codecs = response.compositing_codecs; | |
55 EmeRobustness max_audio_robustness = EmeRobustness::SW_SECURE_CRYPTO; | |
56 EmeRobustness max_video_robustness = EmeRobustness::SW_SECURE_CRYPTO; | |
57 if (is_non_compositing_supported) { | |
58 codecs = response.non_compositing_codecs; | |
59 max_audio_robustness = EmeRobustness::HW_SECURE_CRYPTO; | |
60 max_video_robustness = EmeRobustness::HW_SECURE_ALL; | |
61 } | |
62 | |
63 // We are using MediaDrm API on Android and we cannot guarantee that API | |
64 // doesn't use persistent storage on the device. Therefore always set | |
65 // persistent state to EmeFeatureSupport::ALWAYS_ENABLED to err on the | |
66 // safe side. | |
67 | |
68 if (codecs != media::EME_CODEC_NONE) { | |
69 AddWidevineWithCodecs( | 52 AddWidevineWithCodecs( |
70 WIDEVINE, codecs, max_audio_robustness, max_video_robustness, | 53 WIDEVINE, |
71 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. | 54 response.compositing_codecs, // Regular codecs. |
72 media::EmeSessionTypeSupport:: | 55 response.non_compositing_codecs, // Hardware-secure codecs. |
73 NOT_SUPPORTED, // persistent-release-message. | 56 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. |
74 media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. | 57 EmeRobustness::HW_SECURE_ALL, // Max video robustness. |
75 media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive | 58 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. |
76 // identifier. | 59 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. |
60 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. | |
61 EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier. | |
77 concrete_key_systems); | 62 concrete_key_systems); |
63 } else { | |
64 DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE); | |
78 } | 65 } |
79 | 66 |
80 // For compatibility with the prefixed API, register a separate L1 key system. | 67 // For compatibility with the prefixed API, register a separate L1 key system. |
81 // When creating the WIDEVINE_HR_NON_COMPOSITING key system, | 68 // This key systems acts as though only hardware-secure codecs are available. |
82 // BrowserCdmFactoryAndroid does not configure the CDM's security level (that | 69 // We only register support for codecs with both regular and hardware-secure |
83 // is, leaves it as L1); therefore only secure codecs are supported. | 70 // variants so that we can be sure they will work regardless of the renderer |
84 // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976 | 71 // preference. |
72 // (Note: The prefixed API only consults the regular codecs field.) | |
73 // TODO(sandersd): Only register if the hardware-secure codecs pref is set. | |
85 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { | 74 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { |
86 AddWidevineWithCodecs( | 75 AddWidevineWithCodecs( |
87 WIDEVINE_HR_NON_COMPOSITING, response.non_compositing_codecs, | 76 WIDEVINE_HR_NON_COMPOSITING, |
88 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. | 77 (response.compositing_codecs & |
89 EmeRobustness::HW_SECURE_ALL, // Max video robustness. | 78 response.non_compositing_codecs), // Regular codecs. |
90 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. | 79 media::EME_CODEC_NONE, // Hardware-secure codecs. |
91 media::EmeSessionTypeSupport:: | 80 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. |
92 NOT_SUPPORTED, // persistent-release-message. | 81 EmeRobustness::HW_SECURE_ALL, // Max video robustness. |
93 media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. | 82 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. |
94 media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive | 83 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. |
95 // identifier. | 84 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. |
85 EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier. | |
96 concrete_key_systems); | 86 concrete_key_systems); |
97 } | 87 } |
98 } | 88 } |
99 | 89 |
100 void AddAndroidPlatformKeySystems( | 90 void AddAndroidPlatformKeySystems( |
101 std::vector<KeySystemInfo>* concrete_key_systems) { | 91 std::vector<KeySystemInfo>* concrete_key_systems) { |
102 std::vector<std::string> key_system_names; | 92 std::vector<std::string> key_system_names; |
103 content::RenderThread::Get()->Send( | 93 content::RenderThread::Get()->Send( |
104 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); | 94 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); |
105 | 95 |
106 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); | 96 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); |
107 it != key_system_names.end(); ++it) { | 97 it != key_system_names.end(); ++it) { |
108 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); | 98 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); |
109 if (response.compositing_codecs != media::EME_CODEC_NONE) { | 99 if (response.compositing_codecs != media::EME_CODEC_NONE) { |
110 KeySystemInfo info; | 100 KeySystemInfo info; |
111 info.key_system = *it; | 101 info.key_system = *it; |
112 info.supported_codecs = response.compositing_codecs; | 102 info.supported_codecs = response.compositing_codecs; |
113 // Here we assume that support for a container implies support for the | 103 // Here we assume that support for a container implies support for the |
114 // associated initialization data type. KeySystems handles validating | 104 // associated initialization data type. KeySystems handles validating |
115 // |init_data_type| x |container| pairings. | 105 // |init_data_type| x |container| pairings. |
116 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) | 106 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) |
117 info.supported_init_data_types |= media::kInitDataTypeMaskWebM; | 107 info.supported_init_data_types |= media::kInitDataTypeMaskWebM; |
118 #if defined(USE_PROPRIETARY_CODECS) | 108 #if defined(USE_PROPRIETARY_CODECS) |
119 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) | 109 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) |
120 info.supported_init_data_types |= media::kInitDataTypeMaskCenc; | 110 info.supported_init_data_types |= media::kInitDataTypeMaskCenc; |
121 #endif // defined(USE_PROPRIETARY_CODECS) | 111 #endif // defined(USE_PROPRIETARY_CODECS) |
122 info.max_audio_robustness = EmeRobustness::EMPTY; | 112 info.max_audio_robustness = EmeRobustness::EMPTY; |
123 info.max_video_robustness = EmeRobustness::EMPTY; | 113 info.max_video_robustness = EmeRobustness::EMPTY; |
124 // Assume the worst case (from a user point of view). | 114 // Assume that platform key systems support no features but can and will |
115 // make use of persistence and identifiers. | |
125 info.persistent_license_support = | 116 info.persistent_license_support = |
126 media::EmeSessionTypeSupport::NOT_SUPPORTED; | 117 media::EmeSessionTypeSupport::NOT_SUPPORTED; |
127 info.persistent_release_message_support = | 118 info.persistent_release_message_support = |
128 media::EmeSessionTypeSupport::NOT_SUPPORTED; | 119 media::EmeSessionTypeSupport::NOT_SUPPORTED; |
129 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED; | 120 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED; |
130 info.distinctive_identifier_support = | 121 info.distinctive_identifier_support = |
131 media::EmeFeatureSupport::ALWAYS_ENABLED; | 122 media::EmeFeatureSupport::ALWAYS_ENABLED; |
132 concrete_key_systems->push_back(info); | 123 concrete_key_systems->push_back(info); |
133 } | 124 } |
134 } | 125 } |
135 } | 126 } |
136 | 127 |
137 } // namespace cdm | 128 } // namespace cdm |
OLD | NEW |