Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Widevine CDM #1631

Closed
magreenblatt opened this issue May 13, 2015 · 30 comments
Closed

Add support for Widevine CDM #1631

magreenblatt opened this issue May 13, 2015 · 30 comments
Labels
enhancement Enhancement request

Comments

@magreenblatt
Copy link
Collaborator

Original report by me.


Widevine in a DRM system developed by Google and used by companies like YouTube and Netflix to protect HTML5 video. The binary component used by Chromium, called the Widevine CDM, is a Pepper plugin that is downloaded on Windows and OS X via the Chrome component updater [1] (download on Linux is not yet supported, see WIDEVINE_CDM_IS_COMPONENT usage). Automated download of the binary from Google is allowed but bundling of the Widevine CDM with third-party applications requires a license.

To add support for Widevine CDM in CEF the following changes will be required:

  1. Add a dependency on /third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h and /components/components.gyp:cdm_renderer (cdm_browser is Android-only currently).
  2. Download the binaries [2] from Google, possibly using the component updater (see chrome/browser/component_updater/widevine_cdm_component_installer.cc, RegisterComponentsForUpdate in chrome/browser/chrome_browser_main.cc).
  3. Register the Pepper plugin.
  4. Implement ContentRendererClient::AddKeySystems (see AddChromeKeySystems in chrome/renderer/media/chrome_key_systems.cc).
  5. Additional logic related to content settings may also be required (see ShouldUseJavaScriptSettingForPlugin usage in chrome/renderer/chrome_content_renderer_client.cc and chrome/browser/plugins/plugin_info_message_filter.cc).

Related variables include:

  • enable_pepper_cdms (GYP, on by default in common.gypi)
  • WIDEVINE_CDM_AVAILABLE (defined in third_party/widevine/cdm/stub/widevine_cdm_version.h)
  • WIDEVINE_CDM_IS_COMPONENT (defined in third_party/widevine/cdm/widevine_cdm_common.h, currently Windows and OS X only)

[1] https://chromium.googlesource.com/chromium/chromium/+/trunk/chrome/browser/component_updater

[2] libwidevinecdm.dylib, widevinecdm.dll, libwidevinecdm.so, widevinecdmadapter.plugin, widevinecdmadapter.dll, libwidevinecdmadapter.so

@magreenblatt
Copy link
Collaborator Author

Original comment by Yu-Teh Shen (Bitbucket: shenyute, GitHub: shenyute).


Can I just copy the binaries from release chrome. And the library binary should packaged with cef?

Ex:
linux -> /opt/google/chrome/libwidevinecdmadapter.so /opt/google/chrome/libwidevinecdm.so

@magreenblatt
Copy link
Collaborator Author

@shenyute : You can't distribute the Widevine binaries yourself without a license.

@magreenblatt
Copy link
Collaborator Author

Original comment by Yu-Teh Shen (Bitbucket: shenyute, GitHub: shenyute).


@magreenblatt : so this issue just make the ground work, and let the user to download licensed binary by themselves?

@magreenblatt
Copy link
Collaborator Author

Original comment by Kevin Barresi (Bitbucket: kbarresi, GitHub: kbarresi).


@magreenblatt Just to clarify: with these binaries, CEF would support Netflix/Hulu out of the box? Or would we need to package up H.264 codecs as well?

@magreenblatt
Copy link
Collaborator Author

@kbarresi : I'm not sure what codecs Netflix/Hulu use. If they use H.264 then you would need to build with H.264 codec support. Note that distributing CEF with H.264 support may involve licensing costs.

@magreenblatt
Copy link
Collaborator Author

Attached is a patch contributed by Dan Berger that adds Widevine CDM support in 2454 branch. Component download is currently only supported on Windows and OS X so those are the only platforms tested/supported with this patch.

@magreenblatt
Copy link
Collaborator Author

  • set attachment to "widevine.patch"

@magreenblatt
Copy link
Collaborator Author

