From bd0081df02ed4700429b1ee1a4a97002a2892249 Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Tue, 6 Jun 2023 09:32:27 +0200 Subject: [PATCH] Fix throughput on abort (#4201) * Take account aborted request metrics (for throughput history) --- src/streaming/net/HTTPLoader.js | 22 ++++++++++++++-------- src/streaming/rules/abr/lolp/LoLpRule.js | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/streaming/net/HTTPLoader.js b/src/streaming/net/HTTPLoader.js index dd2c2e5e55..6364cb40db 100644 --- a/src/streaming/net/HTTPLoader.js +++ b/src/streaming/net/HTTPLoader.js @@ -113,6 +113,17 @@ function HTTPLoader(cfg) { throw new Error('config object is not correct or missing'); } + const addHttpRequestMetric = function(success) { + const responseUrl = httpRequest.response ? httpRequest.response.responseURL : null; + const responseStatus = httpRequest.response ? httpRequest.response.status : null; + const responseHeaders = httpRequest.response && httpRequest.response.getAllResponseHeaders ? httpRequest.response.getAllResponseHeaders() : + httpRequest.response ? httpRequest.response.responseHeaders : null; + + const cmsd = responseHeaders && settings.get().streaming.cmsd && settings.get().streaming.cmsd.enabled ? cmsdModel.parseResponseHeaders(responseHeaders, request.mediaType) : null; + + dashMetrics.addHttpRequest(request, responseUrl, responseStatus, responseHeaders, success ? traces : null, cmsd); + } + const handleLoaded = function (success) { needFailureReport = false; @@ -122,14 +133,7 @@ function HTTPLoader(cfg) { request.fileLoaderType = fileLoaderType; if (!request.checkExistenceOnly) { - const responseUrl = httpRequest.response ? httpRequest.response.responseURL : null; - const responseStatus = httpRequest.response ? httpRequest.response.status : null; - const responseHeaders = httpRequest.response && httpRequest.response.getAllResponseHeaders ? httpRequest.response.getAllResponseHeaders() : - httpRequest.response ? httpRequest.response.responseHeaders : null; - - const cmsd = settings.get().streaming.cmsd && settings.get().streaming.cmsd.enabled ? cmsdModel.parseResponseHeaders(responseHeaders, request.mediaType) : null; - - dashMetrics.addHttpRequest(request, responseUrl, responseStatus, responseHeaders, success ? traces : null, cmsd); + addHttpRequestMetric(success); if (request.type === HTTPRequest.MPD_TYPE) { dashMetrics.addManifestUpdate(request); @@ -261,6 +265,8 @@ function HTTPLoader(cfg) { }; const onabort = function () { + addHttpRequestMetric(true); + if (progressTimeout) { clearTimeout(progressTimeout); progressTimeout = null; diff --git a/src/streaming/rules/abr/lolp/LoLpRule.js b/src/streaming/rules/abr/lolp/LoLpRule.js index 52b0e7112a..4564a34377 100644 --- a/src/streaming/rules/abr/lolp/LoLpRule.js +++ b/src/streaming/rules/abr/lolp/LoLpRule.js @@ -145,7 +145,7 @@ function LoLPRule(config) { scheduleController.setTimeToLoadDelay(0); if (switchRequest.quality !== currentQuality) { - console.log('[TgcLearningRule][' + mediaType + '] requesting switch to index: ', switchRequest.quality, 'Average throughput', Math.round(throughput), 'kbps'); + logger.debug('[TgcLearningRule][' + mediaType + '] requesting switch to index: ', switchRequest.quality, 'Average throughput', Math.round(throughput), 'kbps'); } return switchRequest;