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

Add TS to Cue utilities. #2202

Merged
merged 22 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TimelineController from './controller/timeline-controller';
import SubtitleTrackController from './controller/subtitle-track-controller';
import { SubtitleStreamController } from './controller/subtitle-stream-controller';
import EMEController from './controller/eme-controller';
import { requestMediaKeySystemAccess } from './utils/mediakeys-helper';
import { requestMediaKeySystemAccess, MediaKeyFunc } from './utils/mediakeys-helper';

type ABRControllerConfig = {
abrEwmaFastLive: number,
Expand All @@ -42,11 +42,11 @@ type CapLevelControllerConfig = {
capLevelToPlayerSize: boolean
};

type EMEControllerConfig = {
export type EMEControllerConfig = {
licenseXhrSetup?: (xhr: XMLHttpRequest, url: string) => void,
emeEnabled: boolean,
widevineLicenseUrl?: string,
requestMediaKeySystemAccessFunc: Function, // TODO(typescript-mediakeys-helper) Type once file is done
requestMediaKeySystemAccessFunc: MediaKeyFunc | null,
};

type FragmentLoaderConfig = {
Expand Down
31 changes: 15 additions & 16 deletions src/controller/eme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@ import Event from '../events';
import { ErrorTypes, ErrorDetails } from '../errors';

import { logger } from '../utils/logger';
import { EMEControllerConfig } from '../config';
import { KeySystems, MediaKeyFunc } from '../utils/mediakeys-helper';

const MAX_LICENSE_REQUEST_FAILURES = 3;

/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/requestMediaKeySystemAccess
*/
enum KeySystems {
WIDEVINE = 'com.widevine.alpha',
PLAYREADY = 'com.microsoft.playready',
}

/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySystemConfiguration
* @param {Array<string>} audioCodecs List of required audio codecs to support
Expand Down Expand Up @@ -86,12 +80,13 @@ interface MediaKeysListItem {
* @constructor
*/
class EMEController extends EventHandler {
private _widevineLicenseUrl: string;
private _licenseXhrSetup: (xhr: XMLHttpRequest, url: string) => void;
private _widevineLicenseUrl?: string;
private _licenseXhrSetup?: (xhr: XMLHttpRequest, url: string) => void;
private _emeEnabled: boolean;
private _requestMediaKeySystemAccess: (keySystem: KeySystems, supportedConfigurations: MediaKeySystemConfiguration[]) => Promise<MediaKeySystemAccess>
private _requestMediaKeySystemAccess: MediaKeyFunc | null

private _mediaKeysList: MediaKeysListItem[] = []
private _config: EMEControllerConfig;
private _mediaKeysList: MediaKeysListItem[] = [];
private _media: HTMLMediaElement | null = null;
private _hasSetMediaKeys: boolean = false;
private _requestLicenseFailureCount: number = 0;
Expand All @@ -106,11 +101,12 @@ class EMEController extends EventHandler {
Event.MEDIA_DETACHED,
Event.MANIFEST_PARSED
);
this._config = hls.config;

this._widevineLicenseUrl = hls.config.widevineLicenseUrl;
this._licenseXhrSetup = hls.config.licenseXhrSetup;
this._emeEnabled = hls.config.emeEnabled;
this._requestMediaKeySystemAccess = hls.config.requestMediaKeySystemAccessFunc;
this._widevineLicenseUrl = this._config.widevineLicenseUrl;
this._licenseXhrSetup = this._config.licenseXhrSetup;
this._emeEnabled = this._config.emeEnabled;
this._requestMediaKeySystemAccess = this._config.requestMediaKeySystemAccessFunc;
}

/**
Expand All @@ -121,6 +117,9 @@ class EMEController extends EventHandler {
getLicenseServerUrl (keySystem: KeySystems): string {
switch (keySystem) {
case KeySystems.WIDEVINE:
if (!this._widevineLicenseUrl) {
break;
}
return this._widevineLicenseUrl;
}

Expand Down
2 changes: 1 addition & 1 deletion src/controller/id3-track-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ID3TrackController extends EventHandler {
// Give a slight bump to the endTime if it's equal to startTime to avoid a SyntaxError in IE
endTime += 0.0001;
} else if (startTime > endTime) {
logger.warn("detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)");
logger.warn('detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)');
endTime = startTime + 0.25;
}

Expand Down
Loading