Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / cdm / renderer / widevine_key_systems.cc
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.
4
5 #include "components/cdm/renderer/widevine_key_systems.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/logging.h"
11 #include "media/base/eme_constants.h"
12
13 #include "widevine_cdm_version.h"  // In SHARED_INTERMEDIATE_DIR.
14
15 #if defined(WIDEVINE_CDM_AVAILABLE)
16
17 using media::KeySystemInfo;
18 using media::SupportedCodecs;
19
20 namespace cdm {
21
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);
27 }
28
29 void AddWidevineWithCodecs(WidevineCdmType widevine_cdm_type,
30                            SupportedCodecs supported_codecs,
31                            std::vector<KeySystemInfo>* concrete_key_systems) {
32   KeySystemInfo info(kWidevineKeySystem);
33
34   switch (widevine_cdm_type) {
35     case WIDEVINE:
36       // For standard Widevine, add parent name.
37       info.parent_key_system = GetDirectParentName(kWidevineKeySystem);
38       break;
39 #if defined(OS_ANDROID)
40     case WIDEVINE_HR_NON_COMPOSITING:
41       info.key_system.append(".hrnoncompositing");
42       break;
43 #endif  // defined(OS_ANDROID)
44     default:
45       NOTREACHED();
46   }
47
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
50   // initDataType.
51   info.supported_codecs = supported_codecs;
52
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)
62
63 #if defined(ENABLE_PEPPER_CDMS)
64   info.pepper_type = kWidevineCdmPluginMimeType;
65 #endif  // defined(ENABLE_PEPPER_CDMS)
66
67   concrete_key_systems->push_back(info);
68 }
69
70 }  // namespace cdm
71
72 #endif  // defined(WIDEVINE_CDM_AVAILABLE)