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

DVB Font Downloads #4338

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b072cd8
Initial dvb font download work
mattjuggins Dec 13, 2023
73b94b1
Continued dvb font download functionality
mattjuggins Dec 14, 2023
6595f05
Seperate DVBFontUtils and TTML prefixing
mattjuggins Dec 18, 2023
bda2328
Essential Property descriptors working and refactor DVB font handling
mattjuggins Dec 19, 2023
7fe0967
Ensure fonts are removed and handled with essential property descript…
mattjuggins Dec 20, 2023
9754efd
Comment tidy up
mattjuggins Dec 21, 2023
4a11c52
Merge branch 'development' into dvb-font-download
mattjuggins Dec 21, 2023
d15e1bf
Clean up and function commenting
mattjuggins Dec 21, 2023
71c8d9c
Team feedback corrections
mattjuggins Dec 22, 2023
3bad472
Non dvbFonts unit tests
Jan 4, 2024
313a4ee
Merge branch 'dvb-font-download' of https://github.com/mattjuggins/da…
mattjuggins Jan 4, 2024
7c457a4
Add DVBFonts unit tests
mattjuggins Jan 5, 2024
e42ed8e
Update types
mattjuggins Jan 5, 2024
d90e2b3
Update BSD-3 header in accordance with contributor guide
mattjuggins Jan 8, 2024
97a662b
Remove font prefixing functionality
mattjuggins Jan 8, 2024
2555830
Merge branch 'development' into dvb-font-download
mattjuggins Jan 8, 2024
37b877f
Remove references to prefixing fontFamilies in TTMLParser
mattjuggins Jan 8, 2024
2ee0deb
Merge branch 'development' into dvb-font-download
dsilhavy Jan 10, 2024
f0bc9a2
Move events from CoreEvents to MediaPlayerEvents
mattjuggins Jan 12, 2024
7d68cee
Address PR comments on DashAdapter, DashManifestModel and TextSourceB…
mattjuggins Jan 12, 2024
839a57f
Address PR comments for DVBFonts
mattjuggins Jan 12, 2024
e97e8f5
Missing semicolon removal
mattjuggins Jan 12, 2024
07df70e
Add DVB Font Download test streams to reference player
mattjuggins Jan 12, 2024
ccc09e3
Merge branch 'development' into dvb-font-download
dsilhavy Jan 16, 2024
eecb7d0
Use camelCase for DescriptorType dvb extensions
mattjuggins Jan 16, 2024
9e19434
Handle disabled tracks correctly in the reference player controlbar
mattjuggins Jan 16, 2024
e7eb834
Merge branch 'development' into dvb-font-download
dsilhavy Jan 18, 2024
c6b527b
Fix controlbar text track and native track matching
mattjuggins Jan 18, 2024
8fb343c
Fix issue with disabled track cues
mattjuggins Jan 18, 2024
762ce16
Add DVB font download test streams to functional tests
mattjuggins Jan 18, 2024
9374959
Update imscJS version and remove now unneeded fix
mattjuggins Jan 20, 2024
668d75d
Merge branch 'development' into dvb-font-download
mattjuggins Jan 20, 2024
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
51 changes: 47 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ declare namespace dashjs {

getSelectionPriority(realAdaptation: object): number;

getEssentialPropertiesForAdaptation(adaptation: object): object;

getEssentialPropertiesAsArrayForAdaptation(adaptation: object): any[];

getEssentialPropertiesForRepresentation(realRepresentation: object): {schemeIdUri: string, value: string}

getRepresentationFor(index: number, adaptation: object): object;
Expand Down Expand Up @@ -254,9 +258,19 @@ declare namespace dashjs {

getServiceDescriptions(manifest: object): serviceDescriptions;

getSupplementalProperties(adaptation: object): object;
getSegmentAlignment(adaptation: object): boolean;

getSubSegmentAlignment(adaptation: object): boolean;

getSupplementalPropertiesForAdaptation(adaptation: object): object;

getSupplementalPropertiesAsArrayForAdaptation(adaptation: object): any[];

getSupplementalPropertiesForRepresentation(representation: Representation): object;

getSupplementalPropertiesAsArrayForRepresentation(representation: Representation): any[];

setConfig(config: object): void;
}

export interface PatchManifestModel {
Expand Down Expand Up @@ -472,6 +486,9 @@ declare namespace dashjs {
isEmbedded: any | null;
selectionPriority: number;
supplementalProperties: object;
supplementalPropertiesAsArray: any[];
essentialProperties: object;
essentialPropertiesAsArray: any[];
segmentAlignment: boolean;
subSegmentAlignment: boolean;
}
Expand Down Expand Up @@ -582,6 +599,9 @@ declare namespace dashjs {
schemeIdUri: string;
value: string;
id: string;
dvb_url?: string;
dvb_mimeType?: string;
dvb_fontFamily?: string;
}

export class ContentSteeringResponse {
Expand Down Expand Up @@ -3504,7 +3524,32 @@ declare namespace dashjs {
* Streaming - Text
**/

export type TextTrackType = 'subtitles' | 'caption' | 'descriptions' | 'chapters' | 'metadata';
export type TextTrackType = 'subtitles' | 'caption' | 'descriptions' | 'chapters' | 'metadata';

export type FontDownloadStatus = 'unloaded' | 'loaded' | 'error';

export interface FontInfo {
fontFamily: string;
url: string;
mimeType: string;
trackId: number;
streamId: string;
isEssential: boolean;
status: FontDownloadStatus;
fontFace: FontFace;
}

export interface DVBFonts {
addFontsFromTracks(tracks: TextTrackInfo, streamId: string): void;

downloadFonts(): void;

getFonts(): FontInfo[];

getFontsForTrackId(trackId: number): FontInfo[];

reset(): void;
}

export interface EmbeddedTextHtmlRender {
createHTMLCaptionsFromScreen(videoElement: HTMLVideoElement, startTime: number, endTime: number, captionScreen: any): any[];
Expand Down Expand Up @@ -3644,8 +3689,6 @@ declare namespace dashjs {
deleteCuesFromTrackIdx(trackIdx: number, start: number, end: number): void;

deleteAllTextTracks(): void;

deleteTextTrack(idx: number): void;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/core/events/CoreEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class CoreEvents extends EventsBase {
this.CMSD_STATIC_HEADER = 'cmsdStaticHeader';
this.CURRENT_TRACK_CHANGED = 'currentTrackChanged';
this.DATA_UPDATE_COMPLETED = 'dataUpdateCompleted';
this.DVB_FONT_DOWNLOAD_ADDED = 'dvbFontDownloadAdded';
mattjuggins marked this conversation as resolved.
Show resolved Hide resolved
this.DVB_FONT_DOWNLOAD_COMPLETE = 'dvbFontDownloadComplete';
this.DVB_FONT_DOWNLOAD_FAILED = 'dvbFontDownloadFailed';
this.INBAND_EVENTS = 'inbandEvents';
this.INITIAL_STREAM_SWITCH = 'initialStreamSwitch';
this.INIT_FRAGMENT_LOADED = 'initFragmentLoaded';
Expand Down
4 changes: 4 additions & 0 deletions src/dash/DashAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,10 @@ function DashAdapter() {
}
}

// TODO: Unsure if grabbing essential properties present on all representations is necessary like it has been done above
mattjuggins marked this conversation as resolved.
Show resolved Hide resolved
mediaInfo.essentialProperties = dashManifestModel.getEssentialPropertiesForAdaptation(realAdaptation);
mediaInfo.essentialPropertiesAsArray = dashManifestModel.getEssentialPropertiesAsArrayForAdaptation(realAdaptation);

mediaInfo.isFragmented = dashManifestModel.getIsFragmented(realAdaptation);
mediaInfo.isEmbedded = false;

Expand Down
4 changes: 4 additions & 0 deletions src/dash/constants/DashConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class DashConstants {
this.AUDIO_CHANNEL_CONFIGURATION = 'AudioChannelConfiguration';
this.CONTENT_PROTECTION = 'ContentProtection';
this.ESSENTIAL_PROPERTY = 'EssentialProperty';
this.ESSENTIAL_PROPERTY_ASARRAY = 'EssentialProperty_asArray';
this.SUPPLEMENTAL_PROPERTY = 'SupplementalProperty';
this.SUPPLEMENTAL_PROPERTY_ASARRAY = 'SupplementalProperty_asArray';
this.INBAND_EVENT_STREAM = 'InbandEventStream';
Expand Down Expand Up @@ -133,6 +134,9 @@ class DashConstants {
this.CENC_DEFAULT_KID = 'cenc:default_KID';
this.DVB_PRIORITY = 'dvb:priority';
this.DVB_WEIGHT = 'dvb:weight';
this.DVB_URL = 'dvb:url';
this.DVB_MIMETYPE = 'dvb:mimeType';
this.DVB_FONTFAMILY = 'dvb:fontFamily';
this.SUGGESTED_PRESENTATION_DELAY = 'suggestedPresentationDelay';
this.SERVICE_DESCRIPTION = 'ServiceDescription';
this.SERVICE_DESCRIPTION_SCOPE = 'Scope';
Expand Down
38 changes: 34 additions & 4 deletions src/dash/models/DashManifestModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,13 +1290,16 @@ function DashManifestModel() {
return serviceDescriptions;
}

/* SUPPLEMENTAL PROPERTY DESCRIPTORS */

function getSupplementalPropertiesForAdaptation(adaptation) {
const supplementalProperties = {};

if (adaptation && adaptation.hasOwnProperty(DashConstants.SUPPLEMENTAL_PROPERTY_ASARRAY)) {
for (const sp of adaptation.SupplementalProperty_asArray) {
if (sp.hasOwnProperty(Constants.SCHEME_ID_URI) && sp.hasOwnProperty(DashConstants.VALUE)) {
supplementalProperties[sp[Constants.SCHEME_ID_URI]] = sp[DashConstants.VALUE];
if (sp.hasOwnProperty(Constants.SCHEME_ID_URI)) {
// N.B this will only work where there is a single SupplementalProperty descriptor with this SchemeIdUri
supplementalProperties[sp[Constants.SCHEME_ID_URI]] = {...sp};
}
}
}
Expand All @@ -1316,8 +1319,9 @@ function DashManifestModel() {

if (representation && representation.hasOwnProperty(DashConstants.SUPPLEMENTAL_PROPERTY_ASARRAY)) {
for (const sp of representation.SupplementalProperty_asArray) {
if (sp.hasOwnProperty(Constants.SCHEME_ID_URI) && sp.hasOwnProperty(DashConstants.VALUE)) {
supplementalProperties[sp[Constants.SCHEME_ID_URI]] = sp[DashConstants.VALUE];
if (sp.hasOwnProperty(Constants.SCHEME_ID_URI)) {
// N.B this will only work where there is a single SupplementalProperty descriptor with this SchemeIdUri
supplementalProperties[sp[Constants.SCHEME_ID_URI]] = {...sp};
}
}
}
Expand All @@ -1332,6 +1336,30 @@ function DashManifestModel() {
});
}

/* ESSENTIAL PROPERTY DESCRIPTORS */
mattjuggins marked this conversation as resolved.
Show resolved Hide resolved

function getEssentialPropertiesForAdaptation(adaptation) {
const essentialProperties = {};

if (adaptation && adaptation.hasOwnProperty(DashConstants.ESSENTIAL_PROPERTY_ASARRAY)) {
for (const ep of adaptation.EssentialProperty_asArray) {
if (ep.hasOwnProperty(Constants.SCHEME_ID_URI)) {
// N.B this will only work where there is a single EssentialProperty descriptor with this SchemeIdUri
essentialProperties[ep[Constants.SCHEME_ID_URI]] = {...ep};
}
}
}
return essentialProperties;
}

function getEssentialPropertiesAsArrayForAdaptation(adaptation) {
if (!adaptation || !adaptation.hasOwnProperty(DashConstants.ESSENTIAL_PROPERTY_ASARRAY) || !adaptation.EssentialProperty_asArray.length) return [];
return adaptation.EssentialProperty_asArray.map( supp => {
mattjuggins marked this conversation as resolved.
Show resolved Hide resolved
const s = new DescriptorType();
return s.init(supp);
});
}

function setConfig(config) {
if (!config) return;

Expand Down Expand Up @@ -1382,6 +1410,8 @@ function DashManifestModel() {
getRegularPeriods,
getMpd,
getEventsForPeriod,
getEssentialPropertiesForAdaptation,
getEssentialPropertiesAsArrayForAdaptation,
getEssentialPropertiesForRepresentation,
getEventStreamForAdaptationSet,
getEventStreamForRepresentation,
Expand Down
12 changes: 12 additions & 0 deletions src/dash/vo/DescriptorType.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
* @class
* @ignore
*/
import DashConstants from '../constants/DashConstants'

class DescriptorType {
constructor() {
this.schemeIdUri = null;
Expand All @@ -44,6 +46,16 @@ class DescriptorType {
this.schemeIdUri = data.schemeIdUri ? data.schemeIdUri : null;
this.value = data.value ? data.value : null;
this.id = data.id ? data.id : null;
// Only add the DVB extensions if they exist
if (data[DashConstants.DVB_URL]) {
this.dvb_url = data[DashConstants.DVB_URL]
dsilhavy marked this conversation as resolved.
Show resolved Hide resolved
}
if (data[DashConstants.DVB_MIMETYPE]) {
this.dvb_mimeType = data[DashConstants.DVB_MIMETYPE]
}
if (data[DashConstants.DVB_FONTFAMILY]) {
this.dvb_fontFamily = data[DashConstants.DVB_FONTFAMILY]
}
}
return this;
}
Expand Down
2 changes: 2 additions & 0 deletions src/dash/vo/MediaInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class MediaInfo {
this.selectionPriority = 1;
this.supplementalProperties = {};
this.supplementalPropertiesAsArray = [];
this.essentialProperties = {};
this.essentialPropertiesAsArray = [];
this.segmentAlignment = false;
this.subSegmentAlignment = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,7 @@ function MediaPlayer() {
manifestModel,
adapter,
mediaController,
baseURLController,
videoModel,
settings
});
Expand Down
5 changes: 5 additions & 0 deletions src/streaming/constants/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,22 @@ class Constants {
this.INITIALIZE = 'initialize';
this.TEXT_SHOWING = 'showing';
this.TEXT_HIDDEN = 'hidden';
this.TEXT_DISABLED = 'disabled';
this.CC1 = 'CC1';
this.CC3 = 'CC3';
this.UTF8 = 'utf-8';
this.SCHEME_ID_URI = 'schemeIdUri';
this.START_TIME = 'starttime';
this.SERVICE_DESCRIPTION_DVB_LL_SCHEME = 'urn:dvb:dash:lowlatency:scope:2019';
this.SUPPLEMENTAL_PROPERTY_DVB_LL_SCHEME = 'urn:dvb:dash:lowlatency:critical:2019';
this.FONT_DOWNLOAD_DVB_SCHEME = 'urn:dvb:dash:fontdownload:2014';
this.XML = 'XML';
this.ARRAY_BUFFER = 'ArrayBuffer';
this.DVB_REPORTING_URL = 'dvb:reportingUrl';
this.DVB_PROBABILITY = 'dvb:probability';
this.OFF_MIMETYPE = 'application/font-sfnt';
this.WOFF_MIMETYPE = 'application/font-woff';
this.TTS_FONT_FAMILY = 'http://www.w3.org/ns/ttml#styling fontFamily';
this.VIDEO_ELEMENT_READY_STATES = {
HAVE_NOTHING: 0,
HAVE_METADATA: 1,
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/controllers/PlaybackController.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@ function PlaybackController() {

function _checkEnableLowLatency(mediaInfo) {
if (mediaInfo && mediaInfo.supplementalProperties &&
mediaInfo.supplementalProperties[Constants.SUPPLEMENTAL_PROPERTY_DVB_LL_SCHEME] === 'true') {
mediaInfo.supplementalProperties[Constants.SUPPLEMENTAL_PROPERTY_DVB_LL_SCHEME] &&
mediaInfo.supplementalProperties[Constants.SUPPLEMENTAL_PROPERTY_DVB_LL_SCHEME].value === 'true') {
logger.debug('Low Latency critical SupplementalProperty set: Enabling low Latency');
lowLatencyModeEnabled = true;
}
Expand Down
Loading