1 // Copyright 2013 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/renderer/aw_key_systems.h" 6 7 #include <string> 8 9 #include "base/command_line.h" 10 #include "base/logging.h" 11 #include "base/strings/string_split.h" 12 #include "third_party/widevine/cdm/widevine_cdm_common.h" 13 14 using content::KeySystemInfo; 15 16 namespace { 17 18 const char kAudioMp4[] = "audio/mp4"; 19 const char kVideoMp4[] = "video/mp4"; 20 const char kMp4a[] = "mp4a"; 21 const char kMp4aAvc1Avc3[] = "mp4a,avc1,avc3"; 22 23 const uint8 kWidevineUuid[16] = { 24 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, 25 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; 26 27 // Return |name|'s parent key system. 28 std::string GetDirectParentName(const std::string& name) { 29 int last_period = name.find_last_of('.'); 30 DCHECK_GT(last_period, 0); 31 return name.substr(0, last_period); 32 } 33 34 void AddWidevineWithCodecs( 35 const std::string& key_system_name, 36 bool add_parent_name, 37 std::vector<KeySystemInfo>* concrete_key_systems) { 38 KeySystemInfo info(key_system_name); 39 40 if (add_parent_name) 41 info.parent_key_system = GetDirectParentName(key_system_name); 42 43 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); 44 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1Avc3)); 45 46 info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); 47 48 concrete_key_systems->push_back(info); 49 } 50 51 } // namespace 52 53 namespace android_webview { 54 55 void AwAddKeySystems( 56 std::vector<KeySystemInfo>* key_systems_info) { 57 AddWidevineWithCodecs(kWidevineKeySystem, true, key_systems_info); 58 } 59 60 } // namespace android_webview 61