Skip to content

Commit

Permalink
Merge branch 'development' into ChromeCast-receiver-dash
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcunat authored Jun 25, 2020
2 parents a949bcf + dea628c commit e796cd6
Show file tree
Hide file tree
Showing 82 changed files with 1,982 additions and 3,009 deletions.
30 changes: 22 additions & 8 deletions contrib/akamai/controlbar/ControlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
}

// Get thumbnail information
self.player.getThumbnail(mouseTime, function (thumbnail) {
self.player.provideThumbnail(mouseTime, function (thumbnail) {

if (!thumbnail) return;

// Adjust left variable for positioning thumbnail with regards to its viewport
Expand Down Expand Up @@ -463,8 +464,10 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
window.removeEventListener('mousemove', onFullScreenMouseMove);
clearFullscreenState();

if (document.exitFullscreen) {
if (document.fullscreenElement) {
document.exitFullscreen();
} else if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
Expand Down Expand Up @@ -533,9 +536,10 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
if (bitrateListBtn) {
destroyBitrateMenu();
var availableBitrates = { menuType: 'bitrate' };
availableBitrates.audio = self.player.getBitrateInfoListFor('audio') || [];
availableBitrates.video = self.player.getBitrateInfoListFor('video') || [];
if (availableBitrates.audio.length > 1 || availableBitrates.video.length > 1) {
availableBitrates.audio = player.getBitrateInfoListFor('audio') || [];
availableBitrates.video = player.getBitrateInfoListFor('video') || [];
availableBitrates.images = player.getBitrateInfoListFor('image') || [];
if (availableBitrates.audio.length > 1 || availableBitrates.video.length > 1 || availableBitrates.images.length > 1) {
contentFunc = function (element, index) {
var result = isNaN(index) ? ' Auto Switch' : Math.floor(element.bitrate / 1000) + ' kbps';
result += element && element.width && element.height ? ' (' + element.width + 'x' + element.height + ')' : '';
Expand Down Expand Up @@ -608,6 +612,11 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
el = createMenuContent(el, getMenuContent(menuType, info.audio, contentFunc), 'audio', 'audio-' + menuType + '-list');
setMenuItemsState(getMenuInitialIndex(info.audio, menuType, 'audio'), 'audio-' + menuType + '-list');
}
if (info.images && info.images.length > 1) {
el.appendChild(createMediaTypeMenu('image'));
el = createMenuContent(el, getMenuContent(menuType, info.images, contentFunc, false), 'image', 'image-' + menuType + '-list');
setMenuItemsState(getMenuInitialIndex(info.images, menuType, 'image'), 'image-' + menuType + '-list');
}
break;
}

Expand Down Expand Up @@ -649,12 +658,14 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
return (sameId && sameViewpoint && sameLang && sameRoles && sameAccessibility && sameAudioChannelConfiguration);
};

var getMenuContent = function (type, arr, contentFunc) {
var getMenuContent = function (type, arr, contentFunc, autoswitch) {
autoswitch = (autoswitch !== undefined) ? autoswitch : true;

var content = [];
arr.forEach(function (element, index) {
content.push(contentFunc(element, index));
});
if (type !== 'track') {
if (type !== 'track' && autoswitch) {
content.unshift(contentFunc(null, NaN));
}
return content;
Expand Down Expand Up @@ -685,7 +696,7 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {

div.id = type;

title.textContent = type === 'video' ? 'Video' : 'Audio';
title.textContent = type.charAt(0).toUpperCase() + type.slice(1);
title.classList.add('menu-sub-menu-title');

content.id = type + 'Content';
Expand Down Expand Up @@ -779,6 +790,9 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
self.player.updateSettings(cfg);
}
break;
case 'image-bitrate-list':
player.setQualityFor(self.mediaType, self.index);
break;
case 'caption-list':
self.player.setTextTrack(item.index - 1);
break;
Expand Down
88 changes: 81 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,29 @@ declare namespace dashjs {
reset(): void;
}

export interface OfflineRecord {
id: string;
progress: number;
url: string;
originalUrl: string;
status: string;
}

interface OfflineController {
loadRecordsFromStorage(): Promise<void>;
getAllRecords(): OfflineRecord[];
createRecord(manifestURL: string): Promise<string>;
startRecord(id: string, mediaInfos: MediaInfo[]);
stopRecord(id: string): void;
resumeRecord(id: string): void;
deleteRecord(id: string): void;
getRecordProgression(id: string): number;
resetRecords(): void;
reset(): void;
}

export interface Bitrate {
id?: string;
width?: number;
height?: number;
bandwidth?: number;
Expand Down Expand Up @@ -195,7 +217,8 @@ declare namespace dashjs {
on(type: ManifestLoadedEvent['type'], listener: (e: ManifestLoadedEvent) => void, scope?: object): void;
on(type: MetricEvent['type'], listener: (e: MetricEvent) => void, scope?: object): void;
on(type: MetricChangedEvent['type'], listener: (e: MetricChangedEvent) => void, scope?: object): void;
on(type: OfflineStreamEvent['type'], listener: (e: OfflineStreamEvent) => void, scope?: object): void;
on(type: OfflineRecordEvent['type'], listener: (e: OfflineRecordEvent) => void, scope?: object): void;
on(type: OfflineRecordLoademetadataEvent['type'], listener: (e: OfflineRecordLoademetadataEvent) => void, scope?: object): void;
on(type: PeriodSwitchEvent['type'], listener: (e: PeriodSwitchEvent) => void, scope?: object): void;
on(type: PlaybackErrorEvent['type'], listener: (e: PlaybackErrorEvent) => void, scope?: object): void;
on(type: PlaybackPausedEvent['type'], listener: (e: PlaybackPausedEvent) => void, scope?: object): void;
Expand Down Expand Up @@ -260,7 +283,7 @@ declare namespace dashjs {
setTextDefaultLanguage(lang: string): void;
getTextDefaultEnabled(): boolean | undefined;
setTextDefaultEnabled(enable: boolean): void;
getThumbnail(time: number): Thumbnail;
provideThumbnail(time: number, callback: (thumbnail: Thumbnail | null) => void): void;
getBitrateInfoListFor(type: MediaType): BitrateInfo[];
getStreamsFromManifest(manifest: object): StreamInfo[];
getTracksFor(type: MediaType): MediaInfo[];
Expand All @@ -283,6 +306,7 @@ declare namespace dashjs {
getProtectionController(): ProtectionController;
attachProtectionController(value: ProtectionController): void;
setProtectionData(value: ProtectionData): void;
getOfflineController(): OfflineController;
enableManifestDateHeaderTimeSource(value: boolean): void;
displayCaptionsOnTop(value: boolean): void;
attachTTMLRenderingDiv(div: HTMLDivElement): void;
Expand Down Expand Up @@ -352,7 +376,24 @@ declare namespace dashjs {
KEY_SYSTEM_ACCESS_DENIED_ERROR_CODE: 112;
KEY_SESSION_CREATED_ERROR_CODE: 113;
MEDIA_KEY_MESSAGE_LICENSER_ERROR_CODE: 114;
// MSS errors
MSS_NO_TFRF_CODE: 200;
MSS_UNSUPPORTED_CODEC_CODE: 201;
// Offline errors
OFFLINE_ERROR: 11000;
INDEXEDDB_QUOTA_EXCEED_ERROR: 11001;
INDEXEDDB_INVALID_STATE_ERROR: 11002;
INDEXEDDB_NOT_READABLE_ERROR: 11003;
INDEXEDDB_NOT_FOUND_ERROR: 11004;
INDEXEDDB_NETWORK_ERROR: 11005;
INDEXEDDB_DATA_ERROR: 11006;
INDEXEDDB_TRANSACTION_INACTIVE_ERROR: 11007;
INDEXEDDB_NOT_ALLOWED_ERROR: 11008;
INDEXEDDB_NOT_SUPPORTED_ERROR: 11009;
INDEXEDDB_VERSION_ERROR: 11010;
INDEXEDDB_TIMEOUT_ERROR: 11011;
INDEXEDDB_ABORT_ERROR: 11012;
INDEXEDDB_UNKNOWN_ERROR: 11013;
}

interface MediaPlayerEvents {
Expand Down Expand Up @@ -382,6 +423,10 @@ declare namespace dashjs {
METRIC_ADDED: 'metricAdded';
METRIC_CHANGED: 'metricChanged';
METRIC_UPDATED: 'metricUpdated';
OFFLINE_RECORD_FINISHED: 'public_offlineRecordFinished';
OFFLINE_RECORD_LOADEDMETADATA: 'public_offlineRecordLoadedmetadata';
OFFLINE_RECORD_STARTED: 'public_offlineRecordStarted';
OFFLINE_RECORD_STOPPED: 'public_offlineRecordStopped';
PERIOD_SWITCH_COMPLETED: 'periodSwitchCompleted';
PERIOD_SWITCH_STARTED: 'periodSwitchStarted';
PLAYBACK_ENDED: 'playbackEnded';
Expand Down Expand Up @@ -496,6 +541,7 @@ declare namespace dashjs {
MediaPlayerErrors['TIMED_TEXT_ERROR_ID_PARSE_CODE'] |
MediaPlayerErrors['MANIFEST_ERROR_ID_MULTIPLEXED_CODE'] |
MediaPlayerErrors['MEDIASOURCE_TYPE_UNSUPPORTED_CODE'] |
// Protection errors
MediaPlayerErrors['MEDIA_KEYERR_CODE'] |
MediaPlayerErrors['MEDIA_KEYERR_UNKNOWN_CODE'] |
MediaPlayerErrors['MEDIA_KEYERR_CLIENT_CODE'] |
Expand All @@ -511,9 +557,26 @@ declare namespace dashjs {
MediaPlayerErrors['KEY_SYSTEM_ACCESS_DENIED_ERROR_CODE'] |
MediaPlayerErrors['KEY_SESSION_CREATED_ERROR_CODE'] |
MediaPlayerErrors['MEDIA_KEY_MESSAGE_LICENSER_ERROR_CODE'] |
MediaPlayerErrors['MSS_NO_TFRF_CODE'],
message:string,
data:object,
// Offline errors
MediaPlayerErrors['OFFLINE_ERROR'] |
MediaPlayerErrors['INDEXEDDB_QUOTA_EXCEED_ERROR'] |
MediaPlayerErrors['INDEXEDDB_INVALID_STATE_ERROR'] |
MediaPlayerErrors['INDEXEDDB_NOT_READABLE_ERROR'] |
MediaPlayerErrors['INDEXEDDB_NOT_FOUND_ERROR'] |
MediaPlayerErrors['INDEXEDDB_NETWORK_ERROR'] |
MediaPlayerErrors['INDEXEDDB_DATA_ERROR'] |
MediaPlayerErrors['INDEXEDDB_TRANSACTION_INACTIVE_ERROR'] |
MediaPlayerErrors['INDEXEDDB_NOT_ALLOWED_ERROR'] |
MediaPlayerErrors['INDEXEDDB_NOT_SUPPORTED_ERROR'] |
MediaPlayerErrors['INDEXEDDB_VERSION_ERROR'] |
MediaPlayerErrors['INDEXEDDB_TIMEOUT_ERROR'] |
MediaPlayerErrors['INDEXEDDB_ABORT_ERROR'] |
MediaPlayerErrors['INDEXEDDB_UNKNOWN_ERROR'] |
// MSS errors
MediaPlayerErrors['MSS_NO_TFRF_CODE'] |
MediaPlayerErrors['MSS_UNSUPPORTED_CODEC_CODE'],
message: string,
data: object,
}
}

Expand Down Expand Up @@ -621,6 +684,16 @@ declare namespace dashjs {
mediaType: MediaType;
}

export interface OfflineRecordEvent extends Event {
type: MediaPlayerEvents['OFFLINE_RECORD_FINISHED' | 'OFFLINE_RECORD_STARTED' | 'OFFLINE_RECORD_STOPPED' | 'OFFLINE_RECORD_STOPPED'];
id: string;
}

export interface OfflineRecordLoademetadataEvent extends Event {
type: MediaPlayerEvents['OFFLINE_RECORD_LOADEDMETADATA'];
madiaInfos: MediaInfo[];
}

export interface PeriodSwitchEvent extends Event {
type: MediaPlayerEvents['PERIOD_SWITCH_COMPLETED' | 'PERIOD_SWITCH_STARTED'];
toStreamInfo: StreamInfo | null;
Expand Down Expand Up @@ -730,7 +803,7 @@ declare namespace dashjs {
}

export class BitrateInfo {
mediaType: 'video' | 'audio';
mediaType: 'video' | 'audio' | 'image';
bitrate: number;
width: number;
height: number;
Expand Down Expand Up @@ -800,14 +873,15 @@ declare namespace dashjs {
loadedTime: Date;
maxFragmentDuration: number;
minBufferTime: number;
protocol?: string;
}

export class StreamInfo {
id: string;
index: number;
start: number;
duration: number;
manifestInfo: object;
manifestInfo: IManifestInfo;
isLast: boolean;
}

Expand Down
1 change: 1 addition & 0 deletions samples/captioning/caption_vtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

player = dashjs.MediaPlayer({}).create();
player.initialize(video, url, true);
player.setTextDefaultEnabled(true);
}
</script>

Expand Down
4 changes: 4 additions & 0 deletions samples/captioning/multi-track-captions.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

player = dashjs.MediaPlayer().create();
player.initialize(videoElement, url, true);
player.setTextDefaultEnabled(true);
player.setInitialMediaSettingsFor('fragmentedText', {
lang: 'swe'
});
player.attachTTMLRenderingDiv(TTMLRenderingDiv);
controlbar = new ControlBar(player); // Checkout ControlBar.js for more info on how to target/add text tracks to UI
controlbar.initialize();
Expand Down
1 change: 1 addition & 0 deletions samples/captioning/ttml-ebutt-sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

player = dashjs.MediaPlayer().create();
player.initialize(videoElement, url, true);
player.setTextDefaultEnabled(true);
player.attachTTMLRenderingDiv(TTMLRenderingDiv);
controlbar = new ControlBar(player); // Checkout ControlBar.js for more info on how to target/add text tracks to UI
controlbar.initialize();
Expand Down
33 changes: 23 additions & 10 deletions samples/dash-if-reference-player/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors'
let config = JSON.parse(reqConfig.responseText);
if ($scope.player) {
$scope.player.updateSettings(config);
setLatencyAttributes();
}
} else {
// Set default initial configuration
Expand All @@ -260,8 +261,9 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors'
}
}
}
}
};
$scope.player.updateSettings(initialConfig);
setLatencyAttributes();
}
};

Expand Down Expand Up @@ -320,14 +322,6 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors'
$scope.player.attachTTMLRenderingDiv($('#video-caption')[0]);
}

// get buffer default value
var currentConfig = $scope.player.getSettings();
$scope.defaultLiveDelay = currentConfig.streaming.liveDelay;
$scope.defaultStableBufferDelay = currentConfig.streaming.stableBufferTime;
$scope.defaultBufferTimeAtTopQuality = currentConfig.streaming.bufferTimeAtTopQuality;
$scope.defaultBufferTimeAtTopQualityLongForm = currentConfig.streaming.bufferTimeAtTopQualityLongForm;
$scope.lowLatencyModeSelected = currentConfig.streaming.lowLatencyEnabled;

var initVideoTrackSwitchMode = $scope.player.getTrackSwitchModeFor('video');
var initAudioTrackSwitchMode = $scope.player.getTrackSwitchModeFor('audio');

Expand Down Expand Up @@ -627,7 +621,16 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors'
});
}
if ($scope.initialSettings.text) {
$scope.player.setTextDefaultLanguage($scope.initialSettings.text);
if ($scope.initialSettings.textRole) {
$scope.player.setInitialMediaSettingsFor('fragmentedText', {
role: $scope.initialSettings.textRole,
lang: $scope.initialSettings.text
});
} else {
$scope.player.setInitialMediaSettingsFor('fragmentedText', {
lang: $scope.initialSettings.text
});
}
}
$scope.player.setTextDefaultEnabled($scope.initialSettings.textEnabled);
$scope.player.enableForcedTextStreaming($scope.initialSettings.forceTextStreaming);
Expand Down Expand Up @@ -933,6 +936,16 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors'
}
}

function setLatencyAttributes() {
// get buffer default value
var currentConfig = $scope.player.getSettings();
$scope.defaultLiveDelay = currentConfig.streaming.liveDelay;
$scope.defaultStableBufferDelay = currentConfig.streaming.stableBufferTime;
$scope.defaultBufferTimeAtTopQuality = currentConfig.streaming.bufferTimeAtTopQuality;
$scope.defaultBufferTimeAtTopQualityLongForm = currentConfig.streaming.bufferTimeAtTopQualityLongForm;
$scope.lowLatencyModeSelected = currentConfig.streaming.lowLatencyEnabled;
}


(function init() {
$scope.initChartingByMediaType('video');
Expand Down
4 changes: 3 additions & 1 deletion samples/dash-if-reference-player/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@
<label class="options-label">Audio:</label>
<input type="text" class="form-control" placeholder="audio initial lang, e.g. 'en'" ng-model="initialSettings.audio">
<label class="options-label">Video:</label>
<input type="text" class="form-control" placeholder="initial role, e.g. 'alternate'" ng-model="initialSettings.video"> <label class="options-label">Text:</label>
<input type="text" class="form-control" placeholder="initial role, e.g. 'alternate'" ng-model="initialSettings.video">
<label class="options-label">Text:</label>
<input type="text" class="form-control" placeholder="text initial lang, e.g. 'en'" ng-model="initialSettings.text">
<input type="text" class="form-control" placeholder="text initial role, e.g. 'caption'" ng-model="initialSettings.textRole">
<label class="topcoat-checkbox" data-toggle="tooltip" data-placement="right"
title="Enable subtitle on loading text">
<input type="checkbox" id="enableTextAtLoading" ng-model="initialSettings.textEnabled">
Expand Down
Loading

0 comments on commit e796cd6

Please sign in to comment.