Chromium Code Reviews| Index: android_webview/renderer/aw_key_systems.cc |
| diff --git a/android_webview/renderer/aw_key_systems.cc b/android_webview/renderer/aw_key_systems.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ef6dc4c9e2c5aca771759ed6918e1b5413c127e9 |
| --- /dev/null |
| +++ b/android_webview/renderer/aw_key_systems.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "android_webview/renderer/aw_key_systems.h" |
| + |
| +#include <string> |
| + |
| +#include "base/command_line.h" |
| +#include "base/logging.h" |
| +#include "base/strings/string_split.h" |
| +#include "media/base/media_switches.h" |
| +#include "third_party/widevine/cdm/widevine_cdm_common.h" |
| + |
| +using content::KeySystemInfo; |
| + |
| +namespace android_webview { |
| + |
| +static const char kAudioMp4[] = "audio/mp4"; |
|
joth
2013/11/23 23:00:14
nit: prefer anonymous namespace rather than static
|
| +static const char kVideoMp4[] = "video/mp4"; |
| +static const char kMp4a[] = "mp4a"; |
| +static const char kMp4aAvc1Avc3[] = "mp4a,avc1,avc3"; |
| + |
| +static const uint8 kWidevineUuid[16] = { |
| + 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
| + 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
| + |
| +// Return |name|'s parent key system. |
| +static std::string GetDirectParentName(const std::string& name) { |
| + int last_period = name.find_last_of('.'); |
| + DCHECK_GT(last_period, 0); |
| + return name.substr(0, last_period); |
| +} |
| + |
| +static void AddWidevineWithCodecs( |
| + const std::string& key_system_name, |
| + std::vector<KeySystemInfo>* concrete_key_systems) { |
| + KeySystemInfo info(key_system_name); |
| + |
| + info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); |
| + info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1Avc3)); |
| + |
| + info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); |
| + |
| + concrete_key_systems->push_back(info); |
| +} |
| + |
| +void AwAddKeySystems( |
| + std::vector<KeySystemInfo>* key_systems_info) { |
| + // For standard Widevine, add parent name. |
| + std::string widevine_parent = GetDirectParentName(kWidevineKeySystem); |
| + AddWidevineWithCodecs(widevine_parent, key_systems_info); |
| + |
| + if (CommandLine::ForCurrentProcess() |
| + ->HasSwitch(switches::kMediaDrmEnableNonCompositing)) { |
| + std::string widevine_hr_non_compositing = kWidevineKeySystem; |
| + widevine_hr_non_compositing.append(".hrnoncompositing"); |
| + AddWidevineWithCodecs(widevine_hr_non_compositing, key_systems_info); |
| + } |
| +} |
| + |
| +} // namespace android_webview |