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

Fix: Allow the playback whenever the t attribute is missing in the SegmentTimeline elements #4174

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/dash/utils/TimelineConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function TimelineConverter() {
const range = { start: NaN, end: NaN };
const voPeriod = streams[0].getAdapter().getRegularPeriods()[0];
const now = calcPresentationTimeFromWallTime(new Date(), voPeriod);

if (!streams || streams.length === 0) {
return { range, now };
}
Expand Down Expand Up @@ -317,14 +317,19 @@ function TimelineConverter() {
const timescale = representation.SegmentTemplate.timescale;
const segments = timeline.S_asArray;
const range = { start: 0, end: 0 };
const segmentTime = segments[0].t;
const hasValidSegmentTime = !isNaN(segmentTime);
const enhancedSegmentTime = hasValidSegmentTime ? segmentTime : 0;
let d = 0;
let segment,
repeat,
i,
len;

range.start = calcPresentationTimeFromMediaTime(segments[0].t / timescale, voRepresentation);


if(hasValidSegmentTime) {
range.start = calcPresentationTimeFromMediaTime(enhancedSegmentTime / timescale, voRepresentation);
}

for (i = 0, len = segments.length; i < len; i++) {
segment = segments[i];
repeat = 0;
Expand All @@ -334,7 +339,7 @@ function TimelineConverter() {
d += segment.d * (1 + repeat);
}

range.end = calcPresentationTimeFromMediaTime((segments[0].t + d) / timescale, voRepresentation);
range.end = calcPresentationTimeFromMediaTime((enhancedSegmentTime + d) / timescale, voRepresentation);

return range;
}
Expand Down
41 changes: 37 additions & 4 deletions test/unit/dash.utils.TimelineConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('TimelineConverter', function () {
timeShiftBuffer: {
calcFromSegmentTimeline: false
}
}
}
});
});

Expand Down Expand Up @@ -114,7 +114,7 @@ describe('TimelineConverter', function () {

beforeEach(function () {
representation.adaptation.period.mpd.manifest.type = 'dynamic';
});
});


describe('SegmentTemplate and ', function () {
Expand Down Expand Up @@ -861,8 +861,8 @@ describe('TimelineConverter', function () {
const clock = sinon.useFakeTimers(new Date().getTime());
const tsbd = 30;
const dummyRep = voHelper.getDummyTimelineRepresentation(testType);

dummyRep.adaptation.period.start = 0;
dummyRep.adaptation.period.start = 0;
dummyRep.adaptation.period.duration = 300;
streamOneMock.setRepresentation(dummyRep);

Expand Down Expand Up @@ -992,6 +992,39 @@ describe('TimelineConverter', function () {
clock.restore();
});

it('with single period with segements without t attribute', function () {
const clock = sinon.useFakeTimers(new Date().getTime());
const tsbd = 30;
const dummyRep = voHelper.getDummyTimelineRepresentation(testType);

// Remove t attribute(s) from segments
delete dummyRep.adaptation.period.mpd.manifest.Period_asArray[0].AdaptationSet_asArray[0].SegmentTemplate.SegmentTimeline_asArray.S_asArray[0].t
delete dummyRep.adaptation.period.mpd.manifest.Period_asArray[0].AdaptationSet_asArray[0].SegmentTemplate.SegmentTimeline.S_asArray[0].t
delete dummyRep.adaptation.period.mpd.manifest.Period_asArray[0].AdaptationSet_asArray[0].SegmentTemplate_asArray.SegmentTimeline_asArray.S_asArray[0].t
delete dummyRep.adaptation.period.mpd.manifest.Period_asArray[0].AdaptationSet_asArray[0].SegmentTemplate_asArray.SegmentTimeline.S_asArray[0].t

dummyRep.adaptation.period.start = 0;
dummyRep.adaptation.period.duration = Number.POSITIVE_INFINITY;;
streamOneMock.setRepresentation(dummyRep);

streamOneMock.setStreamInfo({
start: 0,
duration: Number.POSITIVE_INFINITY
});
streamOneMock.setRegularPeriods([{
mpd: {
availabilityStartTime: new Date(new Date().getTime() - tsbd * 1000),
timeShiftBufferDepth: tsbd
}
}]);
streams.push(streamOneMock);

const range = timelineConverter.calcTimeShiftBufferWindow(streams, true);
expect(range.start).to.be.equal(0);
expect(range.end).to.be.equal(30);
clock.restore();
});

it('with two periods covering whole tsbd', function () {
const clock = sinon.useFakeTimers(new Date().getTime());
const tsbd = 30;
Expand Down