Mac: Fix performance issues with remote CoreAnimation
[chromium-blink-merge.git] / components / cdm / renderer / android_key_systems.cc
blob83a0d0481df831e62aa1727d3dfaf23a08efcb4a
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/android_key_systems.h"
7 #include <string>
8 #include <vector>
10 #include "base/logging.h"
11 #include "components/cdm/common/cdm_messages_android.h"
12 #include "components/cdm/renderer/widevine_key_systems.h"
13 #include "content/public/renderer/render_thread.h"
14 #include "media/base/eme_constants.h"
16 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
18 using media::KeySystemInfo;
19 using media::SupportedCodecs;
21 namespace cdm {
23 static SupportedKeySystemResponse QueryKeySystemSupport(
24 const std::string& key_system) {
25 SupportedKeySystemRequest request;
26 SupportedKeySystemResponse response;
28 request.key_system = key_system;
29 request.codecs = media::EME_CODEC_ALL;
30 content::RenderThread::Get()->Send(
31 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response));
32 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL))
33 << "unrecognized codec";
34 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL))
35 << "unrecognized codec";
36 return response;
39 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) {
40 SupportedKeySystemResponse response = QueryKeySystemSupport(
41 kWidevineKeySystem);
42 if (response.compositing_codecs != media::EME_CODEC_NONE) {
43 AddWidevineWithCodecs(
44 WIDEVINE,
45 static_cast<SupportedCodecs>(response.compositing_codecs),
46 concrete_key_systems);
49 if (response.non_compositing_codecs != media::EME_CODEC_NONE) {
50 AddWidevineWithCodecs(
51 WIDEVINE_HR_NON_COMPOSITING,
52 static_cast<SupportedCodecs>(response.non_compositing_codecs),
53 concrete_key_systems);
57 void AddAndroidPlatformKeySystems(
58 std::vector<KeySystemInfo>* concrete_key_systems) {
59 std::vector<std::string> key_system_names;
60 content::RenderThread::Get()->Send(
61 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names));
63 for (std::vector<std::string>::const_iterator it = key_system_names.begin();
64 it != key_system_names.end(); ++it) {
65 SupportedKeySystemResponse response = QueryKeySystemSupport(*it);
66 if (response.compositing_codecs != media::EME_CODEC_NONE) {
67 KeySystemInfo info(*it);
68 info.supported_codecs = response.compositing_codecs;
69 // Here we assume that support for a container implies support for the
70 // associated initialization data type. KeySystems handles validating
71 // |init_data_type| x |container| pairings.
72 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL)
73 info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_WEBM;
74 #if defined(USE_PROPRIETARY_CODECS)
75 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL)
76 info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_CENC;
77 #endif // defined(USE_PROPRIETARY_CODECS)
78 concrete_key_systems->push_back(info);
83 } // namespace cdm