build: [m67] enable widevine support (#14519)
* build: [m67] enable widevine support * fix: remove plugin cache reset hack It was added in (#8907) to make widevine cdm shows up in navigator.plugins, since widevine support is no longer enabled by a plugin it can be removed safely.
This commit is contained in:
parent
ce8e93bad3
commit
f76a8c7b24
7 changed files with 81 additions and 148 deletions
2
BUILD.gn
2
BUILD.gn
|
@ -438,8 +438,6 @@ static_library("electron_lib") {
|
|||
|
||||
if (enable_widevine) {
|
||||
sources += [
|
||||
"//chrome/common/widevine_cdm_constants.cc",
|
||||
"//chrome/common/widevine_cdm_constants.h",
|
||||
"//chrome/renderer/media/chrome_key_systems.cc",
|
||||
"//chrome/renderer/media/chrome_key_systems.h",
|
||||
"//chrome/renderer/media/chrome_key_systems_provider.cc",
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "content/public/common/content_constants.h"
|
||||
#include "content/public/common/pepper_plugin_info.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "media/media_buildflags.h"
|
||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/url_constants.h"
|
||||
|
@ -27,8 +26,6 @@
|
|||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE)
|
||||
#include "base/native_library.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "chrome/common/widevine_cdm_constants.h"
|
||||
#include "content/public/common/cdm_info.h"
|
||||
#include "media/base/video_codecs.h"
|
||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||
|
@ -43,8 +40,7 @@ namespace atom {
|
|||
namespace {
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE)
|
||||
bool IsWidevineAvailable(base::FilePath* adapter_path,
|
||||
base::FilePath* cdm_path,
|
||||
bool IsWidevineAvailable(base::FilePath* cdm_path,
|
||||
std::vector<media::VideoCodec>* codecs_supported) {
|
||||
static enum {
|
||||
NOT_CHECKED,
|
||||
|
@ -52,60 +48,30 @@ bool IsWidevineAvailable(base::FilePath* adapter_path,
|
|||
NOT_FOUND,
|
||||
} widevine_cdm_file_check = NOT_CHECKED;
|
||||
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
*adapter_path = command_line->GetSwitchValuePath(switches::kWidevineCdmPath);
|
||||
if (!adapter_path->empty()) {
|
||||
*cdm_path = adapter_path->DirName().AppendASCII(
|
||||
base::GetNativeLibraryName(kWidevineCdmLibraryName));
|
||||
if (widevine_cdm_file_check == NOT_CHECKED) {
|
||||
widevine_cdm_file_check =
|
||||
(base::PathExists(*adapter_path) && base::PathExists(*cdm_path))
|
||||
? FOUND
|
||||
: NOT_FOUND;
|
||||
if (widevine_cdm_file_check == NOT_CHECKED) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
*cdm_path = command_line->GetSwitchValuePath(switches::kWidevineCdmPath);
|
||||
if (!cdm_path->empty()) {
|
||||
*cdm_path = cdm_path->AppendASCII(
|
||||
base::GetNativeLibraryName(kWidevineCdmLibraryName));
|
||||
widevine_cdm_file_check = base::PathExists(*cdm_path) ? FOUND : NOT_FOUND;
|
||||
}
|
||||
if (widevine_cdm_file_check == FOUND) {
|
||||
// Add the supported codecs as if they came from the component manifest.
|
||||
// This list must match the CDM that is being bundled with Chrome.
|
||||
codecs_supported->push_back(media::VideoCodec::kCodecVP8);
|
||||
codecs_supported->push_back(media::VideoCodec::kCodecVP9);
|
||||
}
|
||||
|
||||
if (widevine_cdm_file_check == FOUND) {
|
||||
// Add the supported codecs as if they came from the component manifest.
|
||||
// This list must match the CDM that is being bundled with Chrome.
|
||||
codecs_supported->push_back(media::VideoCodec::kCodecVP8);
|
||||
codecs_supported->push_back(media::VideoCodec::kCodecVP9);
|
||||
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
codecs_supported->push_back(media::VideoCodec::kCodecH264);
|
||||
codecs_supported->push_back(media::VideoCodec::kCodecH264);
|
||||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddWidevineAdapterFromCommandLine(
|
||||
base::CommandLine* command_line,
|
||||
std::vector<content::PepperPluginInfo>* plugins) {
|
||||
base::FilePath adapter_path;
|
||||
base::FilePath cdm_path;
|
||||
std::vector<media::VideoCodec> video_codecs_supported;
|
||||
if (IsWidevineAvailable(&adapter_path, &cdm_path, &video_codecs_supported)) {
|
||||
auto cdm_version_string =
|
||||
command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion);
|
||||
content::PepperPluginInfo info;
|
||||
info.is_out_of_process = true;
|
||||
info.path = adapter_path;
|
||||
info.name = kWidevineCdmDisplayName;
|
||||
info.description =
|
||||
base::StringPrintf("%s (version: %s)", kWidevineCdmDescription,
|
||||
cdm_version_string.c_str());
|
||||
info.version = cdm_version_string;
|
||||
info.permissions = kWidevineCdmPluginPermissions;
|
||||
|
||||
content::WebPluginMimeType mime_type(kWidevineCdmPluginMimeType,
|
||||
kWidevineCdmPluginExtension,
|
||||
kWidevineCdmPluginMimeTypeDescription);
|
||||
info.mime_types.push_back(mime_type);
|
||||
|
||||
plugins->push_back(info);
|
||||
}
|
||||
}
|
||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||
|
||||
#if defined(ENABLE_PEPPER_FLASH)
|
||||
|
@ -235,9 +201,6 @@ void AtomContentClient::AddPepperPlugins(
|
|||
#if defined(ENABLE_PEPPER_FLASH)
|
||||
AddPepperFlashFromCommandLine(command_line, plugins);
|
||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE)
|
||||
AddWidevineAdapterFromCommandLine(command_line, plugins);
|
||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||
ComputeBuiltInPlugins(plugins);
|
||||
}
|
||||
|
||||
|
@ -246,12 +209,10 @@ void AtomContentClient::AddContentDecryptionModules(
|
|||
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) {
|
||||
if (cdms) {
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE)
|
||||
base::FilePath adapter_path;
|
||||
base::FilePath cdm_path;
|
||||
std::vector<media::VideoCodec> video_codecs_supported;
|
||||
bool supports_persistent_license = false;
|
||||
if (IsWidevineAvailable(&adapter_path, &cdm_path,
|
||||
&video_codecs_supported)) {
|
||||
if (IsWidevineAvailable(&cdm_path, &video_codecs_supported)) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
auto cdm_version_string =
|
||||
command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion);
|
||||
|
|
|
@ -170,9 +170,6 @@ void RendererClientBase::RenderFrameCreated(
|
|||
new ContentSettingsObserver(render_frame);
|
||||
new printing::PrintWebViewHelper(render_frame);
|
||||
|
||||
// This is required for widevine plugin detection provided during runtime.
|
||||
blink::ResetPluginCache();
|
||||
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
// Allow access to file scheme from pdf viewer.
|
||||
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "content/public/renderer/content_renderer_client.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
// In SHARED_INTERMEDIATE_DIR.
|
||||
#include "widevine_cdm_version.h" // NOLINT(build/include)
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE)
|
||||
#include "chrome/renderer/media/chrome_key_systems_provider.h"
|
||||
|
|
|
@ -93,8 +93,8 @@ These individual tutorials expand on topics discussed in the guide above.
|
|||
* [Using asar Archives](tutorial/application-packaging.md#using-asar-archives)
|
||||
* [Limitations](tutorial/application-packaging.md#limitations-of-the-node-api)
|
||||
* [Adding Unpacked Files to asar Archives](tutorial/application-packaging.md#adding-unpacked-files-to-asar-archives)
|
||||
* [In Detail: Testing Widevine CDM](tutorial/testing-widevine-cdm.md)
|
||||
* [In Detail: Using Pepper Flash Plugin](tutorial/using-pepper-flash-plugin.md)
|
||||
* [In Detail: Using Widevine CDM Plugin](tutorial/using-widevine-cdm-plugin.md)
|
||||
* [Offscreen Rendering](tutorial/offscreen-rendering.md)
|
||||
|
||||
---
|
||||
|
|
60
docs/tutorial/testing-widevine-cdm.md
Normal file
60
docs/tutorial/testing-widevine-cdm.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Testing Widevine CDM
|
||||
|
||||
In Electron you can use the Widevine CDM library shipped with Chrome browser.
|
||||
|
||||
## Getting the library
|
||||
|
||||
Open `chrome://components/` in Chrome browser, find `Widevine Content Decryption Module`
|
||||
and make sure it is up to date, then you can find the library files from the
|
||||
application directory.
|
||||
|
||||
### On Windows
|
||||
|
||||
The library file `widevinecdm.dll` will be under
|
||||
`Program Files(x86)/Google/Chrome/Application/CHROME_VERSION/WidevineCdm/_platform_specific/win_(x86|x64)/`
|
||||
directory.
|
||||
|
||||
### On MacOS
|
||||
|
||||
The library file `libwidevinecdm.dylib` will be under
|
||||
`/Applications/Google Chrome.app/Contents/Versions/CHROME_VERSION/Google Chrome Framework.framework/Versions/A/Libraries/WidevineCdm/_platform_specific/mac_(x86|x64)/`
|
||||
directory.
|
||||
|
||||
**Note:** Make sure that chrome version used by Electron is greater than or
|
||||
equal to the `min_chrome_version` value of Chrome's widevine cdm component.
|
||||
The value can be found in `manifest.json` under `WidevineCdm` directory.
|
||||
|
||||
## Using the library
|
||||
|
||||
After getting the library files, you should pass the path to the file
|
||||
with `--widevine-cdm-path` command line switch, and the library's version
|
||||
with `--widevine-cdm-version` switch. The command line switches have to be
|
||||
passed before the `ready` event of `app` module gets emitted.
|
||||
|
||||
Example code:
|
||||
|
||||
```javascript
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
|
||||
// You have to pass the directory that contains widevine library here, it is
|
||||
// * `libwidevinecdm.dylib` on macOS,
|
||||
// * `widevinecdm.dll` on Windows.
|
||||
app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevine_library')
|
||||
// The version of plugin can be got from `chrome://plugins` page in Chrome.
|
||||
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866')
|
||||
|
||||
let win = null
|
||||
app.on('ready', () => {
|
||||
win = new BrowserWindow()
|
||||
win.show()
|
||||
})
|
||||
```
|
||||
|
||||
## Verifying Widevine CDM support
|
||||
|
||||
To verify whether widevine works, you can use following ways:
|
||||
|
||||
* Open https://shaka-player-demo.appspot.com/ and load a manifest that uses
|
||||
`Widevine`.
|
||||
* Open http://www.dash-player.com/demo/drm-test-area/, check whether the page
|
||||
says `bitdash uses Widevine in your browser`, then play the video.
|
|
@ -1,85 +0,0 @@
|
|||
# Using Widevine CDM Plugin
|
||||
|
||||
In Electron you can use the Widevine CDM plugin shipped with Chrome browser.
|
||||
|
||||
## Getting the plugin
|
||||
|
||||
Electron doesn't ship with the Widevine CDM plugin for license reasons, to get
|
||||
it, you need to install the official Chrome browser first, which should match
|
||||
the architecture and Chrome version of the Electron build you use.
|
||||
|
||||
**Note:** The major version of Chrome browser has to be the same with the Chrome
|
||||
version used by Electron, otherwise the plugin will not work even though
|
||||
`navigator.plugins` would show it has been loaded.
|
||||
|
||||
### Windows & macOS
|
||||
|
||||
Open `chrome://components/` in Chrome browser, find `WidevineCdm` and make
|
||||
sure it is up to date, then you can find all the plugin binaries from the
|
||||
`Program Files(x86)/Google/Chrome/Application/VERSION/WidevineCDM/_platform_specific/PLATFORM_ARCH/`
|
||||
directory.
|
||||
|
||||
`APP_DATA` is system's location for storing app data, on Windows it is
|
||||
`%LOCALAPPDATA%`, on macOS it is `~/Library/Application Support`. `VERSION` is
|
||||
Widevine CDM plugin's version string, like `1.4.8.866`. `PLATFORM` is `mac` or
|
||||
`win`. `ARCH` is `x86` or `x64`.
|
||||
|
||||
On Windows the required binaries are `widevinecdm.dll` and
|
||||
`widevinecdmadapter.dll`, on macOS they are `libwidevinecdm.dylib` and
|
||||
`widevinecdmadapter.plugin`. You can copy them to anywhere you like, but they
|
||||
have to be put together.
|
||||
|
||||
### Linux
|
||||
|
||||
On Linux the plugin binaries are shipped together with Chrome browser, you can
|
||||
find them under `/opt/google/chrome`, the filenames are `libwidevinecdm.so` and
|
||||
`libwidevinecdmadapter.so`.
|
||||
|
||||
## Using the plugin
|
||||
|
||||
After getting the plugin files, you should pass the `widevinecdmadapter`'s path
|
||||
to Electron with `--widevine-cdm-path` command line switch, and the plugin's
|
||||
version with `--widevine-cdm-version` switch.
|
||||
|
||||
**Note:** Though only the `widevinecdmadapter` binary is passed to Electron, the
|
||||
`widevinecdm` binary has to be put aside it.
|
||||
|
||||
The command line switches have to be passed before the `ready` event of `app`
|
||||
module gets emitted, and the page that uses this plugin must have plugin
|
||||
enabled.
|
||||
|
||||
Example code:
|
||||
|
||||
```javascript
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
|
||||
// You have to pass the filename of `widevinecdmadapter` here, it is
|
||||
// * `widevinecdmadapter.plugin` on macOS,
|
||||
// * `libwidevinecdmadapter.so` on Linux,
|
||||
// * `widevinecdmadapter.dll` on Windows.
|
||||
app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevinecdmadapter.plugin')
|
||||
// The version of plugin can be got from `chrome://plugins` page in Chrome.
|
||||
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866')
|
||||
|
||||
let win = null
|
||||
app.on('ready', () => {
|
||||
win = new BrowserWindow({
|
||||
webPreferences: {
|
||||
// The `plugins` have to be enabled.
|
||||
plugins: true
|
||||
}
|
||||
})
|
||||
win.show()
|
||||
})
|
||||
```
|
||||
|
||||
## Verifying the plugin
|
||||
|
||||
To verify whether the plugin works, you can use following ways:
|
||||
|
||||
* Open devtools and check whether `navigator.plugins` includes the Widevine
|
||||
CDM plugin.
|
||||
* Open https://shaka-player-demo.appspot.com/ and load a manifest that uses
|
||||
`Widevine`.
|
||||
* Open http://www.dash-player.com/demo/drm-test-area/, check whether the page
|
||||
says `bitdash uses Widevine in your browser`, then play the video.
|
Loading…
Reference in a new issue