OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/browser/aw_media_client_android.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" |
| 12 #include "components/cdm/browser/widevine_drm_delegate_android.h" |
| 13 |
| 14 namespace android_webview { |
| 15 |
| 16 namespace { |
| 17 |
| 18 const size_t kGUIDLength = 36U; |
| 19 |
| 20 std::pair<std::string, std::vector<uint8_t>> CreateMappingFromString( |
| 21 const std::string& key_system_uuid_mapping) { |
| 22 std::vector<std::string> tokens; |
| 23 Tokenize(key_system_uuid_mapping, ",", &tokens); |
| 24 |
| 25 std::string key_system; |
| 26 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &key_system); |
| 27 |
| 28 std::vector<uint8_t> uuid; |
| 29 std::string guid(tokens[1]); |
| 30 DCHECK(guid.length() == kGUIDLength); |
| 31 base::RemoveChars(guid, "-", &guid); |
| 32 base::HexStringToBytes(guid, &uuid); |
| 33 |
| 34 return std::make_pair(key_system, uuid); |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
| 39 AwMediaClientAndroid::AwMediaClientAndroid( |
| 40 const std::vector<std::string>& key_system_uuid_mappings) |
| 41 : widevine_delegate_(new cdm::WidevineDrmDelegateAndroid) { |
| 42 for (const std::string& key_system_uuid_mapping : key_system_uuid_mappings) |
| 43 mappings_.push_back(CreateMappingFromString(key_system_uuid_mapping)); |
| 44 } |
| 45 |
| 46 AwMediaClientAndroid::~AwMediaClientAndroid() { |
| 47 } |
| 48 |
| 49 std::vector<std::pair<std::string, std::vector<uint8_t>>> |
| 50 AwMediaClientAndroid::GetKeySystemUUIDMappings() const { |
| 51 return mappings_; |
| 52 } |
| 53 |
| 54 media::MediaDrmBridgeDelegate* |
| 55 AwMediaClientAndroid::GetMediaDrmBridgeDelegate( |
| 56 const std::vector<uint8_t>& scheme_uuid) const { |
| 57 if (scheme_uuid == widevine_delegate_->GetUUID()) |
| 58 return widevine_delegate_.get(); |
| 59 return nullptr; |
| 60 } |
| 61 |
| 62 } // namespace android_webview |
OLD | NEW |