1 // Copyright 2014 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 "components/cdm/renderer/widevine_key_systems.h" 6 7 #include <string> 8 #include <vector> 9 10 #include "base/logging.h" 11 12 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 13 14 #if defined(WIDEVINE_CDM_AVAILABLE) 15 16 using content::KeySystemInfo; 17 using content::SupportedCodecs; 18 19 namespace cdm { 20 21 // Return |name|'s parent key system. 22 static std::string GetDirectParentName(std::string name) { 23 size_t last_period = name.find_last_of('.'); 24 DCHECK_GT(last_period, 0u); 25 return name.substr(0u, last_period); 26 } 27 28 void AddWidevineWithCodecs(WidevineCdmType widevine_cdm_type, 29 SupportedCodecs supported_codecs, 30 std::vector<KeySystemInfo>* concrete_key_systems) { 31 KeySystemInfo info(kWidevineKeySystem); 32 33 switch (widevine_cdm_type) { 34 case WIDEVINE: 35 // For standard Widevine, add parent name. 36 info.parent_key_system = GetDirectParentName(kWidevineKeySystem); 37 break; 38 #if defined(OS_ANDROID) 39 case WIDEVINE_HR_NON_COMPOSITING: 40 info.key_system.append(".hrnoncompositing"); 41 break; 42 #endif // defined(OS_ANDROID) 43 default: 44 NOTREACHED(); 45 } 46 47 // TODO(xhwang): A container or an initDataType may be supported even though 48 // there are no codecs supported in that container. Fix this when we support 49 // initDataType. 50 info.supported_codecs = supported_codecs; 51 52 #if defined(ENABLE_PEPPER_CDMS) 53 info.pepper_type = kWidevineCdmPluginMimeType; 54 #endif // defined(ENABLE_PEPPER_CDMS) 55 56 concrete_key_systems->push_back(info); 57 } 58 59 } // namespace cdm 60 61 #endif // defined(WIDEVINE_CDM_AVAILABLE) 62