Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: components/cdm/renderer/android_key_systems.cc

Issue 1106263004: Support Android secure codecs in requestMediaKeySystemAccess(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include build_config.h. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
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 // 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 51
63 // We are using MediaDrm API on Android and we cannot guarantee that API 52 if (response.compositing_codecs != media::EME_CODEC_NONE) {
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( 53 AddWidevineWithCodecs(
70 WIDEVINE, codecs, max_audio_robustness, max_video_robustness, 54 WIDEVINE,
71 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. 55 response.compositing_codecs, // Regular codecs.
72 media::EmeSessionTypeSupport:: 56 response.non_compositing_codecs, // Hardware-secure codecs.
73 NOT_SUPPORTED, // persistent-release-message. 57 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
74 media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. 58 EmeRobustness::HW_SECURE_ALL, // Max video robustness.
75 media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive 59 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
76 // identifier. 60 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
61 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state.
62 EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier.
77 concrete_key_systems); 63 concrete_key_systems);
64 } else {
65 // It doesn't make sense to support secure codecs but not regular codecs.
66 DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE);
78 } 67 }
79 68
80 // For compatibility with the prefixed API, register a separate L1 key system. 69 // For compatibility with the prefixed API, register a separate L1 key system.
81 // When creating the WIDEVINE_HR_NON_COMPOSITING key system, 70 // This key systems acts as though only hardware-secure codecs are available.
82 // BrowserCdmFactoryAndroid does not configure the CDM's security level (that 71 // We only register support for codecs with both regular and hardware-secure
83 // is, leaves it as L1); therefore only secure codecs are supported. 72 // variants so that we can be sure they will work regardless of the renderer
84 // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976 73 // preference.
85 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { 74 SupportedCodecs secure_codecs =
75 response.compositing_codecs & response.non_compositing_codecs;
76 if (secure_codecs != media::EME_CODEC_NONE) {
77 // Note: The prefixed API only consults the regular codecs field.
86 AddWidevineWithCodecs( 78 AddWidevineWithCodecs(
87 WIDEVINE_HR_NON_COMPOSITING, response.non_compositing_codecs, 79 WIDEVINE_HR_NON_COMPOSITING,
88 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. 80 secure_codecs, // Regular codecs.
89 EmeRobustness::HW_SECURE_ALL, // Max video robustness. 81 media::EME_CODEC_NONE, // Hardware-secure codecs.
90 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. 82 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
91 media::EmeSessionTypeSupport:: 83 EmeRobustness::HW_SECURE_ALL, // Max video robustness.
92 NOT_SUPPORTED, // persistent-release-message. 84 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
93 media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. 85 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
94 media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive 86 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state.
95 // identifier. 87 EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier.
96 concrete_key_systems); 88 concrete_key_systems);
97 } 89 }
98 } 90 }
99 91
100 void AddAndroidPlatformKeySystems( 92 void AddAndroidPlatformKeySystems(
101 std::vector<KeySystemInfo>* concrete_key_systems) { 93 std::vector<KeySystemInfo>* concrete_key_systems) {
102 std::vector<std::string> key_system_names; 94 std::vector<std::string> key_system_names;
103 content::RenderThread::Get()->Send( 95 content::RenderThread::Get()->Send(
104 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); 96 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names));
105 97
106 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); 98 for (std::vector<std::string>::const_iterator it = key_system_names.begin();
107 it != key_system_names.end(); ++it) { 99 it != key_system_names.end(); ++it) {
108 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); 100 SupportedKeySystemResponse response = QueryKeySystemSupport(*it);
109 if (response.compositing_codecs != media::EME_CODEC_NONE) { 101 if (response.compositing_codecs != media::EME_CODEC_NONE) {
110 KeySystemInfo info; 102 KeySystemInfo info;
111 info.key_system = *it; 103 info.key_system = *it;
112 info.supported_codecs = response.compositing_codecs; 104 info.supported_codecs = response.compositing_codecs;
113 // Here we assume that support for a container implies support for the 105 // Here we assume that support for a container implies support for the
114 // associated initialization data type. KeySystems handles validating 106 // associated initialization data type. KeySystems handles validating
115 // |init_data_type| x |container| pairings. 107 // |init_data_type| x |container| pairings.
116 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) 108 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL)
117 info.supported_init_data_types |= media::kInitDataTypeMaskWebM; 109 info.supported_init_data_types |= media::kInitDataTypeMaskWebM;
118 #if defined(USE_PROPRIETARY_CODECS) 110 #if defined(USE_PROPRIETARY_CODECS)
119 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) 111 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL)
120 info.supported_init_data_types |= media::kInitDataTypeMaskCenc; 112 info.supported_init_data_types |= media::kInitDataTypeMaskCenc;
121 #endif // defined(USE_PROPRIETARY_CODECS) 113 #endif // defined(USE_PROPRIETARY_CODECS)
122 info.max_audio_robustness = EmeRobustness::EMPTY; 114 info.max_audio_robustness = EmeRobustness::EMPTY;
123 info.max_video_robustness = EmeRobustness::EMPTY; 115 info.max_video_robustness = EmeRobustness::EMPTY;
124 // Assume the worst case (from a user point of view). 116 // Assume that platform key systems support no features but can and will
117 // make use of persistence and identifiers.
125 info.persistent_license_support = 118 info.persistent_license_support =
126 media::EmeSessionTypeSupport::NOT_SUPPORTED; 119 media::EmeSessionTypeSupport::NOT_SUPPORTED;
127 info.persistent_release_message_support = 120 info.persistent_release_message_support =
128 media::EmeSessionTypeSupport::NOT_SUPPORTED; 121 media::EmeSessionTypeSupport::NOT_SUPPORTED;
129 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED; 122 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED;
130 info.distinctive_identifier_support = 123 info.distinctive_identifier_support =
131 media::EmeFeatureSupport::ALWAYS_ENABLED; 124 media::EmeFeatureSupport::ALWAYS_ENABLED;
132 concrete_key_systems->push_back(info); 125 concrete_key_systems->push_back(info);
133 } 126 }
134 } 127 }
135 } 128 }
136 129
137 } // namespace cdm 130 } // namespace cdm
OLDNEW
« no previous file with comments | « components/cdm/renderer/android_key_systems.h ('k') | components/cdm/renderer/widevine_key_systems.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698