Skip to content

Commit

Permalink
Merge branch 'com-1118-poc-implementation-focus-on-web-and-live-strea…
Browse files Browse the repository at this point in the history
…ming' into next
  • Loading branch information
sck-v committed Aug 23, 2024
2 parents 41d2c32 + 91469be commit 7a1ca51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 35 deletions.
27 changes: 12 additions & 15 deletions src/components/video-container/Video-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,18 @@ export class VideoContainer extends LitElement {
backBufferLength: navigator.userAgent.match(/Android/i) ? 0 : 30,
liveDurationInfinity: true,
emeEnabled: !!this.drmOptions,
drmSystems: this.drmOptions
? ({
"com.apple.fps": {
licenseUrl: this.drmOptions[KeySystems.fps].licenseUrl,
serverCertificateUrl:
this.drmOptions[KeySystems.fps].certificateUrl,
},
"com.widevine.alpha": {
licenseUrl: this.drmOptions[KeySystems.widevine],
},
"com.microsoft.playready": {
licenseUrl: this.drmOptions[KeySystems.playready],
},
} as any)
: {},
drmSystems: this.drmOptions ? {
'com.apple.fps': {
licenseUrl: this.drmOptions[KeySystems.fps].licenseUrl,
serverCertificateUrl: this.drmOptions[KeySystems.fps].certificateUrl,
},
'com.widevine.alpha': {
licenseUrl: this.drmOptions[KeySystems.widevine].licenseUrl
},
'com.microsoft.playready': {
licenseUrl: this.drmOptions[KeySystems.playready].licenseUrl
}
} : {}
});

if (this.muxData)
Expand Down
27 changes: 7 additions & 20 deletions src/helpers/drm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@ const loadFairPlayCertificate = async (certificateUrl: string) => {
return response.arrayBuffer();
};

const fairplayEncryptedCallback = (
fairPlayCertificate: BufferSource,
licenseServerUrl: string,
) => {
return async (event: any) => {
console.log("fairplayEncrypted callback", event);

const video = event.target;
const fairplayEncryptedCallback = (fairPlayCertificate: ArrayBuffer, licenseServerUrl: string) => {
return async (event: MediaEncryptedEvent) => {
const video = event.target as HTMLVideoElement;
const initDataType = event.initDataType;

if (!video.mediaKeys) {
Expand All @@ -54,7 +49,7 @@ const fairplayEncryptedCallback = (

let session = video.mediaKeys.createSession();
session.generateRequest(initDataType, initData);
let message = await new Promise((resolve) => {
let message = await new Promise<MediaKeySessionEventMap["message"]>((resolve) => {
session.addEventListener("message", resolve, { once: true });
});

Expand All @@ -64,19 +59,11 @@ const fairplayEncryptedCallback = (
};
};

const getLicenseResponse = async (event: any, licenseServerUrl: string) => {
// let spc_string = btoa(String.fromCharCode(...new Uint8Array(event.message)));
const getLicenseResponse = async (event: MediaKeySessionEventMap["message"], licenseServerUrl: string) => {
let licenseResponse = await fetch(licenseServerUrl, {
method: "POST",
headers: new Headers({
"Content-type": "application/json",
"X-AxDRM-Message":
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiNjllNTQwODgtZTllMC00NTMwLThjMWEtMWViNmRjZDBkMTRlIiwibWVzc2FnZSI6eyJ2ZXJzaW9uIjoyLCJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImxpY2Vuc2UiOnsiYWxsb3dfcGVyc2lzdGVuY2UiOnRydWV9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiIyMTFhYzFkYy1jOGEyLTQ1NzUtYmFmNy1mYTRiYTU2YzM4YWMiLCJ1c2FnZV9wb2xpY3kiOiJUaGVPbmVQb2xpY3kifV19LCJjb250ZW50X2tleV91c2FnZV9wb2xpY2llcyI6W3sibmFtZSI6IlRoZU9uZVBvbGljeSIsInBsYXlyZWFkeSI6eyJwbGF5X2VuYWJsZXJzIjpbIjc4NjYyN0Q4LUMyQTYtNDRCRS04Rjg4LTA4QUUyNTVCMDFBNyJdfX1dfX0.D9FM9sbTFxBmcCOC8yMHrEtTwm0zy6ejZUCrlJbHz_U",
}),
method: 'POST',
headers: new Headers({'Content-type': 'application/octet-stream'}),
body: event.message,
// body: JSON.stringify({
// "spc" : spc_string
// }),
});
return licenseResponse.arrayBuffer();
};

0 comments on commit 7a1ca51

Please sign in to comment.