From a1557a9663673c3827702bece4d9251dfbc4b981 Mon Sep 17 00:00:00 2001 From: Ivan Kryak Date: Tue, 20 Aug 2024 18:36:25 +0500 Subject: [PATCH 1/2] fix: build errors and warnings --- .../video-container/Video-container.component.ts | 4 ++-- src/helpers/drm.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/video-container/Video-container.component.ts b/src/components/video-container/Video-container.component.ts index 983ca40..80dda8d 100644 --- a/src/components/video-container/Video-container.component.ts +++ b/src/components/video-container/Video-container.component.ts @@ -273,10 +273,10 @@ export class VideoContainer extends LitElement { serverCertificateUrl: this.drmOptions[KeySystems.fps].certificateUrl, }, 'com.widevine.alpha': { - licenseUrl: this.drmOptions[KeySystems.widevine] + licenseUrl: this.drmOptions[KeySystems.widevine].licenseUrl }, 'com.microsoft.playready': { - licenseUrl: this.drmOptions[KeySystems.playready] + licenseUrl: this.drmOptions[KeySystems.playready].licenseUrl } } : {} }); diff --git a/src/helpers/drm.ts b/src/helpers/drm.ts index a88992b..2728f28 100644 --- a/src/helpers/drm.ts +++ b/src/helpers/drm.ts @@ -1,4 +1,4 @@ -import { MuxParams, DRMSystemConfiguration } from "../types"; +import { DRMSystemConfiguration } from "../types"; export const initFairPlayDRM = async (element: HTMLElement, fairPlayOptions: DRMSystemConfiguration) => { const certificateUrl = fairPlayOptions.certificateUrl; @@ -14,11 +14,11 @@ const loadFairPlayCertificate = async (certificateUrl: string) => { return response.arrayBuffer(); } -const fairplayEncryptedCallback = (fairPlayCertificate, licenseServerUrl) => { - return async (event) => { +const fairplayEncryptedCallback = (fairPlayCertificate: ArrayBuffer, licenseServerUrl: string) => { + return async (event: MediaEncryptedEvent) => { console.log("fairplayEncrypted callback", event); - const video = event.target; + const video = event.target as HTMLVideoElement; const initDataType = event.initDataType; if (!video.mediaKeys) { @@ -38,7 +38,7 @@ const fairplayEncryptedCallback = (fairPlayCertificate, licenseServerUrl) => { let session = video.mediaKeys.createSession(); session.generateRequest(initDataType, initData); - let message = await new Promise(resolve => { + let message = await new Promise(resolve => { session.addEventListener('message', resolve, { once: true }); }); @@ -48,8 +48,8 @@ const fairplayEncryptedCallback = (fairPlayCertificate, licenseServerUrl) => { } } -const getLicenseResponse = async (event, licenseServerUrl) => { - let spc_string = btoa(String.fromCharCode(...new Uint8Array(event.message))); +const getLicenseResponse = async (event: MediaKeySessionEventMap["message"], licenseServerUrl: string) => { + // let spc_string = btoa(String.fromCharCode(...new Uint8Array(event.message))); let licenseResponse = await fetch(licenseServerUrl, { method: 'POST', headers: new Headers({'Content-type': 'application/json', 'X-AxDRM-Message': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiNjllNTQwODgtZTllMC00NTMwLThjMWEtMWViNmRjZDBkMTRlIiwibWVzc2FnZSI6eyJ2ZXJzaW9uIjoyLCJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImxpY2Vuc2UiOnsiYWxsb3dfcGVyc2lzdGVuY2UiOnRydWV9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiIyMTFhYzFkYy1jOGEyLTQ1NzUtYmFmNy1mYTRiYTU2YzM4YWMiLCJ1c2FnZV9wb2xpY3kiOiJUaGVPbmVQb2xpY3kifV19LCJjb250ZW50X2tleV91c2FnZV9wb2xpY2llcyI6W3sibmFtZSI6IlRoZU9uZVBvbGljeSIsInBsYXlyZWFkeSI6eyJwbGF5X2VuYWJsZXJzIjpbIjc4NjYyN0Q4LUMyQTYtNDRCRS04Rjg4LTA4QUUyNTVCMDFBNyJdfX1dfX0.D9FM9sbTFxBmcCOC8yMHrEtTwm0zy6ejZUCrlJbHz_U'}), From 91469be2cf08a504cd3da7fdfc1458a353771354 Mon Sep 17 00:00:00 2001 From: Ivan Kryak Date: Thu, 22 Aug 2024 18:56:03 +0500 Subject: [PATCH 2/2] chore(drm): update licence request to conform Mux API --- src/helpers/drm.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/helpers/drm.ts b/src/helpers/drm.ts index 2728f28..5b4c041 100644 --- a/src/helpers/drm.ts +++ b/src/helpers/drm.ts @@ -16,8 +16,6 @@ const loadFairPlayCertificate = async (certificateUrl: string) => { const fairplayEncryptedCallback = (fairPlayCertificate: ArrayBuffer, licenseServerUrl: string) => { return async (event: MediaEncryptedEvent) => { - console.log("fairplayEncrypted callback", event); - const video = event.target as HTMLVideoElement; const initDataType = event.initDataType; @@ -49,14 +47,10 @@ const fairplayEncryptedCallback = (fairPlayCertificate: ArrayBuffer, licenseServ } const getLicenseResponse = async (event: MediaKeySessionEventMap["message"], licenseServerUrl: string) => { - // let spc_string = btoa(String.fromCharCode(...new Uint8Array(event.message))); let licenseResponse = await fetch(licenseServerUrl, { method: 'POST', - headers: new Headers({'Content-type': 'application/json', 'X-AxDRM-Message': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiNjllNTQwODgtZTllMC00NTMwLThjMWEtMWViNmRjZDBkMTRlIiwibWVzc2FnZSI6eyJ2ZXJzaW9uIjoyLCJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImxpY2Vuc2UiOnsiYWxsb3dfcGVyc2lzdGVuY2UiOnRydWV9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiIyMTFhYzFkYy1jOGEyLTQ1NzUtYmFmNy1mYTRiYTU2YzM4YWMiLCJ1c2FnZV9wb2xpY3kiOiJUaGVPbmVQb2xpY3kifV19LCJjb250ZW50X2tleV91c2FnZV9wb2xpY2llcyI6W3sibmFtZSI6IlRoZU9uZVBvbGljeSIsInBsYXlyZWFkeSI6eyJwbGF5X2VuYWJsZXJzIjpbIjc4NjYyN0Q4LUMyQTYtNDRCRS04Rjg4LTA4QUUyNTVCMDFBNyJdfX1dfX0.D9FM9sbTFxBmcCOC8yMHrEtTwm0zy6ejZUCrlJbHz_U'}), + headers: new Headers({'Content-type': 'application/octet-stream'}), body: event.message, - // body: JSON.stringify({ - // "spc" : spc_string - // }), }); return licenseResponse.arrayBuffer(); }