Skip to content
15 changes: 15 additions & 0 deletions packages/playback/src/lib/eme/eme-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ export class EmeManager implements IEmeManager {
// TODO: implement handling of initData
}

// public initializeMediaKeys() {
// // Getting this from contrib eme as it seems to fix a bug in older chrome browsers:
// // https://bugs.chromium.org/p/chromium/issues/detail?id=895449
// // It basically fakes the encrypted event to set up media keys.
// // I'm 80 percent we don't want to keep this
// }
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

public getSupportedCDMs(): Array<string> {
// Get's a list of supported CDMs if the user is interested.
// should check FairPlay, PlayReady, Widevine, and ClearKey.
return [];
}
Comment thread
wseymour15 marked this conversation as resolved.

// Do we want a function to return the current mediaKeySession, licenses, etc.?
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

public handleWaitingForKey(): void {
// TODO: check if we have pending request or init one if we have init data
}
Expand Down
111 changes: 111 additions & 0 deletions packages/playback/src/lib/types/configuration.declarations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CustomTagMap, TransformTagValue, TransformTagAttributes } from '@videojs/hls-parser';
import type { RequestType } from '../consts/request-type';
import type { IKeySystemConfig } from './source.declarations';

export interface NetworkConfiguration {
/**
Expand Down Expand Up @@ -61,10 +62,120 @@ export interface PlayerHlsConfiguration {
customTagMap: CustomTagMap;
transformTagValue: TransformTagValue;
transformTagAttributes: TransformTagAttributes;

}

/** Would be used if we allowed the user to pass in a persistent session */
// If we need this, move it to another file
// export interface KeySessionMetadata {
// sessionId: string;
// initData: Uint8Array;
// initDataType: string;
// }
Comment thread
wseymour15 marked this conversation as resolved.
Outdated


export interface PlayerEmeConfiguration {
/**
* A map of ClearKey key IDs to keys.
* These values should be encoded in hex or base64.
* Defaults to an empty object.
*/
clearKeys: Record<string, string>;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

/**
* Key sessions metadata to load before starting playback.
* Defaults to an empty array.
*/
// initialKeySessions: Array<KeySessionMetadata>;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated


// NOTE: We could make this order the priority that the user intends.
// If not, do we want a different config option that lists priority of key systems?
// Or maybe a `priority` value in the keySystems?
// Do we want to priortize different types of the same DRM (com.widevine.something vs com.widevine.alpha)
keySystems: Record<string, IKeySystemConfig>;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated


/**
* The time in ms to check if the media key session is expired.
* Defaults to 1000.
*/
sessionExpirationInterval: number;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

/**
* The minimum version of HDCP to start EME streams.
* Defaults to ''.
*/
minHdcpVersion: string;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// This will probably replace the firstWebkitneedkeyTimeout option in contrib eme
/**
* Option to ignore duplicate init data on the encrypted event or through pssh boxes.
* Defaults to true
*/
ignoreDuplicateInitData: boolean;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated


/**
* The amount of time in milliseconds to wait on the first `webkitneedkey` event before making the key request.
* is was implemented due to a bug in Safari where rendition switches at the start of playback can cause `webkitneedkey` to fire multiple times, with only the last one being valid.
* Defaults to 1000.
*/
webkitneedkeyTimeout: number;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// POLYFILLS

// This would enable the legacy fairplay specific code, in a polyfill manner.
/**
* Build modern EME into browsers that use Apple's prefixed EME in Safari.
* Defaults to false
*/
enableLegacyFairplay: boolean;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

/**
* Adds the logic to fix setServerCertificate implementation on older platforms which claim to support modern EME.
* Defaults to false
*/
enableSetServerCertificate: boolean;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

/**
* Build modern EME into browsers that use legacy webkit EME API
* Shaka defaults this to true, I'd guess we would too.
*/
enableLegacyWebkit: boolean;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

/**
* Add support for EncryptionScheme queries in EME.
* https://wicg.github.io/encrypted-media-encryption-scheme/
* defaults to false.
*/
enableEncryptionSchemes: boolean;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// keySystemsByURI: Record<string, string>;
// This maps something like 'urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95': 'com.microsoft.playready.recommendation',
Comment thread
wseymour15 marked this conversation as resolved.
Outdated
// I am guessing we want to do this manually. Should the user have this capability?
// They could just create a value in `keySystems`.

// keySystemsMapping: similar to above for two strings, just create another key session.

// delayLicenseRequestUntilPlayed?? - not sure how this would be useful
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// persistentSessionOnlinePlayback?? - try playback with given persistent session ids
// before requesting a license. Also prevents the session removal at playback
// stop, as-to be able to re-use it later..
// DO THIS BY DEFAULT?
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// initDataTransform?? - do we want to allow the user to transform initData??
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// parseInbandPsshEnabled?? - enabled by default I would guess
Comment thread
wseymour15 marked this conversation as resolved.
Outdated

// setMediaKeysNoOp?? - meant to stub out eme API for browsers without it.
Comment thread
wseymour15 marked this conversation as resolved.
Outdated
// Shaka supports this but I do not know if we want this as an option.
}

export interface PlayerConfiguration {
network: PlayerNetworkConfiguration;
mse: PlayerMseConfiguration;
hls: PlayerHlsConfiguration;
eme: PlayerEmeConfiguration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IEmeManager {
attach(videoElement: HTMLVideoElement): void;
detach(): void;
dispose(): void;
getSupportedCDMs(): Array<string>;
stop(): void;
setSource(source: IPlayerSource): void;
handleWaitingForKey(): void;
Expand Down
12 changes: 12 additions & 0 deletions packages/playback/src/lib/types/source.declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ export interface IKeySystemConfig {
audioRobustness?: string;
sessionType?: MediaKeySessionType;
sessionId?: string;
/**
* On 'individualization-request' events, this URI will be used for the license request.
* playready specific
* Defaults to ''.
*/
individualizationServerUri?: string;
getContentId?: (contentId: string) => string;
// Rare cases when we want to leave it up to the user to get the license
getLicense?: (contentId: string, keyMessage: MediaKeyMessageEvent) => void;
// In contrib-eme we give the user to update the values in MediaCapability. I don't think we want to do this??
// audioContentType: string;
// videoContentType: string;
Comment thread
wseymour15 marked this conversation as resolved.
Outdated
// sessionType?? - we will get this from the request for configuration
Comment thread
wseymour15 marked this conversation as resolved.
Outdated
}

export interface ILoadSource {
Expand Down