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

Overwrite manifest mediaPresentationDuration if duration mismatch #3971

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
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ declare namespace dashjs {
applyServiceDescription?: boolean,
cacheInitSegments?: boolean,
eventControllerRefreshDelay?: number,
enableManifestDurationMismatchFix?: boolean,
capabilities?: {
filterUnsupportedEssentialProperties?: boolean,
useMediaCapabilitiesApi?: boolean
Expand Down
4 changes: 4 additions & 0 deletions src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import Events from './events/Events';
* applyServiceDescription: true,
* applyProducerReferenceTime: true,
* eventControllerRefreshDelay: 100,
* enableManifestDurationMismatchFix: true,
* capabilities: {
* filterUnsupportedEssentialProperties: true,
* useMediaCapabilitiesApi: false
Expand Down Expand Up @@ -665,6 +666,8 @@ import Events from './events/Events';
* @property {boolean} [applyProducerReferenceTime=true]
* Set to true if dash.js should use the parameters defined in ProducerReferenceTime elements in combination with ServiceDescription elements.
* @property {number} [eventControllerRefreshDelay=100]
* For multi-period streams, overwrite the manifest mediaPresentationDuration attribute with the sum of period durations if the manifest mediaPresentationDuration is greater than the sum of period durations
* @property {boolean} [enableManifestDurationMismatchFix=true]
* Defines the delay in milliseconds between two consecutive checks for events to be fired.
* @property {module:Settings~Metrics} metrics Metric settings
* @property {module:Settings~LiveDelay} delay Live Delay settings
Expand Down Expand Up @@ -768,6 +771,7 @@ function Settings() {
applyServiceDescription: true,
applyProducerReferenceTime: true,
eventControllerRefreshDelay: 100,
enableManifestDurationMismatchFix: true,
dsilhavy marked this conversation as resolved.
Show resolved Hide resolved
capabilities: {
filterUnsupportedEssentialProperties: true,
useMediaCapabilitiesApi: false
Expand Down
15 changes: 15 additions & 0 deletions src/streaming/ManifestLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function ManifestLoader(config) {
config = config || {};
const context = this.context;
const debug = config.debug;
const settings = config.settings;
const eventBus = EventBus(context).getInstance();
const urlUtils = URLUtils(context).getInstance();

Expand Down Expand Up @@ -194,6 +195,20 @@ function ManifestLoader(config) {
logger.debug('BaseURI set by Location to: ' + baseUri);
}

// If there is a mismatch between the manifest's specified duration and the total duration of all periods,
// and the specified duration is greater than the total duration of all periods,
// overwrite the manifest's duration attribute. This is a patch for if a manifest is generated incorrectly.
if (settings &&
settings.get().streaming.enableManifestDurationMismatchFix &&
manifest.mediaPresentationDuration &&
manifest.Period_asArray.length > 1) {
const sumPeriodDurations = manifest.Period_asArray.reduce((totalDuration, period) => totalDuration + period.duration, 0);
if (manifest.mediaPresentationDuration > sumPeriodDurations) {
logger.warn('Media presentation duration greater than duration of all periods. Setting duration to total period duration');
manifest.mediaPresentationDuration = sumPeriodDurations;
}
}

manifest.baseUri = baseUri;
manifest.loadedTime = new Date();
xlinkController.resolveManifestOnLoad(manifest);
Expand Down