Skip to content

Commit 837cf98

Browse files
authored
add support for Preselection element (Dash-Industry-Forum#4790)
* add support for Preselection element parsing and codecs string replacement * address review comments * one more fix from review * unify getProperty functions * adding id * more updates to index.d.ts * improve preselections capability check with MediaCapabilitiesAPI * missing fix from last commit * improve robustness * rename settings element for preselection to MediaInfo mapping * setting Preselection@id to the default value per spec * move code to helper function * remove currently unsed code * remove declarations from index.d.ts, where respective items were removed from code
1 parent 3a52b30 commit 837cf98

File tree

15 files changed

+579
-192
lines changed

15 files changed

+579
-192
lines changed

contrib/akamai/controlbar/ControlBar.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
577577
var info = '';
578578

579579
if (element.lang) {
580-
info += 'Language - ' + element.lang + ' ';
580+
info += 'Language: ' + element.lang + ' ';
581581
}
582582

583583
if (element.roles && element.roles.length > 0) {
@@ -596,6 +596,10 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
596596
info += '- Id: ' + element.id + ' ';
597597
}
598598

599+
if (element.isPreselection) {
600+
info += '- Preselection';
601+
}
602+
599603
return label || info
600604
};
601605
trackSwitchMenu = createMenu(availableTracks, contentFunc);
@@ -785,6 +789,9 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
785789
};
786790

