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
3 // found in the LICENSE file.
5 #include "components/cdm/renderer/android_key_systems.h"
10 #include "base/logging.h"
11 #include "components/cdm/common/cdm_messages_android.h"
12 #include "components/cdm/renderer/widevine_key_systems.h"
13 #include "content/public/renderer/render_thread.h"
14 #include "media/base/eme_constants.h"
16 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
18 using media::KeySystemInfo
;
19 using media::SupportedCodecs
;
23 static SupportedKeySystemResponse
QueryKeySystemSupport(
24 const std::string
& key_system
) {
25 SupportedKeySystemRequest request
;
26 SupportedKeySystemResponse response
;
28 request
.key_system
= key_system
;
29 request
.codecs
= media::EME_CODEC_ALL
;
30 content::RenderThread::Get()->Send(
31 new ChromeViewHostMsg_QueryKeySystemSupport(request
, &response
));
32 DCHECK(!(response
.compositing_codecs
& ~media::EME_CODEC_ALL
))
33 << "unrecognized codec";
34 DCHECK(!(response
.non_compositing_codecs
& ~media::EME_CODEC_ALL
))
35 << "unrecognized codec";
39 void AddAndroidWidevine(std::vector
<KeySystemInfo
>* concrete_key_systems
) {
40 SupportedKeySystemResponse response
= QueryKeySystemSupport(
42 if (response
.compositing_codecs
!= media::EME_CODEC_NONE
) {
43 AddWidevineWithCodecs(
45 static_cast<SupportedCodecs
>(response
.compositing_codecs
),
46 media::EME_SESSION_TYPE_NOT_SUPPORTED
, // Persistent license.
47 media::EME_SESSION_TYPE_NOT_SUPPORTED
, // Persistent release message.
48 media::EME_FEATURE_NOT_SUPPORTED
, // Persistent state.
49 media::EME_FEATURE_ALWAYS_ENABLED
, // Distinctive identifier.
50 concrete_key_systems
);
53 if (response
.non_compositing_codecs
!= media::EME_CODEC_NONE
) {
54 // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976
55 AddWidevineWithCodecs(
56 WIDEVINE_HR_NON_COMPOSITING
,
57 static_cast<SupportedCodecs
>(response
.non_compositing_codecs
),
58 media::EME_SESSION_TYPE_NOT_SUPPORTED
, // Persistent license.
59 media::EME_SESSION_TYPE_NOT_SUPPORTED
, // Persistent release message.
60 media::EME_FEATURE_NOT_SUPPORTED
, // Persistent state.
61 media::EME_FEATURE_ALWAYS_ENABLED
, // Distinctive identifier.
62 concrete_key_systems
);
66 void AddAndroidPlatformKeySystems(
67 std::vector
<KeySystemInfo
>* concrete_key_systems
) {
68 std::vector
<std::string
> key_system_names
;
69 content::RenderThread::Get()->Send(
70 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names
));
72 for (std::vector
<std::string
>::const_iterator it
= key_system_names
.begin();
73 it
!= key_system_names
.end(); ++it
) {
74 SupportedKeySystemResponse response
= QueryKeySystemSupport(*it
);
75 if (response
.compositing_codecs
!= media::EME_CODEC_NONE
) {
77 info
.key_system
= *it
;
78 info
.supported_codecs
= response
.compositing_codecs
;
79 // Here we assume that support for a container implies support for the
80 // associated initialization data type. KeySystems handles validating
81 // |init_data_type| x |container| pairings.
82 if (response
.compositing_codecs
& media::EME_CODEC_WEBM_ALL
)
83 info
.supported_init_data_types
|= media::EME_INIT_DATA_TYPE_WEBM
;
84 #if defined(USE_PROPRIETARY_CODECS)
85 if (response
.compositing_codecs
& media::EME_CODEC_MP4_ALL
)
86 info
.supported_init_data_types
|= media::EME_INIT_DATA_TYPE_CENC
;
87 #endif // defined(USE_PROPRIETARY_CODECS)
88 // Assume the worst case (from a user point of view).
89 info
.persistent_license_support
= media::EME_SESSION_TYPE_NOT_SUPPORTED
;
90 info
.persistent_release_message_support
=
91 media::EME_SESSION_TYPE_NOT_SUPPORTED
;
92 info
.persistent_state_support
= media::EME_FEATURE_ALWAYS_ENABLED
;
93 info
.distinctive_identifier_support
= media::EME_FEATURE_ALWAYS_ENABLED
;
94 concrete_key_systems
->push_back(info
);