Move the REMB summation into RemoteBitrateEstimatorSingleStream.
BUG= Review URL: https://webrtc-codereview.appspot.com/891004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2946 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a7d8387bdd
commit
3aece4293a
@ -19,8 +19,8 @@ namespace webrtc {
|
||||
|
||||
class MockRemoteBitrateObserver : public RemoteBitrateObserver {
|
||||
public:
|
||||
MOCK_METHOD2(OnReceiveBitrateChanged,
|
||||
void(unsigned int ssrc, unsigned int bitrate));
|
||||
MOCK_METHOD1(OnReceiveBitrateChanged,
|
||||
void(unsigned int bitrate));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -24,11 +24,9 @@ namespace webrtc {
|
||||
// the incoming streams.
|
||||
class RemoteBitrateObserver {
|
||||
public:
|
||||
// Called when a receive channel has a new bitrate estimate for the incoming
|
||||
// stream.
|
||||
// TODO(holmer): Remove |ssrc| argument and remove SSRC map from VieRemb.
|
||||
virtual void OnReceiveBitrateChanged(unsigned int ssrc,
|
||||
unsigned int bitrate) = 0;
|
||||
// Called when a receive channel group has a new bitrate estimate for the
|
||||
// incoming streams.
|
||||
virtual void OnReceiveBitrateChanged(unsigned int bitrate) = 0;
|
||||
|
||||
virtual ~RemoteBitrateObserver() {}
|
||||
};
|
||||
|
@ -122,7 +122,7 @@ void RemoteBitrateEstimatorMultiStream::UpdateEstimate(unsigned int ssrc,
|
||||
const RateControlRegion region = remote_rate_.Update(&input, time_now);
|
||||
unsigned int target_bitrate = remote_rate_.UpdateBandwidthEstimate(time_now);
|
||||
if (remote_rate_.ValidEstimate()) {
|
||||
observer_->OnReceiveBitrateChanged(1, target_bitrate);
|
||||
observer_->OnReceiveBitrateChanged(target_bitrate);
|
||||
}
|
||||
overuse_detector_.SetRateControlRegion(region);
|
||||
}
|
||||
|
@ -28,19 +28,21 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
SsrcBitrateControlsMap::iterator it = bitrate_controls_.find(ssrc);
|
||||
if (it == bitrate_controls_.end()) {
|
||||
SsrcOveruseDetectorMap::iterator it = overuse_detectors_.find(ssrc);
|
||||
if (it == overuse_detectors_.end()) {
|
||||
// This is a new SSRC. Adding to map.
|
||||
// TODO(holmer): If the channel changes SSRC the old SSRC will still be
|
||||
// around in this map until the channel is deleted. This is OK since the
|
||||
// callback will no longer be called for the old SSRC. This will be
|
||||
// automatically cleaned up when we have one RemoteBitrateEstimator per REMB
|
||||
// group.
|
||||
bitrate_controls_.insert(std::make_pair(ssrc, BitrateControls(options_)));
|
||||
it = bitrate_controls_.find(ssrc);
|
||||
std::pair<SsrcOveruseDetectorMap::iterator, bool> insert_result =
|
||||
overuse_detectors_.insert(std::make_pair(ssrc, OveruseDetector(
|
||||
options_)));
|
||||
it = insert_result.first;
|
||||
}
|
||||
OveruseDetector* overuse_detector = &it->second.overuse_detector;
|
||||
it->second.incoming_bitrate.Update(packet_size, arrival_time);
|
||||
OveruseDetector* overuse_detector = &it->second;
|
||||
incoming_bitrate_.Update(packet_size, arrival_time);
|
||||
const BandwidthUsage prior_state = overuse_detector->State();
|
||||
overuse_detector->Update(packet_size, -1, rtp_timestamp, arrival_time);
|
||||
if (prior_state != overuse_detector->State() &&
|
||||
@ -53,49 +55,47 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
void RemoteBitrateEstimatorSingleStream::UpdateEstimate(unsigned int ssrc,
|
||||
int64_t time_now) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
SsrcBitrateControlsMap::iterator it = bitrate_controls_.find(ssrc);
|
||||
if (it == bitrate_controls_.end()) {
|
||||
SsrcOveruseDetectorMap::iterator it = overuse_detectors_.find(ssrc);
|
||||
if (it == overuse_detectors_.end()) {
|
||||
return;
|
||||
}
|
||||
OveruseDetector* overuse_detector = &it->second.overuse_detector;
|
||||
RemoteRateControl* remote_rate = &it->second.remote_rate;
|
||||
OveruseDetector* overuse_detector = &it->second;
|
||||
const RateControlInput input(overuse_detector->State(),
|
||||
it->second.incoming_bitrate.BitRate(time_now),
|
||||
incoming_bitrate_.BitRate(time_now),
|
||||
overuse_detector->NoiseVar());
|
||||
const RateControlRegion region = remote_rate->Update(&input, time_now);
|
||||
unsigned int target_bitrate = remote_rate->UpdateBandwidthEstimate(time_now);
|
||||
if (remote_rate->ValidEstimate()) {
|
||||
observer_->OnReceiveBitrateChanged(ssrc, target_bitrate);
|
||||
const RateControlRegion region = remote_rate_.Update(&input, time_now);
|
||||
unsigned int target_bitrate = remote_rate_.UpdateBandwidthEstimate(time_now);
|
||||
if (remote_rate_.ValidEstimate()) {
|
||||
observer_->OnReceiveBitrateChanged(target_bitrate);
|
||||
}
|
||||
overuse_detector->SetRateControlRegion(region);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::SetRtt(unsigned int rtt) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
for (SsrcBitrateControlsMap::iterator it = bitrate_controls_.begin();
|
||||
it != bitrate_controls_.end(); ++it) {
|
||||
it->second.remote_rate.SetRtt(rtt);
|
||||
}
|
||||
remote_rate_.SetRtt(rtt);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
// Ignoring the return value which is the number of elements erased.
|
||||
bitrate_controls_.erase(ssrc);
|
||||
overuse_detectors_.erase(ssrc);
|
||||
}
|
||||
|
||||
bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
|
||||
unsigned int ssrc, unsigned int* bitrate_bps) const {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
assert(bitrate_bps != NULL);
|
||||
SsrcBitrateControlsMap::const_iterator it = bitrate_controls_.find(ssrc);
|
||||
if (it == bitrate_controls_.end()) {
|
||||
if (!remote_rate_.ValidEstimate()) {
|
||||
return false;
|
||||
}
|
||||
if (!it->second.remote_rate.ValidEstimate()) {
|
||||
return false;
|
||||
}
|
||||
*bitrate_bps = it->second.remote_rate.LatestEstimate();
|
||||
// TODO(holmer): For now we're returning the estimate bandwidth per stream as
|
||||
// it corresponds better to how the ViE API is designed. Will fix this when
|
||||
// the API changes.
|
||||
if (overuse_detectors_.size() > 0)
|
||||
*bitrate_bps = remote_rate_.LatestEstimate() / overuse_detectors_.size();
|
||||
else
|
||||
*bitrate_bps = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,26 +55,12 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
bool LatestEstimate(unsigned int ssrc, unsigned int* bitrate_bps) const;
|
||||
|
||||
private:
|
||||
struct BitrateControls {
|
||||
explicit BitrateControls(const OverUseDetectorOptions& options)
|
||||
: remote_rate(),
|
||||
overuse_detector(options),
|
||||
incoming_bitrate() {
|
||||
}
|
||||
BitrateControls(const BitrateControls& other)
|
||||
: remote_rate(other.remote_rate),
|
||||
overuse_detector(other.overuse_detector),
|
||||
incoming_bitrate(other.incoming_bitrate) {
|
||||
}
|
||||
RemoteRateControl remote_rate;
|
||||
OveruseDetector overuse_detector;
|
||||
BitRateStats incoming_bitrate;
|
||||
};
|
||||
|
||||
typedef std::map<unsigned int, BitrateControls> SsrcBitrateControlsMap;
|
||||
typedef std::map<unsigned int, OveruseDetector> SsrcOveruseDetectorMap;
|
||||
|
||||
const OverUseDetectorOptions& options_;
|
||||
SsrcBitrateControlsMap bitrate_controls_;
|
||||
SsrcOveruseDetectorMap overuse_detectors_;
|
||||
BitRateStats incoming_bitrate_;
|
||||
RemoteRateControl remote_rate_;
|
||||
RemoteBitrateObserver* observer_;
|
||||
scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ class TestBitrateObserver : public RemoteBitrateObserver {
|
||||
public:
|
||||
TestBitrateObserver() : updated_(false), latest_bitrate_(0) {}
|
||||
|
||||
void OnReceiveBitrateChanged(unsigned int ssrc, unsigned int bitrate) {
|
||||
void OnReceiveBitrateChanged(unsigned int bitrate) {
|
||||
latest_bitrate_ = bitrate;
|
||||
updated_ = true;
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const int kRembSendIntervallMs = 1000;
|
||||
const int kRembTimeOutThresholdMs = 2000;
|
||||
const int kRembSendIntervallMs = 1000;
|
||||
const unsigned int kRembMinimumBitrateKbps = 50;
|
||||
|
||||
// % threshold for if we should send a new REMB asap.
|
||||
@ -32,7 +32,9 @@ VieRemb::VieRemb(ProcessThread* process_thread)
|
||||
: process_thread_(process_thread),
|
||||
list_crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
last_remb_time_(TickTime::MillisecondTimestamp()),
|
||||
last_send_bitrate_(0) {
|
||||
last_send_bitrate_(0),
|
||||
bitrate_(0),
|
||||
bitrate_update_time_ms_(-1) {
|
||||
process_thread->RegisterModule(this);
|
||||
}
|
||||
|
||||
@ -62,7 +64,6 @@ void VieRemb::RemoveReceiveChannel(RtpRtcp* rtp_rtcp) {
|
||||
"VieRemb::RemoveReceiveChannel(%p)", rtp_rtcp);
|
||||
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
unsigned int ssrc = rtp_rtcp->RemoteSSRC();
|
||||
for (RtpModules::iterator it = receive_modules_.begin();
|
||||
it != receive_modules_.end(); ++it) {
|
||||
if ((*it) == rtp_rtcp) {
|
||||
@ -70,7 +71,6 @@ void VieRemb::RemoveReceiveChannel(RtpRtcp* rtp_rtcp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_time_bitrates_.erase(ssrc);
|
||||
}
|
||||
|
||||
void VieRemb::AddRembSender(RtpRtcp* rtp_rtcp) {
|
||||
@ -110,23 +110,14 @@ bool VieRemb::InUse() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void VieRemb::OnReceiveBitrateChanged(unsigned int ssrc, unsigned int bitrate) {
|
||||
void VieRemb::OnReceiveBitrateChanged(unsigned int bitrate) {
|
||||
WEBRTC_TRACE(kTraceStream, kTraceVideo, -1,
|
||||
"VieRemb::UpdateBitrateEstimate(ssrc: %u, bitrate: %u)",
|
||||
ssrc, bitrate);
|
||||
"VieRemb::UpdateBitrateEstimate(bitrate: %u)", bitrate);
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
|
||||
// Check if this is a new ssrc and add it to the map if it is.
|
||||
if (update_time_bitrates_.find(ssrc) == update_time_bitrates_.end()) {
|
||||
update_time_bitrates_[ssrc] = std::make_pair(
|
||||
TickTime::MillisecondTimestamp(), bitrate);
|
||||
}
|
||||
|
||||
// If we already have an estimate, check if the new total estimate is below
|
||||
// kSendThresholdPercent of the previous estimate.
|
||||
if (last_send_bitrate_ > 0) {
|
||||
unsigned int new_remb_bitrate = last_send_bitrate_ -
|
||||
update_time_bitrates_[ssrc].second + bitrate;
|
||||
unsigned int new_remb_bitrate = last_send_bitrate_ - bitrate_ + bitrate;
|
||||
|
||||
if (new_remb_bitrate < kSendThresholdPercent * last_send_bitrate_ / 100) {
|
||||
// The new bitrate estimate is less than kSendThresholdPercent % of the
|
||||
@ -134,8 +125,8 @@ void VieRemb::OnReceiveBitrateChanged(unsigned int ssrc, unsigned int bitrate) {
|
||||
last_remb_time_ = TickTime::MillisecondTimestamp() - kRembSendIntervallMs;
|
||||
}
|
||||
}
|
||||
update_time_bitrates_[ssrc] = std::make_pair(
|
||||
TickTime::MillisecondTimestamp(), bitrate);
|
||||
bitrate_ = bitrate;
|
||||
bitrate_update_time_ms_ = TickTime::MillisecondTimestamp();
|
||||
}
|
||||
|
||||
WebRtc_Word32 VieRemb::ChangeUniqueId(const WebRtc_Word32 id) {
|
||||
@ -157,20 +148,14 @@ WebRtc_Word32 VieRemb::Process() {
|
||||
// Calculate total receive bitrate estimate.
|
||||
list_crit_->Enter();
|
||||
|
||||
// Remove any timed out estimates.
|
||||
SsrcTimeBitrate::iterator it = update_time_bitrates_.begin();
|
||||
while (it != update_time_bitrates_.end()) {
|
||||
if (TickTime::MillisecondTimestamp() - it->second.first >
|
||||
// Reset the estimate if it has timed out.
|
||||
if (TickTime::MillisecondTimestamp() - bitrate_update_time_ms_ >
|
||||
kRembTimeOutThresholdMs) {
|
||||
update_time_bitrates_.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
bitrate_ = 0;
|
||||
bitrate_update_time_ms_ = -1;
|
||||
}
|
||||
|
||||
int num_bitrates = update_time_bitrates_.size();
|
||||
|
||||
if (num_bitrates == 0 || receive_modules_.empty()) {
|
||||
if (bitrate_update_time_ms_ == -1 || receive_modules_.empty()) {
|
||||
list_crit_->Leave();
|
||||
return 0;
|
||||
}
|
||||
@ -178,12 +163,6 @@ WebRtc_Word32 VieRemb::Process() {
|
||||
// TODO(mflodman) Use std::vector and change RTP module API.
|
||||
unsigned int* ssrcs = new unsigned int[receive_modules_.size()];
|
||||
|
||||
unsigned int total_bitrate = 0;
|
||||
for (it = update_time_bitrates_.begin(); it != update_time_bitrates_.end();
|
||||
++it) {
|
||||
total_bitrate += it->second.second;
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
RtpModules::iterator rtp_it;
|
||||
for (rtp_it = receive_modules_.begin(); rtp_it != receive_modules_.end();
|
||||
@ -198,7 +177,7 @@ WebRtc_Word32 VieRemb::Process() {
|
||||
} else {
|
||||
sender = receive_modules_.front();
|
||||
}
|
||||
last_send_bitrate_ = total_bitrate;
|
||||
last_send_bitrate_ = bitrate_;
|
||||
|
||||
// Never send a REMB lower than last_send_bitrate_.
|
||||
if (last_send_bitrate_ < kRembMinimumBitrateKbps) {
|
||||
@ -207,7 +186,7 @@ WebRtc_Word32 VieRemb::Process() {
|
||||
list_crit_->Leave();
|
||||
|
||||
if (sender) {
|
||||
sender->SetREMBData(total_bitrate, num_bitrates, ssrcs);
|
||||
sender->SetREMBData(bitrate_, receive_modules_.size(), ssrcs);
|
||||
}
|
||||
delete [] ssrcs;
|
||||
return 0;
|
||||
|
@ -53,12 +53,12 @@ class VieRemb : public RemoteBitrateObserver, public Module {
|
||||
// Returns true if the instance is in use, false otherwise.
|
||||
bool InUse() const;
|
||||
|
||||
// Called every time there is a new bitrate estimate for the received stream
|
||||
// with given SSRC. This call will trigger a new RTCP REMB packet if the
|
||||
// bitrate estimate has decreased or if no RTCP REMB packet has been sent for
|
||||
// Called every time there is a new bitrate estimate for a receive channel
|
||||
// group. This call will trigger a new RTCP REMB packet if the bitrate
|
||||
// estimate has decreased or if no RTCP REMB packet has been sent for
|
||||
// a certain time interval.
|
||||
// Implements RtpReceiveBitrateUpdate.
|
||||
virtual void OnReceiveBitrateChanged(unsigned int ssrc, unsigned int bitrate);
|
||||
virtual void OnReceiveBitrateChanged(unsigned int bitrate);
|
||||
|
||||
// Implements Module.
|
||||
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id);
|
||||
@ -67,8 +67,6 @@ class VieRemb : public RemoteBitrateObserver, public Module {
|
||||
|
||||
private:
|
||||
typedef std::list<RtpRtcp*> RtpModules;
|
||||
typedef std::map<unsigned int, std::pair<int64_t, unsigned int> >
|
||||
SsrcTimeBitrate;
|
||||
|
||||
ProcessThread* process_thread_;
|
||||
scoped_ptr<CriticalSectionWrapper> list_crit_;
|
||||
@ -83,8 +81,9 @@ class VieRemb : public RemoteBitrateObserver, public Module {
|
||||
// All modules that can send REMB RTCP.
|
||||
RtpModules rtcp_sender_;
|
||||
|
||||
// The last bitrate update for each SSRC.
|
||||
SsrcTimeBitrate update_time_bitrates_;
|
||||
// The last bitrate update.
|
||||
unsigned int bitrate_;
|
||||
int64_t bitrate_update_time_ms_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -55,11 +55,11 @@ TEST_F(ViERembTest, OneModuleTestForSendingRemb) {
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
|
||||
const unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234 };
|
||||
unsigned int ssrc = 1234;
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
|
||||
// TODO(mflodman) Add fake clock and remove the lowered bitrate below.
|
||||
SleepMs(1010);
|
||||
@ -68,7 +68,7 @@ TEST_F(ViERembTest, OneModuleTestForSendingRemb) {
|
||||
vie_remb_->Process();
|
||||
|
||||
// Lower bitrate to send another REMB packet.
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate - 100);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate - 100);
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate - 100, 1, _))
|
||||
.Times(1);
|
||||
vie_remb_->Process();
|
||||
@ -83,11 +83,11 @@ TEST_F(ViERembTest, LowerEstimateToSendRemb) {
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234 };
|
||||
unsigned int ssrc = 1234;
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
// Call process to get a first estimate.
|
||||
SleepMs(1010);
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
@ -99,11 +99,11 @@ TEST_F(ViERembTest, LowerEstimateToSendRemb) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
}
|
||||
|
||||
TEST_F(ViERembTest, VerifyCombinedBitrateEstimate) {
|
||||
TEST_F(ViERembTest, VerifyIncreasingAndDecreasing) {
|
||||
MockRtpRtcp rtp_0;
|
||||
MockRtpRtcp rtp_1;
|
||||
vie_remb_->AddReceiveChannel(&rtp_0);
|
||||
@ -113,27 +113,32 @@ TEST_F(ViERembTest, VerifyCombinedBitrateEstimate) {
|
||||
unsigned int bitrate_estimate[] = { 456, 789 };
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate[0]);
|
||||
EXPECT_CALL(rtp_0, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
EXPECT_CALL(rtp_1, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[1]));
|
||||
|
||||
// Call process to get a first estimate.
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[0], 1, _))
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[0], 2, _))
|
||||
.Times(1);
|
||||
SleepMs(1010);
|
||||
vie_remb_->Process();
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[1], bitrate_estimate[1] + 100);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate[1] + 100);
|
||||
EXPECT_CALL(rtp_0, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
EXPECT_CALL(rtp_1, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[1]));
|
||||
|
||||
// Lower the estimate to trigger a callback.
|
||||
int total_bitrate = bitrate_estimate[0] + bitrate_estimate[1];
|
||||
EXPECT_CALL(rtp_0, SetREMBData(total_bitrate, 2, _))
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[1], 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[1], bitrate_estimate[1]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate[1]);
|
||||
vie_remb_->Process();
|
||||
|
||||
vie_remb_->RemoveReceiveChannel(&rtp_0);
|
||||
@ -148,15 +153,13 @@ TEST_F(ViERembTest, NoRembForIncreasedBitrate) {
|
||||
vie_remb_->AddRembSender(&rtp_0);
|
||||
vie_remb_->AddReceiveChannel(&rtp_1);
|
||||
|
||||
unsigned int bitrate_estimate[] = { 456, 789 };
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp_0, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[1], bitrate_estimate[1]);
|
||||
EXPECT_CALL(rtp_1, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[1]));
|
||||
@ -164,19 +167,18 @@ TEST_F(ViERembTest, NoRembForIncreasedBitrate) {
|
||||
// Trigger a first call to have a running state.
|
||||
// TODO(mflodman) Add fake clock.
|
||||
SleepMs(1010);
|
||||
EXPECT_CALL(rtp_0,
|
||||
SetREMBData(bitrate_estimate[0] + bitrate_estimate[1], 2, _))
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->Process();
|
||||
|
||||
// Increased estimate shouldn't trigger a callback right away.
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0] + 1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate + 1);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(_, _, _))
|
||||
.Times(0);
|
||||
|
||||
// Decresing the estimate less than 3% shouldn't trigger a new callback.
|
||||
int lower_estimate = bitrate_estimate[0] * 98 / 100;
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], lower_estimate);
|
||||
// Decreasing the estimate less than 3% shouldn't trigger a new callback.
|
||||
int lower_estimate = bitrate_estimate * 98 / 100;
|
||||
vie_remb_->OnReceiveBitrateChanged(lower_estimate);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(_, _, _))
|
||||
.Times(0);
|
||||
|
||||
@ -193,45 +195,40 @@ TEST_F(ViERembTest, ChangeSendRtpModule) {
|
||||
vie_remb_->AddRembSender(&rtp_0);
|
||||
vie_remb_->AddReceiveChannel(&rtp_1);
|
||||
|
||||
unsigned int bitrate_estimate[] = { 456, 789 };
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp_0, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[1], bitrate_estimate[1]);
|
||||
EXPECT_CALL(rtp_1, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[1]));
|
||||
|
||||
// Call process to get a first estimate.
|
||||
SleepMs(1010);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[0] + bitrate_estimate[1], 2,
|
||||
_))
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->Process();
|
||||
|
||||
// Decrease estimate to trigger a REMB.
|
||||
bitrate_estimate[0] = bitrate_estimate[0] - 100;
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[0] + bitrate_estimate[1], 2,
|
||||
_))
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
|
||||
// Remove the sending module, add it again -> should get remb on the second
|
||||
// module.
|
||||
vie_remb_->RemoveRembSender(&rtp_0);
|
||||
vie_remb_->AddRembSender(&rtp_1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
|
||||
bitrate_estimate[1] = bitrate_estimate[1] - 100;
|
||||
EXPECT_CALL(rtp_1, SetREMBData(bitrate_estimate[0] + bitrate_estimate[1], 2,
|
||||
_))
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp_1, SetREMBData(bitrate_estimate, 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[1], bitrate_estimate[1]);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
|
||||
vie_remb_->RemoveReceiveChannel(&rtp_0);
|
||||
@ -241,13 +238,13 @@ TEST_F(ViERembTest, ChangeSendRtpModule) {
|
||||
TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) {
|
||||
MockRtpRtcp rtp;
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234 };
|
||||
unsigned int ssrc = 1234;
|
||||
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
|
||||
// Call process to get a first estimate.
|
||||
SleepMs(1010);
|
||||
@ -259,7 +256,7 @@ TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
|
||||
// Call Process again, this should not trigger a new callback.
|
||||
@ -295,11 +292,11 @@ TEST_F(ViERembTest, NoSendingRtpModule) {
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234 };
|
||||
unsigned int ssrc = 1234;
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
|
||||
// Call process to get a first estimate.
|
||||
SleepMs(1010);
|
||||
@ -311,7 +308,7 @@ TEST_F(ViERembTest, NoSendingRtpModule) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp, SetREMBData(_, _, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user