Injecting Clock into BitrateAllocator.

Bug: webrtc:10365
Change-Id: I9b722f09a25b3ec0f2899f1c83eae5a4648b6965
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125188
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26952}
This commit is contained in:
Sebastian Jansson 2019-03-04 17:05:12 +01:00 committed by Commit Bot
parent d0f3d84620
commit da6806c204
5 changed files with 13 additions and 8 deletions

View File

@ -28,6 +28,7 @@
#include "modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h"
#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
#include "rtc_base/task_queue.h"
#include "system_wrappers/include/clock.h"
#include "test/field_trial.h"
#include "test/gtest.h"
#include "test/mock_audio_encoder.h"
@ -125,9 +126,10 @@ rtc::scoped_refptr<MockAudioEncoderFactory> SetupEncoderFactoryMock() {
struct ConfigHelper {
ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call)
: stream_config_(/*send_transport=*/nullptr, /*media_transport=*/nullptr),
: clock_(1000000),
stream_config_(/*send_transport=*/nullptr, /*media_transport=*/nullptr),
audio_processing_(new rtc::RefCountedObject<MockAudioProcessing>()),
bitrate_allocator_(&limit_observer_),
bitrate_allocator_(&clock_, &limit_observer_),
worker_queue_("ConfigHelper_worker_queue"),
audio_encoder_(nullptr) {
using testing::Invoke;
@ -283,6 +285,7 @@ struct ConfigHelper {
}
private:
SimulatedClock clock_;
rtc::scoped_refptr<AudioState> audio_state_;
AudioSendStream::Config stream_config_;
testing::StrictMock<MockChannelSend>* channel_send_ = nullptr;

View File

@ -51,7 +51,7 @@ double MediaRatio(uint32_t allocated_bitrate, uint32_t protection_bitrate) {
} // namespace
BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer)
BitrateAllocator::BitrateAllocator(Clock* clock, LimitObserver* limit_observer)
: limit_observer_(limit_observer),
last_target_bps_(0),
last_link_capacity_bps_(0),
@ -60,7 +60,7 @@ BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer)
last_rtt_(0),
last_bwe_period_ms_(1000),
num_pause_events_(0),
clock_(Clock::GetRealTimeClock()),
clock_(clock),
last_bwe_log_time_(0),
total_requested_padding_bitrate_(0),
total_requested_min_bitrate_(0),

View File

@ -90,7 +90,7 @@ class BitrateAllocator : public BitrateAllocatorInterface {
virtual ~LimitObserver() = default;
};
explicit BitrateAllocator(LimitObserver* limit_observer);
BitrateAllocator(Clock* clock, LimitObserver* limit_observer);
~BitrateAllocator() override;
void UpdateStartRate(uint32_t start_rate_bps);

View File

@ -87,7 +87,8 @@ const double kDefaultBitratePriority = 1.0;
class BitrateAllocatorTest : public ::testing::Test {
protected:
BitrateAllocatorTest()
: allocator_(new BitrateAllocatorForTest(&limit_observer_)) {
: allocator_(new BitrateAllocatorForTest(Clock::GetRealTimeClock(),
&limit_observer_)) {
allocator_->OnNetworkChanged(300000u, 0, 0, kDefaultProbingIntervalMs);
}
~BitrateAllocatorTest() {}
@ -267,7 +268,8 @@ TEST_F(BitrateAllocatorTest, RemoveObserverTriggersLimitObserver) {
class BitrateAllocatorTestNoEnforceMin : public ::testing::Test {
protected:
BitrateAllocatorTestNoEnforceMin()
: allocator_(new BitrateAllocatorForTest(&limit_observer_)) {
: allocator_(new BitrateAllocatorForTest(Clock::GetRealTimeClock(),
&limit_observer_)) {
allocator_->OnNetworkChanged(300000u, 0, 0, kDefaultProbingIntervalMs);
}
~BitrateAllocatorTestNoEnforceMin() {}

View File

@ -454,7 +454,7 @@ Call::Call(const Call::Config& config,
num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
module_process_thread_(std::move(module_process_thread)),
call_stats_(new CallStats(clock_, module_process_thread_.get())),
bitrate_allocator_(new BitrateAllocator(this)),
bitrate_allocator_(new BitrateAllocator(clock_, this)),
config_(config),
audio_network_state_(kNetworkDown),
video_network_state_(kNetworkDown),