| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/renderer/media/chrome_key_systems.h" | 5 #include "chrome/renderer/media/chrome_key_systems.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 const char kAudioWebM[] = "audio/webm"; | 30 const char kAudioWebM[] = "audio/webm"; |
| 31 const char kVideoWebM[] = "video/webm"; | 31 const char kVideoWebM[] = "video/webm"; |
| 32 const char kVorbis[] = "vorbis"; | 32 const char kVorbis[] = "vorbis"; |
| 33 const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; | 33 const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; |
| 34 | 34 |
| 35 #if defined(USE_PROPRIETARY_CODECS) | 35 #if defined(USE_PROPRIETARY_CODECS) |
| 36 const char kAudioMp4[] = "audio/mp4"; | 36 const char kAudioMp4[] = "audio/mp4"; |
| 37 const char kVideoMp4[] = "video/mp4"; | 37 const char kVideoMp4[] = "video/mp4"; |
| 38 const char kMp4a[] = "mp4a"; | 38 const char kMp4a[] = "mp4a"; |
| 39 const char kAvc1[] = "avc1"; | 39 const char kAvc1Avc3[] = "avc1,avc3"; |
| 40 const char kMp4aAvc1[] = "mp4a,avc1"; | 40 const char kMp4aAvc1Avc3[] = "mp4a,avc1,avc3"; |
| 41 #endif // defined(USE_PROPRIETARY_CODECS) | 41 #endif // defined(USE_PROPRIETARY_CODECS) |
| 42 | 42 |
| 43 #if defined(ENABLE_PEPPER_CDMS) | 43 #if defined(ENABLE_PEPPER_CDMS) |
| 44 static bool IsPepperCdmRegistered(const std::string& pepper_type) { | 44 static bool IsPepperCdmRegistered(const std::string& pepper_type) { |
| 45 bool is_registered = false; | 45 bool is_registered = false; |
| 46 content::RenderThread::Get()->Send( | 46 content::RenderThread::Get()->Send( |
| 47 new ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType( | 47 new ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType( |
| 48 pepper_type, &is_registered)); | 48 pepper_type, &is_registered)); |
| 49 | 49 |
| 50 return is_registered; | 50 return is_registered; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // External Clear Key (used for testing). | 53 // External Clear Key (used for testing). |
| 54 static void AddExternalClearKey( | 54 static void AddExternalClearKey( |
| 55 std::vector<KeySystemInfo>* concrete_key_systems) { | 55 std::vector<KeySystemInfo>* concrete_key_systems) { |
| 56 static const char kExternalClearKeyKeySystem[] = | 56 static const char kExternalClearKeyKeySystem[] = |
| 57 "org.chromium.externalclearkey"; | 57 "org.chromium.externalclearkey"; |
| 58 static const char kExternalClearKeyPepperType[] = | 58 static const char kExternalClearKeyPepperType[] = |
| 59 "application/x-ppapi-clearkey-cdm"; | 59 "application/x-ppapi-clearkey-cdm"; |
| 60 | 60 |
| 61 if (!IsPepperCdmRegistered(kExternalClearKeyPepperType)) | 61 if (!IsPepperCdmRegistered(kExternalClearKeyPepperType)) |
| 62 return; | 62 return; |
| 63 | 63 |
| 64 KeySystemInfo info(kExternalClearKeyKeySystem); | 64 KeySystemInfo info(kExternalClearKeyKeySystem); |
| 65 | 65 |
| 66 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); | 66 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
| 67 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); | 67 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
| 68 #if defined(USE_PROPRIETARY_CODECS) | 68 #if defined(USE_PROPRIETARY_CODECS) |
| 69 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); | 69 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); |
| 70 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); | 70 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1Avc3)); |
| 71 #endif // defined(USE_PROPRIETARY_CODECS) | 71 #endif // defined(USE_PROPRIETARY_CODECS) |
| 72 info.pepper_type = kExternalClearKeyPepperType; | 72 info.pepper_type = kExternalClearKeyPepperType; |
| 73 | 73 |
| 74 concrete_key_systems->push_back(info); | 74 concrete_key_systems->push_back(info); |
| 75 | 75 |
| 76 // A key system that Chrome thinks is supported by ClearKeyCdm, but actually | 76 // A key system that Chrome thinks is supported by ClearKeyCdm, but actually |
| 77 // will be refused by ClearKeyCdm. This is to test the CDM initialization | 77 // will be refused by ClearKeyCdm. This is to test the CDM initialization |
| 78 // failure case. | 78 // failure case. |
| 79 info.key_system += ".initializefail"; | 79 info.key_system += ".initializefail"; |
| 80 concrete_key_systems->push_back(info); | 80 concrete_key_systems->push_back(info); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (supported_codecs & WEBM_VP8_AND_VORBIS) { | 156 if (supported_codecs & WEBM_VP8_AND_VORBIS) { |
| 157 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); | 157 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
| 158 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); | 158 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 #if defined(USE_PROPRIETARY_CODECS) | 161 #if defined(USE_PROPRIETARY_CODECS) |
| 162 if (supported_codecs & MP4_AAC) | 162 if (supported_codecs & MP4_AAC) |
| 163 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); | 163 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); |
| 164 | 164 |
| 165 if (supported_codecs & MP4_AVC1) { | 165 if (supported_codecs & MP4_AVC1) { |
| 166 const char* video_codecs = (supported_codecs & MP4_AAC) ? kMp4aAvc1 : kAvc1; | 166 const char* video_codecs = |
| 167 (supported_codecs & MP4_AAC) ? kMp4aAvc1Avc3 : kAvc1Avc3; |
| 167 info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs)); | 168 info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs)); |
| 168 } | 169 } |
| 169 #endif // defined(USE_PROPRIETARY_CODECS) | 170 #endif // defined(USE_PROPRIETARY_CODECS) |
| 170 | 171 |
| 171 #if defined(ENABLE_PEPPER_CDMS) | 172 #if defined(ENABLE_PEPPER_CDMS) |
| 172 info.pepper_type = kWidevineCdmPluginMimeType; | 173 info.pepper_type = kWidevineCdmPluginMimeType; |
| 173 #elif defined(OS_ANDROID) | 174 #elif defined(OS_ANDROID) |
| 174 info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); | 175 info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); |
| 175 #endif // defined(ENABLE_PEPPER_CDMS) | 176 #endif // defined(ENABLE_PEPPER_CDMS) |
| 176 | 177 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 250 |
| 250 #if defined(WIDEVINE_CDM_AVAILABLE) | 251 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 251 #if defined(ENABLE_PEPPER_CDMS) | 252 #if defined(ENABLE_PEPPER_CDMS) |
| 252 AddPepperBasedWidevine(key_systems_info); | 253 AddPepperBasedWidevine(key_systems_info); |
| 253 #elif defined(OS_ANDROID) | 254 #elif defined(OS_ANDROID) |
| 254 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableMediaDrm)) | 255 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableMediaDrm)) |
| 255 AddAndroidWidevine(key_systems_info); | 256 AddAndroidWidevine(key_systems_info); |
| 256 #endif | 257 #endif |
| 257 #endif | 258 #endif |
| 258 } | 259 } |
| OLD | NEW |