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: mediaCapabilitiesProber check generateRequest like the RxPlayer DRM selection algorithm #1575

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions src/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import { canRelyOnRequestMediaKeySystemAccess } from "../../../../compat/can_rely_on_request_media_key_system_access";
import eme from "../../../../compat/eme";
import {
DUMMY_PLAY_READY_HEADER,
generatePlayReadyInitData,
} from "../../../../compat/generate_init_data";
import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
import log from "../log";
import type { ICompatibleKeySystem, IMediaConfiguration } from "../types";
Expand Down Expand Up @@ -57,13 +62,37 @@ export default function probeDRMInfos(

return eme
.requestMediaKeySystemAccess(type, [configuration])
.then((keySystemAccess) => {
result.compatibleConfiguration = keySystemAccess.getConfiguration();
const status: [ProberStatus, ICompatibleKeySystem?] = [
ProberStatus.Supported,
result,
];
return status;
.then(async (keySystemAccess) => {
if (!canRelyOnRequestMediaKeySystemAccess(type)) {
try {
const mediaKeys = await keySystemAccess.createMediaKeys();
const session = mediaKeys.createSession();
const initData = generatePlayReadyInitData(DUMMY_PLAY_READY_HEADER);
await session.generateRequest("cenc", initData);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we close the session? Is is supposed to be GCed because the MediaKeys is not refered to anymore?

Maybe a call to close would be safer no?

result.compatibleConfiguration = keySystemAccess.getConfiguration();
const status: [ProberStatus, ICompatibleKeySystem?] = [
ProberStatus.Supported,
result,
];
return status;
} catch (err) {
log.debug("DRM: KeySystemAccess was granted but it is not usable");

const statusError: [ProberStatus, ICompatibleKeySystem] = [
ProberStatus.NotSupported,
result,
];
return statusError;
}
} else {
result.compatibleConfiguration = keySystemAccess.getConfiguration();

const status: [ProberStatus, ICompatibleKeySystem?] = [
ProberStatus.Supported,
result,
];
return status;
}
})
.catch(() => {
return [ProberStatus.NotSupported, result];
Expand Down
Loading