Commit e1393b8d authored by Éloi Bail's avatar Éloi Bail Committed by gerrit2

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
......@@ -375,6 +375,7 @@ VideoRtpSession::adaptQualityAndBitrate()
if (rtcpLongCheckTimer.count() >= RTCP_LONG_CHECKING_INTERVAL) {
needToCheckQuality = true;
hasReachMaxQuality_ = false;
lastLongRTCPCheck_ = std::chrono::system_clock::now();
// we force iterative bitrate adaptation
videoBitrateInfo_.cptBitrateChecking = 0;
......@@ -415,12 +416,15 @@ VideoRtpSession::adaptQualityAndBitrate()
if (((videoBitrateInfo_.videoQualityCurrent != SystemCodecInfo::DEFAULT_NO_QUALITY) &&
(videoBitrateInfo_.videoQualityCurrent != (histoQuality_.empty() ? 0 : histoQuality_.back()))) ||
((videoBitrateInfo_.videoQualityCurrent == SystemCodecInfo::DEFAULT_NO_QUALITY) &&
(videoBitrateInfo_.videoBitrateCurrent != (histoBitrate_.empty() ? 0 : histoBitrate_.back()))))
(videoBitrateInfo_.videoBitrateCurrent != (histoBitrate_.empty() ? 0 : histoBitrate_.back())))) {
mediaRestartNeeded = true;
hasReachMaxQuality_ = true;
}
// 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
videoBitrateInfo_.videoQualityCurrent =
......
......@@ -117,9 +117,10 @@ private:
static constexpr unsigned MAX_SIZE_HISTO_QUALITY_ {30};
static constexpr unsigned MAX_SIZE_HISTO_BITRATE_ {100};
//5 tries in a row
// 5 tries in a row
static constexpr unsigned MAX_ADAPTATIVE_BITRATE_ITERATION {5};
//packet loss threshold
bool hasReachMaxQuality_ {false};
// packet loss threshold
static constexpr float PACKET_LOSS_THRESHOLD {1.0};
InterruptedThreadLoop rtcpCheckerThread_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment