Skip to content

Commit

Permalink
Fix regression for representationInfo's segmentDuration (#3284)
Browse files Browse the repository at this point in the history
* Update segmentDuration if not set yet when updating representation info (for example for SegmentTimeline, not set in manifest)

* Update segmentDuration if not set yet when updating representation info (for example for SegmentTimeline, not set in manifest)
  • Loading branch information
Bertrand Berthelot committed Jun 11, 2020
1 parent 3f0b7ef commit 46d4fb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/dash/controllers/RepresentationController.js
Expand Up @@ -38,6 +38,7 @@ function RepresentationController(config) {
const eventBus = config.eventBus;
const events = config.events;
const errors = config.errors;
const indexHandler = config.indexHandler;
const abrController = config.abrController;
const dashMetrics = config.dashMetrics;
const playbackController = config.playbackController;
Expand Down Expand Up @@ -111,6 +112,12 @@ function RepresentationController(config) {
voAvailableRepresentations = availableRepresentations;

currentVoRepresentation = getRepresentationForQuality(quality);

// In case segmentDuration is not set (ex. SegmentTimeline), request a segment to determine the segmentDuration
if (currentVoRepresentation && isNaN(currentVoRepresentation.segmentDuration)) {
indexHandler.getSegmentRequestForTime(null, currentVoRepresentation, 0);
}

realAdaptation = newRealAdaptation;

if (type !== Constants.VIDEO && type !== Constants.AUDIO && type !== Constants.FRAGMENTED_TEXT) {
Expand Down Expand Up @@ -158,6 +165,10 @@ function RepresentationController(config) {
}

function updateRepresentation(representation, isDynamic) {
// In case segmentDuration is not set (ex. SegmentTimeline), request a segment to determine the segmentDuration
if (isNaN(representation.segmentDuration)) {
indexHandler.getSegmentRequestForTime(null, representation, 0);
}
representation.segmentAvailabilityRange = timelineConverter.calcSegmentAvailabilityRange(representation, isDynamic);

if ((representation.segmentAvailabilityRange.end < representation.segmentAvailabilityRange.start) && !representation.useCalculatedLiveEdgeTime) {
Expand Down
4 changes: 1 addition & 3 deletions src/streaming/StreamProcessor.js
Expand Up @@ -138,6 +138,7 @@ function StreamProcessor(config) {
representationController = RepresentationController(context).create({
streamId: streamInfo.id,
type: type,
indexHandler: indexHandler,
abrController: abrController,
dashMetrics: dashMetrics,
playbackController: playbackController,
Expand Down Expand Up @@ -544,9 +545,6 @@ function StreamProcessor(config) {
const quality = chunk.quality;
const currentRepresentation = getRepresentationInfo(quality);

// Update current representation info (to update fragmentDuration for example in case of SegmentTimeline)
scheduleController.setCurrentRepresentation(currentRepresentation);

const voRepresentation = representationController && currentRepresentation ? representationController.getRepresentationForQuality(currentRepresentation.quality) : null;
const eventStreamMedia = adapter.getEventsFor(currentRepresentation.mediaInfo);
const eventStreamTrack = adapter.getEventsFor(currentRepresentation, voRepresentation);
Expand Down

0 comments on commit 46d4fb4

Please sign in to comment.