Skip to content

Commit

Permalink
fix: Fix DASH transition from dynamic to static (shaka-project#3497)
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván authored Jul 9, 2021
1 parent 2dedd9f commit b3166db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/media/presentation_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ shaka.media.PresentationTimeline = class {
*/
getSegmentAvailabilityEnd() {
if (!this.isLive() && !this.isInProgress()) {
return this.duration_;
// It's a static manifest (can also be a dynamic->static conversion)
return this.maxSegmentEndTime_ || this.duration_;
}
// Can be either live or "in-progress recording" (live with known duration)
return Math.min(this.getLiveEdge_() + this.availabilityTimeOffset_,
this.duration_);
}
Expand Down
19 changes: 19 additions & 0 deletions test/media/presentation_timeline_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,25 @@ describe('PresentationTimeline', () => {
// last segment time (50)
expect(timeline.getSegmentAvailabilityEnd()).toBe(50);
});

it('calculates time when there a transition of live to static', () => {
const timeline = makeLiveTimeline(/* availability= */ 20);

const ref1 = makeSegmentReference(0, 10);
const ref2 = makeSegmentReference(10, 20);
const ref3 = makeSegmentReference(20, 30);
const ref4 = makeSegmentReference(30, 40);
const ref5 = makeSegmentReference(40, 50);

setElapsed(50);
timeline.notifySegments([ref1, ref2, ref3, ref4, ref5]);

expect(timeline.getSegmentAvailabilityEnd()).toBe(50);

timeline.setStatic(true);

expect(timeline.getSegmentAvailabilityEnd()).toBe(50);
});
});

describe('getDuration', () => {
Expand Down

0 comments on commit b3166db

Please sign in to comment.