The above patch will fail with the following error when running cefclient/cefsimple from the Chromium build output directory:

"Uncaught (in promise) InvalidAccessError: Operation not supported by stub CDM."

To fix this error you need to remove widevinecdm.dll from the out\[Debug|Release] directory -- this will force Chromium to use the correct version downloaded to <profile>\AppData\Local\CEF\User Data\WidevineCDM\ by the component updater.

@magreenblatt
Copy link
Collaborator Author

Added in master revision 3640f81 (bb) and 2454 branch revision b977814 (bb).

Tested to work with netflix.com as follows:

1. Build CEF/Chromium with support for proprietary codecs.

set GYP_DEFINES=proprietary_codecs=1 ffmpeg_branding=Chrome

2. Run cefclient with CDM support and cache path.

Windows:

cefclient.exe --enable-widevine-cdm --cache-path=c:\temp\cache

OS X:

open cefclient.app --args --enable-widevine-cdm --cache-path=/Users/marshall/temp/cache

Linux:

cefclient --widevine-cdm-path=/opt/google/stable --widevine-cdm-version=1.4.8.824 --cache-path=/home/marshall/temp/cache

Delivery of CDM binaries via the component upgrade mechanism is version dependent. You must be using a Chromium version within 2 milestones of the current Chromium stable branch. For example, if you are running CEF based on Chromium 44, then the CDM will still support 43 and 42. Once 45 hits stable, support for 42 would be considered deprecated.

@magreenblatt
Copy link
Collaborator Author

  • changed state from "new" to "resolved"

@magreenblatt
Copy link
Collaborator Author

Original comment by amaitland (Bitbucket: amaitland, GitHub: amaitland).


Building a 64bit version of 2454 branch results in the following warning treated as error.

d:\projects\cef\source\chromium\src\media\cdm\stub\stub_cdm.cc(65) : error C2220
: warning treated as error - no 'object' file generated
d:\projects\cef\source\chromium\src\media\cdm\stub\stub_cdm.cc(65) : warning C42
67: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data
d:\projects\cef\source\chromium\src\media\cdm\stub\stub_cdm.cc(67) : warning C42
67: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data
d:\projects\cef\source\chromium\src\media\cdm\stub\stub_cdm.cc(159) : warning C4
267: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data

Suggestions? Let me know if more information is required.

@magreenblatt
Copy link
Collaborator Author

@amaitland : Filed as http://crbug.com/528975

@magreenblatt
Copy link
Collaborator Author

Original comment by amaitland (Bitbucket: amaitland, GitHub: amaitland).


Great thanks! Short term is it worth creating a patch?

@magreenblatt
Copy link
Collaborator Author

@amaitland : Yes, we should patch it. Can you provide a patch that fixes the error for you?

@magreenblatt
Copy link
Collaborator Author

Original comment by amaitland (Bitbucket: amaitland, GitHub: amaitland).


I'll see what I can do, report back soon.

@magreenblatt
Copy link
Collaborator Author

Original comment by amaitland (Bitbucket: amaitland, GitHub: amaitland).


I've created pull request #26 should resolve the issue. Should I create a new issue to link the patch to directly?

@magreenblatt
Copy link
Collaborator Author

@amaitland : Thanks, I'll merge it shortly. No need to create a separate issue.

@magreenblatt
Copy link
Collaborator Author

Original comment by amaitland (Bitbucket: amaitland, GitHub: amaitland).


@magreenblatt Thank you!

@magreenblatt
Copy link
Collaborator Author

Windows 64-bit compile error fixed in master revision 846107b (bb) and 2454 branch revision 71c7271 (bb).

@magreenblatt
Copy link
Collaborator Author

Original comment by Edgardo Gho (Bitbucket: egho, GitHub: egho).


Edited: My bad, I was doing something stupid (got libwidevine.so from an invalid place).

I'm building 2454.85 32bits linux, and I get:
"Uncaught (in promise) InvalidAccessError: Operation not supported by stub CDM."

