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(WidevineCdmType widevine_cdm_type
,
30 SupportedCodecs supported_codecs
,
31 std::vector
<KeySystemInfo
>* concrete_key_systems
) {
32 KeySystemInfo
info(kWidevineKeySystem
);
34 switch (widevine_cdm_type
) {
36 // For standard Widevine, add parent name.
37 info
.parent_key_system
= GetDirectParentName(kWidevineKeySystem
);
39 #if defined(OS_ANDROID)
40 case WIDEVINE_HR_NON_COMPOSITING
:
41 info
.key_system
.append(".hrnoncompositing");
43 #endif // defined(OS_ANDROID)
48 // TODO(xhwang): A container or an initDataType may be supported even though
49 // there are no codecs supported in that container. Fix this when we support
51 info
.supported_codecs
= supported_codecs
;
53 // Here we assume that support for a container imples support for the
54 // associated initialization data type. KeySystems handles validating
55 // |init_data_type| x |container| pairings.
56 if (supported_codecs
& media::EME_CODEC_WEBM_ALL
)
57 info
.supported_init_data_types
|= media::EME_INIT_DATA_TYPE_WEBM
;
58 #if defined(USE_PROPRIETARY_CODECS)
59 if (supported_codecs
& media::EME_CODEC_MP4_ALL
)
60 info
.supported_init_data_types
|= media::EME_INIT_DATA_TYPE_CENC
;
61 #endif // defined(USE_PROPRIETARY_CODECS)
63 #if defined(ENABLE_PEPPER_CDMS)
64 info
.pepper_type
= kWidevineCdmPluginMimeType
;
65 #endif // defined(ENABLE_PEPPER_CDMS)
67 concrete_key_systems
->push_back(info
);
72 #endif // defined(WIDEVINE_CDM_AVAILABLE)