Move SSRC list to RemoteBitrateEstimator.
BUG=1105 Review URL: https://webrtc-codereview.appspot.com/965027 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3130 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5ac387c4d1
commit
4100b0402e
@ -13,14 +13,16 @@
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class MockRemoteBitrateObserver : public RemoteBitrateObserver {
|
||||
public:
|
||||
MOCK_METHOD1(OnReceiveBitrateChanged,
|
||||
void(unsigned int bitrate));
|
||||
MOCK_METHOD2(OnReceiveBitrateChanged,
|
||||
void(std::vector<unsigned int>* ssrcs, unsigned int bitrate));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_REMOTE_BITRATE_ESTIMATOR_H_
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "common_types.h"
|
||||
#include "typedefs.h"
|
||||
@ -26,7 +27,8 @@ class RemoteBitrateObserver {
|
||||
public:
|
||||
// Called when a receive channel group has a new bitrate estimate for the
|
||||
// incoming streams.
|
||||
virtual void OnReceiveBitrateChanged(unsigned int bitrate) = 0;
|
||||
virtual void OnReceiveBitrateChanged(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int bitrate) = 0;
|
||||
|
||||
virtual ~RemoteBitrateObserver() {}
|
||||
};
|
||||
@ -70,8 +72,9 @@ class RemoteBitrateEstimator {
|
||||
virtual void RemoveStream(unsigned int ssrc) = 0;
|
||||
|
||||
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
|
||||
// estimated payload bitrate in bits per second.
|
||||
virtual bool LatestEstimate(unsigned int ssrc,
|
||||
// estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
|
||||
// currently being received and of which the bitrate estimate is based upon.
|
||||
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const = 0;
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,10 @@ void RemoteBitrateEstimatorMultiStream::IncomingPacket(unsigned int ssrc,
|
||||
uint32_t rtp_timestamp) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
incoming_bitrate_.Update(payload_size, arrival_time);
|
||||
StreamMap::iterator stream_it = streams_.find(ssrc);
|
||||
// Add this stream to the map of streams if it doesn't already exist.
|
||||
std::pair<StreamMap::iterator, bool> stream_insert_result =
|
||||
streams_.insert(std::make_pair(ssrc, synchronization::RtcpList()));
|
||||
synchronization::RtcpList* rtcp_list = &stream_insert_result.first->second;
|
||||
if (initial_ssrc_ == 0) {
|
||||
initial_ssrc_ = ssrc;
|
||||
}
|
||||
@ -94,15 +97,14 @@ void RemoteBitrateEstimatorMultiStream::IncomingPacket(unsigned int ssrc,
|
||||
// mode.
|
||||
return;
|
||||
}
|
||||
} else if (stream_it == streams_.end() || stream_it->second.size() < 2) {
|
||||
} else if (rtcp_list->size() < 2) {
|
||||
// We can't use this stream until we have received two RTCP SR reports.
|
||||
return;
|
||||
}
|
||||
const BandwidthUsage prior_state = overuse_detector_.State();
|
||||
int64_t timestamp_in_ms = -1;
|
||||
if (multi_stream_) {
|
||||
synchronization::RtpToNtpMs(rtp_timestamp, stream_it->second,
|
||||
×tamp_in_ms);
|
||||
synchronization::RtpToNtpMs(rtp_timestamp, *rtcp_list, ×tamp_in_ms);
|
||||
}
|
||||
overuse_detector_.Update(payload_size, timestamp_in_ms, rtp_timestamp,
|
||||
arrival_time);
|
||||
@ -122,7 +124,11 @@ 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(target_bitrate);
|
||||
std::vector<unsigned int> ssrcs;
|
||||
GetSsrcs(&ssrcs);
|
||||
if (!ssrcs.empty()) {
|
||||
observer_->OnReceiveBitrateChanged(&ssrcs, target_bitrate);
|
||||
}
|
||||
}
|
||||
overuse_detector_.SetRateControlRegion(region);
|
||||
}
|
||||
@ -138,21 +144,30 @@ void RemoteBitrateEstimatorMultiStream::RemoveStream(unsigned int ssrc) {
|
||||
}
|
||||
|
||||
bool RemoteBitrateEstimatorMultiStream::LatestEstimate(
|
||||
unsigned int ssrc,
|
||||
std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
assert(bitrate_bps != NULL);
|
||||
assert(bitrate_bps);
|
||||
if (!remote_rate_.ValidEstimate()) {
|
||||
return false;
|
||||
}
|
||||
// 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 (streams_.size() > 0)
|
||||
*bitrate_bps = remote_rate_.LatestEstimate() / streams_.size();
|
||||
GetSsrcs(ssrcs);
|
||||
if (ssrcs->empty())
|
||||
*bitrate_bps = 0;
|
||||
else
|
||||
*bitrate_bps = remote_rate_.LatestEstimate();
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorMultiStream::GetSsrcs(
|
||||
std::vector<unsigned int>* ssrcs) const {
|
||||
assert(ssrcs);
|
||||
ssrcs->resize(streams_.size());
|
||||
int i = 0;
|
||||
for (StreamMap::const_iterator it = streams_.begin(); it != streams_.end();
|
||||
++it, ++i) {
|
||||
(*ssrcs)[i] = it->first;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -62,12 +62,16 @@ class RemoteBitrateEstimatorMultiStream : public RemoteBitrateEstimator {
|
||||
void RemoveStream(unsigned int ssrc);
|
||||
|
||||
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
|
||||
// estimated payload bitrate in bits per second.
|
||||
bool LatestEstimate(unsigned int ssrc, unsigned int* bitrate_bps) const;
|
||||
// estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
|
||||
// currently being received and of which the bitrate estimate is based upon.
|
||||
bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const;
|
||||
|
||||
private:
|
||||
typedef std::map<unsigned int, synchronization::RtcpList> StreamMap;
|
||||
|
||||
void GetSsrcs(std::vector<unsigned int>* ssrcs) const;
|
||||
|
||||
RemoteRateControl remote_rate_;
|
||||
OveruseDetector overuse_detector_;
|
||||
BitRateStats incoming_bitrate_;
|
||||
|
@ -66,7 +66,11 @@ void RemoteBitrateEstimatorSingleStream::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(target_bitrate);
|
||||
std::vector<unsigned int> ssrcs;
|
||||
GetSsrcs(&ssrcs);
|
||||
if (!ssrcs.empty()) {
|
||||
observer_->OnReceiveBitrateChanged(&ssrcs, target_bitrate);
|
||||
}
|
||||
}
|
||||
overuse_detector->SetRateControlRegion(region);
|
||||
}
|
||||
@ -83,20 +87,30 @@ void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
|
||||
}
|
||||
|
||||
bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
|
||||
unsigned int ssrc, unsigned int* bitrate_bps) const {
|
||||
std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
assert(bitrate_bps != NULL);
|
||||
assert(bitrate_bps);
|
||||
if (!remote_rate_.ValidEstimate()) {
|
||||
return false;
|
||||
}
|
||||
// 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
|
||||
GetSsrcs(ssrcs);
|
||||
if (ssrcs->empty())
|
||||
*bitrate_bps = 0;
|
||||
else
|
||||
*bitrate_bps = remote_rate_.LatestEstimate();
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
std::vector<unsigned int>* ssrcs) const {
|
||||
assert(ssrcs);
|
||||
ssrcs->resize(overuse_detectors_.size());
|
||||
int i = 0;
|
||||
for (SsrcOveruseDetectorMap::const_iterator it = overuse_detectors_.begin();
|
||||
it != overuse_detectors_.end(); ++it, ++i) {
|
||||
(*ssrcs)[i] = it->first;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -53,14 +53,17 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
// Removes all data for |ssrc|.
|
||||
void RemoveStream(unsigned int ssrc);
|
||||
|
||||
// Returns true if a valid estimate exists for a stream identified by |ssrc|
|
||||
// and sets |bitrate_bps| to the estimated payload bitrate in bits per
|
||||
// second.
|
||||
bool LatestEstimate(unsigned int ssrc, unsigned int* bitrate_bps) const;
|
||||
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
|
||||
// estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
|
||||
// currently being received and of which the bitrate estimate is based upon.
|
||||
bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const;
|
||||
|
||||
private:
|
||||
typedef std::map<unsigned int, OveruseDetector> SsrcOveruseDetectorMap;
|
||||
|
||||
void GetSsrcs(std::vector<unsigned int>* ssrcs) const;
|
||||
|
||||
const OverUseDetectorOptions& options_;
|
||||
SsrcOveruseDetectorMap overuse_detectors_;
|
||||
BitRateStats incoming_bitrate_;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h"
|
||||
@ -26,16 +26,19 @@ TEST_F(RemoteBitrateEstimatorTest, TestInitialBehavior) {
|
||||
unsigned int bitrate_bps = 0;
|
||||
int64_t time_now = 0;
|
||||
uint32_t timestamp = 0;
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(kDefaultSsrc, &bitrate_bps));
|
||||
std::vector<unsigned int> ssrcs;
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||
EXPECT_EQ(0u, ssrcs.size());
|
||||
bitrate_estimator_->UpdateEstimate(kDefaultSsrc, time_now);
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(kDefaultSsrc, &bitrate_bps));
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||
EXPECT_FALSE(bitrate_observer_->updated());
|
||||
bitrate_observer_->Reset();
|
||||
// Inserting a packet. Still no valid estimate. We need to wait 1 second.
|
||||
bitrate_estimator_->IncomingPacket(kDefaultSsrc, kMtu, time_now,
|
||||
timestamp);
|
||||
bitrate_estimator_->UpdateEstimate(kDefaultSsrc, time_now);
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(kDefaultSsrc, &bitrate_bps));
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||
EXPECT_EQ(0u, ssrcs.size());
|
||||
EXPECT_FALSE(bitrate_observer_->updated());
|
||||
bitrate_observer_->Reset();
|
||||
// Waiting more than one second gives us a valid estimate.
|
||||
@ -46,7 +49,9 @@ TEST_F(RemoteBitrateEstimatorTest, TestInitialBehavior) {
|
||||
timestamp);
|
||||
time_now += 2;
|
||||
bitrate_estimator_->UpdateEstimate(kDefaultSsrc, time_now);
|
||||
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(kDefaultSsrc, &bitrate_bps));
|
||||
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||
EXPECT_EQ(1u, ssrcs.size());
|
||||
EXPECT_EQ(kDefaultSsrc, ssrcs.front());
|
||||
EXPECT_EQ(20607u, bitrate_bps);
|
||||
EXPECT_TRUE(bitrate_observer_->updated());
|
||||
bitrate_observer_->Reset();
|
||||
|
@ -31,7 +31,8 @@ class TestBitrateObserver : public RemoteBitrateObserver {
|
||||
public:
|
||||
TestBitrateObserver() : updated_(false), latest_bitrate_(0) {}
|
||||
|
||||
void OnReceiveBitrateChanged(unsigned int bitrate) {
|
||||
void OnReceiveBitrateChanged(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int bitrate) {
|
||||
latest_bitrate_ = bitrate;
|
||||
updated_ = true;
|
||||
}
|
||||
@ -182,7 +183,7 @@ class RemoteBitrateEstimatorTest : public ::testing::Test {
|
||||
unsigned int min_bitrate,
|
||||
unsigned int max_bitrate);
|
||||
|
||||
static const unsigned int kDefaultSsrc = 1;
|
||||
enum { kDefaultSsrc = 1 };
|
||||
|
||||
double time_now_; // Current time at the receiver.
|
||||
OverUseDetectorOptions over_use_detector_options_;
|
||||
|
@ -230,8 +230,11 @@ WebRtc_Word32 ModuleRtpRtcpImpl::Process() {
|
||||
remote_bitrate_->UpdateEstimate(_rtpReceiver.SSRC(), now);
|
||||
if (TMMBR()) {
|
||||
unsigned int target_bitrate = 0;
|
||||
if (remote_bitrate_->LatestEstimate(_rtpReceiver.SSRC(),
|
||||
&target_bitrate)) {
|
||||
std::vector<unsigned int> ssrcs;
|
||||
if (remote_bitrate_->LatestEstimate(&ssrcs, &target_bitrate)) {
|
||||
if (!ssrcs.empty()) {
|
||||
target_bitrate = target_bitrate / ssrcs.size();
|
||||
}
|
||||
_rtcpSender.SetTargetBitrate(target_bitrate);
|
||||
}
|
||||
}
|
||||
@ -1936,10 +1939,13 @@ void ModuleRtpRtcpImpl::BitrateSent(WebRtc_UWord32* totalRate,
|
||||
int ModuleRtpRtcpImpl::EstimatedReceiveBandwidth(
|
||||
WebRtc_UWord32* available_bandwidth) const {
|
||||
if (remote_bitrate_) {
|
||||
if (!remote_bitrate_->LatestEstimate(_rtpReceiver.SSRC(),
|
||||
available_bandwidth)) {
|
||||
std::vector<unsigned int> ssrcs;
|
||||
if (!remote_bitrate_->LatestEstimate(&ssrcs, available_bandwidth)) {
|
||||
return -1;
|
||||
}
|
||||
if (!ssrcs.empty()) {
|
||||
*available_bandwidth /= ssrcs.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// No bandwidth receive-side bandwidth estimation is connected to this module.
|
||||
|
@ -110,9 +110,11 @@ bool VieRemb::InUse() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void VieRemb::OnReceiveBitrateChanged(unsigned int bitrate) {
|
||||
void VieRemb::OnReceiveBitrateChanged(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int bitrate) {
|
||||
WEBRTC_TRACE(kTraceStream, kTraceVideo, -1,
|
||||
"VieRemb::UpdateBitrateEstimate(bitrate: %u)", bitrate);
|
||||
assert(ssrcs);
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
// If we already have an estimate, check if the new total estimate is below
|
||||
// kSendThresholdPercent of the previous estimate.
|
||||
@ -126,6 +128,8 @@ void VieRemb::OnReceiveBitrateChanged(unsigned int bitrate) {
|
||||
}
|
||||
}
|
||||
bitrate_ = bitrate;
|
||||
ssrcs_.resize(ssrcs->size());
|
||||
std::copy(ssrcs->begin(), ssrcs->end(), ssrcs_.begin());
|
||||
bitrate_update_time_ms_ = TickTime::MillisecondTimestamp();
|
||||
}
|
||||
|
||||
@ -154,22 +158,11 @@ WebRtc_Word32 VieRemb::Process() {
|
||||
bitrate_ = 0;
|
||||
bitrate_update_time_ms_ = -1;
|
||||
}
|
||||
|
||||
if (bitrate_update_time_ms_ == -1 || receive_modules_.empty()) {
|
||||
if (bitrate_update_time_ms_ == -1 || ssrcs_.empty()) {
|
||||
list_crit_->Leave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(mflodman) Use std::vector and change RTP module API.
|
||||
unsigned int* ssrcs = new unsigned int[receive_modules_.size()];
|
||||
|
||||
int idx = 0;
|
||||
RtpModules::iterator rtp_it;
|
||||
for (rtp_it = receive_modules_.begin(); rtp_it != receive_modules_.end();
|
||||
++rtp_it, ++idx) {
|
||||
ssrcs[idx] = (*rtp_it)->RemoteSSRC();
|
||||
}
|
||||
|
||||
// Send a REMB packet.
|
||||
RtpRtcp* sender = NULL;
|
||||
if (!rtcp_sender_.empty()) {
|
||||
@ -186,9 +179,9 @@ WebRtc_Word32 VieRemb::Process() {
|
||||
list_crit_->Leave();
|
||||
|
||||
if (sender) {
|
||||
sender->SetREMBData(bitrate_, receive_modules_.size(), ssrcs);
|
||||
// TODO(holmer): Change RTP module API to take a vector pointer.
|
||||
sender->SetREMBData(bitrate_, ssrcs_.size(), &ssrcs_[0]);
|
||||
}
|
||||
delete [] ssrcs;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,8 @@ class VieRemb : public RemoteBitrateObserver, public Module {
|
||||
// estimate has decreased or if no RTCP REMB packet has been sent for
|
||||
// a certain time interval.
|
||||
// Implements RtpReceiveBitrateUpdate.
|
||||
virtual void OnReceiveBitrateChanged(unsigned int bitrate);
|
||||
virtual void OnReceiveBitrateChanged(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int bitrate);
|
||||
|
||||
// Implements Module.
|
||||
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id);
|
||||
@ -83,6 +84,7 @@ class VieRemb : public RemoteBitrateObserver, public Module {
|
||||
|
||||
// The last bitrate update.
|
||||
unsigned int bitrate_;
|
||||
std::vector<unsigned int> ssrcs_;
|
||||
int64_t bitrate_update_time_ms_;
|
||||
};
|
||||
|
||||
|
@ -55,10 +55,9 @@ TEST_F(ViERembTest, OneModuleTestForSendingRemb) {
|
||||
|
||||
const unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
@ -66,7 +65,7 @@ TEST_F(ViERembTest, OneModuleTestForSendingRemb) {
|
||||
vie_remb_->Process();
|
||||
|
||||
// Lower bitrate to send another REMB packet.
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate - 100);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate - 100);
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate - 100, 1, _))
|
||||
.Times(1);
|
||||
vie_remb_->Process();
|
||||
@ -82,10 +81,9 @@ TEST_F(ViERembTest, LowerEstimateToSendRemb) {
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
// Call process to get a first estimate.
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
@ -97,7 +95,7 @@ TEST_F(ViERembTest, LowerEstimateToSendRemb) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
}
|
||||
|
||||
@ -110,14 +108,9 @@ TEST_F(ViERembTest, VerifyIncreasingAndDecreasing) {
|
||||
|
||||
unsigned int bitrate_estimate[] = { 456, 789 };
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[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]));
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[0]);
|
||||
|
||||
// Call process to get a first estimate.
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[0], 2, _))
|
||||
@ -125,18 +118,12 @@ TEST_F(ViERembTest, VerifyIncreasingAndDecreasing) {
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
vie_remb_->Process();
|
||||
|
||||
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]));
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[1] + 100);
|
||||
|
||||
// Lower the estimate to trigger a callback.
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[1], 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate[1]);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[1]);
|
||||
vie_remb_->Process();
|
||||
|
||||
vie_remb_->RemoveReceiveChannel(&rtp_0);
|
||||
@ -153,15 +140,9 @@ TEST_F(ViERembTest, NoRembForIncreasedBitrate) {
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp_0, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
EXPECT_CALL(rtp_1, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[1]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
// Trigger a first call to have a running state.
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _))
|
||||
@ -169,13 +150,13 @@ TEST_F(ViERembTest, NoRembForIncreasedBitrate) {
|
||||
vie_remb_->Process();
|
||||
|
||||
// Increased estimate shouldn't trigger a callback right away.
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate + 1);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate + 1);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(_, _, _))
|
||||
.Times(0);
|
||||
|
||||
// Decreasing the estimate less than 3% shouldn't trigger a new callback.
|
||||
int lower_estimate = bitrate_estimate * 98 / 100;
|
||||
vie_remb_->OnReceiveBitrateChanged(lower_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, lower_estimate);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(_, _, _))
|
||||
.Times(0);
|
||||
|
||||
@ -194,15 +175,9 @@ TEST_F(ViERembTest, ChangeSendRtpModule) {
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp_0, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[0]));
|
||||
EXPECT_CALL(rtp_1, RemoteSSRC())
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Return(ssrc[1]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
// Call process to get a first estimate.
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _))
|
||||
@ -213,19 +188,19 @@ TEST_F(ViERembTest, ChangeSendRtpModule) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, 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(bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp_1, SetREMBData(bitrate_estimate, 2, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
|
||||
vie_remb_->RemoveReceiveChannel(&rtp_0);
|
||||
@ -236,13 +211,11 @@ TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) {
|
||||
MockRtpRtcp rtp;
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
// Call process to get a first estimate.
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
EXPECT_CALL(rtp, SetREMBData(_, _, _))
|
||||
@ -253,7 +226,7 @@ TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
|
||||
// Call Process again, this should not trigger a new callback.
|
||||
@ -266,8 +239,6 @@ TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) {
|
||||
|
||||
TEST_F(ViERembTest, NoOnReceivedBitrateChangedCall) {
|
||||
MockRtpRtcp rtp;
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(1234));
|
||||
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
@ -290,10 +261,9 @@ TEST_F(ViERembTest, NoSendingRtpModule) {
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
EXPECT_CALL(rtp, RemoteSSRC())
|
||||
.WillRepeatedly(Return(ssrc));
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
|
||||
// Call process to get a first estimate.
|
||||
TickTime::AdvanceFakeClock(1000);
|
||||
@ -305,7 +275,7 @@ TEST_F(ViERembTest, NoSendingRtpModule) {
|
||||
bitrate_estimate = bitrate_estimate - 100;
|
||||
EXPECT_CALL(rtp, SetREMBData(_, _, _))
|
||||
.Times(1);
|
||||
vie_remb_->OnReceiveBitrateChanged(bitrate_estimate);
|
||||
vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate);
|
||||
vie_remb_->Process();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user