I've tried placing both libwidevinecdmadapter.so and libwidevinecdm.so from src/out/Release on /opt/google/stable , and also got the ubuntu 32bit chromium deb package version (extracted both files from there).
With both I get the same error.

Any pointers?
Thanks!

@magreenblatt
Copy link
Collaborator Author

Original comment by Luke Pulverenti (Bitbucket: Luke Pulverenti).


Does this change also mean that the browser can handle mp4, aac, mp3, etc, provided we now supply ffmpegsumo?

@magreenblatt
Copy link
Collaborator Author

Does this change also mean that the browser can handle mp4, aac, mp3, etc, provided we now supply ffmpegsumo?

You can build CEF/Chromium with proprietary codec support, however a license is required to legally redistribute those binaries.

@magreenblatt
Copy link
Collaborator Author

Original comment by Nick Kichukov (Bitbucket: nkichukov, GitHub: nkichukov).


I just tried building latest Master branch on Windows 10 ( via the automated GIT method ) by setting GYP_DEFINES=proprietary_codecs=1 ffmpeg_branding=Chrome. All completed successfully and the widevinecdmadapter.dll is in the out\Debug directory. However starting cef with the "cefclient.exe --enable-widevine-cdm --cache-path=c:\temp\cache" does not make DRM work on Netflix or Amazon. Both fails with errors about missing/outdated WiDevine CDM. In addition after this happens the cef process just hangs in TaskManager and never dies when closed.

Is the feature still working or I am missing something during the build/startup ?

@magreenblatt
Copy link
Collaborator Author

@Vissuall : Did you remove widevinecdm.dll from build output directory as described in #1631/add-support-for-widevine-cdm#comment-21379717 ?

@magreenblatt
Copy link
Collaborator Author

Original comment by Nick Kichukov (Bitbucket: nkichukov, GitHub: nkichukov).


Yes I tried this but there is no change. The behavior is the same - amazon ( netlfix too ) gives an error that widevine is not installed or outdated and cefclient hangs and can not be stopped unless manually terminated from TaskManager. By the way the binary cef package behaves the same way.

@magreenblatt
Copy link
Collaborator Author

Original comment by Nick Kichukov (Bitbucket: nkichukov, GitHub: nkichukov).


After some debugging of cef with Visual Studio: IsPepperCdmAvailable -> CefViewHostMsg_IsInternalPluginAvailableForMimeType in cef_key_systems.cc returns false.

@magreenblatt
Copy link
Collaborator Author

Original comment by Nick Kichukov (Bitbucket: nkichukov, GitHub: nkichukov).


@magreenblatt : Some more on this: if I undefine WIDEVINE_CDM_IS_COMPONENT and rebuild and then supply the path and version to WiDevine binaries I can get further. The IsPepperCdmAvailable will return true and all will look like being loaded. Amazon playback will still fail though in a while with a generic error message that something went wrong ( same for Netflix ). So unclear what the issue is this time. Any ideas? The same command line used with chromium will play successfully Amazon HTML5 though with the same WiDevine binaries.

Is this feature really working for someone with latest master on Windows 10?

@magreenblatt
Copy link
Collaborator Author

@Vissuall : I have not tested it on Windows 10. Does it work for you on older Windows versions?

@magreenblatt
Copy link
Collaborator Author

Download via component updater is being removed. See issue #2009 for details.

@magreenblatt
Copy link
Collaborator Author

Download via component updater is being restored. See issue #3149 for details.

filipnavara pushed a commit to emclient/cef that referenced this issue Dec 26, 2023
- Windows/Mac: Use `--enable-widevine-cdm` command-line flag to
  enable download of CDM binaries via the component updater.
- Linux: Use `--widevide-cdm-path` and `--widevine-cdm-version`
  command-line flags to load CDM binaries that already exist on
  the system.
- A cache-path value is usually required when CDM is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement request
Projects
None yet
Development

No branches or pull requests

1 participant