Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: components/cdm/renderer/widevine_key_systems.cc

Issue 253593002: Componentize EncryptedMediaMessageFilter and rename it CdmMessageFilter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the reviewers' comments. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/cdm_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
ddorwin 2014/05/05 17:20:25 nit: The ifdef can even be here.
ycheo (away) 2014/05/06 07:16:22 Done.
17 using content::KeySystemInfo;
18 using content::SupportedCodecs;
19
20 #if defined(WIDEVINE_CDM_AVAILABLE)
21
22 namespace cdm {
23
24 // Return |name|'s parent key system.
25 static std::string GetDirectParentName(std::string name) {
26 int last_period = name.find_last_of('.');
27 DCHECK_GT(last_period, 0);
28 return name.substr(0, last_period);
29 }
30
31 void AddWidevineWithCodecs(WidevineCdmType widevine_cdm_type,
32 SupportedCodecs supported_codecs,
33 std::vector<KeySystemInfo>* concrete_key_systems) {
34 KeySystemInfo info(kWidevineKeySystem);
35
36 switch (widevine_cdm_type) {
37 case WIDEVINE:
38 // For standard Widevine, add parent name.
39 info.parent_key_system = GetDirectParentName(kWidevineKeySystem);
40 break;
41 #if defined(OS_ANDROID)
42 case WIDEVINE_HR_NON_COMPOSITING:
43 info.key_system.append(".hrnoncompositing");
44 break;
45 #endif // defined(OS_ANDROID)
46 default:
47 NOTREACHED();
48 }
49
50 // TODO(xhwang): A container or an initDataType may be supported even though
51 // there are no codecs supported in that container. Fix this when we support
52 // initDataType.
53 info.supported_codecs = supported_codecs;
54
55 #if defined(ENABLE_PEPPER_CDMS)
56 info.pepper_type = kWidevineCdmPluginMimeType;
57 #endif // defined(ENABLE_PEPPER_CDMS)
58
59 concrete_key_systems->push_back(info);
60 }
61
62 #if defined(OS_ANDROID)
63 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) {
64 SupportedKeySystemRequest request;
65 SupportedKeySystemResponse response;
66
67 request.key_system = kWidevineKeySystem;
68 request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL;
69 content::RenderThread::Get()->Send(
70 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response));
71 DCHECK(response.compositing_codecs & content::EME_CODEC_ALL)
72 << "unrecognized codec";
73 DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL)
74 << "unrecognized codec";
75 if (response.compositing_codecs != content::EME_CODEC_NONE) {
76 AddWidevineWithCodecs(
77 WIDEVINE,
78 static_cast<SupportedCodecs>(response.compositing_codecs),
79 concrete_key_systems);
80 }
81
82 if (response.non_compositing_codecs != content::EME_CODEC_NONE) {
83 AddWidevineWithCodecs(
84 WIDEVINE_HR_NON_COMPOSITING,
85 static_cast<SupportedCodecs>(response.non_compositing_codecs),
86 concrete_key_systems);
87 }
88 }
89 #endif // OS_ANDROID
90
91 } // namespace cdm
92
93 #endif // defined(WIDEVINE_CDM_AVAILABLE)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698