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

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

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

Powered by Google App Engine
This is Rietveld 408576698