Only create ALR detector in PacedSender if deprecated functions are called.

Bug: webrtc:10108
Change-Id: Ic41693c4017b47093fc373547d59b7723493c70d
Reviewed-on: https://webrtc-review.googlesource.com/c/113527
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25937}
This commit is contained in:
Bjorn Terelius 2018-12-07 17:45:41 +01:00 committed by Commit Bot
parent 1d61c430d9
commit a956d498a7
3 changed files with 13 additions and 9 deletions

View File

@ -36,8 +36,7 @@ class MockPacedSender : public PacedSender {
MOCK_CONST_METHOD0(QueueInMs, int64_t());
MOCK_CONST_METHOD0(QueueInPackets, int());
MOCK_CONST_METHOD0(ExpectedQueueTimeMs, int64_t());
MOCK_CONST_METHOD0(GetApplicationLimitedRegionStartTime,
absl::optional<int64_t>());
MOCK_METHOD0(GetApplicationLimitedRegionStartTime, absl::optional<int64_t>());
MOCK_METHOD0(Process, void());
};

View File

@ -47,7 +47,7 @@ PacedSender::PacedSender(const Clock* clock,
RtcEventLog* event_log)
: clock_(clock),
packet_sender_(packet_sender),
alr_detector_(absl::make_unique<AlrDetector>(event_log)),
alr_detector_(),
drain_large_queues_(!field_trial::IsDisabled("WebRTC-Pacer-DrainQueue")),
send_padding_if_silent_(
field_trial::IsEnabled("WebRTC-Pacer-PadInSilence")),
@ -158,6 +158,8 @@ void PacedSender::SetEstimatedBitrate(uint32_t bitrate_bps) {
pacing_bitrate_kbps_ =
std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
pacing_factor_;
if (!alr_detector_)
alr_detector_ = absl::make_unique<AlrDetector>(nullptr /*event_log*/);
alr_detector_->SetEstimatedBitrate(bitrate_bps);
}
@ -214,9 +216,10 @@ int64_t PacedSender::ExpectedQueueTimeMs() const {
pacing_bitrate_kbps_);
}
absl::optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime()
const {
absl::optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime() {
rtc::CritScope cs(&critsect_);
if (!alr_detector_)
alr_detector_ = absl::make_unique<AlrDetector>(nullptr /*event_log*/);
return alr_detector_->GetApplicationLimitedRegionStartTime();
}
@ -295,7 +298,8 @@ void PacedSender::Process() {
size_t bytes_sent = packet_sender_->TimeToSendPadding(1, PacedPacketInfo());
critsect_.Enter();
OnPaddingSent(bytes_sent);
alr_detector_->OnBytesSent(bytes_sent, now_us / 1000);
if (alr_detector_)
alr_detector_->OnBytesSent(bytes_sent, now_us / 1000);
}
if (paused_)
@ -378,7 +382,8 @@ void PacedSender::Process() {
if (!probing_send_failure_)
prober_.ProbeSent(TimeMilliseconds(), bytes_sent);
}
alr_detector_->OnBytesSent(bytes_sent, now_us / 1000);
if (alr_detector_)
alr_detector_->OnBytesSent(bytes_sent, now_us / 1000);
}
void PacedSender::ProcessThreadAttached(ProcessThread* process_thread) {

View File

@ -127,7 +127,7 @@ class PacedSender : public Pacer {
virtual int64_t ExpectedQueueTimeMs() const;
// Deprecated, alr detection will be moved out of the pacer.
virtual absl::optional<int64_t> GetApplicationLimitedRegionStartTime() const;
virtual absl::optional<int64_t> GetApplicationLimitedRegionStartTime();
// Returns the number of milliseconds until the module want a worker thread
// to call Process.
@ -167,7 +167,7 @@ class PacedSender : public Pacer {
const Clock* const clock_;
PacketSender* const packet_sender_;
const std::unique_ptr<AlrDetector> alr_detector_ RTC_PT_GUARDED_BY(critsect_);
std::unique_ptr<AlrDetector> alr_detector_ RTC_PT_GUARDED_BY(critsect_);
const bool drain_large_queues_;
const bool send_padding_if_silent_;