Skip to content

Commit

Permalink
getSegmentForTime is returning indicies off by one segment (#3122)
Browse files Browse the repository at this point in the history
* Fix for getSegementForTime requesting the segment before

* Fix the test that got segment indexes wrong
  • Loading branch information
robertbryer authored and jeoliva committed Nov 27, 2019
1 parent 7608668 commit fde839c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/dash/utils/TemplateSegmentsGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function TemplateSegmentsGetter(config, isDynamic) {
}

const periodTime = timelineConverter.calcPeriodRelativeTimeFromMpdRelativeTime(representation, requestedTime);
const index = Math.floor(periodTime / duration) - 1;
const index = Math.floor(periodTime / duration);

return getSegmentByIndex(representation, index);
}
Expand Down
8 changes: 4 additions & 4 deletions test/unit/dash.utils.TemplateSegmentsGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ describe('TemplateSegmentsGetter', () => {
expect(seg.duration).to.equal(5);

seg = templateSegmentsGetter.getSegmentByTime(representation, 12);
expect(seg.availabilityIdx).to.equal(1);
expect(seg.presentationStartTime).to.equal(5);
expect(seg.availabilityIdx).to.equal(2);
expect(seg.presentationStartTime).to.equal(10);
expect(seg.duration).to.equal(5);

seg = templateSegmentsGetter.getSegmentByTime(representation, 17);
expect(seg.availabilityIdx).to.equal(2);
expect(seg.presentationStartTime).to.equal(10);
expect(seg.availabilityIdx).to.equal(3);
expect(seg.presentationStartTime).to.equal(15);
expect(seg.duration).to.equal(5);
});

Expand Down

0 comments on commit fde839c

Please sign in to comment.