Skip to content

Commit

Permalink
fix(DASH): Fix manifest update time for LL-DASH (#5736)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Oct 11, 2023
1 parent 01da5fa commit 8b7141f
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 6 deletions.
8 changes: 8 additions & 0 deletions externs/shaka/manifest_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ shaka.extern.ManifestParser = class {
* @exportDoc
*/
onExpirationUpdated(sessionId, expiration) {}

/**
* Tell the parser that the initial variant has been chosen.
*
* @param {shaka.extern.Variant} variant
* @exportDoc
*/
onInitialVariantChosen(variant) {}
};


Expand Down
31 changes: 25 additions & 6 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,31 @@ shaka.dash.DashParser = class {
// No-op
}

/**
* @override
* @exportInterface
*/
onInitialVariantChosen(variant) {
if (this.manifest_ && this.lowLatencyMode_ &&
this.minTotalAvailabilityTimeOffset_) {
const stream = variant.video || variant.audio;
if (stream && stream.segmentIndex) {
const availabilityEnd =
this.manifest_.presentationTimeline.getSegmentAvailabilityEnd();
const position = stream.segmentIndex.find(availabilityEnd);
if (position == null) {
return;
}
const reference = stream.segmentIndex.get(position);
if (!reference) {
return;
}
this.updatePeriod_ = reference.endTime - availabilityEnd;
this.setUpdateTimer_(/* offset= */ 0);
}
}
}

/**
* Makes a network request for the manifest and parses the resulting data.
*
Expand Down Expand Up @@ -496,12 +521,6 @@ shaka.dash.DashParser = class {
minBufferTime = 0;
}

// Set updatePeriod_ to minTotalAvailabilityTimeOffset_ to achieve the best
// latency in LL streams
if (this.lowLatencyMode_ && this.minTotalAvailabilityTimeOffset_) {
this.updatePeriod_ = this.minTotalAvailabilityTimeOffset_;
}

// These steps are not done on manifest update.
if (!this.manifest_) {
this.manifest_ = {
Expand Down
8 changes: 8 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ shaka.hls.HlsParser = class {
// No-op
}

/**
* @override
* @exportInterface
*/
onInitialVariantChosen(variant) {
// No-op
}

/**
* Align the streams by sequence number by dropping early segments. Then
* offset the streams to begin at presentation time 0.
Expand Down
8 changes: 8 additions & 0 deletions lib/mss/mss_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ shaka.mss.MssParser = class {
// No-op
}

/**
* @override
* @exportInterface
*/
onInitialVariantChosen(variant) {
// No-op
}

/**
* Makes a network request for the manifest and parses the resulting data.
*
Expand Down
5 changes: 5 additions & 0 deletions lib/offline/offline_manifest_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ shaka.offline.OfflineManifestParser = class {
await muxer.destroy();
}
}

/** @override */
onInitialVariantChosen(variant) {
// No-op
}
};


Expand Down
4 changes: 4 additions & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
await Promise.all(createSegmentIndexPromises);
}

if (this.parser_ && this.parser_.onInitialVariantChosen) {
this.parser_.onInitialVariantChosen(toLazyLoad);
}

shaka.Player.applyPlayRange_(this.manifest_.presentationTimeline,
this.config_.playRangeStart,
this.config_.playRangeEnd);
Expand Down
3 changes: 3 additions & 0 deletions test/offline/storage_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,9 @@ filterDescribe('Storage', storageSupport, () => {

/** @override */
onExpirationUpdated(session, number) {}

/** @override */
onInitialVariantChosen(variant) {}
};

/**
Expand Down
3 changes: 3 additions & 0 deletions test/test/util/test_scheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ shaka.test.TestScheme.ManifestParser = class {

/** @override */
onExpirationUpdated() {}

/** @override */
onInitialVariantChosen() {}
};


Expand Down

0 comments on commit 8b7141f

Please sign in to comment.