-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: Support browsers with clear MCap but no encrypted MCap #18
fix: Support browsers with clear MCap but no encrypted MCap #18
Conversation
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.
Looks good otherwise. Thanks for fixing this!
index.js
Outdated
if (!mediaKeySystemAccess) { | ||
const mediaKeySystemConfig = | ||
McEncryptionSchemePolyfill.convertToMediaKeySystemConfig_( | ||
requestedConfiguration); | ||
capabilities.keySystemAccess = | ||
await navigator.requestMediaKeySystemAccess( | ||
requestedConfiguration.keySystemConfiguration.keySystem, | ||
[mediaKeySystemConfig]); | ||
return capabilities; | ||
} | ||
|
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.
Since this is taken care of in polyfillDecodingInfo_, you don't need to it here. We chain to the polyfill immediately below this point.
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.
We'll call the native decodingInfo again in polyfillDecodingInfo_. Would it be better if we use the result of the first call directly?
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.
Not significantly, I would guess. This will only happen once. We will patch over it with the polyfill version, and the probe version will not be called again.
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.
The Player actually calls probeDecodingInfo() a few times before we settle on polyfillDecodingInfo_(), since the Player call decodingInfo in parallel and that's is async. I'll improve that in the future if we see the latency as an issue.
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.
Ah, you make a good point.
index.js
Outdated
* @return {!MediaKeySystemConfiguration} | ||
*/ | ||
static convertToMediaKeySystemConfig_(decodingConfig) { | ||
const mediaCapkeySystemConfig = decodingConfig.keySystemConfiguration; |
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.
For camelCase, this should be mediaCapKeySystemConfig (capital K on Key).
index.js
Outdated
|
||
/** @type {!MediaKeySystemConfiguration} */ | ||
const mediaKeySystemConfig = { | ||
initDataTypes: [mediaCapkeySystemConfig.initDataType], |
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.
This is allowed to be an empty list in EME, and it's allowed to be undefined in MCap.
In native MCap, it defaults to an empty string if it's undefined, but neither undefined nor the empty string are allowed as array members in EME.
index.js
Outdated
contentType: decodingConfig.video.contentType, | ||
}; | ||
videoCapabilities.push(capability); | ||
} | ||
|
||
const mediaCapInitDataType = mediaCapKeySystemConfig.initDataType; | ||
const initDataTypes = mediaCapInitDataType && mediaCapInitDataType.length : |
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.
Just a boolean check should suffice. If it's a non-empty string, it will be truthy.
Check if native
mediaCapabilities.decodingInfo
result has thekeySystemAccess
property for encrypted content. If not, we should patch that.