Adds ability to delay pacer start until media is added.
This avoids the pacer thread waking up at 5ms interval if a PeerConnection is created without actually using media. The TaskQueuePacedSender solves the problem too, this CL is mostly a safeguard in case we still find issues when turning it on... Can be turned off by setting field trial "WebRTC-LazyPacerStart" to "Disabled". Bug: webrtc:10809 Change-Id: I8501106e608eccb14487576f24bdceaf3f324d80 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183982 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32101}
This commit is contained in:
26
call/call.cc
26
call/call.cc
@ -306,7 +306,9 @@ class Call final : public webrtc::Call,
|
|||||||
void UpdateHistograms();
|
void UpdateHistograms();
|
||||||
void UpdateAggregateNetworkState();
|
void UpdateAggregateNetworkState();
|
||||||
|
|
||||||
void RegisterRateObserver();
|
// Ensure that necessary process threads are started, and any required
|
||||||
|
// callbacks have been registered.
|
||||||
|
void EnsureStarted() RTC_EXCLUSIVE_LOCKS_REQUIRED(worker_thread_);
|
||||||
|
|
||||||
rtc::TaskQueue* send_transport_queue() const {
|
rtc::TaskQueue* send_transport_queue() const {
|
||||||
return transport_send_ptr_->GetWorkerQueue();
|
return transport_send_ptr_->GetWorkerQueue();
|
||||||
@ -433,8 +435,7 @@ class Call final : public webrtc::Call,
|
|||||||
// last ensures that it is destroyed first and any running tasks are finished.
|
// last ensures that it is destroyed first and any running tasks are finished.
|
||||||
std::unique_ptr<RtpTransportControllerSendInterface> transport_send_;
|
std::unique_ptr<RtpTransportControllerSendInterface> transport_send_;
|
||||||
|
|
||||||
bool is_target_rate_observer_registered_ RTC_GUARDED_BY(worker_thread_) =
|
bool is_started_ RTC_GUARDED_BY(worker_thread_) = false;
|
||||||
false;
|
|
||||||
|
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(Call);
|
RTC_DISALLOW_COPY_AND_ASSIGN(Call);
|
||||||
};
|
};
|
||||||
@ -655,19 +656,18 @@ Call::~Call() {
|
|||||||
UpdateHistograms();
|
UpdateHistograms();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Call::RegisterRateObserver() {
|
void Call::EnsureStarted() {
|
||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
if (is_started_) {
|
||||||
|
|
||||||
if (is_target_rate_observer_registered_)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
is_target_rate_observer_registered_ = true;
|
is_started_ = true;
|
||||||
|
|
||||||
// This call seems to kick off a number of things, so probably better left
|
// This call seems to kick off a number of things, so probably better left
|
||||||
// off being kicked off on request rather than in the ctor.
|
// off being kicked off on request rather than in the ctor.
|
||||||
transport_send_ptr_->RegisterTargetTransferRateObserver(this);
|
transport_send_ptr_->RegisterTargetTransferRateObserver(this);
|
||||||
|
|
||||||
module_process_thread_->EnsureStarted();
|
module_process_thread_->EnsureStarted();
|
||||||
|
transport_send_ptr_->EnsureStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Call::SetClientBitratePreferences(const BitrateSettings& preferences) {
|
void Call::SetClientBitratePreferences(const BitrateSettings& preferences) {
|
||||||
@ -762,7 +762,7 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream(
|
|||||||
TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
|
TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
|
||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||||
|
|
||||||
RegisterRateObserver();
|
EnsureStarted();
|
||||||
|
|
||||||
// Stream config is logged in AudioSendStream::ConfigureStream, as it may
|
// Stream config is logged in AudioSendStream::ConfigureStream, as it may
|
||||||
// change during the stream's lifetime.
|
// change during the stream's lifetime.
|
||||||
@ -822,7 +822,7 @@ webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
|
|||||||
const webrtc::AudioReceiveStream::Config& config) {
|
const webrtc::AudioReceiveStream::Config& config) {
|
||||||
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
|
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
|
||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||||
RegisterRateObserver();
|
EnsureStarted();
|
||||||
event_log_->Log(std::make_unique<RtcEventAudioReceiveStreamConfig>(
|
event_log_->Log(std::make_unique<RtcEventAudioReceiveStreamConfig>(
|
||||||
CreateRtcLogStreamConfig(config)));
|
CreateRtcLogStreamConfig(config)));
|
||||||
AudioReceiveStream* receive_stream = new AudioReceiveStream(
|
AudioReceiveStream* receive_stream = new AudioReceiveStream(
|
||||||
@ -877,7 +877,7 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
|
|||||||
TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
|
TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
|
||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||||
|
|
||||||
RegisterRateObserver();
|
EnsureStarted();
|
||||||
|
|
||||||
video_send_delay_stats_->AddSsrcs(config);
|
video_send_delay_stats_->AddSsrcs(config);
|
||||||
for (size_t ssrc_index = 0; ssrc_index < config.rtp.ssrcs.size();
|
for (size_t ssrc_index = 0; ssrc_index < config.rtp.ssrcs.size();
|
||||||
@ -976,7 +976,7 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
|
|||||||
receive_side_cc_.SetSendPeriodicFeedback(
|
receive_side_cc_.SetSendPeriodicFeedback(
|
||||||
SendPeriodicFeedback(configuration.rtp.extensions));
|
SendPeriodicFeedback(configuration.rtp.extensions));
|
||||||
|
|
||||||
RegisterRateObserver();
|
EnsureStarted();
|
||||||
|
|
||||||
TaskQueueBase* current = GetCurrentTaskQueueOrThread();
|
TaskQueueBase* current = GetCurrentTaskQueueOrThread();
|
||||||
RTC_CHECK(current);
|
RTC_CHECK(current);
|
||||||
|
|||||||
@ -82,6 +82,7 @@ RtpTransportControllerSend::RtpTransportControllerSend(
|
|||||||
: clock_(clock),
|
: clock_(clock),
|
||||||
event_log_(event_log),
|
event_log_(event_log),
|
||||||
bitrate_configurator_(bitrate_config),
|
bitrate_configurator_(bitrate_config),
|
||||||
|
process_thread_started_(false),
|
||||||
process_thread_(std::move(process_thread)),
|
process_thread_(std::move(process_thread)),
|
||||||
use_task_queue_pacer_(IsEnabled(trials, "WebRTC-TaskQueuePacer")),
|
use_task_queue_pacer_(IsEnabled(trials, "WebRTC-TaskQueuePacer")),
|
||||||
process_thread_pacer_(use_task_queue_pacer_
|
process_thread_pacer_(use_task_queue_pacer_
|
||||||
@ -130,15 +131,13 @@ RtpTransportControllerSend::RtpTransportControllerSend(
|
|||||||
pacer()->SetPacingRates(
|
pacer()->SetPacingRates(
|
||||||
DataRate::BitsPerSec(bitrate_config.start_bitrate_bps), DataRate::Zero());
|
DataRate::BitsPerSec(bitrate_config.start_bitrate_bps), DataRate::Zero());
|
||||||
|
|
||||||
if (!use_task_queue_pacer_) {
|
if (!absl::StartsWith(trials->Lookup("WebRTC-LazyPacerStart"), "Disabled")) {
|
||||||
process_thread_->Start();
|
EnsureStarted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RtpTransportControllerSend::~RtpTransportControllerSend() {
|
RtpTransportControllerSend::~RtpTransportControllerSend() {
|
||||||
if (!use_task_queue_pacer_) {
|
process_thread_->Stop();
|
||||||
process_thread_->Stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RtpVideoSenderInterface* RtpTransportControllerSend::CreateRtpVideoSender(
|
RtpVideoSenderInterface* RtpTransportControllerSend::CreateRtpVideoSender(
|
||||||
@ -491,6 +490,13 @@ void RtpTransportControllerSend::IncludeOverheadInPacedSender() {
|
|||||||
pacer()->SetIncludeOverhead();
|
pacer()->SetIncludeOverhead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RtpTransportControllerSend::EnsureStarted() {
|
||||||
|
if (!use_task_queue_pacer_ && !process_thread_started_) {
|
||||||
|
process_thread_started_ = true;
|
||||||
|
process_thread_->Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RtpTransportControllerSend::OnReceivedEstimatedBitrate(uint32_t bitrate) {
|
void RtpTransportControllerSend::OnReceivedEstimatedBitrate(uint32_t bitrate) {
|
||||||
RemoteBitrateReport msg;
|
RemoteBitrateReport msg;
|
||||||
msg.receive_time = Timestamp::Millis(clock_->TimeInMilliseconds());
|
msg.receive_time = Timestamp::Millis(clock_->TimeInMilliseconds());
|
||||||
|
|||||||
@ -110,6 +110,7 @@ class RtpTransportControllerSend final
|
|||||||
|
|
||||||
void AccountForAudioPacketsInPacedSender(bool account_for_audio) override;
|
void AccountForAudioPacketsInPacedSender(bool account_for_audio) override;
|
||||||
void IncludeOverheadInPacedSender() override;
|
void IncludeOverheadInPacedSender() override;
|
||||||
|
void EnsureStarted() override;
|
||||||
|
|
||||||
// Implements RtcpBandwidthObserver interface
|
// Implements RtcpBandwidthObserver interface
|
||||||
void OnReceivedEstimatedBitrate(uint32_t bitrate) override;
|
void OnReceivedEstimatedBitrate(uint32_t bitrate) override;
|
||||||
@ -151,6 +152,7 @@ class RtpTransportControllerSend final
|
|||||||
std::vector<std::unique_ptr<RtpVideoSenderInterface>> video_rtp_senders_;
|
std::vector<std::unique_ptr<RtpVideoSenderInterface>> video_rtp_senders_;
|
||||||
RtpBitrateConfigurator bitrate_configurator_;
|
RtpBitrateConfigurator bitrate_configurator_;
|
||||||
std::map<std::string, rtc::NetworkRoute> network_routes_;
|
std::map<std::string, rtc::NetworkRoute> network_routes_;
|
||||||
|
bool process_thread_started_;
|
||||||
const std::unique_ptr<ProcessThread> process_thread_;
|
const std::unique_ptr<ProcessThread> process_thread_;
|
||||||
const bool use_task_queue_pacer_;
|
const bool use_task_queue_pacer_;
|
||||||
std::unique_ptr<PacedSender> process_thread_pacer_;
|
std::unique_ptr<PacedSender> process_thread_pacer_;
|
||||||
|
|||||||
@ -154,6 +154,8 @@ class RtpTransportControllerSendInterface {
|
|||||||
|
|
||||||
virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
|
virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
|
||||||
virtual void IncludeOverheadInPacedSender() = 0;
|
virtual void IncludeOverheadInPacedSender() = 0;
|
||||||
|
|
||||||
|
virtual void EnsureStarted() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -143,6 +143,7 @@ class RtpVideoSenderTestFixture {
|
|||||||
VideoEncoderConfig::ContentType::kRealtimeVideo),
|
VideoEncoderConfig::ContentType::kRealtimeVideo),
|
||||||
retransmission_rate_limiter_(time_controller_.GetClock(),
|
retransmission_rate_limiter_(time_controller_.GetClock(),
|
||||||
kRetransmitWindowSizeMs) {
|
kRetransmitWindowSizeMs) {
|
||||||
|
transport_controller_.EnsureStarted();
|
||||||
std::map<uint32_t, RtpState> suspended_ssrcs;
|
std::map<uint32_t, RtpState> suspended_ssrcs;
|
||||||
router_ = std::make_unique<RtpVideoSender>(
|
router_ = std::make_unique<RtpVideoSender>(
|
||||||
time_controller_.GetClock(), suspended_ssrcs, suspended_payload_states,
|
time_controller_.GetClock(), suspended_ssrcs, suspended_payload_states,
|
||||||
|
|||||||
@ -99,6 +99,7 @@ class MockRtpTransportControllerSend
|
|||||||
MOCK_METHOD(void, AccountForAudioPacketsInPacedSender, (bool), (override));
|
MOCK_METHOD(void, AccountForAudioPacketsInPacedSender, (bool), (override));
|
||||||
MOCK_METHOD(void, IncludeOverheadInPacedSender, (), (override));
|
MOCK_METHOD(void, IncludeOverheadInPacedSender, (), (override));
|
||||||
MOCK_METHOD(void, OnReceivedPacket, (const ReceivedPacket&), (override));
|
MOCK_METHOD(void, OnReceivedPacket, (const ReceivedPacket&), (override));
|
||||||
|
MOCK_METHOD(void, EnsureStarted, (), (override));
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif // CALL_TEST_MOCK_RTP_TRANSPORT_CONTROLLER_SEND_H_
|
#endif // CALL_TEST_MOCK_RTP_TRANSPORT_CONTROLLER_SEND_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user