Check for key system support using new mojo service KeySystemSupport
https://chromium-review.googlesource.com/c/chromium/src/+/834764
This commit is contained in:
parent
e1f25253db
commit
77f427acc8
10 changed files with 68 additions and 233 deletions
|
@ -20,7 +20,6 @@
|
|||
#include "content/public/common/user_agent.h"
|
||||
#include "media/media_features.h"
|
||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||
#include "third_party/widevine/cdm/stub/widevine_cdm_version.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
|
@ -90,20 +89,6 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
|||
kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
|
||||
kWidevineCdmPluginMimeTypeDescription);
|
||||
|
||||
// Add the supported codecs as if they came from the component manifest.
|
||||
std::vector<std::string> codecs;
|
||||
codecs.push_back(kCdmSupportedCodecVp8);
|
||||
codecs.push_back(kCdmSupportedCodecVp9);
|
||||
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
codecs.push_back(kCdmSupportedCodecAvc1);
|
||||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
std::string codec_string = base::JoinString(
|
||||
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
|
||||
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;
|
||||
|
||||
|
@ -224,4 +209,36 @@ void AtomContentClient::AddPepperPlugins(
|
|||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
}
|
||||
|
||||
void AtomContentClient::AddContentDecryptionModules(
|
||||
std::vector<content::CdmInfo>* cdms,
|
||||
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) {
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
base::FilePath widevine_cdm_path =
|
||||
command_line->GetSwitchValuePath(switches::kWidevineCdmPath);
|
||||
if (widevine_cdm_path.empty())
|
||||
return;
|
||||
|
||||
if (!base::PathExists(widevine_cdm_path))
|
||||
return;
|
||||
|
||||
auto widevine_cdm_version =
|
||||
command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion);
|
||||
if (widevine_cdm_version.empty())
|
||||
return;
|
||||
|
||||
std::vector<media::VideoCodec> supported_video_codecs;
|
||||
supported_video_codecs.push_back(media::VideoCodec::kCodecVP8);
|
||||
supported_video_codecs.push_back(media::VideoCodec::kCodecVP9);
|
||||
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
supported_video_codecs.push_back(media::VideoCodec::kCodecH264);
|
||||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
content::CdmRegistry::GetInstance()->RegisterCdm(
|
||||
content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid,
|
||||
base::Version(widevine_cdm_version), widevine_cdm_path,
|
||||
kWidevineCdmFileSystemId, supported_video_codecs, false,
|
||||
kWidevineKeySystem, false));
|
||||
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -26,6 +26,9 @@ class AtomContentClient : public brightray::ContentClient {
|
|||
void AddAdditionalSchemes(Schemes* schemes) override;
|
||||
void AddPepperPlugins(
|
||||
std::vector<content::PepperPluginInfo>* plugins) override;
|
||||
void AddContentDecryptionModules(
|
||||
std::vector<content::CdmInfo>* cdms,
|
||||
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "base/strings/string_util.h"
|
||||
#include "chrome/browser/printing/printing_message_filter.h"
|
||||
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
||||
#include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h"
|
||||
#include "chrome/browser/speech/tts_message_filter.h"
|
||||
#include "content/public/browser/browser_ppapi_host.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
|
@ -186,8 +185,6 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
|||
|
||||
host->AddFilter(new printing::PrintingMessageFilter(process_id));
|
||||
host->AddFilter(new TtsMessageFilter(process_id, host->GetBrowserContext()));
|
||||
host->AddFilter(
|
||||
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
|
||||
|
||||
ProcessPreferences prefs;
|
||||
auto* web_preferences =
|
||||
|
|
|
@ -8,4 +8,3 @@
|
|||
#include "chrome/common/chrome_utility_printing_messages.h"
|
||||
#include "chrome/common/print_messages.h"
|
||||
#include "chrome/common/tts_messages.h"
|
||||
#include "chrome/common/widevine_cdm_messages.h"
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/webplugininfo.h"
|
||||
#include "media/media_features.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
using content::PluginService;
|
||||
using content::WebPluginInfo;
|
||||
|
||||
WidevineCdmMessageFilter::WidevineCdmMessageFilter(
|
||||
int render_process_id,
|
||||
content::BrowserContext* browser_context)
|
||||
: BrowserMessageFilter(ChromeMsgStart),
|
||||
render_process_id_(render_process_id),
|
||||
browser_context_(browser_context) {}
|
||||
|
||||
bool WidevineCdmMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_BEGIN_MESSAGE_MAP(WidevineCdmMessageFilter, message)
|
||||
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
|
||||
OnIsInternalPluginAvailableForMimeType)
|
||||
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
IPC_MESSAGE_UNHANDLED(return false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
return true;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
void WidevineCdmMessageFilter::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<WebPluginInfo> plugins;
|
||||
PluginService::GetInstance()->GetInternalPlugins(&plugins);
|
||||
|
||||
for (size_t i = 0; i < plugins.size(); ++i) {
|
||||
const 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 // BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
|
||||
void WidevineCdmMessageFilter::OnDestruct() const {
|
||||
BrowserThread::DeleteOnUIThread::Destruct(this);
|
||||
}
|
||||
|
||||
WidevineCdmMessageFilter::~WidevineCdmMessageFilter() {}
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_WIDEVINE_CDM_MESSAGE_FILTER_H_
|
||||
#define CHROME_BROWSER_RENDERER_HOST_PEPPER_WIDEVINE_CDM_MESSAGE_FILTER_H_
|
||||
|
||||
#include "chrome/common/widevine_cdm_messages.h"
|
||||
#include "content/public/browser/browser_message_filter.h"
|
||||
#include "media/media_features.h"
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
}
|
||||
|
||||
class WidevineCdmMessageFilter : public content::BrowserMessageFilter {
|
||||
public:
|
||||
explicit WidevineCdmMessageFilter(int render_process_id,
|
||||
content::BrowserContext* browser_context);
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
void OnDestruct() const override;
|
||||
|
||||
private:
|
||||
friend class content::BrowserThread;
|
||||
friend class base::DeleteHelper<WidevineCdmMessageFilter>;
|
||||
|
||||
~WidevineCdmMessageFilter() override;
|
||||
|
||||
#if BUILDFLAG(ENABLE_LIBRARY_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 // BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
|
||||
int render_process_id_;
|
||||
content::BrowserContext* browser_context_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WidevineCdmMessageFilter);
|
||||
};
|
||||
|
||||
#endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_WIDEVINE_CDM_MESSAGE_FILTER_H_
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/macros.h"
|
||||
#include "third_party/widevine/cdm/widevine_cdm_common.h"
|
||||
|
||||
extern const char kWidevineCdmPluginExtension[];
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Multiply-included message file, hence no include guard.
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "media/media_features.h"
|
||||
|
||||
#define IPC_MESSAGE_START ChromeMsgStart
|
||||
|
||||
// Renderer -> Browser messages.
|
||||
|
||||
#if BUILDFLAG(ENABLE_LIBRARY_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(
|
||||
ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
|
||||
std::string /* mime_type */,
|
||||
bool /* is_available */,
|
||||
std::vector<base::string16> /* additional_param_names */,
|
||||
std::vector<base::string16> /* additional_param_values */)
|
||||
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
|
||||
// Browser -> Renderer messages.
|
|
@ -13,13 +13,17 @@
|
|||
#include "base/strings/string16.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/common/widevine_cdm_messages.h"
|
||||
#include "components/cdm/renderer/widevine_key_system_properties.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
#include "media/base/eme_constants.h"
|
||||
#include "media/base/key_system_properties.h"
|
||||
#include "media/media_features.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||
#include "content/public/renderer/key_system_support.h"
|
||||
#include "media/base/video_codecs.h"
|
||||
#endif
|
||||
|
||||
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
|
||||
|
||||
// The following must be after widevine_cdm_version.h.
|
||||
|
@ -36,19 +40,6 @@ using media::SupportedCodecs;
|
|||
static const char kExternalClearKeyPepperType[] =
|
||||
"application/x-ppapi-clearkey-cdm";
|
||||
|
||||
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 ChromeViewHostMsg_IsInternalPluginAvailableForMimeType(
|
||||
pepper_type, &is_available, additional_param_names,
|
||||
additional_param_values));
|
||||
|
||||
return is_available;
|
||||
}
|
||||
|
||||
// KeySystemProperties implementation for external Clear Key systems.
|
||||
class ExternalClearKeyProperties : public KeySystemProperties {
|
||||
public:
|
||||
|
@ -133,11 +124,11 @@ static void AddExternalClearKey(
|
|||
static const char kExternalClearKeyCrashKeySystem[] =
|
||||
"org.chromium.externalclearkey.crash";
|
||||
|
||||
std::vector<base::string16> additional_param_names;
|
||||
std::vector<base::string16> additional_param_values;
|
||||
if (!IsPepperCdmAvailable(kExternalClearKeyPepperType,
|
||||
&additional_param_names,
|
||||
&additional_param_values)) {
|
||||
std::vector<media::VideoCodec> supported_video_codecs;
|
||||
bool supports_persistent_license;
|
||||
if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem,
|
||||
&supported_video_codecs,
|
||||
&supports_persistent_license)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -164,33 +155,6 @@ static void AddExternalClearKey(
|
|||
}
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE)
|
||||
// This function finds "codecs" and parses the value into the vector |codecs|.
|
||||
// Converts the codec strings to UTF-8 since we only expect ASCII strings and
|
||||
// this simplifies the rest of the code in this file.
|
||||
void GetSupportedCodecsForPepperCdm(
|
||||
const std::vector<base::string16>& additional_param_names,
|
||||
const std::vector<base::string16>& additional_param_values,
|
||||
std::vector<std::string>* codecs) {
|
||||
DCHECK(codecs->empty());
|
||||
DCHECK_EQ(additional_param_names.size(), additional_param_values.size());
|
||||
for (size_t i = 0; i < additional_param_names.size(); ++i) {
|
||||
if (additional_param_names[i] ==
|
||||
base::ASCIIToUTF16(kCdmSupportedCodecsParamName)) {
|
||||
const base::string16& codecs_string16 = additional_param_values[i];
|
||||
std::string codecs_string;
|
||||
if (!base::UTF16ToUTF8(codecs_string16.c_str(), codecs_string16.length(),
|
||||
&codecs_string)) {
|
||||
DLOG(WARNING) << "Non-UTF-8 codecs string.";
|
||||
// Continue using the best effort conversion.
|
||||
}
|
||||
*codecs = base::SplitString(
|
||||
codecs_string, std::string(1, kCdmSupportedCodecsValueDelimiter),
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AddPepperBasedWidevine(
|
||||
std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) {
|
||||
#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
|
||||
|
@ -200,18 +164,15 @@ static void AddPepperBasedWidevine(
|
|||
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)) {
|
||||
std::vector<media::VideoCodec> supported_video_codecs;
|
||||
bool supports_persistent_license = false;
|
||||
if (!content::IsKeySystemSupported(kWidevineKeySystem,
|
||||
&supported_video_codecs,
|
||||
&supports_persistent_license)) {
|
||||
DVLOG(1) << "Widevine CDM is not currently available.";
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> codecs;
|
||||
GetSupportedCodecsForPepperCdm(additional_param_names,
|
||||
additional_param_values, &codecs);
|
||||
|
||||
SupportedCodecs supported_codecs = media::EME_CODEC_NONE;
|
||||
|
||||
// Audio codecs are always supported.
|
||||
|
@ -223,17 +184,25 @@ static void AddPepperBasedWidevine(
|
|||
supported_codecs |= media::EME_CODEC_MP4_AAC;
|
||||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
|
||||
for (size_t i = 0; i < codecs.size(); ++i) {
|
||||
if (codecs[i] == kCdmSupportedCodecVp8)
|
||||
// Video codecs are determined by what was registered for the CDM.
|
||||
for (const auto& codec : supported_video_codecs) {
|
||||
switch (codec) {
|
||||
case media::VideoCodec::kCodecVP8:
|
||||
supported_codecs |= media::EME_CODEC_WEBM_VP8;
|
||||
if (codecs[i] == kCdmSupportedCodecVp9) {
|
||||
break;
|
||||
case media::VideoCodec::kCodecVP9:
|
||||
supported_codecs |= media::EME_CODEC_WEBM_VP9;
|
||||
supported_codecs |= media::EME_CODEC_COMMON_VP9;
|
||||
}
|
||||
break;
|
||||
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
if (codecs[i] == kCdmSupportedCodecAvc1)
|
||||
case media::VideoCodec::kCodecH264:
|
||||
supported_codecs |= media::EME_CODEC_MP4_AVC1;
|
||||
break;
|
||||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
default:
|
||||
DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
using Robustness = cdm::WidevineKeySystemProperties::Robustness;
|
||||
|
|
|
@ -607,8 +607,6 @@
|
|||
'chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h',
|
||||
'chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc',
|
||||
'chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h',
|
||||
'chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.cc',
|
||||
'chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h',
|
||||
'chromium_src/chrome/browser/speech/tts_controller.h',
|
||||
'chromium_src/chrome/browser/speech/tts_controller_impl.cc',
|
||||
'chromium_src/chrome/browser/speech/tts_controller_impl.h',
|
||||
|
@ -642,7 +640,6 @@
|
|||
'chromium_src/chrome/common/tts_messages.h',
|
||||
'chromium_src/chrome/common/tts_utterance_request.cc',
|
||||
'chromium_src/chrome/common/tts_utterance_request.h',
|
||||
'chromium_src/chrome/common/widevine_cdm_messages.h',
|
||||
'chromium_src/chrome/common/widevine_cdm_constants.cc',
|
||||
'chromium_src/chrome/common/widevine_cdm_constants.h',
|
||||
'chromium_src/chrome/renderer/media/chrome_key_systems.cc',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue