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

Add dynamic attribute for calls to getAverageThrougput #3814

Merged
merged 2 commits into from
Nov 17, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/streaming/StreamProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/controllers/AbrController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '.'));

Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/rules/ThroughputHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/rules/abr/InsufficientBufferRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down