Skip to content
Snippets Groups Projects
Commit e1393b8d authored by Eloi Bail's avatar Eloi Bail Committed by gerrit2
Browse files

media/video: avoid quality toggling

Based on RTCP information. Video quality was often toggling.
To avoid that, we only allow to decrease quality if a higher quality
was already calculated in of the 5 previous tries.

Tuleap: #158
Change-Id: I9a42a87f7958e4477dbebecc4c24c6a3d000b835
parent ada76ca1
No related branches found
No related tags found
No related merge requests found
...@@ -375,6 +375,7 @@ VideoRtpSession::adaptQualityAndBitrate() ...@@ -375,6 +375,7 @@ VideoRtpSession::adaptQualityAndBitrate()
if (rtcpLongCheckTimer.count() >= RTCP_LONG_CHECKING_INTERVAL) { if (rtcpLongCheckTimer.count() >= RTCP_LONG_CHECKING_INTERVAL) {
needToCheckQuality = true; needToCheckQuality = true;
hasReachMaxQuality_ = false;
lastLongRTCPCheck_ = std::chrono::system_clock::now(); lastLongRTCPCheck_ = std::chrono::system_clock::now();
// we force iterative bitrate adaptation // we force iterative bitrate adaptation
videoBitrateInfo_.cptBitrateChecking = 0; videoBitrateInfo_.cptBitrateChecking = 0;
...@@ -415,12 +416,15 @@ VideoRtpSession::adaptQualityAndBitrate() ...@@ -415,12 +416,15 @@ VideoRtpSession::adaptQualityAndBitrate()
if (((videoBitrateInfo_.videoQualityCurrent != SystemCodecInfo::DEFAULT_NO_QUALITY) && if (((videoBitrateInfo_.videoQualityCurrent != SystemCodecInfo::DEFAULT_NO_QUALITY) &&
(videoBitrateInfo_.videoQualityCurrent != (histoQuality_.empty() ? 0 : histoQuality_.back()))) || (videoBitrateInfo_.videoQualityCurrent != (histoQuality_.empty() ? 0 : histoQuality_.back()))) ||
((videoBitrateInfo_.videoQualityCurrent == SystemCodecInfo::DEFAULT_NO_QUALITY) && ((videoBitrateInfo_.videoQualityCurrent == SystemCodecInfo::DEFAULT_NO_QUALITY) &&
(videoBitrateInfo_.videoBitrateCurrent != (histoBitrate_.empty() ? 0 : histoBitrate_.back())))) (videoBitrateInfo_.videoBitrateCurrent != (histoBitrate_.empty() ? 0 : histoBitrate_.back())))) {
mediaRestartNeeded = true; mediaRestartNeeded = true;
hasReachMaxQuality_ = true;
}
// no packet lost: increase quality and bitrate // no packet lost: increase quality and bitrate
} else if (videoBitrateInfo_.cptBitrateChecking <= videoBitrateInfo_.maxBitrateChecking) { } else if ((videoBitrateInfo_.cptBitrateChecking <= videoBitrateInfo_.maxBitrateChecking)
and not hasReachMaxQuality_) {
// calculate new quality by dichotomie // calculate new quality by dichotomie
videoBitrateInfo_.videoQualityCurrent = videoBitrateInfo_.videoQualityCurrent =
......
...@@ -119,6 +119,7 @@ private: ...@@ -119,6 +119,7 @@ private:
// 5 tries in a row // 5 tries in a row
static constexpr unsigned MAX_ADAPTATIVE_BITRATE_ITERATION {5}; static constexpr unsigned MAX_ADAPTATIVE_BITRATE_ITERATION {5};
bool hasReachMaxQuality_ {false};
// packet loss threshold // packet loss threshold
static constexpr float PACKET_LOSS_THRESHOLD {1.0}; static constexpr float PACKET_LOSS_THRESHOLD {1.0};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment