Skip to content

Commit

Permalink
Warn when UTCTiming is missing for live
Browse files Browse the repository at this point in the history
Without a UTCTiming element in the manifest, a client cannot
synchronize its clock.  This can easily lead to playback failures,
so we warn application developers when we detect this.

Issue #290

Change-Id: Idcb395f5ece67bf2c7d0d984ad277f552d030eb8
  • Loading branch information
joeyparrish committed May 3, 2016
1 parent 8ad7762 commit 1fb7892
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,10 @@ shaka.dash.DashParser.prototype.parseManifest_ =

// Cannot return until we calculate the clock offset.
var timingElements = XmlUtils.findChildren(mpd, 'UTCTiming');
return this.parseUtcTiming_(timingElements).then(function(offset) {
var isLive = duration == Number.POSITIVE_INFINITY ||
(segmentAvailabilityDuration != null &&
segmentAvailabilityDuration < Number.POSITIVE_INFINITY);
return this.parseUtcTiming_(timingElements, isLive).then(function(offset) {
// Detect calls to stop().
if (!this.networkingEngine_)
return;
Expand Down Expand Up @@ -1053,10 +1056,11 @@ shaka.dash.DashParser.prototype.requestForTiming_ = function(uri, method) {
* Parses an array of UTCTiming elements.
*
* @param {!Array.<!Element>} elems
* @param {boolean} isLive
* @return {!Promise.<number>}
* @private
*/
shaka.dash.DashParser.prototype.parseUtcTiming_ = function(elems) {
shaka.dash.DashParser.prototype.parseUtcTiming_ = function(elems, isLive) {
var Functional = shaka.util.Functional;
return Functional.createFallbackPromiseChain(elems, function(elem) {
var scheme = elem.getAttribute('schemeIdUri');
Expand Down Expand Up @@ -1088,8 +1092,14 @@ shaka.dash.DashParser.prototype.parseUtcTiming_ = function(elems) {
'Unrecognized scheme in UTCTiming element', scheme);
return Promise.reject();
}
}.bind(this))
.catch(function() { return 0; });
}.bind(this)).catch(function() {
if (isLive) {
shaka.log.warning(
'A UTCTiming element should always be given in live manifests! ' +
'This content may not play on clients with bad clocks!');
}
return 0;
});
};


Expand Down

0 comments on commit 1fb7892

Please sign in to comment.