| Index: android_webview/browser/aw_media_client_android.cc
|
| diff --git a/android_webview/browser/aw_media_client_android.cc b/android_webview/browser/aw_media_client_android.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d0052c0747d896d25a698ccdd3901188b3c39a6a
|
| --- /dev/null
|
| +++ b/android_webview/browser/aw_media_client_android.cc
|
| @@ -0,0 +1,62 @@
|
| +// Copyright 2015 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/browser/aw_media_client_android.h"
|
| +
|
| +#include <utility>
|
| +
|
| +#include "base/stl_util.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_util.h"
|
| +#include "components/cdm/browser/widevine_drm_delegate_android.h"
|
| +
|
| +namespace android_webview {
|
| +
|
| +namespace {
|
| +
|
| +const size_t kGUIDLength = 36U;
|
| +
|
| +std::pair<std::string, std::vector<uint8_t>> CreateMappingFromString(
|
| + const std::string& key_system_uuid_mapping) {
|
| + std::vector<std::string> tokens;
|
| + Tokenize(key_system_uuid_mapping, ",", &tokens);
|
| +
|
| + std::string key_system;
|
| + base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &key_system);
|
| +
|
| + std::vector<uint8_t> uuid;
|
| + std::string guid(tokens[1]);
|
| + DCHECK(guid.length() == kGUIDLength);
|
| + base::RemoveChars(guid, "-", &guid);
|
| + base::HexStringToBytes(guid, &uuid);
|
| +
|
| + return std::make_pair(key_system, uuid);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +AwMediaClientAndroid::AwMediaClientAndroid(
|
| + const std::vector<std::string>& key_system_uuid_mappings)
|
| + : widevine_delegate_(new cdm::WidevineDrmDelegateAndroid) {
|
| + for (const std::string& key_system_uuid_mapping : key_system_uuid_mappings)
|
| + mappings_.push_back(CreateMappingFromString(key_system_uuid_mapping));
|
| +}
|
| +
|
| +AwMediaClientAndroid::~AwMediaClientAndroid() {
|
| +}
|
| +
|
| +std::vector<std::pair<std::string, std::vector<uint8_t>>>
|
| +AwMediaClientAndroid::GetKeySystemUUIDMappings() const {
|
| + return mappings_;
|
| +}
|
| +
|
| +media::MediaDrmBridgeDelegate*
|
| +AwMediaClientAndroid::GetMediaDrmBridgeDelegate(
|
| + const std::vector<uint8_t>& scheme_uuid) const {
|
| + if (scheme_uuid == widevine_delegate_->GetUUID())
|
| + return widevine_delegate_.get();
|
| + return nullptr;
|
| +}
|
| +
|
| +} // namespace android_webview
|
|
|