Clean up of CongestionController.
Removes unused methods and moves out ViERemb to Call. R=pbos@webrtc.org, solenberg@webrtc.org Review URL: https://codereview.webrtc.org/1663413003 . Cr-Commit-Position: refs/heads/master@{#11527}
This commit is contained in:
parent
d1d66bab3d
commit
58c664c13d
@ -67,9 +67,11 @@ struct ConfigHelper {
|
||||
ConfigHelper()
|
||||
: simulated_clock_(123456),
|
||||
call_stats_(&simulated_clock_),
|
||||
congestion_controller_(&process_thread_,
|
||||
congestion_controller_(&simulated_clock_,
|
||||
&process_thread_,
|
||||
&call_stats_,
|
||||
&bitrate_observer_) {
|
||||
&bitrate_observer_,
|
||||
&remote_bitrate_observer_) {
|
||||
using testing::Invoke;
|
||||
|
||||
EXPECT_CALL(voice_engine_,
|
||||
@ -157,6 +159,7 @@ struct ConfigHelper {
|
||||
CallStats call_stats_;
|
||||
PacketRouter packet_router_;
|
||||
testing::NiceMock<MockBitrateObserver> bitrate_observer_;
|
||||
testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
|
||||
testing::NiceMock<MockProcessThread> process_thread_;
|
||||
MockCongestionController congestion_controller_;
|
||||
MockRemoteBitrateEstimator remote_bitrate_estimator_;
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "webrtc/call/congestion_controller.h"
|
||||
#include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller.h"
|
||||
#include "webrtc/modules/pacing/paced_sender.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_estimator.h"
|
||||
#include "webrtc/test/mock_voe_channel_proxy.h"
|
||||
#include "webrtc/test/mock_voice_engine.h"
|
||||
#include "webrtc/video/call_stats.h"
|
||||
@ -51,12 +52,15 @@ const uint32_t kTelephoneEventDuration = 6789;
|
||||
|
||||
struct ConfigHelper {
|
||||
ConfigHelper()
|
||||
: stream_config_(nullptr),
|
||||
call_stats_(Clock::GetRealTimeClock()),
|
||||
: simulated_clock_(123456),
|
||||
stream_config_(nullptr),
|
||||
call_stats_(&simulated_clock_),
|
||||
process_thread_(ProcessThread::Create("AudioTestThread")),
|
||||
congestion_controller_(process_thread_.get(),
|
||||
congestion_controller_(&simulated_clock_,
|
||||
process_thread_.get(),
|
||||
&call_stats_,
|
||||
&bitrate_observer_) {
|
||||
&bitrate_observer_,
|
||||
&remote_bitrate_observer_) {
|
||||
using testing::Invoke;
|
||||
using testing::StrEq;
|
||||
|
||||
@ -153,12 +157,14 @@ struct ConfigHelper {
|
||||
}
|
||||
|
||||
private:
|
||||
SimulatedClock simulated_clock_;
|
||||
testing::StrictMock<MockVoiceEngine> voice_engine_;
|
||||
rtc::scoped_refptr<AudioState> audio_state_;
|
||||
AudioSendStream::Config stream_config_;
|
||||
testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
|
||||
CallStats call_stats_;
|
||||
testing::NiceMock<MockBitrateObserver> bitrate_observer_;
|
||||
testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
|
||||
rtc::scoped_ptr<ProcessThread> process_thread_;
|
||||
CongestionController congestion_controller_;
|
||||
};
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include "webrtc/video/call_stats.h"
|
||||
#include "webrtc/video/video_receive_stream.h"
|
||||
#include "webrtc/video/video_send_stream.h"
|
||||
#include "webrtc/video/vie_remb.h"
|
||||
#include "webrtc/voice_engine/include/voe_codec.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -165,6 +166,7 @@ class Call : public webrtc::Call, public PacketReceiver,
|
||||
int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
|
||||
int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_);
|
||||
|
||||
VieRemb remb_;
|
||||
const rtc::scoped_ptr<CongestionController> congestion_controller_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Call);
|
||||
@ -196,10 +198,13 @@ Call::Call(const Call::Config& config)
|
||||
estimated_send_bitrate_sum_kbits_(0),
|
||||
pacer_bitrate_sum_kbits_(0),
|
||||
num_bitrate_updates_(0),
|
||||
remb_(clock_),
|
||||
congestion_controller_(
|
||||
new CongestionController(module_process_thread_.get(),
|
||||
new CongestionController(clock_,
|
||||
module_process_thread_.get(),
|
||||
call_stats_.get(),
|
||||
this)) {
|
||||
this,
|
||||
&remb_)) {
|
||||
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
||||
RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
|
||||
RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
|
||||
@ -226,6 +231,7 @@ Call::Call(const Call::Config& config)
|
||||
}
|
||||
|
||||
Call::~Call() {
|
||||
RTC_DCHECK(!remb_.InUse());
|
||||
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
||||
UpdateSendHistograms();
|
||||
UpdateReceiveHistograms();
|
||||
@ -379,7 +385,7 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
|
||||
// the call has already started.
|
||||
VideoSendStream* send_stream = new VideoSendStream(
|
||||
num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
|
||||
congestion_controller_.get(), bitrate_allocator_.get(), config,
|
||||
congestion_controller_.get(), &remb_, bitrate_allocator_.get(), config,
|
||||
encoder_config, suspended_video_send_ssrcs_);
|
||||
|
||||
if (!network_enabled_)
|
||||
@ -437,8 +443,8 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
|
||||
TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
|
||||
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
||||
VideoReceiveStream* receive_stream = new VideoReceiveStream(
|
||||
num_cpu_cores_, congestion_controller_.get(), config,
|
||||
voice_engine(), module_process_thread_.get(), call_stats_.get());
|
||||
num_cpu_cores_, congestion_controller_.get(), config, voice_engine(),
|
||||
module_process_thread_.get(), call_stats_.get(), &remb_);
|
||||
|
||||
WriteLockScoped write_lock(*receive_crit_);
|
||||
RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
|
||||
|
||||
@ -10,8 +10,11 @@
|
||||
|
||||
#include "webrtc/call/congestion_controller.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/socket.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
||||
#include "webrtc/modules/pacing/paced_sender.h"
|
||||
@ -21,14 +24,10 @@
|
||||
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/utility/include/process_thread.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/video/call_stats.h"
|
||||
#include "webrtc/video/payload_router.h"
|
||||
#include "webrtc/video/vie_encoder.h"
|
||||
#include "webrtc/video/vie_remb.h"
|
||||
#include "webrtc/voice_engine/include/voe_video_sync.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
@ -131,7 +130,7 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
|
||||
}
|
||||
|
||||
RemoteBitrateObserver* observer_;
|
||||
Clock* clock_;
|
||||
Clock* const clock_;
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
rtc::scoped_ptr<RemoteBitrateEstimator> rbe_;
|
||||
bool using_absolute_send_time_;
|
||||
@ -143,30 +142,31 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
|
||||
|
||||
} // namespace
|
||||
|
||||
CongestionController::CongestionController(ProcessThread* process_thread,
|
||||
CallStats* call_stats,
|
||||
BitrateObserver* bitrate_observer)
|
||||
: remb_(new VieRemb(Clock::GetRealTimeClock())),
|
||||
CongestionController::CongestionController(
|
||||
Clock* clock,
|
||||
ProcessThread* process_thread,
|
||||
CallStats* call_stats,
|
||||
BitrateObserver* bitrate_observer,
|
||||
RemoteBitrateObserver* remote_bitrate_observer)
|
||||
: clock_(clock),
|
||||
packet_router_(new PacketRouter()),
|
||||
pacer_(new PacedSender(Clock::GetRealTimeClock(),
|
||||
pacer_(new PacedSender(clock_,
|
||||
packet_router_.get(),
|
||||
BitrateController::kDefaultStartBitrateKbps,
|
||||
PacedSender::kDefaultPaceMultiplier *
|
||||
BitrateController::kDefaultStartBitrateKbps,
|
||||
0)),
|
||||
remote_bitrate_estimator_(
|
||||
new WrappingBitrateEstimator(remb_.get(), Clock::GetRealTimeClock())),
|
||||
new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
|
||||
remote_estimator_proxy_(
|
||||
new RemoteEstimatorProxy(Clock::GetRealTimeClock(),
|
||||
packet_router_.get())),
|
||||
new RemoteEstimatorProxy(clock_, packet_router_.get())),
|
||||
process_thread_(process_thread),
|
||||
call_stats_(call_stats),
|
||||
pacer_thread_(ProcessThread::Create("PacerThread")),
|
||||
// Constructed last as this object calls the provided callback on
|
||||
// construction.
|
||||
bitrate_controller_(
|
||||
BitrateController::CreateBitrateController(Clock::GetRealTimeClock(),
|
||||
bitrate_observer)),
|
||||
BitrateController::CreateBitrateController(clock_, bitrate_observer)),
|
||||
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {
|
||||
call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get());
|
||||
|
||||
@ -174,8 +174,8 @@ CongestionController::CongestionController(ProcessThread* process_thread,
|
||||
pacer_thread_->RegisterModule(remote_estimator_proxy_.get());
|
||||
pacer_thread_->Start();
|
||||
|
||||
process_thread->RegisterModule(remote_bitrate_estimator_.get());
|
||||
process_thread->RegisterModule(bitrate_controller_.get());
|
||||
process_thread_->RegisterModule(remote_bitrate_estimator_.get());
|
||||
process_thread_->RegisterModule(bitrate_controller_.get());
|
||||
}
|
||||
|
||||
CongestionController::~CongestionController() {
|
||||
@ -187,24 +187,8 @@ CongestionController::~CongestionController() {
|
||||
call_stats_->DeregisterStatsObserver(remote_bitrate_estimator_.get());
|
||||
if (transport_feedback_adapter_.get())
|
||||
call_stats_->DeregisterStatsObserver(transport_feedback_adapter_.get());
|
||||
RTC_DCHECK(!remb_->InUse());
|
||||
RTC_DCHECK(encoders_.empty());
|
||||
}
|
||||
|
||||
void CongestionController::AddEncoder(ViEEncoder* encoder) {
|
||||
rtc::CritScope lock(&encoder_crit_);
|
||||
encoders_.push_back(encoder);
|
||||
}
|
||||
|
||||
void CongestionController::RemoveEncoder(ViEEncoder* encoder) {
|
||||
rtc::CritScope lock(&encoder_crit_);
|
||||
for (auto it = encoders_.begin(); it != encoders_.end(); ++it) {
|
||||
if (*it == encoder) {
|
||||
encoders_.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CongestionController::SetBweBitrates(int min_bitrate_bps,
|
||||
int start_bitrate_bps,
|
||||
@ -237,10 +221,10 @@ TransportFeedbackObserver*
|
||||
CongestionController::GetTransportFeedbackObserver() {
|
||||
if (transport_feedback_adapter_.get() == nullptr) {
|
||||
transport_feedback_adapter_.reset(new TransportFeedbackAdapter(
|
||||
bitrate_controller_.get(), Clock::GetRealTimeClock(), process_thread_));
|
||||
bitrate_controller_.get(), clock_, process_thread_));
|
||||
transport_feedback_adapter_->SetBitrateEstimator(
|
||||
new RemoteBitrateEstimatorAbsSendTime(
|
||||
transport_feedback_adapter_.get(), Clock::GetRealTimeClock()));
|
||||
new RemoteBitrateEstimatorAbsSendTime(transport_feedback_adapter_.get(),
|
||||
clock_));
|
||||
transport_feedback_adapter_->GetBitrateEstimator()->SetMinBitrate(
|
||||
min_bitrate_bps_);
|
||||
call_stats_->RegisterStatsObserver(transport_feedback_adapter_.get());
|
||||
@ -258,23 +242,6 @@ int64_t CongestionController::GetPacerQueuingDelayMs() const {
|
||||
return pacer_->QueueInMs();
|
||||
}
|
||||
|
||||
// TODO(mflodman): Move out of this class.
|
||||
void CongestionController::SetChannelRembStatus(bool sender,
|
||||
bool receiver,
|
||||
RtpRtcp* rtp_module) {
|
||||
rtp_module->SetREMBStatus(sender || receiver);
|
||||
if (sender) {
|
||||
remb_->AddRembSender(rtp_module);
|
||||
} else {
|
||||
remb_->RemoveRembSender(rtp_module);
|
||||
}
|
||||
if (receiver) {
|
||||
remb_->AddReceiveChannel(rtp_module);
|
||||
} else {
|
||||
remb_->RemoveReceiveChannel(rtp_module);
|
||||
}
|
||||
}
|
||||
|
||||
void CongestionController::SignalNetworkState(NetworkState state) {
|
||||
if (state == kNetworkUp) {
|
||||
pacer_->Resume();
|
||||
|
||||
@ -11,46 +11,41 @@
|
||||
#ifndef WEBRTC_CALL_CONGESTION_CONTROLLER_H_
|
||||
#define WEBRTC_CALL_CONGESTION_CONTROLLER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/socket.h"
|
||||
#include "webrtc/stream.h"
|
||||
|
||||
namespace rtc {
|
||||
struct SentPacket;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class BitrateController;
|
||||
class BitrateObserver;
|
||||
class CallStats;
|
||||
class Config;
|
||||
class Clock;
|
||||
class PacedSender;
|
||||
class PacketRouter;
|
||||
class ProcessThread;
|
||||
class RemoteBitrateEstimator;
|
||||
class RemoteBitrateObserver;
|
||||
class RemoteEstimatorProxy;
|
||||
class RtpRtcp;
|
||||
class SendStatisticsProxy;
|
||||
class TransportFeedbackAdapter;
|
||||
class TransportFeedbackObserver;
|
||||
class ViEEncoder;
|
||||
class VieRemb;
|
||||
|
||||
class CongestionController {
|
||||
public:
|
||||
CongestionController(ProcessThread* process_thread, CallStats* call_stats,
|
||||
BitrateObserver* bitrate_observer);
|
||||
CongestionController(Clock* clock,
|
||||
ProcessThread* process_thread,
|
||||
CallStats* call_stats,
|
||||
BitrateObserver* bitrate_observer,
|
||||
RemoteBitrateObserver* remote_bitrate_observer);
|
||||
virtual ~CongestionController();
|
||||
virtual void AddEncoder(ViEEncoder* encoder);
|
||||
virtual void RemoveEncoder(ViEEncoder* encoder);
|
||||
virtual void SetBweBitrates(int min_bitrate_bps,
|
||||
int start_bitrate_bps,
|
||||
int max_bitrate_bps);
|
||||
|
||||
virtual void SetChannelRembStatus(bool sender,
|
||||
bool receiver,
|
||||
RtpRtcp* rtp_module);
|
||||
|
||||
virtual void SignalNetworkState(NetworkState state);
|
||||
|
||||
virtual BitrateController* GetBitrateController() const;
|
||||
@ -68,15 +63,12 @@ class CongestionController {
|
||||
virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<VieRemb> remb_;
|
||||
Clock* const clock_;
|
||||
rtc::scoped_ptr<PacketRouter> packet_router_;
|
||||
rtc::scoped_ptr<PacedSender> pacer_;
|
||||
rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
|
||||
rtc::scoped_ptr<RemoteEstimatorProxy> remote_estimator_proxy_;
|
||||
|
||||
rtc::CriticalSection encoder_crit_;
|
||||
std::vector<ViEEncoder*> encoders_ GUARDED_BY(encoder_crit_);
|
||||
|
||||
// Registered at construct time and assumed to outlive this class.
|
||||
ProcessThread* const process_thread_;
|
||||
CallStats* const call_stats_;
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#define WEBRTC_CALL_MOCK_MOCK_CONGESTION_CONTROLLER_H_
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "webrtc/base/socket.h"
|
||||
#include "webrtc/call/congestion_controller.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -19,18 +20,20 @@ namespace test {
|
||||
|
||||
class MockCongestionController : public CongestionController {
|
||||
public:
|
||||
MockCongestionController(ProcessThread* process_thread,
|
||||
MockCongestionController(Clock* clock,
|
||||
ProcessThread* process_thread,
|
||||
CallStats* call_stats,
|
||||
BitrateObserver* bitrate_observer)
|
||||
: CongestionController(process_thread, call_stats, bitrate_observer) {}
|
||||
MOCK_METHOD1(AddEncoder, void(ViEEncoder* encoder));
|
||||
MOCK_METHOD1(RemoveEncoder, void(ViEEncoder* encoder));
|
||||
BitrateObserver* bitrate_observer,
|
||||
RemoteBitrateObserver* remote_bitrate_observer)
|
||||
: CongestionController(clock,
|
||||
process_thread,
|
||||
call_stats,
|
||||
bitrate_observer,
|
||||
remote_bitrate_observer) {}
|
||||
MOCK_METHOD3(SetBweBitrates,
|
||||
void(int min_bitrate_bps,
|
||||
int start_bitrate_bps,
|
||||
int max_bitrate_bps));
|
||||
MOCK_METHOD3(SetChannelRembStatus,
|
||||
void(bool sender, bool receiver, RtpRtcp* rtp_module));
|
||||
MOCK_METHOD1(SignalNetworkState, void(NetworkState state));
|
||||
MOCK_CONST_METHOD0(GetBitrateController, BitrateController*());
|
||||
MOCK_CONST_METHOD1(GetRemoteBitrateEstimator,
|
||||
|
||||
@ -18,14 +18,19 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class MockRemoteBitrateObserver : public RemoteBitrateObserver {
|
||||
public:
|
||||
MOCK_METHOD2(OnReceiveBitrateChanged,
|
||||
void(const std::vector<uint32_t>& ssrcs, uint32_t bitrate));
|
||||
};
|
||||
|
||||
class MockRemoteBitrateEstimator : public RemoteBitrateEstimator {
|
||||
public:
|
||||
MOCK_METHOD1(IncomingPacketFeedbackVector,
|
||||
void(const std::vector<PacketInfo>&));
|
||||
MOCK_METHOD4(IncomingPacket, void(int64_t, size_t, const RTPHeader&, bool));
|
||||
MOCK_METHOD1(RemoveStream, void(unsigned int));
|
||||
MOCK_CONST_METHOD2(LatestEstimate,
|
||||
bool(std::vector<unsigned int>*, unsigned int*));
|
||||
MOCK_METHOD1(RemoveStream, void(uint32_t));
|
||||
MOCK_CONST_METHOD2(LatestEstimate, bool(std::vector<uint32_t>*, uint32_t*));
|
||||
MOCK_CONST_METHOD1(GetStats, bool(ReceiveBandwidthEstimatorStats*));
|
||||
|
||||
// From CallStatsObserver;
|
||||
|
||||
@ -32,8 +32,8 @@ class RemoteBitrateObserver {
|
||||
public:
|
||||
// Called when a receive channel group has a new bitrate estimate for the
|
||||
// incoming streams.
|
||||
virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) = 0;
|
||||
virtual void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) = 0;
|
||||
|
||||
virtual ~RemoteBitrateObserver() {}
|
||||
};
|
||||
@ -80,13 +80,13 @@ class RemoteBitrateEstimator : public CallStatsObserver, public Module {
|
||||
bool was_paced) = 0;
|
||||
|
||||
// Removes all data for |ssrc|.
|
||||
virtual void RemoveStream(unsigned int ssrc) = 0;
|
||||
virtual void RemoveStream(uint32_t ssrc) = 0;
|
||||
|
||||
// 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.
|
||||
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const = 0;
|
||||
virtual bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
||||
uint32_t* bitrate_bps) const = 0;
|
||||
|
||||
// Returns true if the statistics are available.
|
||||
virtual bool GetStats(ReceiveBandwidthEstimatorStats* output) const = 0;
|
||||
|
||||
@ -371,7 +371,7 @@ void RemoteBitrateEstimatorAbsSendTime::UpdateEstimate(int64_t now_ms) {
|
||||
incoming_bitrate_.Rate(now_ms),
|
||||
estimator_.var_noise());
|
||||
remote_rate_.Update(&input, now_ms);
|
||||
unsigned int target_bitrate = remote_rate_.UpdateBandwidthEstimate(now_ms);
|
||||
uint32_t target_bitrate = remote_rate_.UpdateBandwidthEstimate(now_ms);
|
||||
if (remote_rate_.ValidEstimate()) {
|
||||
process_interval_ms_ = remote_rate_.GetFeedbackInterval();
|
||||
observer_->OnReceiveBitrateChanged(Keys(ssrcs_), target_bitrate);
|
||||
@ -384,14 +384,14 @@ void RemoteBitrateEstimatorAbsSendTime::OnRttUpdate(int64_t avg_rtt_ms,
|
||||
remote_rate_.SetRtt(avg_rtt_ms);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorAbsSendTime::RemoveStream(unsigned int ssrc) {
|
||||
void RemoteBitrateEstimatorAbsSendTime::RemoveStream(uint32_t ssrc) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
ssrcs_.erase(ssrc);
|
||||
}
|
||||
|
||||
bool RemoteBitrateEstimatorAbsSendTime::LatestEstimate(
|
||||
std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const {
|
||||
std::vector<uint32_t>* ssrcs,
|
||||
uint32_t* bitrate_bps) const {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
assert(ssrcs);
|
||||
assert(bitrate_bps);
|
||||
|
||||
@ -83,14 +83,14 @@ class RemoteBitrateEstimatorAbsSendTime : public RemoteBitrateEstimator {
|
||||
int32_t Process() override;
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
||||
void RemoveStream(unsigned int ssrc) override;
|
||||
bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const override;
|
||||
void RemoveStream(uint32_t ssrc) override;
|
||||
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
||||
uint32_t* bitrate_bps) const override;
|
||||
bool GetStats(ReceiveBandwidthEstimatorStats* output) const override;
|
||||
void SetMinBitrate(int min_bitrate_bps) override;
|
||||
|
||||
private:
|
||||
typedef std::map<unsigned int, int64_t> Ssrcs;
|
||||
typedef std::map<uint32_t, int64_t> Ssrcs;
|
||||
|
||||
static bool IsWithinClusterBounds(int send_delta_ms,
|
||||
const Cluster& cluster_aggregate);
|
||||
|
||||
@ -175,10 +175,10 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
incoming_bitrate_.Rate(now_ms),
|
||||
mean_noise_var);
|
||||
remote_rate_->Update(&input, now_ms);
|
||||
unsigned int target_bitrate = remote_rate_->UpdateBandwidthEstimate(now_ms);
|
||||
uint32_t target_bitrate = remote_rate_->UpdateBandwidthEstimate(now_ms);
|
||||
if (remote_rate_->ValidEstimate()) {
|
||||
process_interval_ms_ = remote_rate_->GetFeedbackInterval();
|
||||
std::vector<unsigned int> ssrcs;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
GetSsrcs(&ssrcs);
|
||||
observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate);
|
||||
}
|
||||
@ -200,8 +200,8 @@ void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
|
||||
}
|
||||
|
||||
bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
|
||||
std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const {
|
||||
std::vector<uint32_t>* ssrcs,
|
||||
uint32_t* bitrate_bps) const {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
assert(bitrate_bps);
|
||||
if (!remote_rate_->ValidEstimate()) {
|
||||
@ -222,7 +222,7 @@ bool RemoteBitrateEstimatorSingleStream::GetStats(
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
std::vector<unsigned int>* ssrcs) const {
|
||||
std::vector<uint32_t>* ssrcs) const {
|
||||
assert(ssrcs);
|
||||
ssrcs->resize(overuse_detectors_.size());
|
||||
int i = 0;
|
||||
|
||||
@ -34,22 +34,22 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
int32_t Process() override;
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
||||
void RemoveStream(unsigned int ssrc) override;
|
||||
bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const override;
|
||||
void RemoveStream(uint32_t ssrc) override;
|
||||
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
||||
uint32_t* bitrate_bps) const override;
|
||||
bool GetStats(ReceiveBandwidthEstimatorStats* output) const override;
|
||||
void SetMinBitrate(int min_bitrate_bps) override;
|
||||
|
||||
private:
|
||||
struct Detector;
|
||||
|
||||
typedef std::map<unsigned int, Detector*> SsrcOveruseEstimatorMap;
|
||||
typedef std::map<uint32_t, Detector*> SsrcOveruseEstimatorMap;
|
||||
|
||||
// Triggers a new estimate calculation.
|
||||
void UpdateEstimate(int64_t time_now)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get());
|
||||
|
||||
void GetSsrcs(std::vector<unsigned int>* ssrcs) const
|
||||
void GetSsrcs(std::vector<uint32_t>* ssrcs) const
|
||||
SHARED_LOCKS_REQUIRED(crit_sect_.get());
|
||||
|
||||
Clock* clock_;
|
||||
|
||||
@ -16,21 +16,21 @@
|
||||
namespace webrtc {
|
||||
|
||||
const size_t kMtu = 1200;
|
||||
const unsigned int kAcceptedBitrateErrorBps = 50000;
|
||||
const uint32_t kAcceptedBitrateErrorBps = 50000;
|
||||
|
||||
namespace testing {
|
||||
|
||||
void TestBitrateObserver::OnReceiveBitrateChanged(
|
||||
const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) {
|
||||
latest_bitrate_ = bitrate;
|
||||
updated_ = true;
|
||||
}
|
||||
|
||||
RtpStream::RtpStream(int fps,
|
||||
int bitrate_bps,
|
||||
unsigned int ssrc,
|
||||
unsigned int frequency,
|
||||
uint32_t ssrc,
|
||||
uint32_t frequency,
|
||||
uint32_t timestamp_offset,
|
||||
int64_t rtcp_receive_time)
|
||||
: fps_(fps),
|
||||
@ -104,12 +104,12 @@ int RtpStream::bitrate_bps() const {
|
||||
return bitrate_bps_;
|
||||
}
|
||||
|
||||
unsigned int RtpStream::ssrc() const {
|
||||
uint32_t RtpStream::ssrc() const {
|
||||
return ssrc_;
|
||||
}
|
||||
|
||||
bool RtpStream::Compare(const std::pair<unsigned int, RtpStream*>& left,
|
||||
const std::pair<unsigned int, RtpStream*>& right) {
|
||||
bool RtpStream::Compare(const std::pair<uint32_t, RtpStream*>& left,
|
||||
const std::pair<uint32_t, RtpStream*>& right) {
|
||||
return left.second->next_rtp_time_ < right.second->next_rtp_time_;
|
||||
}
|
||||
|
||||
@ -158,8 +158,7 @@ void StreamGenerator::SetBitrateBps(int bitrate_bps) {
|
||||
}
|
||||
|
||||
// Set the RTP timestamp offset for the stream identified by |ssrc|.
|
||||
void StreamGenerator::set_rtp_timestamp_offset(unsigned int ssrc,
|
||||
uint32_t offset) {
|
||||
void StreamGenerator::set_rtp_timestamp_offset(uint32_t ssrc, uint32_t offset) {
|
||||
streams_[ssrc]->set_rtp_timestamp_offset(offset);
|
||||
}
|
||||
|
||||
@ -216,7 +215,7 @@ uint32_t RemoteBitrateEstimatorTest::AddAbsSendTime(uint32_t t1, uint32_t t2) {
|
||||
return (t1 + t2) & 0x00fffffful;
|
||||
}
|
||||
|
||||
const unsigned int RemoteBitrateEstimatorTest::kDefaultSsrc = 1;
|
||||
const uint32_t RemoteBitrateEstimatorTest::kDefaultSsrc = 1;
|
||||
|
||||
void RemoteBitrateEstimatorTest::IncomingPacket(uint32_t ssrc,
|
||||
size_t payload_size,
|
||||
@ -240,8 +239,8 @@ void RemoteBitrateEstimatorTest::IncomingPacket(uint32_t ssrc,
|
||||
// Returns true if an over-use was seen, false otherwise.
|
||||
// The StreamGenerator::updated() should be used to check for any changes in
|
||||
// target bitrate after the call to this function.
|
||||
bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(unsigned int ssrc,
|
||||
unsigned int bitrate_bps) {
|
||||
bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(uint32_t ssrc,
|
||||
uint32_t bitrate_bps) {
|
||||
stream_generator_->SetBitrateBps(bitrate_bps);
|
||||
testing::RtpStream::PacketList packets;
|
||||
int64_t next_time_us = stream_generator_->GenerateFrame(
|
||||
@ -275,14 +274,13 @@ bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(unsigned int ssrc,
|
||||
// until it reaches |target_bitrate|.
|
||||
// Can for instance be used to run the estimator for some time to get it
|
||||
// into a steady state.
|
||||
unsigned int RemoteBitrateEstimatorTest::SteadyStateRun(
|
||||
unsigned int ssrc,
|
||||
int max_number_of_frames,
|
||||
unsigned int start_bitrate,
|
||||
unsigned int min_bitrate,
|
||||
unsigned int max_bitrate,
|
||||
unsigned int target_bitrate) {
|
||||
unsigned int bitrate_bps = start_bitrate;
|
||||
uint32_t RemoteBitrateEstimatorTest::SteadyStateRun(uint32_t ssrc,
|
||||
int max_number_of_frames,
|
||||
uint32_t start_bitrate,
|
||||
uint32_t min_bitrate,
|
||||
uint32_t max_bitrate,
|
||||
uint32_t target_bitrate) {
|
||||
uint32_t bitrate_bps = start_bitrate;
|
||||
bool bitrate_update_seen = false;
|
||||
// Produce |number_of_frames| frames and give them to the estimator.
|
||||
for (int i = 0; i < max_number_of_frames; ++i) {
|
||||
@ -305,14 +303,14 @@ unsigned int RemoteBitrateEstimatorTest::SteadyStateRun(
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorTest::InitialBehaviorTestHelper(
|
||||
unsigned int expected_converge_bitrate) {
|
||||
uint32_t expected_converge_bitrate) {
|
||||
const int kFramerate = 50; // 50 fps to avoid rounding errors.
|
||||
const int kFrameIntervalMs = 1000 / kFramerate;
|
||||
const uint32_t kFrameIntervalAbsSendTime = AbsSendTime(1, kFramerate);
|
||||
unsigned int bitrate_bps = 0;
|
||||
uint32_t bitrate_bps = 0;
|
||||
uint32_t timestamp = 0;
|
||||
uint32_t absolute_send_time = 0;
|
||||
std::vector<unsigned int> ssrcs;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||
EXPECT_EQ(0u, ssrcs.size());
|
||||
clock_.AdvanceTimeMilliseconds(1000);
|
||||
@ -403,7 +401,7 @@ void RemoteBitrateEstimatorTest::RateIncreaseRtpTimestampsTestHelper(
|
||||
// This threshold corresponds approximately to increasing linearly with
|
||||
// bitrate(i) = 1.04 * bitrate(i-1) + 1000
|
||||
// until bitrate(i) > 500000, with bitrate(1) ~= 30000.
|
||||
unsigned int bitrate_bps = 30000;
|
||||
uint32_t bitrate_bps = 30000;
|
||||
int iterations = 0;
|
||||
AddDefaultStream();
|
||||
// Feed the estimator with a stream of packets and verify that it reaches
|
||||
@ -427,13 +425,13 @@ void RemoteBitrateEstimatorTest::RateIncreaseRtpTimestampsTestHelper(
|
||||
void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
||||
int number_of_streams,
|
||||
bool wrap_time_stamp,
|
||||
unsigned int expected_bitrate_drop_delta) {
|
||||
uint32_t expected_bitrate_drop_delta) {
|
||||
const int kFramerate = 30;
|
||||
const int kStartBitrate = 900e3;
|
||||
const int kMinExpectedBitrate = 800e3;
|
||||
const int kMaxExpectedBitrate = 1100e3;
|
||||
const unsigned int kInitialCapacityBps = 1000e3;
|
||||
const unsigned int kReducedCapacityBps = 500e3;
|
||||
const uint32_t kInitialCapacityBps = 1000e3;
|
||||
const uint32_t kReducedCapacityBps = 500e3;
|
||||
|
||||
int steady_state_time = 0;
|
||||
if (number_of_streams <= 1) {
|
||||
@ -468,12 +466,9 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
||||
|
||||
// Run in steady state to make the estimator converge.
|
||||
stream_generator_->set_capacity_bps(kInitialCapacityBps);
|
||||
unsigned int bitrate_bps = SteadyStateRun(kDefaultSsrc,
|
||||
steady_state_time * kFramerate,
|
||||
kStartBitrate,
|
||||
kMinExpectedBitrate,
|
||||
kMaxExpectedBitrate,
|
||||
kInitialCapacityBps);
|
||||
uint32_t bitrate_bps = SteadyStateRun(
|
||||
kDefaultSsrc, steady_state_time * kFramerate, kStartBitrate,
|
||||
kMinExpectedBitrate, kMaxExpectedBitrate, kInitialCapacityBps);
|
||||
EXPECT_NEAR(kInitialCapacityBps, bitrate_bps, 110000u);
|
||||
bitrate_observer_->Reset();
|
||||
|
||||
@ -498,8 +493,8 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
||||
bitrate_drop_time - overuse_start_time, 33);
|
||||
|
||||
// Remove stream one by one.
|
||||
unsigned int latest_bps = 0;
|
||||
std::vector<unsigned int> ssrcs;
|
||||
uint32_t latest_bps = 0;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
for (int i = 0; i < number_of_streams; i++) {
|
||||
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &latest_bps));
|
||||
EXPECT_EQ(number_of_streams - i, static_cast<int>(ssrcs.size()));
|
||||
@ -646,8 +641,8 @@ void RemoteBitrateEstimatorTest::TestWrappingHelper(
|
||||
kFrameIntervalAbsSendTime);
|
||||
bitrate_estimator_->Process();
|
||||
}
|
||||
unsigned int bitrate_before = 0;
|
||||
std::vector<unsigned int> ssrcs;
|
||||
uint32_t bitrate_before = 0;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_before);
|
||||
|
||||
clock_.AdvanceTimeMilliseconds(silence_time_s * 1000);
|
||||
@ -663,7 +658,7 @@ void RemoteBitrateEstimatorTest::TestWrappingHelper(
|
||||
kFrameIntervalAbsSendTime);
|
||||
bitrate_estimator_->Process();
|
||||
}
|
||||
unsigned int bitrate_after = 0;
|
||||
uint32_t bitrate_after = 0;
|
||||
bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after);
|
||||
EXPECT_LT(bitrate_after, bitrate_before);
|
||||
}
|
||||
|
||||
@ -30,18 +30,18 @@ class TestBitrateObserver : public RemoteBitrateObserver {
|
||||
TestBitrateObserver() : updated_(false), latest_bitrate_(0) {}
|
||||
virtual ~TestBitrateObserver() {}
|
||||
|
||||
void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) override;
|
||||
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) override;
|
||||
|
||||
void Reset() { updated_ = false; }
|
||||
|
||||
bool updated() const { return updated_; }
|
||||
|
||||
unsigned int latest_bitrate() const { return latest_bitrate_; }
|
||||
uint32_t latest_bitrate() const { return latest_bitrate_; }
|
||||
|
||||
private:
|
||||
bool updated_;
|
||||
unsigned int latest_bitrate_;
|
||||
uint32_t latest_bitrate_;
|
||||
};
|
||||
|
||||
class RtpStream {
|
||||
@ -51,22 +51,26 @@ class RtpStream {
|
||||
int64_t arrival_time;
|
||||
uint32_t rtp_timestamp;
|
||||
size_t size;
|
||||
unsigned int ssrc;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
|
||||
struct RtcpPacket {
|
||||
uint32_t ntp_secs;
|
||||
uint32_t ntp_frac;
|
||||
uint32_t timestamp;
|
||||
unsigned int ssrc;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
|
||||
typedef std::list<RtpPacket*> PacketList;
|
||||
|
||||
enum { kSendSideOffsetUs = 1000000 };
|
||||
|
||||
RtpStream(int fps, int bitrate_bps, unsigned int ssrc, unsigned int frequency,
|
||||
uint32_t timestamp_offset, int64_t rtcp_receive_time);
|
||||
RtpStream(int fps,
|
||||
int bitrate_bps,
|
||||
uint32_t ssrc,
|
||||
uint32_t frequency,
|
||||
uint32_t timestamp_offset,
|
||||
int64_t rtcp_receive_time);
|
||||
void set_rtp_timestamp_offset(uint32_t offset);
|
||||
|
||||
// Generates a new frame for this stream. If called too soon after the
|
||||
@ -84,18 +88,18 @@ class RtpStream {
|
||||
|
||||
int bitrate_bps() const;
|
||||
|
||||
unsigned int ssrc() const;
|
||||
uint32_t ssrc() const;
|
||||
|
||||
static bool Compare(const std::pair<unsigned int, RtpStream*>& left,
|
||||
const std::pair<unsigned int, RtpStream*>& right);
|
||||
static bool Compare(const std::pair<uint32_t, RtpStream*>& left,
|
||||
const std::pair<uint32_t, RtpStream*>& right);
|
||||
|
||||
private:
|
||||
enum { kRtcpIntervalUs = 1000000 };
|
||||
|
||||
int fps_;
|
||||
int bitrate_bps_;
|
||||
unsigned int ssrc_;
|
||||
unsigned int frequency_;
|
||||
uint32_t ssrc_;
|
||||
uint32_t frequency_;
|
||||
int64_t next_rtp_time_;
|
||||
int64_t next_rtcp_time_;
|
||||
uint32_t rtp_timestamp_offset_;
|
||||
@ -123,14 +127,14 @@ class StreamGenerator {
|
||||
void SetBitrateBps(int bitrate_bps);
|
||||
|
||||
// Set the RTP timestamp offset for the stream identified by |ssrc|.
|
||||
void set_rtp_timestamp_offset(unsigned int ssrc, uint32_t offset);
|
||||
void set_rtp_timestamp_offset(uint32_t ssrc, uint32_t offset);
|
||||
|
||||
// TODO(holmer): Break out the channel simulation part from this class to make
|
||||
// it possible to simulate different types of channels.
|
||||
int64_t GenerateFrame(RtpStream::PacketList* packets, int64_t time_now_us);
|
||||
|
||||
private:
|
||||
typedef std::map<unsigned int, RtpStream*> StreamMap;
|
||||
typedef std::map<uint32_t, RtpStream*> StreamMap;
|
||||
|
||||
// Capacity of the simulated channel in bits per second.
|
||||
int capacity_;
|
||||
@ -178,18 +182,18 @@ class RemoteBitrateEstimatorTest : public ::testing::Test {
|
||||
// Returns true if an over-use was seen, false otherwise.
|
||||
// The StreamGenerator::updated() should be used to check for any changes in
|
||||
// target bitrate after the call to this function.
|
||||
bool GenerateAndProcessFrame(unsigned int ssrc, unsigned int bitrate_bps);
|
||||
bool GenerateAndProcessFrame(uint32_t ssrc, uint32_t bitrate_bps);
|
||||
|
||||
// Run the bandwidth estimator with a stream of |number_of_frames| frames, or
|
||||
// until it reaches |target_bitrate|.
|
||||
// Can for instance be used to run the estimator for some time to get it
|
||||
// into a steady state.
|
||||
unsigned int SteadyStateRun(unsigned int ssrc,
|
||||
int number_of_frames,
|
||||
unsigned int start_bitrate,
|
||||
unsigned int min_bitrate,
|
||||
unsigned int max_bitrate,
|
||||
unsigned int target_bitrate);
|
||||
uint32_t SteadyStateRun(uint32_t ssrc,
|
||||
int number_of_frames,
|
||||
uint32_t start_bitrate,
|
||||
uint32_t min_bitrate,
|
||||
uint32_t max_bitrate,
|
||||
uint32_t target_bitrate);
|
||||
|
||||
void TestTimestampGroupingTestHelper();
|
||||
|
||||
@ -197,14 +201,14 @@ class RemoteBitrateEstimatorTest : public ::testing::Test {
|
||||
|
||||
void TestWrappingHelper(int silence_time_s);
|
||||
|
||||
void InitialBehaviorTestHelper(unsigned int expected_converge_bitrate);
|
||||
void RateIncreaseReorderingTestHelper(unsigned int expected_bitrate);
|
||||
void InitialBehaviorTestHelper(uint32_t expected_converge_bitrate);
|
||||
void RateIncreaseReorderingTestHelper(uint32_t expected_bitrate);
|
||||
void RateIncreaseRtpTimestampsTestHelper(int expected_iterations);
|
||||
void CapacityDropTestHelper(int number_of_streams,
|
||||
bool wrap_time_stamp,
|
||||
unsigned int expected_bitrate_drop_delta);
|
||||
uint32_t expected_bitrate_drop_delta);
|
||||
|
||||
static const unsigned int kDefaultSsrc;
|
||||
static const uint32_t kDefaultSsrc;
|
||||
static const int kArrivalTimeClockOffsetMs = 60000;
|
||||
|
||||
SimulatedClock clock_; // Time at the receiver.
|
||||
|
||||
@ -128,10 +128,8 @@ FeedbackPacket* RembReceiver::GetFeedback(int64_t now_ms) {
|
||||
return feedback;
|
||||
}
|
||||
|
||||
void RembReceiver::OnReceiveBitrateChanged(
|
||||
const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
}
|
||||
void RembReceiver::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) {}
|
||||
|
||||
RTCPReportBlock RembReceiver::BuildReportBlock(
|
||||
StreamStatistician* statistician) {
|
||||
@ -148,8 +146,8 @@ RTCPReportBlock RembReceiver::BuildReportBlock(
|
||||
|
||||
bool RembReceiver::LatestEstimate(uint32_t* estimate_bps) {
|
||||
if (latest_estimate_bps_ < 0) {
|
||||
std::vector<unsigned int> ssrcs;
|
||||
unsigned int bps = 0;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
uint32_t bps = 0;
|
||||
if (!estimator_->LatestEstimate(&ssrcs, &bps)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,8 +58,8 @@ class RembReceiver : public BweReceiver, public RemoteBitrateObserver {
|
||||
const MediaPacket& media_packet) override;
|
||||
FeedbackPacket* GetFeedback(int64_t now_ms) override;
|
||||
// Implements RemoteBitrateObserver.
|
||||
void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) override;
|
||||
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) override;
|
||||
|
||||
private:
|
||||
static RTCPReportBlock BuildReportBlock(StreamStatistician* statistician);
|
||||
|
||||
@ -101,9 +101,8 @@ void FullBweSender::OnPacketsSent(const Packets& packets) {
|
||||
}
|
||||
}
|
||||
|
||||
void FullBweSender::OnReceiveBitrateChanged(
|
||||
const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
void FullBweSender::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) {
|
||||
feedback_observer_->OnReceivedEstimatedBitrate(bitrate);
|
||||
}
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ class FullBweSender : public BweSender, public RemoteBitrateObserver {
|
||||
int GetFeedbackIntervalMs() const override;
|
||||
void GiveFeedback(const FeedbackPacket& feedback) override;
|
||||
void OnPacketsSent(const Packets& packets) override;
|
||||
void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) override;
|
||||
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) override;
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
int Process() override;
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ class Observer : public webrtc::RemoteBitrateObserver {
|
||||
|
||||
// Called when a receive channel group has a new bitrate estimate for the
|
||||
// incoming streams.
|
||||
virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
virtual void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) {
|
||||
printf("[%u] Num SSRCs: %d, bitrate: %u\n",
|
||||
static_cast<uint32_t>(clock_->TimeInMilliseconds()),
|
||||
static_cast<int>(ssrcs.size()), bitrate);
|
||||
|
||||
@ -122,8 +122,8 @@ void TransportFeedbackAdapter::OnTransportFeedback(
|
||||
}
|
||||
|
||||
void TransportFeedbackAdapter::OnReceiveBitrateChanged(
|
||||
const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) {
|
||||
bitrate_controller_->UpdateDelayBasedEstimate(bitrate);
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,8 @@ class TransportFeedbackAdapter : public TransportFeedbackObserver,
|
||||
}
|
||||
|
||||
private:
|
||||
void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) override;
|
||||
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) override;
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
||||
|
||||
rtc::CriticalSection lock_;
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/video/call_stats.h"
|
||||
#include "webrtc/video/receive_statistics_proxy.h"
|
||||
#include "webrtc/video/vie_remb.h"
|
||||
#include "webrtc/video_receive_stream.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -147,7 +148,8 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
const VideoReceiveStream::Config& config,
|
||||
webrtc::VoiceEngine* voice_engine,
|
||||
ProcessThread* process_thread,
|
||||
CallStats* call_stats)
|
||||
CallStats* call_stats,
|
||||
VieRemb* remb)
|
||||
: transport_adapter_(config.rtcp_send_transport),
|
||||
encoded_frame_proxy_(config.pre_decode_callback),
|
||||
config_(config),
|
||||
@ -155,6 +157,7 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
clock_(Clock::GetRealTimeClock()),
|
||||
congestion_controller_(congestion_controller),
|
||||
call_stats_(call_stats),
|
||||
remb_(remb),
|
||||
vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)),
|
||||
incoming_video_stream_(
|
||||
0,
|
||||
@ -178,6 +181,10 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
rtp_rtcp_(vie_channel_.rtp_rtcp()) {
|
||||
LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
|
||||
|
||||
RTC_DCHECK(process_thread_);
|
||||
RTC_DCHECK(congestion_controller_);
|
||||
RTC_DCHECK(call_stats_);
|
||||
RTC_DCHECK(remb_);
|
||||
RTC_CHECK(vie_channel_.Init() == 0);
|
||||
|
||||
// Register the channel to receive stats updates.
|
||||
@ -210,8 +217,10 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
vie_receiver_->SetUseRtxPayloadMappingOnRestore(
|
||||
config_.rtp.use_rtx_payload_mapping_on_restore);
|
||||
|
||||
congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb,
|
||||
rtp_rtcp_);
|
||||
if (config_.rtp.remb) {
|
||||
rtp_rtcp_->SetREMBStatus(true);
|
||||
remb_->AddReceiveChannel(rtp_rtcp_);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
|
||||
const std::string& extension = config_.rtp.extensions[i].name;
|
||||
@ -304,7 +313,8 @@ VideoReceiveStream::~VideoReceiveStream() {
|
||||
vcm_->RegisterPreDecodeImageCallback(nullptr);
|
||||
|
||||
call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver());
|
||||
congestion_controller_->SetChannelRembStatus(false, false, rtp_rtcp_);
|
||||
rtp_rtcp_->SetREMBStatus(false);
|
||||
remb_->RemoveReceiveChannel(rtp_rtcp_);
|
||||
|
||||
congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_))
|
||||
->RemoveStream(vie_receiver_->GetRemoteSsrc());
|
||||
|
||||
@ -33,6 +33,7 @@ class CallStats;
|
||||
class CongestionController;
|
||||
class ProcessThread;
|
||||
class VoiceEngine;
|
||||
class VieRemb;
|
||||
|
||||
namespace internal {
|
||||
|
||||
@ -46,7 +47,8 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
|
||||
const VideoReceiveStream::Config& config,
|
||||
webrtc::VoiceEngine* voice_engine,
|
||||
ProcessThread* process_thread,
|
||||
CallStats* call_stats);
|
||||
CallStats* call_stats,
|
||||
VieRemb* remb);
|
||||
~VideoReceiveStream() override;
|
||||
|
||||
// webrtc::ReceiveStream implementation.
|
||||
@ -86,6 +88,7 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
|
||||
|
||||
CongestionController* const congestion_controller_;
|
||||
CallStats* const call_stats_;
|
||||
VieRemb* const remb_;
|
||||
|
||||
rtc::scoped_ptr<VideoCodingModule> vcm_;
|
||||
IncomingVideoStream incoming_video_stream_;
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "webrtc/video/video_capture_input.h"
|
||||
#include "webrtc/video/vie_channel.h"
|
||||
#include "webrtc/video/vie_encoder.h"
|
||||
#include "webrtc/video/vie_remb.h"
|
||||
#include "webrtc/video_send_stream.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -125,6 +126,7 @@ VideoSendStream::VideoSendStream(
|
||||
ProcessThread* module_process_thread,
|
||||
CallStats* call_stats,
|
||||
CongestionController* congestion_controller,
|
||||
VieRemb* remb,
|
||||
BitrateAllocator* bitrate_allocator,
|
||||
const VideoSendStream::Config& config,
|
||||
const VideoEncoderConfig& encoder_config,
|
||||
@ -139,6 +141,7 @@ VideoSendStream::VideoSendStream(
|
||||
module_process_thread_(module_process_thread),
|
||||
call_stats_(call_stats),
|
||||
congestion_controller_(congestion_controller),
|
||||
remb_(remb),
|
||||
overuse_detector_(
|
||||
Clock::GetRealTimeClock(),
|
||||
GetCpuOveruseOptions(config.encoder_settings.full_overuse_time),
|
||||
@ -148,7 +151,12 @@ VideoSendStream::VideoSendStream(
|
||||
encoder_feedback_(new EncoderStateFeedback()),
|
||||
use_config_bitrate_(true) {
|
||||
LOG(LS_INFO) << "VideoSendStream: " << config_.ToString();
|
||||
|
||||
RTC_DCHECK(!config_.rtp.ssrcs.empty());
|
||||
RTC_DCHECK(module_process_thread_);
|
||||
RTC_DCHECK(call_stats_);
|
||||
RTC_DCHECK(congestion_controller_);
|
||||
RTC_DCHECK(remb_);
|
||||
|
||||
// Set up Call-wide sequence numbers, if configured for this send stream.
|
||||
TransportFeedbackObserver* transport_feedback_observer = nullptr;
|
||||
@ -206,8 +214,9 @@ VideoSendStream::VideoSendStream(
|
||||
}
|
||||
}
|
||||
|
||||
congestion_controller_->SetChannelRembStatus(true, false,
|
||||
vie_channel_->rtp_rtcp());
|
||||
RtpRtcp* rtp_module = vie_channel_->rtp_rtcp();
|
||||
remb_->AddRembSender(rtp_module);
|
||||
rtp_module->SetREMBStatus(true);
|
||||
|
||||
// Enable NACK, FEC or both.
|
||||
const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0;
|
||||
@ -249,7 +258,6 @@ VideoSendStream::VideoSendStream(
|
||||
if (config_.suspend_below_min_bitrate)
|
||||
vie_encoder_->SuspendBelowMinBitrate();
|
||||
|
||||
congestion_controller_->AddEncoder(vie_encoder_.get());
|
||||
encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get());
|
||||
|
||||
vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_);
|
||||
@ -282,12 +290,13 @@ VideoSendStream::~VideoSendStream() {
|
||||
config_.encoder_settings.payload_type);
|
||||
|
||||
call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver());
|
||||
congestion_controller_->SetChannelRembStatus(false, false,
|
||||
vie_channel_->rtp_rtcp());
|
||||
|
||||
RtpRtcp* rtp_module = vie_channel_->rtp_rtcp();
|
||||
rtp_module->SetREMBStatus(false);
|
||||
remb_->RemoveRembSender(rtp_module);
|
||||
|
||||
// Remove the feedback, stop all encoding threads and processing. This must be
|
||||
// done before deleting the channel.
|
||||
congestion_controller_->RemoveEncoder(vie_encoder_.get());
|
||||
encoder_feedback_->RemoveEncoder(vie_encoder_.get());
|
||||
|
||||
uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC();
|
||||
|
||||
@ -34,6 +34,7 @@ class EncoderStateFeedback;
|
||||
class ProcessThread;
|
||||
class ViEChannel;
|
||||
class ViEEncoder;
|
||||
class VieRemb;
|
||||
|
||||
namespace internal {
|
||||
|
||||
@ -44,6 +45,7 @@ class VideoSendStream : public webrtc::VideoSendStream,
|
||||
ProcessThread* module_process_thread,
|
||||
CallStats* call_stats,
|
||||
CongestionController* congestion_controller,
|
||||
VieRemb* remb,
|
||||
BitrateAllocator* bitrate_allocator,
|
||||
const VideoSendStream::Config& config,
|
||||
const VideoEncoderConfig& encoder_config,
|
||||
@ -86,6 +88,7 @@ class VideoSendStream : public webrtc::VideoSendStream,
|
||||
ProcessThread* const module_process_thread_;
|
||||
CallStats* const call_stats_;
|
||||
CongestionController* const congestion_controller_;
|
||||
VieRemb* const remb_;
|
||||
|
||||
OveruseFrameDetector overuse_detector_;
|
||||
rtc::scoped_ptr<VideoCaptureInput> input_;
|
||||
|
||||
@ -24,7 +24,7 @@ namespace webrtc {
|
||||
const int kRembSendIntervalMs = 200;
|
||||
|
||||
// % threshold for if we should send a new REMB asap.
|
||||
const unsigned int kSendThresholdPercent = 97;
|
||||
const uint32_t kSendThresholdPercent = 97;
|
||||
|
||||
VieRemb::VieRemb(Clock* clock)
|
||||
: clock_(clock),
|
||||
@ -90,15 +90,15 @@ bool VieRemb::InUse() const {
|
||||
return !receive_modules_.empty() || !rtcp_sender_.empty();
|
||||
}
|
||||
|
||||
void VieRemb::OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
void VieRemb::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) {
|
||||
RtpRtcp* sender = NULL;
|
||||
{
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
// 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_ - bitrate_ + bitrate;
|
||||
uint32_t 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
|
||||
|
||||
@ -51,8 +51,8 @@ class VieRemb : public RemoteBitrateObserver {
|
||||
// estimate has decreased or if no RTCP REMB packet has been sent for
|
||||
// a certain time interval.
|
||||
// Implements RtpReceiveBitrateUpdate.
|
||||
virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate);
|
||||
virtual void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate);
|
||||
|
||||
private:
|
||||
typedef std::list<RtpRtcp*> RtpModules;
|
||||
@ -62,7 +62,7 @@ class VieRemb : public RemoteBitrateObserver {
|
||||
|
||||
// The last time a REMB was sent.
|
||||
int64_t last_remb_time_;
|
||||
unsigned int last_send_bitrate_;
|
||||
uint32_t last_send_bitrate_;
|
||||
|
||||
// All RtpRtcp modules to include in the REMB packet.
|
||||
RtpModules receive_modules_;
|
||||
@ -71,7 +71,7 @@ class VieRemb : public RemoteBitrateObserver {
|
||||
RtpModules rtcp_sender_;
|
||||
|
||||
// The last bitrate update.
|
||||
unsigned int bitrate_;
|
||||
uint32_t bitrate_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -48,9 +48,9 @@ TEST_F(ViERembTest, OneModuleTestForSendingRemb) {
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
|
||||
const unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
const uint32_t bitrate_estimate = 456;
|
||||
uint32_t ssrc = 1234;
|
||||
std::vector<uint32_t> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrcs, bitrate_estimate);
|
||||
|
||||
@ -73,9 +73,9 @@ TEST_F(ViERembTest, LowerEstimateToSendRemb) {
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
uint32_t bitrate_estimate = 456;
|
||||
uint32_t ssrc = 1234;
|
||||
std::vector<uint32_t> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrcs, bitrate_estimate);
|
||||
// Call OnReceiveBitrateChanged twice to get a first estimate.
|
||||
@ -99,9 +99,9 @@ TEST_F(ViERembTest, VerifyIncreasingAndDecreasing) {
|
||||
vie_remb_->AddRembSender(&rtp_0);
|
||||
vie_remb_->AddReceiveChannel(&rtp_1);
|
||||
|
||||
unsigned int bitrate_estimate[] = { 456, 789 };
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
uint32_t bitrate_estimate[] = {456, 789};
|
||||
uint32_t ssrc[] = {1234, 5678};
|
||||
std::vector<uint32_t> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrcs, bitrate_estimate[0]);
|
||||
|
||||
@ -130,9 +130,9 @@ TEST_F(ViERembTest, NoRembForIncreasedBitrate) {
|
||||
vie_remb_->AddRembSender(&rtp_0);
|
||||
vie_remb_->AddReceiveChannel(&rtp_1);
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
uint32_t bitrate_estimate = 456;
|
||||
uint32_t ssrc[] = {1234, 5678};
|
||||
std::vector<uint32_t> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrcs, bitrate_estimate);
|
||||
// Call OnReceiveBitrateChanged twice to get a first estimate.
|
||||
@ -164,9 +164,9 @@ TEST_F(ViERembTest, ChangeSendRtpModule) {
|
||||
vie_remb_->AddRembSender(&rtp_0);
|
||||
vie_remb_->AddReceiveChannel(&rtp_1);
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc[] = { 1234, 5678 };
|
||||
std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
uint32_t bitrate_estimate = 456;
|
||||
uint32_t ssrc[] = {1234, 5678};
|
||||
std::vector<uint32_t> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0]));
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrcs, bitrate_estimate);
|
||||
// Call OnReceiveBitrateChanged twice to get a first estimate.
|
||||
@ -198,9 +198,9 @@ TEST_F(ViERembTest, ChangeSendRtpModule) {
|
||||
|
||||
TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) {
|
||||
MockRtpRtcp rtp;
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
uint32_t bitrate_estimate = 456;
|
||||
uint32_t ssrc = 1234;
|
||||
std::vector<uint32_t> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
vie_remb_->AddRembSender(&rtp);
|
||||
@ -231,9 +231,9 @@ TEST_F(ViERembTest, NoSendingRtpModule) {
|
||||
MockRtpRtcp rtp;
|
||||
vie_remb_->AddReceiveChannel(&rtp);
|
||||
|
||||
unsigned int bitrate_estimate = 456;
|
||||
unsigned int ssrc = 1234;
|
||||
std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1);
|
||||
uint32_t bitrate_estimate = 456;
|
||||
uint32_t ssrc = 1234;
|
||||
std::vector<uint32_t> ssrcs(&ssrc, &ssrc + 1);
|
||||
|
||||
vie_remb_->OnReceiveBitrateChanged(ssrcs, bitrate_estimate);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user