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

Side by Side Diff: components/encrypted_media/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: Componetized EncryptedMediaMessageFilter. 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/encrypted_media/renderer/widevine_key_systems.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/logging.h"
11 #include "content/public/renderer/key_system_info.h"
12 #include "content/public/renderer/render_thread.h"
13
14 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
15
16 #if defined(OS_ANDROID)
17 #include "components/encrypted_media/common/encrypted_media_messages_android.h"
18 #endif
19
20 using content::KeySystemInfo;
21 using content::SupportedCodecs;
22
23 namespace encrypted_media {
xhwang 2014/05/01 22:41:22 ddorwin: shall we use "encrypted_media" or "eme" f
ycheo (away) 2014/05/02 10:05:46 Changed to 'cdm' per ddorwin's advice.
24
25 #if defined(WIDEVINE_CDM_AVAILABLE)
26 enum WidevineCdmType {
27 WIDEVINE,
28 WIDEVINE_HR,
ddorwin 2014/05/02 01:12:58 Remove. Never used.
ycheo (away) 2014/05/02 10:05:46 Done.
29 #if defined(OS_ANDROID)
30 WIDEVINE_HR_NON_COMPOSITING,
31 #endif
32 };
33
34 // Return |name|'s parent key system.
35 static std::string GetDirectParentName(std::string name) {
36 int last_period = name.find_last_of('.');
37 DCHECK_GT(last_period, 0);
38 return name.substr(0, last_period);
39 }
40
41 static void AddWidevineWithCodecs(
42 WidevineCdmType widevine_cdm_type,
43 SupportedCodecs supported_codecs,
44 std::vector<KeySystemInfo>* concrete_key_systems) {
45 KeySystemInfo info(kWidevineKeySystem);
46
47 switch (widevine_cdm_type) {
48 case WIDEVINE:
49 // For standard Widevine, add parent name.
50 info.parent_key_system = GetDirectParentName(kWidevineKeySystem);
51 break;
52 case WIDEVINE_HR:
ddorwin 2014/05/02 01:12:58 Remove See above.
ycheo (away) 2014/05/02 10:05:46 Done.
53 info.key_system.append(".hr");
54 break;
55 #if defined(OS_ANDROID)
56 case WIDEVINE_HR_NON_COMPOSITING:
57 info.key_system.append(".hrnoncompositing");
58 break;
59 #endif
60 default:
61 NOTREACHED();
62 }
63
64 // TODO(xhwang): A container or an initDataType may be supported even though
65 // there are no codecs supported in that container. Fix this when we support
66 // initDataType.
67 info.supported_codecs = supported_codecs;
68
69 #if defined(ENABLE_PEPPER_CDMS)
70 info.pepper_type = kWidevineCdmPluginMimeType;
71 #endif // defined(ENABLE_PEPPER_CDMS)
72
73 concrete_key_systems->push_back(info);
74 }
75
76 #if defined(ENABLE_PEPPER_CDMS)
77 void AddPepperBasedWidevine(std::vector<KeySystemInfo>* concrete_key_systems,
ddorwin 2014/05/02 01:12:58 Output parameter should be last.
ycheo (away) 2014/05/02 10:05:46 The function itself was removed.
78 bool is_widevine_hr_supported,
ddorwin 2014/05/02 01:12:58 Unnecessary. See above.
ycheo (away) 2014/05/02 10:05:46 Done.
79 SupportedCodecs supported_codecs) {
80 AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems);
81
82 if (is_widevine_hr_supported)
83 AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems);
84 }
85 #elif defined(OS_ANDROID)
86 void AddAndroidWidevine(
87 std::vector<KeySystemInfo>* concrete_key_systems) {
88 SupportedKeySystemRequest request;
89 SupportedKeySystemResponse response;
90
91 request.key_system = kWidevineKeySystem;
92 request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL;
93 content::RenderThread::Get()->Send(
94 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response));
95 DCHECK(response.compositing_codecs & content::EME_CODEC_ALL)
96 << "unrecognized codec";
97 DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL)
98 << "unrecognized codec";
99 if (response.compositing_codecs != content::EME_CODEC_NONE) {
100 AddWidevineWithCodecs(
101 WIDEVINE,
102 static_cast<SupportedCodecs>(response.compositing_codecs),
103 concrete_key_systems);
104 }
105
106 if (response.non_compositing_codecs != content::EME_CODEC_NONE) {
107 AddWidevineWithCodecs(
108 WIDEVINE_HR_NON_COMPOSITING,
109 static_cast<SupportedCodecs>(response.non_compositing_codecs),
110 concrete_key_systems);
111 }
112 }
113 #endif // defined(ENABLE_PEPPER_CDMS)
114 #endif // defined(WIDEVINE_CDM_AVAILABLE)
115
116 } // namespace encrypted_media
OLDNEW
« components/encrypted_media.gypi ('K') | « components/encrypted_media/renderer/widevine_key_systems.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698