Changing the bitrate clamping in BitrateControllerImpl
This CL implements an alternative to the bitrate clamping that is done in BitrateControllerImpl. The default behavior is unchanged, but if the new algorithm is enabled the behavior is as follows: When the new bitrate is lower than the sum of min bitrates, the algorithm will give each observer up to its min bitrate, one observer at a time, until the bitrate budget is depleted. Thus, with this change, some observers may get less than their min bitrate, or even zero. Unit tests are implemented. Also fixing two old lint warnings in the affected files. This change is related to the auto-muter feature. BUG=2436 R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2439005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5007 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
|
||||
#include "webrtc/modules/bitrate_controller/bitrate_controller_impl.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
|
||||
@ -69,13 +70,58 @@ class RtcpBandwidthObserverImpl : public RtcpBandwidthObserver {
|
||||
owner_->OnReceivedRtcpReceiverReport(fraction_lost_aggregate, rtt,
|
||||
total_number_of_packets, now_ms);
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<uint32_t, uint32_t> ssrc_to_last_received_extended_high_seq_num_;
|
||||
BitrateControllerImpl* owner_;
|
||||
};
|
||||
|
||||
BitrateController* BitrateController::CreateBitrateController() {
|
||||
return new BitrateControllerImpl();
|
||||
class BitrateControllerEnforceMinRate : public BitrateControllerImpl {
|
||||
private:
|
||||
void LowRateAllocation(uint32_t bitrate,
|
||||
uint8_t fraction_loss,
|
||||
uint32_t rtt,
|
||||
uint32_t sum_min_bitrates) {
|
||||
// Min bitrate to all observers.
|
||||
BitrateObserverConfList::iterator it;
|
||||
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end();
|
||||
++it) {
|
||||
it->first->OnNetworkChanged(it->second->min_bitrate_, fraction_loss,
|
||||
rtt);
|
||||
}
|
||||
// Set sum of min to current send bitrate.
|
||||
bandwidth_estimation_.SetSendBitrate(sum_min_bitrates);
|
||||
}
|
||||
};
|
||||
|
||||
class BitrateControllerNoEnforceMinRate : public BitrateControllerImpl {
|
||||
private:
|
||||
void LowRateAllocation(uint32_t bitrate,
|
||||
uint8_t fraction_loss,
|
||||
uint32_t rtt,
|
||||
uint32_t sum_min_bitrates) {
|
||||
// Allocate up to |min_bitrate_| to one observer at a time, until
|
||||
// |bitrate| is depleted.
|
||||
uint32_t remainder = bitrate;
|
||||
BitrateObserverConfList::iterator it;
|
||||
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end();
|
||||
++it) {
|
||||
uint32_t allocation = std::min(remainder, it->second->min_bitrate_);
|
||||
it->first->OnNetworkChanged(allocation, fraction_loss, rtt);
|
||||
remainder -= allocation;
|
||||
}
|
||||
// Set |bitrate| to current send bitrate.
|
||||
bandwidth_estimation_.SetSendBitrate(bitrate);
|
||||
}
|
||||
};
|
||||
|
||||
BitrateController* BitrateController::CreateBitrateController(
|
||||
bool enforce_min_bitrate) {
|
||||
if (enforce_min_bitrate) {
|
||||
return new BitrateControllerEnforceMinRate();
|
||||
} else {
|
||||
return new BitrateControllerNoEnforceMinRate();
|
||||
}
|
||||
}
|
||||
|
||||
BitrateControllerImpl::BitrateControllerImpl()
|
||||
@ -201,15 +247,7 @@ void BitrateControllerImpl::OnNetworkChanged(const uint32_t bitrate,
|
||||
sum_min_bitrates += it->second->min_bitrate_;
|
||||
}
|
||||
if (bitrate <= sum_min_bitrates) {
|
||||
// Min bitrate to all observers.
|
||||
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end();
|
||||
++it) {
|
||||
it->first->OnNetworkChanged(it->second->min_bitrate_, fraction_loss,
|
||||
rtt);
|
||||
}
|
||||
// Set sum of min to current send bitrate.
|
||||
bandwidth_estimation_.SetSendBitrate(sum_min_bitrates);
|
||||
return;
|
||||
return LowRateAllocation(bitrate, fraction_loss, rtt, sum_min_bitrates);
|
||||
}
|
||||
uint32_t bitrate_per_observer = (bitrate - sum_min_bitrates) /
|
||||
number_of_observers;
|
||||
@ -248,4 +286,5 @@ void BitrateControllerImpl::OnNetworkChanged(const uint32_t bitrate,
|
||||
bool BitrateControllerImpl::AvailableBandwidth(uint32_t* bandwidth) const {
|
||||
return bandwidth_estimation_.AvailableBandwidth(bandwidth);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user