Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / cdm / renderer / widevine_key_systems.cc
blob2a41322112eac5fac5e2dd64a7c46eff29705304
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"
7 #include <string>
8 #include <vector>
10 #include "base/logging.h"
12 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
14 #if defined(WIDEVINE_CDM_AVAILABLE)
16 using content::KeySystemInfo;
17 using content::SupportedCodecs;
19 namespace cdm {
21 // Return |name|'s parent key system.
22 static std::string GetDirectParentName(std::string name) {
23 size_t last_period = name.find_last_of('.');
24 DCHECK_GT(last_period, 0u);
25 return name.substr(0u, last_period);
28 void AddWidevineWithCodecs(WidevineCdmType widevine_cdm_type,
29 SupportedCodecs supported_codecs,
30 std::vector<KeySystemInfo>* concrete_key_systems) {
31 KeySystemInfo info(kWidevineKeySystem);
33 switch (widevine_cdm_type) {
34 case WIDEVINE:
35 // For standard Widevine, add parent name.
36 info.parent_key_system = GetDirectParentName(kWidevineKeySystem);
37 break;
38 #if defined(OS_ANDROID)
39 case WIDEVINE_HR_NON_COMPOSITING:
40 info.key_system.append(".hrnoncompositing");
41 break;
42 #endif // defined(OS_ANDROID)
43 default:
44 NOTREACHED();
47 // TODO(xhwang): A container or an initDataType may be supported even though
48 // there are no codecs supported in that container. Fix this when we support
49 // initDataType.
50 info.supported_codecs = supported_codecs;
52 #if defined(ENABLE_PEPPER_CDMS)
53 info.pepper_type = kWidevineCdmPluginMimeType;
54 #endif // defined(ENABLE_PEPPER_CDMS)
56 concrete_key_systems->push_back(info);
59 } // namespace cdm
61 #endif // defined(WIDEVINE_CDM_AVAILABLE)