OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/common/aw_media_client_android.h" | 5 #include "android_webview/common/aw_media_drm_bridge_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 | 14 |
15 namespace android_webview { | 15 namespace android_webview { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const size_t kGUIDLength = 36U; | 19 const size_t kGUIDLength = 36U; |
20 | 20 |
21 #define RCHECK(x) \ | 21 #define RCHECK(x) \ |
22 if (!(x)) { \ | 22 if (!(x)) { \ |
23 LOG(ERROR) << "Can't parse key-system mapping: " \ | 23 LOG(ERROR) << "Can't parse key-system mapping: " \ |
24 << key_system_uuid_mapping; \ | 24 << key_system_uuid_mapping; \ |
25 return std::make_pair("", uuid); \ | 25 return std::make_pair("", uuid); \ |
26 } | 26 } |
27 | 27 |
28 media::MediaClientAndroid::KeySystemUuidMap::value_type CreateMappingFromString( | 28 media::MediaDrmBridgeClient::KeySystemUuidMap::value_type |
29 const std::string& key_system_uuid_mapping) { | 29 CreateMappingFromString(const std::string& key_system_uuid_mapping) { |
30 std::vector<uint8_t> uuid; | 30 std::vector<uint8_t> uuid; |
31 | 31 |
32 std::vector<std::string> tokens = | 32 std::vector<std::string> tokens = |
33 base::SplitString(key_system_uuid_mapping, ",", base::KEEP_WHITESPACE, | 33 base::SplitString(key_system_uuid_mapping, ",", base::KEEP_WHITESPACE, |
34 base::SPLIT_WANT_NONEMPTY); | 34 base::SPLIT_WANT_NONEMPTY); |
35 RCHECK(tokens.size() == 2); | 35 RCHECK(tokens.size() == 2); |
36 | 36 |
37 std::string key_system; | 37 std::string key_system; |
38 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &key_system); | 38 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &key_system); |
39 | 39 |
40 std::string guid(tokens[1]); | 40 std::string guid(tokens[1]); |
41 RCHECK(guid.length() == kGUIDLength); | 41 RCHECK(guid.length() == kGUIDLength); |
42 base::RemoveChars(guid, "-", &guid); | 42 base::RemoveChars(guid, "-", &guid); |
43 RCHECK(base::HexStringToBytes(guid, &uuid)); | 43 RCHECK(base::HexStringToBytes(guid, &uuid)); |
44 | 44 |
45 return std::make_pair(key_system, uuid); | 45 return std::make_pair(key_system, uuid); |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 AwMediaClientAndroid::AwMediaClientAndroid( | 50 AwMediaDrmBridgeClient::AwMediaDrmBridgeClient( |
51 const std::vector<std::string>& key_system_uuid_mappings) | 51 const std::vector<std::string>& key_system_uuid_mappings) |
52 : key_system_uuid_mappings_(key_system_uuid_mappings) {} | 52 : key_system_uuid_mappings_(key_system_uuid_mappings) {} |
53 | 53 |
54 AwMediaClientAndroid::~AwMediaClientAndroid() {} | 54 AwMediaDrmBridgeClient::~AwMediaDrmBridgeClient() {} |
55 | 55 |
56 void AwMediaClientAndroid::AddKeySystemUUIDMappings(KeySystemUuidMap* map) { | 56 void AwMediaDrmBridgeClient::AddKeySystemUUIDMappings(KeySystemUuidMap* map) { |
57 for (const std::string& key_system_uuid_mapping : key_system_uuid_mappings_) { | 57 for (const std::string& key_system_uuid_mapping : key_system_uuid_mappings_) { |
58 auto mapping = CreateMappingFromString(key_system_uuid_mapping); | 58 auto mapping = CreateMappingFromString(key_system_uuid_mapping); |
59 if (!mapping.first.empty()) | 59 if (!mapping.first.empty()) |
60 map->insert(mapping); | 60 map->insert(mapping); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 media::MediaDrmBridgeDelegate* AwMediaClientAndroid::GetMediaDrmBridgeDelegate( | 64 media::MediaDrmBridgeDelegate* |
| 65 AwMediaDrmBridgeClient::GetMediaDrmBridgeDelegate( |
65 const media::UUID& scheme_uuid) { | 66 const media::UUID& scheme_uuid) { |
66 if (scheme_uuid == widevine_delegate_.GetUUID()) | 67 if (scheme_uuid == widevine_delegate_.GetUUID()) |
67 return &widevine_delegate_; | 68 return &widevine_delegate_; |
68 return nullptr; | 69 return nullptr; |
69 } | 70 } |
70 | 71 |
71 } // namespace android_webview | 72 } // namespace android_webview |
OLD | NEW |