OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 "android_webview/renderer/aw_key_systems.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/command_line.h" | |
10 #include "base/logging.h" | |
11 #include "base/strings/string_split.h" | |
12 #include "media/base/media_switches.h" | |
13 #include "third_party/widevine/cdm/widevine_cdm_common.h" | |
14 | |
15 using content::KeySystemInfo; | |
16 | |
17 namespace android_webview { | |
18 | |
19 static const char kAudioMp4[] = "audio/mp4"; | |
joth
2013/11/23 23:00:14
nit: prefer anonymous namespace rather than static
| |
20 static const char kVideoMp4[] = "video/mp4"; | |
21 static const char kMp4a[] = "mp4a"; | |
22 static const char kMp4aAvc1Avc3[] = "mp4a,avc1,avc3"; | |
23 | |
24 static const uint8 kWidevineUuid[16] = { | |
25 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
26 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | |
27 | |
28 // Return |name|'s parent key system. | |
29 static std::string GetDirectParentName(const 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( | |
36 const std::string& key_system_name, | |
37 std::vector<KeySystemInfo>* concrete_key_systems) { | |
38 KeySystemInfo info(key_system_name); | |
39 | |
40 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); | |
41 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1Avc3)); | |
42 | |
43 info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); | |
44 | |
45 concrete_key_systems->push_back(info); | |
46 } | |
47 | |
48 void AwAddKeySystems( | |
49 std::vector<KeySystemInfo>* key_systems_info) { | |
50 // For standard Widevine, add parent name. | |
51 std::string widevine_parent = GetDirectParentName(kWidevineKeySystem); | |
52 AddWidevineWithCodecs(widevine_parent, key_systems_info); | |
53 | |
54 if (CommandLine::ForCurrentProcess() | |
55 ->HasSwitch(switches::kMediaDrmEnableNonCompositing)) { | |
56 std::string widevine_hr_non_compositing = kWidevineKeySystem; | |
57 widevine_hr_non_compositing.append(".hrnoncompositing"); | |
58 AddWidevineWithCodecs(widevine_hr_non_compositing, key_systems_info); | |
59 } | |
60 } | |
61 | |
62 } // namespace android_webview | |
OLD | NEW |