-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: patch
setServerCertificate()
on older Tizens & webOS (#6696)
We've tried to enable setting server certificates to optimize playback start, but turned out that with our widevine certificate shaka was throwing 6004 error. The issue is not reproducible starting from Tizen 5.5. The same certificate was working properly also on Chrome.
- Loading branch information
1 parent
737fac7
commit 0c76912
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*! @license | ||
* Shaka Player | ||
* Copyright 2016 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
goog.provide('shaka.polyfill.PatchedMediaKeysCert'); | ||
|
||
goog.require('shaka.log'); | ||
goog.require('shaka.polyfill'); | ||
goog.require('shaka.util.Platform'); | ||
|
||
|
||
/** | ||
* @summary A polyfill to fix setServerCertificate implementation on | ||
* older platforms which claim to support modern EME. | ||
* @export | ||
*/ | ||
shaka.polyfill.PatchedMediaKeysCert = class { | ||
/** | ||
* Installs the polyfill if needed. | ||
* @export | ||
*/ | ||
static install() { | ||
if (!window.MediaKeys) { | ||
// No MediaKeys available | ||
return; | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
if (MediaKeys.prototype.setServerCertificate && | ||
!shaka.polyfill.PatchedMediaKeysCert.hasInvalidImplementation_()) { | ||
// setServerCertificate is there and userAgent seems to be valid. | ||
return; | ||
} | ||
|
||
shaka.log.info('Patching MediaKeys.setServerCertificate'); | ||
// eslint-disable-next-line no-restricted-syntax | ||
MediaKeys.prototype.setServerCertificate = | ||
shaka.polyfill.PatchedMediaKeysCert.setServerCertificate_; | ||
} | ||
|
||
/** | ||
* @param {!BufferSource} certificate | ||
* @return {!Promise<boolean>} | ||
* @private | ||
*/ | ||
static setServerCertificate_(certificate) { | ||
shaka.log.debug('PatchedMediaKeysCert.setServerCertificate'); | ||
return Promise.resolve(false); | ||
} | ||
|
||
/** | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
static hasInvalidImplementation_() { | ||
return shaka.util.Platform.isTizen3() || shaka.util.Platform.isTizen4() || | ||
shaka.util.Platform.isTizen5_0() || shaka.util.Platform.isWebOS3(); | ||
} | ||
}; | ||
|
||
shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysCert.install); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters