Skip to content

Commit 06e639e

Browse files
authored
Add dynamic attribute for calls to getAverageThrougput (#3814)
* Add dynamic attribute for calls to throughputHistory.getAverageThroughput * Refactor variable name
1 parent 4b13cda commit 06e639e

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/streaming/MediaPlayer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,9 @@ function MediaPlayer() {
10851085
*/
10861086
function getAverageThroughput(type) {
10871087
const throughputHistory = abrController.getThroughputHistory();
1088-
return throughputHistory ? throughputHistory.getAverageThroughput(type) : 0;
1088+
const isDynamic = playbackController.getIsDynamic();
1089+
1090+
return throughputHistory ? throughputHistory.getAverageThroughput(type, isDynamic) : 0;
10891091
}
10901092

10911093
/**

src/streaming/StreamProcessor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ function StreamProcessor(config) {
834834
let bitrate = null;
835835

836836
if ((realAdaptation === null || (realAdaptation.id !== newRealAdaptation.id)) && type !== Constants.TEXT) {
837-
averageThroughput = abrController.getThroughputHistory().getAverageThroughput(type);
837+
averageThroughput = abrController.getThroughputHistory().getAverageThroughput(type, isDynamic);
838838
bitrate = averageThroughput || abrController.getInitialBitrateFor(type, streamInfo.id);
839839
quality = abrController.getQualityForBitrate(mediaInfo, bitrate, streamInfo.id);
840840
} else {

src/streaming/controllers/AbrController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ function AbrController() {
711711
function _changeQuality(type, oldQuality, newQuality, maxIdx, reason, streamId) {
712712
if (type && streamProcessorDict[streamId] && streamProcessorDict[streamId][type]) {
713713
const streamInfo = streamProcessorDict[streamId][type].getStreamInfo();
714+
const isDynamic = streamInfo && streamInfo.manifestInfo && streamInfo.manifestInfo.isDynamic;
714715
const bufferLevel = dashMetrics.getCurrentBufferLevel(type);
715716
logger.info('Stream ID: ' + streamId + ' [' + type + '] switch from ' + oldQuality + ' to ' + newQuality + '/' + maxIdx + ' (buffer: ' + bufferLevel + ') ' + (reason ? JSON.stringify(reason) : '.'));
716717

@@ -729,7 +730,7 @@ function AbrController() {
729730
},
730731
{ streamId: streamInfo.id, mediaType: type }
731732
);
732-
const bitrate = throughputHistory.getAverageThroughput(type);
733+
const bitrate = throughputHistory.getAverageThroughput(type, isDynamic);
733734
if (!isNaN(bitrate)) {
734735
domStorage.setSavedBitrateSettings(type, bitrate);
735736
}

src/streaming/rules/ThroughputHistory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ function ThroughputHistory(config) {
152152
ewmaObj.totalWeight += weight;
153153
}
154154

155-
function getSampleSize(isThroughput, mediaType, isLive) {
155+
function getSampleSize(isThroughput, mediaType, isDynamic) {
156156
let arr,
157157
sampleSize;
158158

159159
if (isThroughput) {
160160
arr = throughputDict[mediaType];
161-
sampleSize = isLive ? AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_LIVE : AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_VOD;
161+
sampleSize = isDynamic ? AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_LIVE : AVERAGE_THROUGHPUT_SAMPLE_AMOUNT_VOD;
162162
} else {
163163
arr = latencyDict[mediaType];
164164
sampleSize = AVERAGE_LATENCY_SAMPLE_AMOUNT;

src/streaming/rules/abr/InsufficientBufferRule.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function InsufficientBufferRule(config) {
9090
const fragmentDuration = representationInfo.fragmentDuration;
9191
const streamInfo = rulesContext.getStreamInfo();
9292
const streamId = streamInfo ? streamInfo.id : null;
93+
const isDynamic = streamInfo && streamInfo.manifestInfo && streamInfo.manifestInfo.isDynamic;
9394

9495
// Don't ask for a bitrate change if there is not info about buffer state or if fragmentDuration is not defined
9596
if (shouldIgnore(mediaType) || !fragmentDuration) {
@@ -106,7 +107,7 @@ function InsufficientBufferRule(config) {
106107
const throughputHistory = abrController.getThroughputHistory();
107108

108109
const bufferLevel = dashMetrics.getCurrentBufferLevel(mediaType);
109-
const throughput = throughputHistory.getAverageThroughput(mediaType);
110+
const throughput = throughputHistory.getAverageThroughput(mediaType, isDynamic);
110111
const latency = throughputHistory.getAverageLatency(mediaType);
111112
const bitrate = throughput * (bufferLevel / fragmentDuration) * INSUFFICIENT_BUFFER_SAFETY_FACTOR;
112113

0 commit comments

Comments
 (0)