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

ProducerReferenceTime #3895

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d037dae
Calculate and apply time offsets from ProducerReferenceTime when sett…
mattjuggins Feb 18, 2022
30eb52d
Calculate and apply time offsets from ProducerReferenceTime when sett…
mattjuggins Feb 18, 2022
004195e
Merge branch 'producer-reference-time' of https://github.com/mattjugg…
mattjuggins Feb 18, 2022
4242a80
Clearer variables and function names
mattjuggins Feb 21, 2022
8ef6da3
Add collection of PRFTs from Representations
mattjuggins Feb 22, 2022
9b345ff
Calculate and apply time offsets from ProducerReferenceTime when sett…
mattjuggins Feb 18, 2022
ef30e51
Clearer variables and function names
mattjuggins Feb 21, 2022
521543e
Add collection of PRFTs from Representations
mattjuggins Feb 22, 2022
0f362fe
Check for PRFT over all periods and factor in presentationTimeOffset …
mattjuggins Mar 2, 2022
6a165d7
fix conflicts
mattjuggins Mar 2, 2022
8397c07
Merge branch 'development' into producer-reference-time
mattjuggins Mar 23, 2022
77cb57a
Corrections and additional test
mattjuggins Mar 23, 2022
5773ed9
Apply offset to all latency values
mattjuggins Apr 11, 2022
67dce68
Calculate and apply time offsets from ProducerReferenceTime when sett…
mattjuggins Feb 18, 2022
276c723
Clearer variables and function names
mattjuggins Feb 21, 2022
3cc07cc
Add collection of PRFTs from Representations
mattjuggins Feb 22, 2022
a3e027d
Check for PRFT over all periods and factor in presentationTimeOffset …
mattjuggins Mar 2, 2022
a1b26fb
Corrections and additional test
mattjuggins Mar 23, 2022
1b2ac43
Integrate ProducerReferenceTime offset calculations with ServiceDescr…
mattjuggins Apr 14, 2022
009849a
Fix merge errors
mattjuggins Apr 14, 2022
203fee3
Revert tests changed in merge
mattjuggins Apr 14, 2022
393dcc3
Merge branch 'development' into producer-reference-time
mattjuggins Apr 14, 2022
f024522
Fix StreamController formatting
mattjuggins Apr 14, 2022
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
12 changes: 8 additions & 4 deletions src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import Events from './events/Events';
* wallclockTimeUpdateInterval: 100,
* manifestUpdateRetryInterval: 100,
* cacheInitSegments: true,
* applyServiceDescription: true,
* applyProducerReferenceTime: true,
* eventControllerRefreshDelay: 100,
* capabilities: {
* filterUnsupportedEssentialProperties: true,
Expand All @@ -78,8 +80,7 @@ import Events from './events/Events';
* delay: {
* liveDelayFragmentCount: NaN,
* liveDelay: NaN,
* useSuggestedPresentationDelay: true,
* applyServiceDescription: true
* useSuggestedPresentationDelay: true
* },
* protection: {
* keepProtectionMediaKeys: false
Expand Down Expand Up @@ -237,8 +238,6 @@ import Events from './events/Events';
* If set, this parameter will take precedence over setLiveDelayFragmentCount and manifest info.
* @property {boolean} [useSuggestedPresentationDelay=true]
* Set to true if you would like to overwrite the default live delay and honor the SuggestedPresentationDelay attribute in by the manifest.
* @property {boolean} [applyServiceDescription=true]
* Set to true if dash.js should use the parameters defined in ServiceDescription elements
*/

/**
Expand Down Expand Up @@ -650,6 +649,10 @@ import Events from './events/Events';
* For live streams, set the interval-frequency in milliseconds at which dash.js will check if the current manifest is still processed before downloading the next manifest once the minimumUpdatePeriod time has.
* @property {boolean} [cacheInitSegments=true]
* Enables the caching of init segments to avoid requesting the init segments before each representation switch.
* @property {boolean} [applyServiceDescription=true]
* Set to true if dash.js should use the parameters defined in ServiceDescription elements
* @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]
* Defines the delay in milliseconds between two consecutive checks for events to be fired.
* @property {module:Settings~Metrics} metrics Metric settings
Expand Down Expand Up @@ -752,6 +755,7 @@ function Settings() {
manifestUpdateRetryInterval: 100,
cacheInitSegments: false,
applyServiceDescription: true,
applyProducerReferenceTime: true,
eventControllerRefreshDelay: 150,
capabilities: {
filterUnsupportedEssentialProperties: true,
Expand Down
23 changes: 23 additions & 0 deletions src/dash/DashAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,28 @@ function DashAdapter() {
return realAdaptation;
}

/**
* Returns the ProducerReferenceTimes as saved in the DashManifestModel if present
* @param {object} streamInfo
* @param {object} mediaInfo
* @returns {object} producerReferenceTimes
* @memberOf module:DashAdapter
* @instance
*/
function getProducerReferenceTimes(streamInfo, mediaInfo) {
let id, realAdaptation;

const selectedVoPeriod = getPeriodForStreamInfo(streamInfo, voPeriods);
id = mediaInfo ? mediaInfo.id : null;

if (voPeriods.length > 0 && selectedVoPeriod) {
realAdaptation = id ? dashManifestModel.getAdaptationForId(id, voPeriods[0].mpd.manifest, selectedVoPeriod.index) : dashManifestModel.getAdaptationForIndex(mediaInfo ? mediaInfo.index : null, voPeriods[0].mpd.manifest, selectedVoPeriod.index);
}

if (!realAdaptation) return [];
return dashManifestModel.getProducerReferenceTimesForAdaptation(realAdaptation);
}

/**
* Return all EssentialProperties of a Representation
* @param {object} representation
Expand Down Expand Up @@ -1165,6 +1187,7 @@ function DashAdapter() {
getAllMediaInfoForType,
getAdaptationForType,
getRealAdaptation,
getProducerReferenceTimes,
getRealPeriodByIndex,
getEssentialPropertiesForRepresentation,
getVoRepresentations,
Expand Down
5 changes: 5 additions & 0 deletions src/dash/constants/DashConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class DashConstants {
this.ESSENTIAL_PROPERTY = 'EssentialProperty';
this.SUPPLEMENTAL_PROPERTY = 'SupplementalProperty';
this.INBAND_EVENT_STREAM = 'InbandEventStream';
this.PRODUCER_REFERENCE_TIME = 'ProducerReferenceTime';
this.ACCESSIBILITY = 'Accessibility';
this.ROLE = 'Role';
this.RATING = 'Rating';
Expand All @@ -98,6 +99,8 @@ class DashConstants {
this.LANG = 'lang';
this.VIEWPOINT = 'Viewpoint';
this.ROLE_ASARRAY = 'Role_asArray';
this.REPRESENTATION_ASARRAY = 'Representation_asArray';
this.PRODUCERREFERENCETIME_ASARRAY = 'ProducerReferenceTime_asArray';
this.ACCESSIBILITY_ASARRAY = 'Accessibility_asArray';
this.AUDIOCHANNELCONFIGURATION_ASARRAY = 'AudioChannelConfiguration_asArray';
this.CONTENTPROTECTION_ASARRAY = 'ContentProtection_asArray';
Expand Down Expand Up @@ -137,6 +140,8 @@ class DashConstants {
this.PUBLISH_TIME = 'publishTime';
this.ORIGINAL_PUBLISH_TIME = 'originalPublishTime';
this.ORIGINAL_MPD_ID = 'mpdId';
this.WALL_CLOCK_TIME = 'wallClockTime';
this.PRESENTATION_TIME = 'presentationTime';
}

constructor () {
Expand Down
52 changes: 51 additions & 1 deletion src/dash/models/DashManifestModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import UTCTiming from '../vo/UTCTiming';
import Event from '../vo/Event';
import BaseURL from '../vo/BaseURL';
import EventStream from '../vo/EventStream';
import ProducerReferenceTime from '../vo/ProducerReferenceTime';
import ObjectUtils from '../../streaming/utils/ObjectUtils';
import URLUtils from '../../streaming/utils/URLUtils';
import FactoryMaker from '../../core/FactoryMaker';
Expand Down Expand Up @@ -162,6 +163,53 @@ function DashManifestModel() {
return getIsTypeOf(adaptation, Constants.IMAGE);
}

function getProducerReferenceTimesForAdaptation(adaptation) {
const prtArray = adaptation && adaptation.hasOwnProperty(DashConstants.PRODUCERREFERENCETIME_ASARRAY) ? adaptation[DashConstants.PRODUCERREFERENCETIME_ASARRAY] : [];

// ProducerReferenceTime elements can also be contained in Representations
const representationsArray = adaptation && adaptation.hasOwnProperty(DashConstants.REPRESENTATION_ASARRAY) ? adaptation[DashConstants.REPRESENTATION_ASARRAY] : [];

representationsArray.forEach((rep) => {
if (rep.hasOwnProperty(DashConstants.PRODUCERREFERENCETIME_ASARRAY)) {
prtArray.push(...rep[DashConstants.PRODUCERREFERENCETIME_ASARRAY]);
}
});

const prtsForAdaptation = [];

// Unlikely to have multiple ProducerReferenceTimes.
prtArray.forEach((prt) => {
const entry = new ProducerReferenceTime();

if (prt.hasOwnProperty(DashConstants.ID)) {
entry[DashConstants.ID] = prt[DashConstants.ID];
} else {
// Ignore. Missing mandatory attribute
return;
}

if (prt.hasOwnProperty(DashConstants.WALL_CLOCK_TIME)) {
entry[DashConstants.WALL_CLOCK_TIME] = prt[DashConstants.WALL_CLOCK_TIME];
} else {
// Ignore. Missing mandatory attribute
return;
}

if (prt.hasOwnProperty(DashConstants.PRESENTATION_TIME)) {
entry[DashConstants.PRESENTATION_TIME] = prt[DashConstants.PRESENTATION_TIME];
} else {
// Ignore. Missing mandatory attribute
return;
}

// Not interested in other attributes for now
// UTC element contained must be same as that in the MPD
prtsForAdaptation.push(entry);
})

return prtsForAdaptation;
}

function getLanguageForAdaptation(adaptation) {
let lang = '';

Expand Down Expand Up @@ -1122,7 +1170,8 @@ function DashManifestModel() {
latency = {
target: parseInt(sd[prop].target),
max: parseInt(sd[prop].max),
min: parseInt(sd[prop].min)
min: parseInt(sd[prop].min),
referenceId: parseInt(sd[prop].referenceId)
};
} else if (prop === DashConstants.SERVICE_DESCRIPTION_PLAYBACK_RATE) {
playbackRate = {
Expand Down Expand Up @@ -1192,6 +1241,7 @@ function DashManifestModel() {
getIsTypeOf,
getIsText,
getIsFragmented,
getProducerReferenceTimesForAdaptation,
getLanguageForAdaptation,
getViewpointForAdaptation,
getRolesForAdaptation,
Expand Down
47 changes: 47 additions & 0 deletions src/dash/vo/ProducerReferenceTime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* The copyright in this software is being made available under the BSD License,
* included below. This software may be subject to other third party and contributor
* rights, including patent rights, and no such rights are granted under this license.
*
* Copyright (c) 2013, Dash Industry Forum.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* * Neither the name of Dash Industry Forum nor the names of its
* contributors may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @class
* @ignore
*/
class ProducerReferenceTime {
constructor() {
this.id = null;
this.inband = false;
this.type = 'encoder';
this.applicationScheme = null;
this.wallClockTime = null;
this.presentationTime = NaN;
dsilhavy marked this conversation as resolved.
Show resolved Hide resolved
this.UTCTiming = null;
}
}

export default ProducerReferenceTime;
4 changes: 4 additions & 0 deletions src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ function MediaPlayer() {
adapter: adapter
});

serviceDescriptionController.setConfig({
adapter: adapter
});

if (!segmentBaseController) {
segmentBaseController = SegmentBaseController(context).getInstance({
dashMetrics: dashMetrics,
Expand Down
Loading