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 |
| 13 namespace android_webview { |
| 14 |
| 15 namespace { |
| 16 |
| 17 const size_t kGUIDLength = 36U; |
| 18 |
| 19 std::pair<std::string, media::UUID> CreateMappingFromString( |
| 20 const std::string& key_system_uuid_mapping) { |
| 21 std::vector<std::string> tokens; |
| 22 Tokenize(key_system_uuid_mapping, ",", &tokens); |
| 23 |
| 24 std::string key_system; |
| 25 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &key_system); |
| 26 |
| 27 std::vector<uint8_t> uuid; |
| 28 std::string guid(tokens[1]); |
| 29 DCHECK(guid.length() == kGUIDLength); |
| 30 base::RemoveChars(guid, "-", &guid); |
| 31 base::HexStringToBytes(guid, &uuid); |
| 32 |
| 33 return std::make_pair(key_system, uuid); |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
| 38 AwMediaClientAndroid::AwMediaClientAndroid( |
| 39 const std::vector<std::string>& key_system_uuid_mappings) { |
| 40 for (const std::string& key_system_uuid_mapping : key_system_uuid_mappings) { |
| 41 std::pair<std::string, media::UUID> mapping = |
| 42 CreateMappingFromString(key_system_uuid_mapping); |
| 43 AddKeySystemUUIDMapping(mapping.first, mapping.second); |
| 44 } |
| 45 } |
| 46 |
| 47 AwMediaClientAndroid::~AwMediaClientAndroid() { |
| 48 } |
| 49 |
| 50 media::MediaDrmBridgeDelegate* |
| 51 AwMediaClientAndroid::GetMediaDrmBridgeDelegate( |
| 52 const media::UUID& scheme_uuid) { |
| 53 if (scheme_uuid == widevine_delegate_.GetUUID()) |
| 54 return &widevine_delegate_; |
| 55 return nullptr; |
| 56 } |
| 57 |
| 58 } // namespace android_webview |
OLD | NEW |