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/widevine_key_systems.h"
10 #include "base/logging.h"
11 #include "media/base/eme_constants.h"
13 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
15 #if defined(WIDEVINE_CDM_AVAILABLE)
17 using media::KeySystemInfo
;
18 using media::SupportedCodecs
;
22 // Return |name|'s parent key system.
23 static std::string
GetDirectParentName(std::string name
) {
24 size_t last_period
= name
.find_last_of('.');
25 DCHECK_GT(last_period
, 0u);
26 return name
.substr(0u, last_period
);
29 void AddWidevineWithCodecs(
30 WidevineCdmType widevine_cdm_type
,
31 SupportedCodecs supported_codecs
,
32 #if defined(OS_ANDROID)
33 SupportedCodecs supported_secure_codecs
,
34 #endif // defined(OS_ANDROID)
35 media::EmeRobustness max_audio_robustness
,
36 media::EmeRobustness max_video_robustness
,
37 media::EmeSessionTypeSupport persistent_license_support
,
38 media::EmeSessionTypeSupport persistent_release_message_support
,
39 media::EmeFeatureSupport persistent_state_support
,
40 media::EmeFeatureSupport distinctive_identifier_support
,
41 std::vector
<KeySystemInfo
>* concrete_key_systems
) {
43 info
.key_system
= kWidevineKeySystem
;
45 switch (widevine_cdm_type
) {
47 // For standard Widevine, add parent name.
48 info
.parent_key_system
= GetDirectParentName(kWidevineKeySystem
);
50 #if defined(OS_ANDROID)
51 case WIDEVINE_HR_NON_COMPOSITING
:
52 info
.key_system
.append(".hrnoncompositing");
54 #endif // defined(OS_ANDROID)
59 // TODO(xhwang): A container or an initDataType may be supported even though
60 // there are no codecs supported in that container. Fix this when we support
62 info
.supported_codecs
= supported_codecs
;
63 #if defined(OS_ANDROID)
64 info
.supported_secure_codecs
= supported_secure_codecs
;
65 #endif // defined(OS_ANDROID)
67 // Here we assume that support for a container imples support for the
68 // associated initialization data type. KeySystems handles validating
69 // |init_data_type| x |container| pairings.
70 if (supported_codecs
& media::EME_CODEC_WEBM_ALL
)
71 info
.supported_init_data_types
|= media::kInitDataTypeMaskWebM
;
72 #if defined(USE_PROPRIETARY_CODECS)
73 if (supported_codecs
& media::EME_CODEC_MP4_ALL
)
74 info
.supported_init_data_types
|= media::kInitDataTypeMaskCenc
;
75 #endif // defined(USE_PROPRIETARY_CODECS)
77 info
.max_audio_robustness
= max_audio_robustness
;
78 info
.max_video_robustness
= max_video_robustness
;
79 info
.persistent_license_support
= persistent_license_support
;
80 info
.persistent_release_message_support
= persistent_release_message_support
;
81 info
.persistent_state_support
= persistent_state_support
;
82 info
.distinctive_identifier_support
= distinctive_identifier_support
;
84 #if defined(ENABLE_PEPPER_CDMS)
85 info
.pepper_type
= kWidevineCdmPluginMimeType
;
86 #endif // defined(ENABLE_PEPPER_CDMS)
88 concrete_key_systems
->push_back(info
);
93 #endif // defined(WIDEVINE_CDM_AVAILABLE)