1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cdm/renderer/android_key_systems.h"
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
#include "components/cdm/common/cdm_messages_android.h"
#include "components/cdm/renderer/widevine_key_systems.h"
#include "content/public/renderer/render_thread.h"
#include "media/base/eme_constants.h"
#include "media/base/media_switches.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
using media::EmeFeatureSupport;
using media::EmeRobustness;
using media::EmeSessionTypeSupport;
using media::KeySystemInfo;
using media::SupportedCodecs;
namespace cdm {
static SupportedKeySystemResponse QueryKeySystemSupport(
const std::string& key_system) {
SupportedKeySystemRequest request;
SupportedKeySystemResponse response;
request.key_system = key_system;
request.codecs = media::EME_CODEC_ALL;
content::RenderThread::Get()->Send(
new ChromeViewHostMsg_QueryKeySystemSupport(request, &response));
DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL))
<< "unrecognized codec";
DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL))
<< "unrecognized codec";
return response;
}
void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) {
SupportedKeySystemResponse response = QueryKeySystemSupport(
kWidevineKeySystem);
// Since we do not control the implementation of the MediaDrm API on Android,
// we assume that it can and will make use of persistence even though no
// persistence-based features are supported.
if (response.compositing_codecs != media::EME_CODEC_NONE) {
AddWidevineWithCodecs(
WIDEVINE,
response.compositing_codecs, // Regular codecs.
response.non_compositing_codecs, // Hardware-secure codecs.
EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
EmeRobustness::HW_SECURE_ALL, // Max video robustness.
EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state.
EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier.
concrete_key_systems);
} else {
// It doesn't make sense to support secure codecs but not regular codecs.
DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE);
}
// For compatibility with the prefixed API, register a separate L1 key system.
// This key systems acts as though only hardware-secure codecs are available.
// We only register support for codecs with both regular and hardware-secure
// variants so that we can be sure they will work regardless of the renderer
// preference.
SupportedCodecs secure_codecs =
response.compositing_codecs & response.non_compositing_codecs;
if (secure_codecs != media::EME_CODEC_NONE) {
// Note: The prefixed API only consults the regular codecs field.
AddWidevineWithCodecs(
WIDEVINE_HR_NON_COMPOSITING,
secure_codecs, // Regular codecs.
media::EME_CODEC_NONE, // Hardware-secure codecs.
EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
EmeRobustness::HW_SECURE_ALL, // Max video robustness.
EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state.
EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier.
concrete_key_systems);
}
}
void AddAndroidPlatformKeySystems(
std::vector<KeySystemInfo>* concrete_key_systems) {
std::vector<std::string> key_system_names;
content::RenderThread::Get()->Send(
new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names));
for (std::vector<std::string>::const_iterator it = key_system_names.begin();
it != key_system_names.end(); ++it) {
SupportedKeySystemResponse response = QueryKeySystemSupport(*it);
if (response.compositing_codecs != media::EME_CODEC_NONE) {
KeySystemInfo info;
info.key_system = *it;
info.supported_codecs = response.compositing_codecs;
// Here we assume that support for a container implies support for the
// associated initialization data type. KeySystems handles validating
// |init_data_type| x |container| pairings.
if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL)
info.supported_init_data_types |= media::kInitDataTypeMaskWebM;
#if defined(USE_PROPRIETARY_CODECS)
if (response.compositing_codecs & media::EME_CODEC_MP4_ALL)
info.supported_init_data_types |= media::kInitDataTypeMaskCenc;
#endif // defined(USE_PROPRIETARY_CODECS)
info.max_audio_robustness = EmeRobustness::EMPTY;
info.max_video_robustness = EmeRobustness::EMPTY;
// Assume that platform key systems support no features but can and will
// make use of persistence and identifiers.
info.persistent_license_support =
media::EmeSessionTypeSupport::NOT_SUPPORTED;
info.persistent_release_message_support =
media::EmeSessionTypeSupport::NOT_SUPPORTED;
info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED;
info.distinctive_identifier_support =
media::EmeFeatureSupport::ALWAYS_ENABLED;
concrete_key_systems->push_back(info);
}
}
}
} // namespace cdm
|