diff --git a/src/streaming/MediaPlayer.js b/src/streaming/MediaPlayer.js index 6ee8404328..1dc68aaace 100644 --- a/src/streaming/MediaPlayer.js +++ b/src/streaming/MediaPlayer.js @@ -1085,7 +1085,9 @@ function MediaPlayer() { */ function getAverageThroughput(type) { const throughputHistory = abrController.getThroughputHistory(); - return throughputHistory ? throughputHistory.getAverageThroughput(type) : 0; + const isDynamic = playbackController.getIsDynamic(); + + return throughputHistory ? throughputHistory.getAverageThroughput(type, isDynamic) : 0; } /** diff --git a/src/streaming/StreamProcessor.js b/src/streaming/StreamProcessor.js index fc1aa4d786..41d6fea7f8 100644 --- a/src/streaming/StreamProcessor.js +++ b/src/streaming/StreamProcessor.js @@ -834,7 +834,7 @@ function StreamProcessor(config) { let bitrate = null; if ((realAdaptation === null || (realAdaptation.id !== newRealAdaptation.id)) && type !== Constants.TEXT) { - averageThroughput = abrController.getThroughputHistory().getAverageThroughput(type); + averageThroughput = abrController.getThroughputHistory().getAverageThroughput(type, isDynamic); bitrate = averageThroughput || abrController.getInitialBitrateFor(type, streamInfo.id); quality = abrController.getQualityForBitrate(mediaInfo, bitrate, streamInfo.id); } else { diff --git a/src/streaming/controllers/AbrController.js b/src/streaming/controllers/AbrController.js index d078e03f69..592256d4de 100644 --- a/src/streaming/controllers/AbrController.js +++ b/src/streaming/controllers/AbrController.js @@ -711,6 +711,7 @@ function AbrController() { function _changeQuality(type, oldQuality, newQuality, maxIdx, reason, streamId) { if (type && streamProcessorDict[streamId] && streamProcessorDict[streamId][type]) { const streamInfo = streamProcessorDict[streamId][type].getStreamInfo(); + const isDynamic = streamInfo && streamInfo.manifestInfo && streamInfo.manifestInfo.isDynamic; const bufferLevel = dashMetrics.getCurrentBufferLevel(type); logger.info('Stream ID: ' + streamId + ' [' + type + '] switch from ' + oldQuality + ' to ' + newQuality + '/' + maxIdx + ' (buffer: ' + bufferLevel + ') ' + (reason ? JSON.stringify(reason) : '.')); @@ -729,7 +730,7 @@ function AbrController() { }, { streamId: streamInfo.id, mediaType: type } ); - const bitrate = throughputHistory.getAverageThroughput(type); + const bitrate = throughputHistory.getAverageThroughput(type, isDynamic); if (!isNaN(bitrate)) { domStorage.setSavedBitrateSettings(type, bitrate); } diff --git a/src/streaming/rules/ThroughputHistory.js b/src/streaming/rules/ThroughputHistory.js index 3f1dbb01a2..ce94350844 100644 --- a/src/streaming/rules/ThroughputHistory.js +++ b/src/streaming/rules/ThroughputHistory.js @@ -152,13 +152,13 @@ function ThroughputHistory(config) { ewmaObj.totalWeight += weight; } - function getSampleSize(isThroughput, mediaType, isLive) { + function getSampleSize(isThroughput, mediaType, isDynamic) { let arr, sampleSize; if (isThroughput) { arr = throughputDict[mediaType]; - sampleSize = isLive ? AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_LIVE : AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_VOD; + sampleSize = isDynamic ? AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_LIVE : AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_VOD; } else { arr = latencyDict[mediaType]; sampleSize = AVERAGE_LATENCY_SAMPLE_AMOUNT; diff --git a/src/streaming/rules/abr/InsufficientBufferRule.js b/src/streaming/rules/abr/InsufficientBufferRule.js index e4f077a6a2..1285e1bde7 100644 --- a/src/streaming/rules/abr/InsufficientBufferRule.js +++ b/src/streaming/rules/abr/InsufficientBufferRule.js @@ -90,6 +90,7 @@ function InsufficientBufferRule(config) { const fragmentDuration = representationInfo.fragmentDuration; const streamInfo = rulesContext.getStreamInfo(); const streamId = streamInfo ? streamInfo.id : null; + const isDynamic = streamInfo && streamInfo.manifestInfo && streamInfo.manifestInfo.isDynamic; // Don't ask for a bitrate change if there is not info about buffer state or if fragmentDuration is not defined if (shouldIgnore(mediaType) || !fragmentDuration) { @@ -106,7 +107,7 @@ function InsufficientBufferRule(config) { const throughputHistory = abrController.getThroughputHistory(); const bufferLevel = dashMetrics.getCurrentBufferLevel(mediaType); - const throughput = throughputHistory.getAverageThroughput(mediaType); + const throughput = throughputHistory.getAverageThroughput(mediaType, isDynamic); const latency = throughputHistory.getAverageLatency(mediaType); const bitrate = throughput * (bufferLevel / fragmentDuration) * INSUFFICIENT_BUFFER_SAFETY_FACTOR;