OLD | NEW |
---|---|
(Empty) | |
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 "components/cdm/common/encrypted_media_messages_android.h" | |
12 #include "content/public/renderer/key_system_info.h" | |
13 #include "content/public/renderer/render_thread.h" | |
14 | |
15 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | |
16 | |
17 using content::KeySystemInfo; | |
18 using content::SupportedCodecs; | |
19 | |
20 namespace cdm { | |
21 | |
22 #if defined(WIDEVINE_CDM_AVAILABLE) | |
ddorwin
2014/05/02 17:58:55
This can be outside the namespace (at line 17).
ycheo (away)
2014/05/05 10:15:08
Done.
| |
23 enum WidevineCdmType { | |
24 WIDEVINE, | |
25 WIDEVINE_HR_NON_COMPOSITING, | |
26 }; | |
27 | |
28 // Return |name|'s parent key system. | |
29 static std::string GetDirectParentName(std::string name) { | |
30 int last_period = name.find_last_of('.'); | |
31 DCHECK_GT(last_period, 0); | |
32 return name.substr(0, last_period); | |
33 } | |
34 | |
35 static void AddWidevineWithCodecs( | |
ddorwin
2014/05/02 17:58:55
This function (and the one above) is now duplicate
ycheo (away)
2014/05/05 10:15:08
Done.
| |
36 WidevineCdmType widevine_cdm_type, | |
37 SupportedCodecs supported_codecs, | |
38 std::vector<KeySystemInfo>* concrete_key_systems) { | |
39 KeySystemInfo info(kWidevineKeySystem); | |
40 | |
41 switch (widevine_cdm_type) { | |
42 case WIDEVINE: | |
43 // For standard Widevine, add parent name. | |
44 info.parent_key_system = GetDirectParentName(kWidevineKeySystem); | |
45 break; | |
46 case WIDEVINE_HR_NON_COMPOSITING: | |
47 info.key_system.append(".hrnoncompositing"); | |
48 break; | |
49 default: | |
50 NOTREACHED(); | |
51 } | |
52 | |
53 // TODO(xhwang): A container or an initDataType may be supported even though | |
54 // there are no codecs supported in that container. Fix this when we support | |
55 // initDataType. | |
56 info.supported_codecs = supported_codecs; | |
57 | |
58 concrete_key_systems->push_back(info); | |
59 } | |
60 | |
61 void AddAndroidWidevine( | |
62 std::vector<KeySystemInfo>* concrete_key_systems) { | |
63 SupportedKeySystemRequest request; | |
64 SupportedKeySystemResponse response; | |
65 | |
66 request.key_system = kWidevineKeySystem; | |
67 request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL; | |
68 content::RenderThread::Get()->Send( | |
69 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response)); | |
70 DCHECK(response.compositing_codecs & content::EME_CODEC_ALL) | |
71 << "unrecognized codec"; | |
72 DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL) | |
73 << "unrecognized codec"; | |
74 if (response.compositing_codecs != content::EME_CODEC_NONE) { | |
75 AddWidevineWithCodecs( | |
76 WIDEVINE, | |
77 static_cast<SupportedCodecs>(response.compositing_codecs), | |
78 concrete_key_systems); | |
79 } | |
80 | |
81 if (response.non_compositing_codecs != content::EME_CODEC_NONE) { | |
82 AddWidevineWithCodecs( | |
83 WIDEVINE_HR_NON_COMPOSITING, | |
84 static_cast<SupportedCodecs>(response.non_compositing_codecs), | |
85 concrete_key_systems); | |
86 } | |
87 } | |
88 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
89 | |
90 } // namespace cdm | |
OLD | NEW |