diff --git a/src/streaming/models/MetricsModel.js b/src/streaming/models/MetricsModel.js index 59ea2989d2..6c315ad842 100644 --- a/src/streaming/models/MetricsModel.js +++ b/src/streaming/models/MetricsModel.js @@ -197,6 +197,7 @@ function MetricsModel(config) { vo._fileLoaderType = request.fileLoaderType; vo._resourceTimingValues = request.resourceTimingValues; vo._streamId = request && request.representation && request.representation.mediaInfo && request.representation.mediaInfo.streamInfo ? request.representation.mediaInfo.streamInfo.id : null; + vo._bandwidthRatio = request && request.bandwidth && request.representation && request.representation.mediaInfo ? request.representation.mediaInfo.bitrateList[request.representation.mediaInfo.bitrateList.length - 1].bandwidth / request.bandwidth : 1; if (traces) { traces.forEach(trace => { diff --git a/src/streaming/models/ThroughputModel.js b/src/streaming/models/ThroughputModel.js index b4d79039ad..294b1822b2 100644 --- a/src/streaming/models/ThroughputModel.js +++ b/src/streaming/models/ThroughputModel.js @@ -106,7 +106,7 @@ function ThroughputModel(config) { } } - const cacheReferenceTime = (httpRequest._tfinish.getTime() - httpRequest.trequest.getTime()); + const cacheReferenceTime = (httpRequest._tfinish.getTime() - httpRequest.trequest.getTime()) * httpRequest._bandwidthRatio; if (_isCachedResponse(mediaType, cacheReferenceTime, httpRequest)) { logger.debug(`${mediaType} Assuming segment ${httpRequest.url} came from cache, ignoring it for throughput calculation`); diff --git a/src/streaming/vo/metrics/HTTPRequest.js b/src/streaming/vo/metrics/HTTPRequest.js index 83da477275..d6d5e57054 100644 --- a/src/streaming/vo/metrics/HTTPRequest.js +++ b/src/streaming/vo/metrics/HTTPRequest.js @@ -141,6 +141,10 @@ class HTTPRequest { * The values derived from the ResourceTimingAPI. */ this._resourceTimingValues = null; + /** + * The ratio of the current representation bandwidth to the top representation bandwidth - used for adjusting cachedetection to bitrate ladder. + */ + this._bandwidthRatio = 1; } } diff --git a/test/unit/test/streaming/streaming.models.ThroughputModel.js b/test/unit/test/streaming/streaming.models.ThroughputModel.js index 00b9894af9..a78e50d809 100644 --- a/test/unit/test/streaming/streaming.models.ThroughputModel.js +++ b/test/unit/test/streaming/streaming.models.ThroughputModel.js @@ -148,6 +148,7 @@ describe('ThroughputModel', () => { } }) dummyHttpRequest._tfinish = dummyHttpRequest.trequest; + dummyHttpRequest._bandwidthRatio = 1; throughputModel.addEntry('video', dummyHttpRequest); const values = throughputModel.getThroughputDict('video');