Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dash.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ declare namespace dashjs {
defaultTimingSource?: {
scheme?: string,
value?: string
}
},
artificialTimeOffsetToApply?: number
},
scheduling?: {
defaultTimeout?: number,
Expand Down
416 changes: 277 additions & 139 deletions dist/dash.all.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.all.debug.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.all.min.js.map

Large diffs are not rendered by default.

366 changes: 246 additions & 120 deletions dist/dash.mediaplayer.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.mediaplayer.debug.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.mediaplayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.mediaplayer.min.js.map

Large diffs are not rendered by default.

174 changes: 109 additions & 65 deletions dist/dash.offline.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.offline.debug.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.offline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.offline.min.js.map

Large diffs are not rendered by default.

132 changes: 103 additions & 29 deletions dist/dash.reporting.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.reporting.debug.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.reporting.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dash.reporting.min.js.map

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions src/dash/DashHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,17 @@ function DashHandler(config) {
}


function getSegmentRequestForTime(mediaInfo, representation, time) {
function getSegmentRequestForTime(mediaInfo, representation, timeToRequest) {
let request = null;

if (!representation || !representation.segmentInfoType) {
return request;
}

const segment = segmentsController.getSegmentByTime(representation, time);
const segment = segmentsController.getSegment(representation, null, timeToRequest);
if (segment) {
lastSegment = segment;
logger.debug('Index for time ' + time + ' is ' + segment.index);
logger.debug('Index for time ' + timeToRequest + ' is ' + segment.index);
request = _getRequestForSegment(mediaInfo, segment);
}

Expand All @@ -259,10 +259,11 @@ function DashHandler(config) {
function getNextSegmentRequestIdempotent(mediaInfo, representation) {
let request = null;
let indexToRequest = lastSegment ? lastSegment.index + 1 : 0;
const segment = segmentsController.getSegmentByIndex(
let timeToRequest = lastSegment ? lastSegment.mediaStartTime + lastSegment.duration : 0;
const segment = segmentsController.getSegment(
representation,
indexToRequest,
lastSegment ? lastSegment.mediaStartTime : -1
timeToRequest
);
if (!segment) return null;
request = _getRequestForSegment(mediaInfo, segment);
Expand All @@ -281,8 +282,9 @@ function DashHandler(config) {
}

let indexToRequest = lastSegment ? lastSegment.index + 1 : 0;
let timeToRequest = lastSegment ? lastSegment.mediaStartTime + lastSegment.duration : 0;

return _getRequest(mediaInfo, representation, indexToRequest);
return _getRequest(mediaInfo, representation, indexToRequest, timeToRequest);
}

function repeatSegmentRequest(mediaInfo, representation) {
Expand All @@ -291,13 +293,14 @@ function DashHandler(config) {
}

let indexToRequest = lastSegment ? lastSegment.index : 0;
let timeToRequest = lastSegment ? lastSegment.mediaStartTime : 0;

return _getRequest(mediaInfo, representation, indexToRequest);
return _getRequest(mediaInfo, representation, indexToRequest, timeToRequest);
}

function _getRequest(mediaInfo, representation, indexToRequest) {
function _getRequest(mediaInfo, representation, indexToRequest, timeToRequest) {
let request = null;
const segment = segmentsController.getSegmentByIndex(representation, indexToRequest, lastSegment ? lastSegment.mediaStartTime : -1);
const segment = segmentsController.getSegment(representation, indexToRequest, timeToRequest);

// No segment found
if (!segment) {
Expand Down
12 changes: 3 additions & 9 deletions src/dash/controllers/SegmentsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,9 @@ function SegmentsController(config) {
return representation ? representation.segments ? getters[dashConstants.SEGMENT_BASE] : getters[representation.segmentInfoType] : null;
}

function getSegmentByIndex(representation, index, lastSegmentTime) {
function getSegment(representation, index, requestedTime) {
const getter = getSegmentsGetter(representation);
return getter ? getter.getSegmentByIndex(representation, index, lastSegmentTime) : null;
}

function getSegmentByTime(representation, time) {
const getter = getSegmentsGetter(representation);
return getter ? getter.getSegmentByTime(representation, time) : null;
return getter ? getter.getSegment(representation, index, requestedTime) : null;
}

function getMediaFinishedInformation(representation) {
Expand All @@ -103,8 +98,7 @@ function SegmentsController(config) {
initialize,
updateInitData,
updateSegmentData,
getSegmentByIndex,
getSegmentByTime,
getSegment,
getMediaFinishedInformation
};

Expand Down
8 changes: 6 additions & 2 deletions src/dash/utils/ListSegmentsGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ function ListSegmentsGetter(config, isDynamic) {
return mediaFinishedInformation
}

function getSegment(representation, index, requestedTime) {
if (index != null) return getSegmentByIndex(representation, index)
return getSegmentByTime(representation, requestedTime)
}

function getSegmentByIndex(representation, index) {
checkConfig();

Expand Down Expand Up @@ -114,8 +119,7 @@ function ListSegmentsGetter(config, isDynamic) {
}

instance = {
getSegmentByIndex,
getSegmentByTime,
getSegment,
getMediaFinishedInformation
};

Expand Down
8 changes: 6 additions & 2 deletions src/dash/utils/SegmentBaseGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ function SegmentBaseGetter(config) {
return mediaFinishedInformation;
}

function getSegment(representation, index, requestedTime) {
if (index != null) return getSegmentByIndex(representation, index)
return getSegmentByTime(representation, requestedTime)
}

function getSegmentByIndex(representation, index) {
checkConfig();

Expand Down Expand Up @@ -127,8 +132,7 @@ function SegmentBaseGetter(config) {
}

instance = {
getSegmentByIndex,
getSegmentByTime,
getSegment,
getMediaFinishedInformation
};

Expand Down
8 changes: 6 additions & 2 deletions src/dash/utils/TemplateSegmentsGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ function TemplateSegmentsGetter(config, isDynamic) {
return mediaFinishedInformation;
}

function getSegment(representation, index, requestedTime) {
if (index != null) return getSegmentByIndex(representation, index)
return getSegmentByTime(representation, requestedTime)
}

function getSegmentByIndex(representation, index) {
checkConfig();

Expand Down Expand Up @@ -108,8 +113,7 @@ function TemplateSegmentsGetter(config, isDynamic) {
}

instance = {
getSegmentByIndex,
getSegmentByTime,
getSegment,
getMediaFinishedInformation
};

Expand Down
48 changes: 3 additions & 45 deletions src/dash/utils/TimelineSegmentsGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,49 +187,8 @@ function TimelineSegmentsGetter(config, isDynamic) {
return Math.max(Math.ceil((repeatEndTime - scaledTime) / (frag.d / fTimescale)) - 1, 0);
}


function getSegmentByIndex(representation, index, lastSegmentTime) {
checkConfig();

if (!representation) {
return null;
}

let segment = null;
let found = false;

iterateSegments(representation, function (time, base, list, frag, fTimescale, relativeIdx, i) {
if (found || lastSegmentTime < 0) {
let media = base.media;
let mediaRange = frag.mediaRange;

if (list) {
media = list[i].media || '';
mediaRange = list[i].mediaRange;
}

segment = getTimeBasedSegment(
timelineConverter,
isDynamic,
representation,
time,
frag.d,
fTimescale,
media,
mediaRange,
relativeIdx,
frag.tManifest);

return true;
} else if (time >= (lastSegmentTime * fTimescale) - (frag.d * 0.5)) { // same logic, if deviation is
// 50% of segment duration, segment is found if time is greater than or equal to (startTime of previous segment - half of the previous segment duration)
found = true;
}

return false;
});

return segment;
function getSegment(representation, index, requestedTime) {
return getSegmentByTime(representation, requestedTime)
}

function getSegmentByTime(representation, requestedTime) {
Expand Down Expand Up @@ -286,8 +245,7 @@ function TimelineSegmentsGetter(config, isDynamic) {
}

instance = {
getSegmentByIndex,
getSegmentByTime,
getSegment,
getMediaFinishedInformation
};

Expand Down