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

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

Issue 1932893004: Revert of Convert Widevine and Android platform key systems to KeySystemProperties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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_system_properties.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::EmeConfigRule;
21 using media::EmeFeatureSupport; 20 using media::EmeFeatureSupport;
22 using media::EmeInitDataType;
23 using media::EmeRobustness; 21 using media::EmeRobustness;
24 using media::EmeSessionTypeSupport; 22 using media::EmeSessionTypeSupport;
25 using media::KeySystemProperties; 23 using media::KeySystemInfo;
26 using media::SupportedCodecs; 24 using media::SupportedCodecs;
27 25
28 namespace cdm { 26 namespace cdm {
29 27
30 namespace {
31
32 // Implementation of KeySystemProperties for platform-supported key systems.
33 // Assumes that platform key systems support no features but can and will
34 // make use of persistence and identifiers.
35 class AndroidPlatformKeySystemProperties : public KeySystemProperties {
36 public:
37 AndroidPlatformKeySystemProperties(const std::string& name,
38 SupportedCodecs supported_codecs)
39 : name_(name), supported_codecs_(supported_codecs) {}
40
41 std::string GetKeySystemName() const override { return name_; }
42
43 bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override {
44 // Here we assume that support for a container implies support for the
45 // associated initialization data type. KeySystems handles validating
46 // |init_data_type| x |container| pairings.
47 switch (init_data_type) {
48 case EmeInitDataType::WEBM:
49 return (supported_codecs_ & media::EME_CODEC_WEBM_ALL) != 0;
50 case EmeInitDataType::CENC:
51 #if defined(USE_PROPRIETARY_CODECS)
52 return (supported_codecs_ & media::EME_CODEC_MP4_ALL) != 0;
53 #else
54 return false;
55 #endif // defined(USE_PROPRIETARY_CODECS)
56 case EmeInitDataType::KEYIDS:
57 case EmeInitDataType::UNKNOWN:
58 return false;
59 }
60 NOTREACHED();
61 return false;
62 }
63
64 SupportedCodecs GetSupportedCodecs() const override {
65 return supported_codecs_;
66 }
67
68 EmeConfigRule GetRobustnessConfigRule(
69 media::EmeMediaType media_type,
70 const std::string& requested_robustness) const override {
71 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED
72 : EmeConfigRule::NOT_SUPPORTED;
73 }
74
75 EmeSessionTypeSupport GetPersistentLicenseSessionSupport() const override {
76 return EmeSessionTypeSupport::NOT_SUPPORTED;
77 }
78 EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport()
79 const override {
80 return EmeSessionTypeSupport::NOT_SUPPORTED;
81 }
82 EmeFeatureSupport GetPersistentStateSupport() const override {
83 return EmeFeatureSupport::ALWAYS_ENABLED;
84 }
85 EmeFeatureSupport GetDistinctiveIdentifierSupport() const override {
86 return EmeFeatureSupport::ALWAYS_ENABLED;
87 }
88
89 private:
90 const std::string name_;
91 const SupportedCodecs supported_codecs_;
92 };
93
94 } // namespace
95
96 static SupportedKeySystemResponse QueryKeySystemSupport( 28 static SupportedKeySystemResponse QueryKeySystemSupport(
97 const std::string& key_system) { 29 const std::string& key_system) {
98 SupportedKeySystemRequest request; 30 SupportedKeySystemRequest request;
99 SupportedKeySystemResponse response; 31 SupportedKeySystemResponse response;
100 32
101 request.key_system = key_system; 33 request.key_system = key_system;
102 request.codecs = media::EME_CODEC_ALL; 34 request.codecs = media::EME_CODEC_ALL;
103 content::RenderThread::Get()->Send( 35 content::RenderThread::Get()->Send(
104 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); 36 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response));
105 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) 37 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL))
106 << "unrecognized codec"; 38 << "unrecognized codec";
107 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) 39 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL))
108 << "unrecognized codec"; 40 << "unrecognized codec";
109 return response; 41 return response;
110 } 42 }
111 43
112 void AddAndroidWidevine( 44 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) {
113 std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) {
114 SupportedKeySystemResponse response = QueryKeySystemSupport( 45 SupportedKeySystemResponse response = QueryKeySystemSupport(
115 kWidevineKeySystem); 46 kWidevineKeySystem);
116 47
117 // Since we do not control the implementation of the MediaDrm API on Android, 48 // Since we do not control the implementation of the MediaDrm API on Android,
118 // we assume that it can and will make use of persistence even though no 49 // we assume that it can and will make use of persistence even though no
119 // persistence-based features are supported. 50 // persistence-based features are supported.
120 51
121 if (response.compositing_codecs != media::EME_CODEC_NONE) { 52 if (response.compositing_codecs != media::EME_CODEC_NONE) {
122 concrete_key_systems->emplace_back(new WidevineKeySystemProperties( 53 AddWidevineWithCodecs(
123 response.compositing_codecs, // Regular codecs. 54 response.compositing_codecs, // Regular codecs.
124 response.non_compositing_codecs, // Hardware-secure codecs. 55 response.non_compositing_codecs, // Hardware-secure codecs.
125 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. 56 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
126 EmeRobustness::HW_SECURE_ALL, // Max video robustness. 57 EmeRobustness::HW_SECURE_ALL, // Max video robustness.
127 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. 58 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
128 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. 59 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
129 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. 60 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state.
130 EmeFeatureSupport::ALWAYS_ENABLED)); // Distinctive identifier. 61 EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier.
62 concrete_key_systems);
131 } else { 63 } else {
132 // It doesn't make sense to support secure codecs but not regular codecs. 64 // It doesn't make sense to support secure codecs but not regular codecs.
133 DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE); 65 DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE);
134 } 66 }
135 } 67 }
136 68
137 void AddAndroidPlatformKeySystems( 69 void AddAndroidPlatformKeySystems(
138 std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) { 70 std::vector<KeySystemInfo>* concrete_key_systems) {
139 std::vector<std::string> key_system_names; 71 std::vector<std::string> key_system_names;
140 content::RenderThread::Get()->Send( 72 content::RenderThread::Get()->Send(
141 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); 73 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names));
142 74
143 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); 75 for (std::vector<std::string>::const_iterator it = key_system_names.begin();
144 it != key_system_names.end(); ++it) { 76 it != key_system_names.end(); ++it) {
145 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); 77 SupportedKeySystemResponse response = QueryKeySystemSupport(*it);
146 if (response.compositing_codecs != media::EME_CODEC_NONE) { 78 if (response.compositing_codecs != media::EME_CODEC_NONE) {
147 concrete_key_systems->emplace_back(new AndroidPlatformKeySystemProperties( 79 KeySystemInfo info;
148 *it, response.compositing_codecs)); 80 info.key_system = *it;
81 info.supported_codecs = response.compositing_codecs;
82 // Here we assume that support for a container implies support for the
83 // associated initialization data type. KeySystems handles validating
84 // |init_data_type| x |container| pairings.
85 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL)
86 info.supported_init_data_types |= media::kInitDataTypeMaskWebM;
87 #if defined(USE_PROPRIETARY_CODECS)
88 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL)
89 info.supported_init_data_types |= media::kInitDataTypeMaskCenc;
90 #endif // defined(USE_PROPRIETARY_CODECS)
91 info.max_audio_robustness = EmeRobustness::EMPTY;
92 info.max_video_robustness = EmeRobustness::EMPTY;
93 // Assume that platform key systems support no features but can and will
94 // make use of persistence and identifiers.
95 info.persistent_license_support =
96 media::EmeSessionTypeSupport::NOT_SUPPORTED;
97 info.persistent_release_message_support =
98 media::EmeSessionTypeSupport::NOT_SUPPORTED;
99 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED;
100 info.distinctive_identifier_support =
101 media::EmeFeatureSupport::ALWAYS_ENABLED;
102 concrete_key_systems->push_back(info);
149 } 103 }
150 } 104 }
151 } 105 }
152 106
153 } // namespace cdm 107 } // namespace cdm
OLDNEW
« no previous file with comments | « components/cdm/renderer/android_key_systems.h ('k') | components/cdm/renderer/widevine_key_system_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698