787791
var isTracksEqual = function (t1, t2) {
792+
if (!t1 && !t2) return true;
793+
if (!t1 || !t2) return false;
794+
if (t1.isPreselection !== t2.isPreselection) return false;
788795
var sameId = t1.id === t2.id;
789796
var sameViewpoint = t1.viewpoint === t2.viewpoint;
790797
var sameLang = t1.lang === t2.lang;

index.d.ts

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ declare namespace dashjs {
415415

416416
getCodec(adaptation: object, representationIndex: number, addResolutionInfo: boolean): string;
417417

418+
getCodecForPreselection(preselection: Preselection, adaptations: AdaptationSet[], addResolutionInfo: boolean): string;
419+
418420
getContentProtectionByAdaptation(adaptation: object): any;
419421

420422
getContentProtectionByManifest(manifest: object): any[];
@@ -427,7 +429,7 @@ declare namespace dashjs {
427429

428430
getEndTimeForLastPeriod(voPeriod: Period): number;
429431

430-
getEssentialPropertiesForRepresentation(realRepresentation: object): { schemeIdUri: string, value: string }
432+
getEssentialProperties(element: object): DescriptorType | [];
431433

432434
getEventStreamForAdaptationSet(manifest: object, adaptation: object): EventStream[];
433435

@@ -467,12 +469,22 @@ declare namespace dashjs {
467469

468470
getLoction(manifest: object): MpdLocation | [];
469471

472+
getMainAdaptationSetForPreselection(preselection: Preselection, adaptations: AdaptationSet[]): AdaptationSet | undefined;
473+
474+
getCommonRepresentationForPreselection(preselection: Preselection, adaptations: AdaptationSet[]): Representation | undefined;
475+
470476
getManifestUpdatePeriod(manifest: object, latencyOfLastUpdate?: number): number;
471477

472478
getMimeType(adaptation: object): object;
473479

474480
getMpd(manifest: object): Mpd;
475481

482+
getPatchLocation(manifest: object): PatchLocation[];
483+
484+
getPreselectionIsTypeOf(preselection: Preselection, adaptations: AdaptationSet[], type: MediaType): boolean;
485+
486+
getPreselectionsForPeriod(voPeriod: object): Preselection[];
487+
476488
getPeriodId(realPeriod: Period, i: number): string;
477489

478490
getProducerReferenceTimesForAdaptation(adaptation: object): any[];
@@ -509,9 +521,7 @@ declare namespace dashjs {
509521

510522
getSuggestedPresentationDelay(mpd: Mpd): any;
511523

512-
getSupplementalPropertiesForAdaptation(adaptation: object): DescriptorType | [];
513-
514-
getSupplementalPropertiesForRepresentation(representation: Representation): DescriptorType | [];
524+
getSupplementalProperties(element: object): DescriptorType | [];
515525

516526
getUTCTimingSources(manifest: object): any[];
517527

@@ -672,6 +682,7 @@ declare namespace dashjs {
672682

673683
export class AdaptationSet {
674684
period: Period | null;
685+
id: string | null;
675686
index: number;
676687
type: string | null;
677688
}
@@ -879,6 +890,7 @@ declare namespace dashjs {
879890
index: number | null;
880891
isEmbedded: any | null;
881892
isFragmented: any | null;
893+
isPreselection: boolean;
882894
isText: boolean;
883895
labels: { text: string, lang?: string }[];
884896
lang: string | null;
@@ -944,6 +956,16 @@ declare namespace dashjs {
944956
start: number;
945957
}
946958

959+
export interface Preselection {
960+
period: Period | null;
961+
index: number;
962+
id: string | null;
963+
order: string | null;
964+
preselectionComponents: any[];
965+
tag: string | null;
966+
type: string | null;
967+
}
968+
947969
export interface ProducerReferenceTime {
948970
UTCTiming: any;
949971
applicationSchme: any;
@@ -1056,13 +1078,15 @@ declare namespace dashjs {
10561078

10571079
getCodec(adaptation: object, representationIndex: number, addResolutionInfo: boolean): string;
10581080

1081+
getCodecForPreselection(preselection: Preselection, adaptations: AdaptationSet[]): string;
1082+
1083+
getCommonRepresentationForPreselection(preselection: Preselection, adaptations: AdaptationSet[]): Representation | null;
1084+
10591085
getContentSteering(manifest: object): object;
10601086

10611087
getDuration(externalManifest?: object): number;
10621088

1063-
getEssentialPropertiesAdaptationSet(adaptationSet: AdaptationSet): object | [];
1064-
1065-
getEssentialPropertiesForRepresentation(representation: Representation): any[];
1089+
getEssentialProperties(element: AdaptationSet | Representation | Preselection): DescriptorType | [];
10661090

10671091
getEvent(eventBox: object, eventStreams: object, mediaStartTime: number, voRepresentation: object): null | Event;
10681092

@@ -1086,6 +1110,10 @@ declare namespace dashjs {
10861110

10871111
getLocation(manifest: object): MpdLocation[];
10881112

1113+
getMainAdaptationForType(type: string, streamInfo: object): object;
1114+
1115+
getMainAdaptationSetForPreselection(preselection: Preselection, adaptations: AdaptationSet[]): AdaptationSet | undefined;
1116+
10891117
getManifestUpdatePeriod(manifest: object, latencyOfLastUpdate?: number): number;
10901118

10911119
getMediaInfoForType(streamInfo: object, type: MediaType): MediaInfo | null;
@@ -1096,6 +1124,8 @@ declare namespace dashjs {
10961124

10971125
getPeriodById(id: string): Period | null;
10981126

1127+
getPreselectionIsTypeOf(preselection: Preselection, adaptations: AdaptationSet[], type: MediaType): boolean;
1128+
10991129
getProducerReferenceTime(streamInfo: StreamInfo, mediaInfo: MediaInfo): object | [];
11001130

11011131
getPublishTime(manifest: object): number | null;
@@ -1112,7 +1142,7 @@ declare namespace dashjs {
11121142

11131143
getSuggestedPresentationDelay(): string;
11141144

1115-
getSupplementalCodex(representation: Representation): Array<any>;
1145+
getSupplementalCodecs(representation: Representation): Array<any>;
11161146

11171147
getUTCTimingSources(): any[];
11181148

@@ -1771,6 +1801,8 @@ declare namespace dashjs {
17711801
video?: TrackSwitchMode;
17721802
audio?: TrackSwitchMode;
17731803
};
1804+
includePreselectionsInMediainfo?: boolean;
1805+
includePreselectionsForInitialTrackSelection?: boolean;
17741806
ignoreSelectionPriority?: boolean;
17751807
prioritizeRoleMain?: boolean;
17761808
assumeDefaultRoleAsMain?: boolean;

src/core/Settings.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ import Events from './events/Events.js';
189189
* audio: Constants.TRACK_SWITCH_MODE_ALWAYS_REPLACE,
190190
* video: Constants.TRACK_SWITCH_MODE_NEVER_REPLACE
191191
* },
192+
* includePreselectionsInMediainfoArray: true,
193+
* includePreselectionsForInitialTrackSelection: false,
192194
* ignoreSelectionPriority: false,
193195
* prioritizeRoleMain: true,
194196
* assumeDefaultRoleAsMain: true,
@@ -1007,6 +1009,12 @@ import Events from './events/Events.js';
10071009
* - Constants.TRACK_SWITCH_MODE_NEVER_REPLACE
10081010
* Do not replace existing segments in the buffer
10091011
*
1012+
* @property {} [includePreselectionsInMediainfoArray: true]
1013+
* provides the option to include Preselections in the MediaInfo object
1014+
*
1015+
* @property {} [includePreselectionsForInitialTrackSelection: false]
1016+
* provides the option to include Preselections for initial track selection
1017+
*
10101018
* @property {} [ignoreSelectionPriority: false]
10111019
* provides the option to disregard any signalled selectionPriority attribute. If disabled and if no initial media settings are set, track selection is accomplished as defined by selectionModeForInitialTrack.
10121020
*
@@ -1246,6 +1254,8 @@ function Settings() {
12461254
audio: Constants.TRACK_SWITCH_MODE_ALWAYS_REPLACE,
12471255
video: Constants.TRACK_SWITCH_MODE_NEVER_REPLACE
12481256
},
1257+
includePreselectionsInMediainfoArray: true,
1258+
includePreselectionsForInitialTrackSelection: false,
12491259
ignoreSelectionPriority: false,
12501260
prioritizeRoleMain: true,
12511261
assumeDefaultRoleAsMain: true,

0 commit comments

Comments
 (0)