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 media::EmeSessionTypeSupport persistent_license_support
,
33 media::EmeSessionTypeSupport persistent_release_message_support
,
34 media::EmeFeatureSupport persistent_state_support
,
35 media::EmeFeatureSupport distinctive_identifier_support
,
36 std::vector
<KeySystemInfo
>* concrete_key_systems
) {
38 info
.key_system
= kWidevineKeySystem
;
40 switch (widevine_cdm_type
) {
42 // For standard Widevine, add parent name.
43 info
.parent_key_system
= GetDirectParentName(kWidevineKeySystem
);
45 #if defined(OS_ANDROID)
46 case WIDEVINE_HR_NON_COMPOSITING
:
47 info
.key_system
.append(".hrnoncompositing");
49 #endif // defined(OS_ANDROID)
54 // TODO(xhwang): A container or an initDataType may be supported even though
55 // there are no codecs supported in that container. Fix this when we support
57 info
.supported_codecs
= supported_codecs
;
59 // Here we assume that support for a container imples support for the
60 // associated initialization data type. KeySystems handles validating
61 // |init_data_type| x |container| pairings.
62 if (supported_codecs
& media::EME_CODEC_WEBM_ALL
)
63 info
.supported_init_data_types
|= media::EME_INIT_DATA_TYPE_WEBM
;
64 #if defined(USE_PROPRIETARY_CODECS)
65 if (supported_codecs
& media::EME_CODEC_MP4_ALL
)
66 info
.supported_init_data_types
|= media::EME_INIT_DATA_TYPE_CENC
;
67 #endif // defined(USE_PROPRIETARY_CODECS)
69 info
.persistent_license_support
= persistent_license_support
;
70 info
.persistent_release_message_support
= persistent_release_message_support
;
71 info
.persistent_state_support
= persistent_state_support
;
72 info
.distinctive_identifier_support
= distinctive_identifier_support
;
74 #if defined(ENABLE_PEPPER_CDMS)
75 info
.pepper_type
= kWidevineCdmPluginMimeType
;
76 #endif // defined(ENABLE_PEPPER_CDMS)
78 concrete_key_systems
->push_back(info
);
83 #endif // defined(WIDEVINE_CDM_AVAILABLE)