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
Implementation of Cef.RegisterWidevineCdm #1935
Changes from 5 commits
4f7ea22
442f311
eb2459e
aa7de2e
c554b76
9cb80e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
#include "Internals/PluginVisitor.h" | ||
#include "Internals/CefTaskScheduler.h" | ||
#include "Internals/CefGetGeolocationCallbackWrapper.h" | ||
#include "Internals/CefRegisterCdmCallbackAdapter.h" | ||
#include "CookieManager.h" | ||
#include "CefSettings.h" | ||
#include "RequestContext.h" | ||
|
@@ -461,7 +462,7 @@ namespace CefSharp | |
static void UnregisterInternalWebPlugin(String^ path) | ||
{ | ||
CefUnregisterInternalWebPlugin(StringUtils::ToNative(path)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Call during process startup to enable High-DPI support on Windows 7 or newer. | ||
|
@@ -607,5 +608,67 @@ namespace CefSharp | |
{ | ||
CefSetCrashKeyValue(StringUtils::ToNative(key), StringUtils::ToNative(value)); | ||
} | ||
|
||
/// <summary> | ||
/// Register the Widevine CDM plugin. | ||
/// | ||
/// The client application is responsible for downloading an appropriate | ||
/// platform-specific CDM binary distribution from Google, extracting the | ||
/// contents, and building the required directory structure on the local machine. | ||
/// The CefBrowserHost::StartDownload method and CefZipArchive class can be used | ||
/// to implement this functionality in CEF. Contact Google via | ||
/// https://www.widevine.com/contact.html for details on CDM download. | ||
/// | ||
/// | ||
/// |path| is a directory that must contain the following files: | ||
/// 1. manifest.json file from the CDM binary distribution (see below). | ||
/// 2. widevinecdm file from the CDM binary distribution (e.g. | ||
/// widevinecdm.dll on Windows, libwidevinecdm.dylib on OS X, | ||
/// libwidevinecdm.so on Linux). | ||
/// 3. widevidecdmadapter file from the CEF binary distribution (e.g. | ||
/// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X, | ||
/// libwidevinecdmadapter.so on Linux). | ||
/// | ||
/// If any of these files are missing or if the manifest file has incorrect | ||
/// contents the registration will fail and |callback| will receive a |result| | ||
/// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS. | ||
/// | ||
/// The manifest.json file must contain the following keys: | ||
/// A. "os": Supported OS (e.g. "mac", "win" or "linux"). | ||
/// B. "arch": Supported architecture (e.g. "ia32" or "x64"). | ||
/// C. "x-cdm-module-versions": Module API version (e.g. "4"). | ||
/// D. "x-cdm-interface-versions": Interface API version (e.g. "8"). | ||
/// E. "x-cdm-host-versions": Host API version (e.g. "8"). | ||
/// F. "version": CDM version (e.g. "1.4.8.903"). | ||
/// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1"). | ||
/// | ||
/// A through E are used to verify compatibility with the current Chromium | ||
/// version. If the CDM is not compatible the registration will fail and | ||
/// |callback| will receive a |result| value of | ||
/// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE. | ||
/// | ||
/// |callback| will be executed asynchronously once registration is complete. | ||
/// | ||
/// On Linux this function must be called before CefInitialize() and the | ||
/// registration cannot be changed during runtime. If registration is not | ||
/// supported at the time that CefRegisterWidevineCdm() is called then |callback| | ||
/// will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED. | ||
/// </summary> | ||
static void RegisterWidevineCdm(String^ path, IRegisterCdmCallback^ callback) | ||
{ | ||
auto adapter = new CefRegisterCdmCallbackAdapter(callback); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no point creating a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean pass nullptr into CefRegisterWidevineCdm when there is no callback provided? (tested and yep that doesn't cause any issues with the CEF API - at this time anyway). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
CefRegisterWidevineCdm(StringUtils::ToNative(path), adapter); | ||
} | ||
|
||
/// <summary> | ||
/// Register the Widevine CDM plugin. | ||
/// | ||
/// See RegisterWidevineCdm(String, IRegisterCdmCallback) for more details. | ||
/// </summary> | ||
static void RegisterWidevineCdm(String^ path) | ||
{ | ||
RegisterWidevineCdm(path, nullptr); | ||
} | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright � 2010-2016 The CefSharp Authors. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
#pragma once | ||
|
||
#include "Stdafx.h" | ||
#include "CefWrapper.h" | ||
|
||
namespace CefSharp | ||
{ | ||
namespace Internals | ||
{ | ||
private class CefRegisterCdmCallbackAdapter : public CefRegisterCdmCallback | ||
{ | ||
private: | ||
gcroot<IRegisterCdmCallback^> _callback; | ||
|
||
public: | ||
CefRegisterCdmCallbackAdapter(IRegisterCdmCallback^ callback) | ||
{ | ||
_callback = callback; | ||
} | ||
|
||
~CefRegisterCdmCallbackAdapter() | ||
{ | ||
if (static_cast<IRegisterCdmCallback^>(_callback) != nullptr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can call |
||
delete _callback; | ||
_callback = nullptr; | ||
} | ||
|
||
/// <summary> | ||
/// Method that will be called when CDM registration is complete. |result| | ||
/// will be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed | ||
/// successfully. Otherwise, |result| and |error_message| will contain | ||
/// additional information about why registration failed. | ||
/// </summary> | ||
virtual void OnCdmRegistrationComplete(cef_cdm_registration_error_t result, | ||
const CefString& error_message) OVERRIDE | ||
{ | ||
auto r = gcnew CdmRegistration(); | ||
|
||
r->ErrorCode = (CdmRegistrationErrorCode)result; | ||
r->ErrorMessage = StringUtils::ToClr(error_message); | ||
|
||
if (static_cast<IRegisterCdmCallback^>(_callback) != nullptr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to only create an instance if there is a callback and remove this check. |
||
_callback->OnRegistrationComplete(r); | ||
} | ||
|
||
IMPLEMENT_REFCOUNTING(CefRegisterCdmCallbackAdapter) | ||
}; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
| ||
<html> | ||
<head> | ||
<script language="JavaScript"> | ||
function probeSupport() { | ||
var tests = []; | ||
var testKeySystems = [ | ||
'com.widevine.alpha', | ||
'org.w3.clearkey' | ||
]; | ||
|
||
var testCodecs = [ | ||
{ type: 'H.264', contentType: 'video/mp4; codecs="avc1.42E01E"' }, | ||
{ type: 'H.264/MPEG-4 AVC', contentType: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' }, | ||
{ type: 'ogg', contentType: 'video/ogg; codecs="theora"' }, | ||
{ type: 'webm-vp8', contentType: 'video/webm; codecs="vp8"' }, | ||
{ type: 'webm-vp9-', contentType: 'video/webm; codecs="vp9"' } | ||
]; | ||
|
||
var basicVideoCapabilities = [ | ||
{ contentType: 'video/mp4; codecs="avc1.42E01E"' }, | ||
{ contentType: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' }, | ||
{ contentType: 'video/webm; codecs="vp8"' }, | ||
{ contentType: 'video/webm; codecs="vp9"' } | ||
]; | ||
|
||
var basicConfig = { | ||
videoCapabilities: basicVideoCapabilities | ||
}; | ||
var configs = [basicConfig]; | ||
var support = { contentDecryptionModules: {}, playbackSupport: {} }; | ||
|
||
testKeySystems.forEach(function (keySystem) { | ||
var p = navigator.requestMediaKeySystemAccess(keySystem, configs) | ||
.then(function (access) { | ||
var config = access.getConfiguration(); | ||
support.contentDecryptionModules[keySystem] = "AVAILABLE"; | ||
}, function () { | ||
support.contentDecryptionModules[keySystem] = "NOT AVAILABLE"; | ||
}); | ||
tests.push(p); | ||
}); | ||
|
||
return Promise.all(tests).then(function () { | ||
var testEl = document.createElement("video"), | ||
mpeg4, h264, ogg, webm; | ||
testCodecs.forEach(function (testCodec) { | ||
var canPlay = testEl.canPlayType(testCodec.contentType); | ||
canPlay = canPlay !== "" ? canPlay : "no"; | ||
support.playbackSupport[testCodec.type] = { "contentType": testCodec.contentType, "supported": canPlay }; | ||
}); | ||
return support; | ||
}); | ||
} | ||
|
||
function printSupport(support) { | ||
var output = document.getElementById('output'); | ||
output.textContent = support; | ||
} | ||
|
||
function doTest() { | ||
probeSupport().then(function (support) { | ||
printSupport(JSON.stringify(support, null, ' ')); | ||
}); | ||
} | ||
</script> | ||
</head> | ||
<body onload="doTest()"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be some sort of disclaimer here that explains What happens if you open this page with a default build? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Widevine not registered and not using proprietary codecs just says that widevine is "NOT AVAILABLE", and some of the codecs are listed as not supporting playback. I'll add a note at the end of the page re proprietary codecs and contacting Widevine for access to widevine - and a link to the issue #1934. |
||
<pre id="output"></pre> | ||
<p> | ||
<a href="https://shaka-player-demo.appspot.com/demo/">Google Shaka Player demo - video play back</a> | ||
</p> | ||
<p> | ||
<strong>Note:</strong><br /> | ||
<ul> | ||
<li> | ||
Support for Widevine CDM requires additional steps as | ||
<a href="https://github.com/cefsharp/CefSharp/issues/1934">outlined here</a>. | ||
</li> | ||
<li> | ||
Use of proprietary codecs (such as H.264) requires a custom build of CEF to be used due to | ||
licensing requirements.<br /> | ||
Details on how to build the CEF project and other resources can be | ||
<a href="https://bitbucket.org/chromiumembedded/cef">found here</a>.</li> | ||
</ul> | ||
</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
using System; | ||
|
||
namespace CefSharp | ||
{ | ||
/// <summary> | ||
/// Represents the response to an attempt to register the Widevine Content Decryption Module (CDM) | ||
/// </summary> | ||
public class CdmRegistration | ||
{ | ||
/// <summary> | ||
/// If CDM registration succeeded then value will be <see cref="CdmRegistrationErrorCode.None"/>, for other values see the enumeration <see cref="CdmRegistrationErrorCode" />. | ||
/// </summary> | ||
public CdmRegistrationErrorCode ErrorCode { get; set; } | ||
|
||
/// <summary> | ||
/// Contains an error message containing additional information if <see cref="ErrorCode"/> is not <see cref="CdmRegistrationErrorCode.None"/>. | ||
/// </summary> | ||
public string ErrorMessage { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
using System; | ||
|
||
namespace CefSharp | ||
{ | ||
/// <summary> | ||
/// Lists the errors that can be reported during Widevine Content Decryption Module (CDM) registration. | ||
/// </summary> | ||
public enum CdmRegistrationErrorCode | ||
{ | ||
/// <summary> | ||
/// No error. Registration completed successfully. | ||
/// </summary> | ||
None, | ||
|
||
/// <summary> | ||
/// Required files or manifest contents are missing. | ||
/// </summary> | ||
IncorrectContents, | ||
|
||
/// <summary> | ||
/// The CDM is incompatible with the current Chromium version. | ||
/// </summary> | ||
Incompatible, | ||
|
||
/// <summary> | ||
/// CDM registration is not supported at this time. | ||
/// </summary> | ||
NotSupported, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments should be updated to make relevant in context of
CefSharp
.