diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-04 16:01:13 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-19 08:47:46 +0000 |
commit | 96f120fd9ec94befcf0cc510ef40a7730677c0ad (patch) | |
tree | 98dba04b8b89ca1a932190bfdcfe9684a94d7c2e /src | |
parent | 440fbed83646f16bf002749f7cecf6ad6fc59bbf (diff) |
Enable Widevine CDM
Enable loading Google Chrome's Widevine pepper plugin.
Flash and Widevine plugins will now also be searched for in
the plugins/ppapi directory.
Task-number: QTBUG-50132
Change-Id: I28fb56bb08d7e81629e34420be626621a7981181
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/browser_message_filter_qt.cpp | 90 | ||||
-rw-r--r-- | src/core/browser_message_filter_qt.h | 71 | ||||
-rw-r--r-- | src/core/common/qt_messages.h | 18 | ||||
-rw-r--r-- | src/core/config/desktop_linux.pri | 1 | ||||
-rw-r--r-- | src/core/config/mac_osx.pri | 3 | ||||
-rw-r--r-- | src/core/config/windows.pri | 1 | ||||
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 4 | ||||
-rw-r--r-- | src/core/content_client_qt.cpp | 85 | ||||
-rw-r--r-- | src/core/core_gyp_generator.pro | 2 | ||||
-rw-r--r-- | src/core/qtwebengine.gypi | 1 | ||||
-rw-r--r-- | src/core/renderer/content_renderer_client_qt.cpp | 144 | ||||
-rw-r--r-- | src/core/renderer/content_renderer_client_qt.h | 1 |
12 files changed, 420 insertions, 1 deletions
diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp new file mode 100644 index 000000000..a91e41faa --- /dev/null +++ b/src/core/browser_message_filter_qt.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "browser_message_filter_qt.h" + +#include "common/qt_messages.h" +#include "content/public/browser/plugin_service.h" +#include "type_conversion.h" + +namespace QtWebEngineCore { + +BrowserMessageFilterQt::BrowserMessageFilterQt(int /*render_process_id*/) + : BrowserMessageFilter(QtMsgStart) +{ +} + +bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message) +{ + IPC_BEGIN_MESSAGE_MAP(BrowserMessageFilterQt, message) +#if defined(ENABLE_PEPPER_CDMS) + IPC_MESSAGE_HANDLER( + QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType, + OnIsInternalPluginAvailableForMimeType) +#endif + IPC_MESSAGE_UNHANDLED(return false) + IPC_END_MESSAGE_MAP() + return true; +} + +#if defined(ENABLE_PEPPER_CDMS) +void BrowserMessageFilterQt::OnIsInternalPluginAvailableForMimeType( + const std::string& mime_type, bool* is_available, + std::vector<base::string16>* additional_param_names, + std::vector<base::string16>* additional_param_values) +{ + std::vector<content::WebPluginInfo> plugins; + content::PluginService::GetInstance()->GetInternalPlugins(&plugins); + + for (size_t i = 0; i < plugins.size(); ++i) { + const content::WebPluginInfo& plugin = plugins[i]; + const std::vector<content::WebPluginMimeType>& mime_types = plugin.mime_types; + for (size_t j = 0; j < mime_types.size(); ++j) { + if (mime_types[j].mime_type == mime_type) { + *is_available = true; + *additional_param_names = mime_types[j].additional_param_names; + *additional_param_values = mime_types[j].additional_param_values; + return; + } + } + } + + *is_available = false; +} + +#endif // defined(ENABLE_PEPPER_CDMS) + +} // namespace QtWebEngineCore diff --git a/src/core/browser_message_filter_qt.h b/src/core/browser_message_filter_qt.h new file mode 100644 index 000000000..35ea37fa9 --- /dev/null +++ b/src/core/browser_message_filter_qt.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BROWSER_MESSAGE_FILTER_QT_H +#define BROWSER_MESSAGE_FILTER_QT_H + +#include "content/public/browser/browser_message_filter.h" + +#include <QtGlobal> + +namespace QtWebEngineCore { + +class BrowserMessageFilterQt : public content::BrowserMessageFilter +{ +public: + BrowserMessageFilterQt(int render_process_id); + +private: + bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE; +#if defined(ENABLE_PEPPER_CDMS) + // Returns whether any internal plugin supporting |mime_type| is registered + // and enabled. Does not determine whether the plugin can actually be + // instantiated (e.g. whether it has all its dependencies). + // When the returned *|is_available| is true, |additional_param_names| and + // |additional_param_values| contain the name-value pairs, if any, specified + // for the *first* non-disabled plugin found that is registered for + // |mime_type|. + void OnIsInternalPluginAvailableForMimeType( + const std::string& mime_type, + bool* is_available, + std::vector<base::string16>* additional_param_names, + std::vector<base::string16>* additional_param_values); +#endif +}; + +} // namespace QtWebEngineCore + +#endif // BROWSER_MESSAGE_FILTER_QT_H diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h index 386f8fc76..de30c34d6 100644 --- a/src/core/common/qt_messages.h +++ b/src/core/common/qt_messages.h @@ -64,3 +64,21 @@ IPC_MESSAGE_ROUTED2(RenderViewObserverHostQt_DidFetchDocumentInnerText, IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout) IPC_MESSAGE_ROUTED1(WebChannelIPCTransportHost_SendMessage, std::vector<char> /*binaryJSON*/) + +//----------------------------------------------------------------------------- +// Misc messages +// These are messages sent from the renderer to the browser process. + +#if defined(ENABLE_PEPPER_CDMS) +// Returns whether any internal plugin supporting |mime_type| is registered and +// enabled. Does not determine whether the plugin can actually be instantiated +// (e.g. whether it has all its dependencies). +// When the returned *|is_available| is true, |additional_param_names| and +// |additional_param_values| contain the name-value pairs, if any, specified +// for the *first* non-disabled plugin found that is registered for |mime_type|. +IPC_SYNC_MESSAGE_CONTROL1_3(QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType, + std::string /* mime_type */, + bool /* is_available */, + std::vector<base::string16> /* additional_param_names */, + std::vector<base::string16> /* additional_param_values */) +#endif diff --git a/src/core/config/desktop_linux.pri b/src/core/config/desktop_linux.pri index f0bf6cb23..7e1d9b106 100644 --- a/src/core/config/desktop_linux.pri +++ b/src/core/config/desktop_linux.pri @@ -5,6 +5,7 @@ include(linux.pri) GYP_CONFIG += \ desktop_linux=1 \ enable_plugins=1 \ + enable_widevine=1 linux-clang: GYP_CONFIG += clang=1 host_clang=1 clang_use_chrome_plugins=0 make_clang_dir=/usr else: GYP_CONFIG += clang=0 host_clang=0 diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri index 93c77623c..b1659985e 100644 --- a/src/core/config/mac_osx.pri +++ b/src/core/config/mac_osx.pri @@ -15,7 +15,8 @@ GYP_CONFIG += \ mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \ make_clang_dir=\"$${QMAKE_CLANG_DIR}\" \ clang_use_chrome_plugins=0 \ - enable_plugins=1 + enable_plugins=1 \ + enable_widevine=1 QMAKE_MAC_SDK_PATH = "$$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path)" exists($$QMAKE_MAC_SDK_PATH): GYP_CONFIG += mac_sdk_path=\"$${QMAKE_MAC_SDK_PATH}\" diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index 1e875f308..92e193422 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -4,6 +4,7 @@ GYP_CONFIG += \ disable_nacl=1 \ remoting=0 \ use_ash=0 \ + enable_widevine=1 # Chromium builds with debug info in release by default but Qt doesn't CONFIG(release, debug|release):!force_debug_info: GYP_CONFIG += fastbuild=1 diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 61e0f3399..ef0494396 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -61,6 +61,7 @@ #include "access_token_store_qt.h" #include "browser_context_adapter.h" #include "browser_context_qt.h" +#include "browser_message_filter_qt.h" #include "certificate_error_controller.h" #include "certificate_error_controller_p.h" #include "desktop_screen_qt.h" @@ -350,6 +351,9 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* // FIXME: Add a settings variable to enable/disable the file scheme. content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), url::kFileScheme); static_cast<BrowserContextQt*>(host->GetBrowserContext())->m_adapter->userScriptController()->renderProcessStartedWithHost(host); +#if defined(ENABLE_PEPPER_CDMS) + host->AddFilter(new BrowserMessageFilterQt(host->GetID())); +#endif } void ContentBrowserClientQt::ResourceDispatcherHostCreated() diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 8d7ea397b..36ee8d0a1 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -37,9 +37,11 @@ #include "content_client_qt.h" #include "base/command_line.h" +#include "base/files/file_util.h" #include "base/strings/string_piece.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "base/strings/utf_string_conversions.h" #include "content/public/common/content_constants.h" #include "content/public/common/user_agent.h" #include "ui/base/layout.h" @@ -49,11 +51,15 @@ #include <QCoreApplication> #include <QFile> +#include <QLibraryInfo> +#include <QString> #if defined(ENABLE_PLUGINS) #include "content/public/common/pepper_plugin_info.h" #include "ppapi/shared_impl/ppapi_permissions.h" +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + static const int32 kPepperFlashPermissions = ppapi::PERMISSION_DEV | ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_BYPASS_USER_GESTURE | @@ -62,8 +68,30 @@ static const int32 kPepperFlashPermissions = ppapi::PERMISSION_DEV | namespace switches { const char kPpapiFlashPath[] = "ppapi-flash-path"; const char kPpapiFlashVersion[] = "ppapi-flash-version"; +const char kPpapiWidevinePath[] = "ppapi-widevine-path"; +} + +static const base::FilePath::CharType kWidevineCdmBaseDirectory[] = FILE_PATH_LITERAL("WidevineCDM"); + +static const char kWidevineCdmPluginExtension[] = ""; + +static const int32 kWidevineCdmPluginPermissions = ppapi::PERMISSION_DEV + | ppapi::PERMISSION_PRIVATE; + +static QString ppapiPluginsPath() +{ + // Look for plugins in /plugins/ppapi or application dir. + static bool initialized = false; + static QString potentialPluginsPath = QLibraryInfo::location(QLibraryInfo::PluginsPath) % QLatin1String("/ppapi"); + if (!initialized) { + initialized = true; + if (!QFileInfo::exists(potentialPluginsPath)) + potentialPluginsPath = QCoreApplication::applicationDirPath(); + } + return potentialPluginsPath; } + // Adopted from chrome_content_client.cc content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, const std::string& version) { @@ -112,14 +140,17 @@ void AddPepperFlashFromSystem(std::vector<content::PepperPluginInfo>* plugins) pluginDir.setFilter(QDir::Files); Q_FOREACH (const QFileInfo &info, pluginDir.entryInfoList(QStringList("pepflashplayer*.dll"))) pluginPaths << info.absoluteFilePath(); + pluginPaths << ppapiPluginsPath() + QStringLiteral("/pepflashplayer.dll"); #endif #if defined(Q_OS_OSX) pluginPaths << "/Library/Internet Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin"; // Mac OS X + pluginPaths << ppapiPluginsPath() + QStringLiteral("/PepperFlashPlayer.plugin"); #endif #if defined(Q_OS_LINUX) pluginPaths << "/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so" // Ubuntu << "/usr/lib/PepperFlash/libpepflashplayer.so" // Arch << "/usr/lib64/chromium/PepperFlash/libpepflashplayer.so"; // OpenSuSE + pluginPaths << ppapiPluginsPath() + QStringLiteral("/libpepflashplayer.so"); #endif for (auto it = pluginPaths.constBegin(); it != pluginPaths.constEnd(); ++it) { if (!QFile(*it).exists()) @@ -139,12 +170,66 @@ void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugi plugins->push_back(CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); } +void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins) +{ +#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && !defined(WIDEVINE_CDM_IS_COMPONENT) + QStringList pluginPaths; + const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kPpapiWidevinePath); + if (!widevine_argument.empty()) + pluginPaths << QtWebEngineCore::toQt(widevine_argument); + else { + pluginPaths << ppapiPluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmAdapterFileName); +#if defined(Q_OS_LINUX) + pluginPaths << QStringLiteral("/opt/google/chrome/libwidevinecdmadapter.so") // Google Chrome + << QStringLiteral("/usr/lib/chromium/libwidevinecdmadapter.so"); // Arch +#endif + } + + Q_FOREACH (const QString &pluginPath, pluginPaths) { + base::FilePath path = QtWebEngineCore::toFilePath(pluginPath); + if (base::PathExists(path)) { + content::PepperPluginInfo widevine_cdm; + widevine_cdm.is_out_of_process = true; + widevine_cdm.path = path; + widevine_cdm.name = kWidevineCdmDisplayName; + widevine_cdm.description = kWidevineCdmDescription; + content::WebPluginMimeType widevine_cdm_mime_type( + kWidevineCdmPluginMimeType, + kWidevineCdmPluginExtension, + kWidevineCdmPluginMimeTypeDescription); + + // Add the supported codecs as if they came from the component manifest. + std::vector<std::string> codecs; + codecs.push_back(kCdmSupportedCodecVorbis); + codecs.push_back(kCdmSupportedCodecVp8); + codecs.push_back(kCdmSupportedCodecVp9); +#if defined(USE_PROPRIETARY_CODECS) + codecs.push_back(kCdmSupportedCodecAac); + codecs.push_back(kCdmSupportedCodecAvc1); +#endif // defined(USE_PROPRIETARY_CODECS) + std::string codec_string = + base::JoinString(codecs, ","); + widevine_cdm_mime_type.additional_param_names.push_back( + base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); + widevine_cdm_mime_type.additional_param_values.push_back( + base::ASCIIToUTF16(codec_string)); + + widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); + widevine_cdm.permissions = kWidevineCdmPluginPermissions; + plugins->push_back(widevine_cdm); + } + } +#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && + // !defined(WIDEVINE_CDM_IS_COMPONENT) +} + namespace QtWebEngineCore { void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins) { AddPepperFlashFromSystem(plugins); AddPepperFlashFromCommandLine(plugins); + AddPepperWidevine(plugins); } } diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro index 7145d8e04..80bf662d6 100644 --- a/src/core/core_gyp_generator.pro +++ b/src/core/core_gyp_generator.pro @@ -35,6 +35,7 @@ SOURCES = \ browser_accessibility_qt.cpp \ browser_context_adapter.cpp \ browser_context_qt.cpp \ + browser_message_filter_qt.cpp \ certificate_error_controller.cpp \ chromium_gpu_helper.cpp \ chromium_overrides.cpp \ @@ -109,6 +110,7 @@ HEADERS = \ browser_context_adapter.h \ browser_context_adapter_client.h \ browser_context_qt.h \ + browser_message_filter_qt.h \ certificate_error_controller_p.h \ certificate_error_controller.h \ chromium_overrides.h \ diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi index 96b48e2ca..c4fcc4309 100644 --- a/src/core/qtwebengine.gypi +++ b/src/core/qtwebengine.gypi @@ -15,6 +15,7 @@ '<(chromium_src_dir)/components/components.gyp:visitedlink_renderer', '<(chromium_src_dir)/components/components.gyp:web_cache_browser', '<(chromium_src_dir)/components/components.gyp:web_cache_renderer', + '<(chromium_src_dir)/components/components.gyp:cdm_renderer', '<(chromium_src_dir)/content/content.gyp:content', '<(chromium_src_dir)/content/content.gyp:content_app_browser', '<(chromium_src_dir)/content/content.gyp:content_browser', diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 2d36d71bd..dbbb773eb 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -36,8 +36,12 @@ #include "renderer/content_renderer_client_qt.h" +#include "common/qt_messages.h" + +#include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "chrome/common/localized_error.h" +#include "components/cdm/renderer/widevine_key_systems.h" #include "components/error_page/common/error_page_params.h" #include "components/visitedlink/renderer/visitedlink_slave.h" #include "components/web_cache/renderer/web_cache_render_process_observer.h" @@ -60,6 +64,8 @@ #include "grit/renderer_resources.h" +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + namespace QtWebEngineCore { static const char kHttpErrorDomain[] = "http"; @@ -156,4 +162,142 @@ bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash) return m_visitedLinkSlave->IsVisited(linkHash); } +#if defined(ENABLE_PEPPER_CDMS) +static bool IsPepperCdmAvailable(const std::string& pepper_type, + std::vector<base::string16>* additional_param_names, + std::vector<base::string16>* additional_param_values) +{ + bool is_available = false; + content::RenderThread::Get()->Send( + new QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType( + pepper_type, + &is_available, + additional_param_names, + additional_param_values)); + + return is_available; +} + +// External Clear Key (used for testing). +static void AddExternalClearKey(std::vector<media::KeySystemInfo>* concrete_key_systems) +{ + static const char kExternalClearKeyKeySystem[] = + "org.chromium.externalclearkey"; + static const char kExternalClearKeyDecryptOnlyKeySystem[] = + "org.chromium.externalclearkey.decryptonly"; + static const char kExternalClearKeyFileIOTestKeySystem[] = + "org.chromium.externalclearkey.fileiotest"; + static const char kExternalClearKeyInitializeFailKeySystem[] = + "org.chromium.externalclearkey.initializefail"; + static const char kExternalClearKeyCrashKeySystem[] = + "org.chromium.externalclearkey.crash"; + static const char kExternalClearKeyPepperType[] = + "application/x-ppapi-clearkey-cdm"; + + std::vector<base::string16> additional_param_names; + std::vector<base::string16> additional_param_values; + if (!IsPepperCdmAvailable(kExternalClearKeyPepperType, + &additional_param_names, + &additional_param_values)) + return; + + media::KeySystemInfo info; + info.key_system = kExternalClearKeyKeySystem; + + info.supported_init_data_types = + media::kInitDataTypeMaskWebM | media::kInitDataTypeMaskKeyIds; + info.supported_codecs = media::EME_CODEC_WEBM_ALL; +#if defined(USE_PROPRIETARY_CODECS) + info.supported_init_data_types |= media::kInitDataTypeMaskCenc; + info.supported_codecs |= media::EME_CODEC_MP4_ALL; +#endif // defined(USE_PROPRIETARY_CODECS) + + info.max_audio_robustness = media::EmeRobustness::EMPTY; + info.max_video_robustness = media::EmeRobustness::EMPTY; + + // Persistent sessions are faked. + info.persistent_license_support = media::EmeSessionTypeSupport::SUPPORTED; + info.persistent_release_message_support = + media::EmeSessionTypeSupport::NOT_SUPPORTED; + info.persistent_state_support = media::EmeFeatureSupport::REQUESTABLE; + info.distinctive_identifier_support = media::EmeFeatureSupport::NOT_SUPPORTED; + + info.pepper_type = kExternalClearKeyPepperType; + + concrete_key_systems->push_back(info); + + // Add support of decrypt-only mode in ClearKeyCdm. + info.key_system = kExternalClearKeyDecryptOnlyKeySystem; + concrete_key_systems->push_back(info); + + // A key system that triggers FileIO test in ClearKeyCdm. + info.key_system = kExternalClearKeyFileIOTestKeySystem; + concrete_key_systems->push_back(info); + + // A key system that Chrome thinks is supported by ClearKeyCdm, but actually + // will be refused by ClearKeyCdm. This is to test the CDM initialization + // failure case. + info.key_system = kExternalClearKeyInitializeFailKeySystem; + concrete_key_systems->push_back(info); + + // A key system that triggers a crash in ClearKeyCdm. + info.key_system = kExternalClearKeyCrashKeySystem; + concrete_key_systems->push_back(info); +} + +#if defined(WIDEVINE_CDM_AVAILABLE) + +static void AddPepperBasedWidevine(std::vector<media::KeySystemInfo>* concrete_key_systems) +{ +//#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) +// Version glibc_version(gnu_get_libc_version()); +// DCHECK(glibc_version.IsValid()); +// if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) +// return; +//#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) + + std::vector<base::string16> additional_param_names; + std::vector<base::string16> additional_param_values; + if (!IsPepperCdmAvailable(kWidevineCdmPluginMimeType, + &additional_param_names, + &additional_param_values)) { + DVLOG(1) << "Widevine CDM is not currently available."; + return; + } + + media::SupportedCodecs supported_codecs = media::EME_CODEC_NONE; + + supported_codecs |= media::EME_CODEC_WEBM_OPUS; + supported_codecs |= media::EME_CODEC_WEBM_VORBIS; + supported_codecs |= media::EME_CODEC_WEBM_VP8; + supported_codecs |= media::EME_CODEC_WEBM_VP9; +#if defined(USE_PROPRIETARY_CODECS) + supported_codecs |= media::EME_CODEC_MP4_AVC1; + supported_codecs |= media::EME_CODEC_MP4_AAC; +#endif // defined(USE_PROPRIETARY_CODECS) + + cdm::AddWidevineWithCodecs( + cdm::WIDEVINE, supported_codecs, + media::EmeRobustness::SW_SECURE_CRYPTO, // Maximum audio robustness. + media::EmeRobustness::SW_SECURE_DECODE, // Maximum video robustness. + media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. + media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. + media::EmeFeatureSupport::REQUESTABLE, // Persistent state. + media::EmeFeatureSupport::NOT_SUPPORTED, // Distinctive identifier. + concrete_key_systems); +} +#endif // defined(WIDEVINE_CDM_AVAILABLE) +#endif // defined(ENABLE_PEPPER_CDMS) + +void ContentRendererClientQt::AddKeySystems(std::vector<media::KeySystemInfo>* key_systems_info) +{ +#if defined(ENABLE_PEPPER_CDMS) + AddExternalClearKey(key_systems_info); + +#if defined(WIDEVINE_CDM_AVAILABLE) + AddPepperBasedWidevine(key_systems_info); +#endif // defined(WIDEVINE_CDM_AVAILABLE) +#endif // defined(ENABLE_PEPPER_CDMS) +} + } // namespace diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index eb55156ad..a48ef3fee 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -65,6 +65,7 @@ public: virtual unsigned long long VisitedLinkHash(const char *canonicalUrl, size_t length) Q_DECL_OVERRIDE; virtual bool IsLinkVisited(unsigned long long linkHash) Q_DECL_OVERRIDE; + virtual void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) Q_DECL_OVERRIDE; private: QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave; |