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

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

Issue 1926533002: Convert Widevine and Android platform key systems to KeySystemProperties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits 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_systems.h" 13 #include "components/cdm/renderer/widevine_key_system_properties.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;
20 using media::EmeFeatureSupport; 21 using media::EmeFeatureSupport;
22 using media::EmeInitDataType;
21 using media::EmeRobustness; 23 using media::EmeRobustness;
22 using media::EmeSessionTypeSupport; 24 using media::EmeSessionTypeSupport;
23 using media::KeySystemInfo; 25 using media::KeySystemProperties;
24 using media::SupportedCodecs; 26 using media::SupportedCodecs;
25 27
26 namespace cdm { 28 namespace cdm {
27 29
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) {}
ddorwin 2016/04/27 22:41:54 In the future, we'll need some value other than th
halliwell 2016/04/27 23:50:45 Acknowledged.
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.
ddorwin 2016/04/27 22:41:54 What does this mean?
halliwell 2016/04/27 23:50:45 This is a copy-paste from key_systems.cc. Do you
47 if (init_data_type == EmeInitDataType::WEBM)
ddorwin 2016/04/27 22:41:54 Can we force the caller to make this assumption in
halliwell 2016/04/27 23:50:45 Ack, follow up on those bugs separately?
48 return (supported_codecs_ & media::EME_CODEC_WEBM_ALL) != 0;
49 #if defined(USE_PROPRIETARY_CODECS)
50 if (init_data_type == EmeInitDataType::CENC)
ddorwin 2016/04/27 22:41:54 Use a switch statement instead? Then explicitly li
halliwell 2016/04/27 23:50:45 Done.
51 return (supported_codecs_ & media::EME_CODEC_MP4_ALL) != 0;
52 #endif // defined(USE_PROPRIETARY_CODECS)
53 return false;
54 }
55
56 SupportedCodecs GetSupportedCodecs() const override {
57 return supported_codecs_;
58 }
59
60 EmeConfigRule GetRobustnessConfigRule(
61 media::EmeMediaType media_type,
62 const std::string& requested_robustness) const override {
63 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED
64 : EmeConfigRule::NOT_SUPPORTED;
65 }
66
67 EmeSessionTypeSupport GetPersistentLicenseSessionSupport() const override {
68 return EmeSessionTypeSupport::NOT_SUPPORTED;
69 }
70 EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport()
71 const override {
72 return EmeSessionTypeSupport::NOT_SUPPORTED;
73 }
74 EmeFeatureSupport GetPersistentStateSupport() const override {
75 return EmeFeatureSupport::ALWAYS_ENABLED;
76 }
77 EmeFeatureSupport GetDistinctiveIdentifierSupport() const override {
78 return EmeFeatureSupport::ALWAYS_ENABLED;
79 }
80
81 private:
82 std::string name_;
ddorwin 2016/04/27 22:41:54 nit: can be consts
halliwell 2016/04/27 23:50:45 Done.
83 SupportedCodecs supported_codecs_;
84 };
85
86 } // namespace
87
28 static SupportedKeySystemResponse QueryKeySystemSupport( 88 static SupportedKeySystemResponse QueryKeySystemSupport(
29 const std::string& key_system) { 89 const std::string& key_system) {
30 SupportedKeySystemRequest request; 90 SupportedKeySystemRequest request;
31 SupportedKeySystemResponse response; 91 SupportedKeySystemResponse response;
32 92
33 request.key_system = key_system; 93 request.key_system = key_system;
34 request.codecs = media::EME_CODEC_ALL; 94 request.codecs = media::EME_CODEC_ALL;
35 content::RenderThread::Get()->Send( 95 content::RenderThread::Get()->Send(
36 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); 96 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response));
37 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) 97 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL))
38 << "unrecognized codec"; 98 << "unrecognized codec";
39 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) 99 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL))
40 << "unrecognized codec"; 100 << "unrecognized codec";
41 return response; 101 return response;
42 } 102 }
43 103
44 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { 104 void AddAndroidWidevine(
105 std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) {
45 SupportedKeySystemResponse response = QueryKeySystemSupport( 106 SupportedKeySystemResponse response = QueryKeySystemSupport(
46 kWidevineKeySystem); 107 kWidevineKeySystem);
47 108
48 // Since we do not control the implementation of the MediaDrm API on Android, 109 // Since we do not control the implementation of the MediaDrm API on Android,
49 // we assume that it can and will make use of persistence even though no 110 // we assume that it can and will make use of persistence even though no
50 // persistence-based features are supported. 111 // persistence-based features are supported.
51 112
52 if (response.compositing_codecs != media::EME_CODEC_NONE) { 113 if (response.compositing_codecs != media::EME_CODEC_NONE) {
53 AddWidevineWithCodecs( 114 concrete_key_systems->emplace_back(new WidevineKeySystemProperties(
54 response.compositing_codecs, // Regular codecs. 115 response.compositing_codecs, // Regular codecs.
55 response.non_compositing_codecs, // Hardware-secure codecs. 116 response.non_compositing_codecs, // Hardware-secure codecs.
56 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. 117 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
57 EmeRobustness::HW_SECURE_ALL, // Max video robustness. 118 EmeRobustness::HW_SECURE_ALL, // Max video robustness.
58 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. 119 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
59 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. 120 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
60 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. 121 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state.
61 EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier. 122 EmeFeatureSupport::ALWAYS_ENABLED)); // Distinctive identifier.
62 concrete_key_systems);
63 } else { 123 } else {
64 // It doesn't make sense to support secure codecs but not regular codecs. 124 // It doesn't make sense to support secure codecs but not regular codecs.
65 DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE); 125 DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE);
66 } 126 }
67 } 127 }
68 128
69 void AddAndroidPlatformKeySystems( 129 void AddAndroidPlatformKeySystems(
70 std::vector<KeySystemInfo>* concrete_key_systems) { 130 std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) {
71 std::vector<std::string> key_system_names; 131 std::vector<std::string> key_system_names;
72 content::RenderThread::Get()->Send( 132 content::RenderThread::Get()->Send(
73 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); 133 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names));
74 134
75 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); 135 for (std::vector<std::string>::const_iterator it = key_system_names.begin();
76 it != key_system_names.end(); ++it) { 136 it != key_system_names.end(); ++it) {
77 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); 137 SupportedKeySystemResponse response = QueryKeySystemSupport(*it);
78 if (response.compositing_codecs != media::EME_CODEC_NONE) { 138 if (response.compositing_codecs != media::EME_CODEC_NONE) {
79 KeySystemInfo info; 139 concrete_key_systems->emplace_back(new AndroidPlatformKeySystemProperties(
80 info.key_system = *it; 140 *it, response.compositing_codecs));
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);
103 } 141 }
104 } 142 }
105 } 143 }
106 144
107 } // namespace cdm 145 } // namespace cdm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698