Chromium Code Reviews| 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/logging.h" | |
| 10 #include "base/stl_util.h" | |
| 11 #include "base/strings/string_number_conversions.h" | |
| 12 #include "base/strings/string_util.h" | |
| 13 | |
| 14 namespace android_webview { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 const size_t kGUIDLength = 36U; | |
| 19 | |
| 20 #define RCHECK(x) \ | |
| 21 if (!(x)) { \ | |
| 22 LOG(ERROR) << "Can't parse key-system mapping: " \ | |
| 23 << key_system_uuid_mapping; \ | |
| 24 return std::make_pair("", uuid); \ | |
| 25 } | |
| 26 | |
| 27 std::pair<std::string, media::UUID> CreateMappingFromString( | |
| 28 const std::string& key_system_uuid_mapping) { | |
| 29 std::vector<uint8_t> uuid; | |
| 30 | |
| 31 std::vector<std::string> tokens; | |
| 32 Tokenize(key_system_uuid_mapping, ",", &tokens); | |
| 33 RCHECK(tokens.size() == 2); | |
| 34 | |
| 35 std::string key_system; | |
| 36 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &key_system); | |
| 37 | |
| 38 std::string guid(tokens[1]); | |
| 39 RCHECK(guid.length() == kGUIDLength); | |
| 40 base::RemoveChars(guid, "-", &guid); | |
| 41 RCHECK(base::HexStringToBytes(guid, &uuid)); | |
| 42 | |
| 43 return std::make_pair(key_system, uuid); | |
| 44 } | |
| 45 | |
| 46 } // namespace | |
| 47 | |
| 48 AwMediaClientAndroid::AwMediaClientAndroid( | |
| 49 const std::vector<std::string>& key_system_uuid_mappings) | |
| 50 : key_system_uuid_mappings_(key_system_uuid_mappings) { | |
| 51 } | |
| 52 | |
| 53 AwMediaClientAndroid::~AwMediaClientAndroid() { | |
| 54 } | |
| 55 | |
| 56 void AwMediaClientAndroid::AddKeySystemUUIDMappings(KeySystemUuidMap* map) { | |
| 57 for (const std::string& key_system_uuid_mapping : key_system_uuid_mappings_) { | |
| 58 std::pair<std::string, media::UUID> mapping = | |
| 59 CreateMappingFromString(key_system_uuid_mapping); | |
| 60 if (!mapping.first.empty()) | |
| 61 map->insert(std::make_pair(mapping.first, mapping.second)); | |
|
boliu
2015/04/29 23:15:44
|mapping| is already a pair, no?
And probably sho
gunsch
2015/04/29 23:32:16
Done! Guess I learn something new about C++ every
| |
| 62 } | |
| 63 } | |
| 64 | |
| 65 media::MediaDrmBridgeDelegate* AwMediaClientAndroid::GetMediaDrmBridgeDelegate( | |
| 66 const media::UUID& scheme_uuid) { | |
| 67 if (scheme_uuid == widevine_delegate_.GetUUID()) | |
| 68 return &widevine_delegate_; | |
| 69 return nullptr; | |
| 70 } | |
| 71 | |
| 72 } // namespace android_webview | |
| OLD | NEW |