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

fix: Support browsers with clear MCap but no encrypted MCap #18

Merged
merged 4 commits into from
Apr 19, 2021

Conversation

michellezhuogg
Copy link
Contributor

Check if native mediaCapabilities.decodingInfo result has the keySystemAccess property for encrypted content. If not, we should patch that.

Copy link
Member

@joeyparrish joeyparrish left a 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
Comment on lines 314 to 324
if (!mediaKeySystemAccess) {
const mediaKeySystemConfig =
McEncryptionSchemePolyfill.convertToMediaKeySystemConfig_(
requestedConfiguration);
capabilities.keySystemAccess =
await navigator.requestMediaKeySystemAccess(
requestedConfiguration.keySystemConfiguration.keySystem,
[mediaKeySystemConfig]);
return capabilities;
}

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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;
Copy link
Member

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],
Copy link
Member

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.

@joeyparrish joeyparrish changed the title fix: Fix decodingInfo polyfill fix: Support browsers with clear MCap but no encrypted MCap Apr 19, 2021
@joeyparrish joeyparrish added the type: bug Something isn't working correctly label Apr 19, 2021
index.js Outdated
contentType: decodingConfig.video.contentType,
};
videoCapabilities.push(capability);
}

const mediaCapInitDataType = mediaCapKeySystemConfig.initDataType;
const initDataTypes = mediaCapInitDataType && mediaCapInitDataType.length :
Copy link
Member

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.

@joeyparrish joeyparrish merged commit 7191c50 into shaka-project:master Apr 19, 2021
@michellezhuogg michellezhuogg deleted the fixDecodingInfo branch April 26, 2021 23:54
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants