Delete CallConfig constructor that doesn't use Environment

Bug: webrtc:15656
Change-Id: Id7a1115f1256be6a3962de2de0cbe602084c42e3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329841
Reviewed-by: Emil Lundmark <lndmrk@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41316}
This commit is contained in:
Danil Chapovalov 2023-12-04 18:53:09 +01:00 committed by WebRTC LUCI CQ
parent ece5cb8371
commit e79e722834
5 changed files with 33 additions and 77 deletions

View File

@ -42,10 +42,8 @@ rtc_library("call_interfaces") {
":rtp_interfaces", ":rtp_interfaces",
":video_stream_api", ":video_stream_api",
"../api:fec_controller_api", "../api:fec_controller_api",
"../api:field_trials_view",
"../api:frame_transformer_interface", "../api:frame_transformer_interface",
"../api:network_state_predictor_api", "../api:network_state_predictor_api",
"../api:rtc_error",
"../api:rtp_headers", "../api:rtp_headers",
"../api:rtp_parameters", "../api:rtp_parameters",
"../api:rtp_sender_interface", "../api:rtp_sender_interface",

View File

@ -185,8 +185,7 @@ class Call final : public webrtc::Call,
public: public:
Call(Clock* clock, Call(Clock* clock,
const CallConfig& config, const CallConfig& config,
std::unique_ptr<RtpTransportControllerSendInterface> transport_send, std::unique_ptr<RtpTransportControllerSendInterface> transport_send);
TaskQueueFactory* task_queue_factory);
~Call() override; ~Call() override;
Call(const Call&) = delete; Call(const Call&) = delete;
@ -345,8 +344,10 @@ class Call final : public webrtc::Call,
// callbacks have been registered. // callbacks have been registered.
void EnsureStarted() RTC_RUN_ON(worker_thread_); void EnsureStarted() RTC_RUN_ON(worker_thread_);
// TODO: bugs.webrtc.org/15656 - Delete `clock_` when it would always be the
// same as &env_.clock()
Clock* const clock_; Clock* const clock_;
TaskQueueFactory* const task_queue_factory_; const Environment env_;
TaskQueueBase* const worker_thread_; TaskQueueBase* const worker_thread_;
TaskQueueBase* const network_thread_; TaskQueueBase* const network_thread_;
const std::unique_ptr<DecodeSynchronizer> decode_sync_; const std::unique_ptr<DecodeSynchronizer> decode_sync_;
@ -356,8 +357,6 @@ class Call final : public webrtc::Call,
const std::unique_ptr<CallStats> call_stats_; const std::unique_ptr<CallStats> call_stats_;
const std::unique_ptr<BitrateAllocator> bitrate_allocator_; const std::unique_ptr<BitrateAllocator> bitrate_allocator_;
const CallConfig config_ RTC_GUARDED_BY(worker_thread_); const CallConfig config_ RTC_GUARDED_BY(worker_thread_);
// Maps to config_.trials, can be used from any thread via `trials()`.
const FieldTrialsView& trials_;
NetworkState audio_network_state_ RTC_GUARDED_BY(worker_thread_); NetworkState audio_network_state_ RTC_GUARDED_BY(worker_thread_);
NetworkState video_network_state_ RTC_GUARDED_BY(worker_thread_); NetworkState video_network_state_ RTC_GUARDED_BY(worker_thread_);
@ -413,8 +412,6 @@ class Call final : public webrtc::Call,
RtpPayloadStateMap suspended_video_payload_states_ RtpPayloadStateMap suspended_video_payload_states_
RTC_GUARDED_BY(worker_thread_); RTC_GUARDED_BY(worker_thread_);
webrtc::RtcEventLog* const event_log_;
// TODO(bugs.webrtc.org/11993) ready to move stats access to the network // TODO(bugs.webrtc.org/11993) ready to move stats access to the network
// thread. // thread.
ReceiveStats receive_stats_ RTC_GUARDED_BY(worker_thread_); ReceiveStats receive_stats_ RTC_GUARDED_BY(worker_thread_);
@ -474,8 +471,7 @@ std::string Call::Stats::ToString(int64_t time_ms) const {
} }
std::unique_ptr<Call> Call::Create(const CallConfig& config) { std::unique_ptr<Call> Call::Create(const CallConfig& config) {
Clock* clock = Clock* clock = &config.env.clock();
config.env.has_value() ? &config.env->clock() : Clock::GetRealTimeClock();
return Create(config, clock, return Create(config, clock,
RtpTransportControllerSendFactory().Create( RtpTransportControllerSendFactory().Create(
config.ExtractTransportConfig(), clock)); config.ExtractTransportConfig(), clock));
@ -486,10 +482,8 @@ std::unique_ptr<Call> Call::Create(
Clock* clock, Clock* clock,
std::unique_ptr<RtpTransportControllerSendInterface> std::unique_ptr<RtpTransportControllerSendInterface>
transportControllerSend) { transportControllerSend) {
RTC_DCHECK(config.task_queue_factory);
return std::make_unique<internal::Call>(clock, config, return std::make_unique<internal::Call>(clock, config,
std::move(transportControllerSend), std::move(transportControllerSend));
config.task_queue_factory);
} }
// This method here to avoid subclasses has to implement this method. // This method here to avoid subclasses has to implement this method.
@ -657,10 +651,9 @@ void Call::SendStats::SetMinAllocatableRate(BitrateAllocationLimits limits) {
Call::Call(Clock* clock, Call::Call(Clock* clock,
const CallConfig& config, const CallConfig& config,
std::unique_ptr<RtpTransportControllerSendInterface> transport_send, std::unique_ptr<RtpTransportControllerSendInterface> transport_send)
TaskQueueFactory* task_queue_factory)
: clock_(clock), : clock_(clock),
task_queue_factory_(task_queue_factory), env_(config.env),
worker_thread_(GetCurrentTaskQueueOrThread()), worker_thread_(GetCurrentTaskQueueOrThread()),
// If `network_task_queue_` was set to nullptr, network related calls // If `network_task_queue_` was set to nullptr, network related calls
// must be made on `worker_thread_` (i.e. they're one and the same). // must be made on `worker_thread_` (i.e. they're one and the same).
@ -675,11 +668,9 @@ Call::Call(Clock* clock,
call_stats_(new CallStats(clock_, worker_thread_)), call_stats_(new CallStats(clock_, worker_thread_)),
bitrate_allocator_(new BitrateAllocator(this)), bitrate_allocator_(new BitrateAllocator(this)),
config_(config), config_(config),
trials_(*config.trials),
audio_network_state_(kNetworkDown), audio_network_state_(kNetworkDown),
video_network_state_(kNetworkDown), video_network_state_(kNetworkDown),
aggregate_network_up_(false), aggregate_network_up_(false),
event_log_(config.event_log),
receive_stats_(clock_), receive_stats_(clock_),
send_stats_(clock_), send_stats_(clock_),
receive_side_cc_(clock, receive_side_cc_(clock,
@ -689,13 +680,11 @@ Call::Call(Clock* clock,
transport_send->packet_router()), transport_send->packet_router()),
/*network_state_estimator=*/nullptr), /*network_state_estimator=*/nullptr),
receive_time_calculator_( receive_time_calculator_(
ReceiveTimeCalculator::CreateFromFieldTrial(*config.trials)), ReceiveTimeCalculator::CreateFromFieldTrial(env_.field_trials())),
video_send_delay_stats_(new SendDelayStats(clock_)), video_send_delay_stats_(new SendDelayStats(clock_)),
start_of_call_(clock_->CurrentTime()), start_of_call_(clock_->CurrentTime()),
transport_send_ptr_(transport_send.get()), transport_send_ptr_(transport_send.get()),
transport_send_(std::move(transport_send)) { transport_send_(std::move(transport_send)) {
RTC_DCHECK(config.event_log != nullptr);
RTC_DCHECK(config.trials != nullptr);
RTC_DCHECK(network_thread_); RTC_DCHECK(network_thread_);
RTC_DCHECK(worker_thread_->IsCurrent()); RTC_DCHECK(worker_thread_->IsCurrent());
@ -776,8 +765,8 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream(
} }
AudioSendStream* send_stream = new AudioSendStream( AudioSendStream* send_stream = new AudioSendStream(
clock_, config, config_.audio_state, task_queue_factory_, clock_, config, config_.audio_state, &env_.task_queue_factory(),
transport_send_.get(), bitrate_allocator_.get(), event_log_, transport_send_.get(), bitrate_allocator_.get(), &env_.event_log(),
call_stats_->AsRtcpRttStats(), suspended_rtp_state, trials()); call_stats_->AsRtcpRttStats(), suspended_rtp_state, trials());
RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
audio_send_ssrcs_.end()); audio_send_ssrcs_.end());
@ -829,12 +818,12 @@ webrtc::AudioReceiveStreamInterface* Call::CreateAudioReceiveStream(
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
EnsureStarted(); EnsureStarted();
event_log_->Log(std::make_unique<RtcEventAudioReceiveStreamConfig>( env_.event_log().Log(std::make_unique<RtcEventAudioReceiveStreamConfig>(
CreateRtcLogStreamConfig(config))); CreateRtcLogStreamConfig(config)));
AudioReceiveStreamImpl* receive_stream = new AudioReceiveStreamImpl( AudioReceiveStreamImpl* receive_stream = new AudioReceiveStreamImpl(
clock_, transport_send_->packet_router(), config_.neteq_factory, config, clock_, transport_send_->packet_router(), config_.neteq_factory, config,
config_.audio_state, event_log_); config_.audio_state, &env_.event_log());
audio_receive_streams_.insert(receive_stream); audio_receive_streams_.insert(receive_stream);
// TODO(bugs.webrtc.org/11993): Make the registration on the network thread // TODO(bugs.webrtc.org/11993): Make the registration on the network thread
@ -896,7 +885,7 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
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();
++ssrc_index) { ++ssrc_index) {
event_log_->Log(std::make_unique<RtcEventVideoSendStreamConfig>( env_.event_log().Log(std::make_unique<RtcEventVideoSendStreamConfig>(
CreateRtcLogStreamConfig(config, ssrc_index))); CreateRtcLogStreamConfig(config, ssrc_index)));
} }
@ -906,12 +895,12 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
std::vector<uint32_t> ssrcs = config.rtp.ssrcs; std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
VideoSendStream* send_stream = new VideoSendStream( VideoSendStream* send_stream = new VideoSendStream(
clock_, num_cpu_cores_, task_queue_factory_, network_thread_, clock_, num_cpu_cores_, &env_.task_queue_factory(), network_thread_,
call_stats_->AsRtcpRttStats(), transport_send_.get(), call_stats_->AsRtcpRttStats(), transport_send_.get(),
bitrate_allocator_.get(), video_send_delay_stats_.get(), event_log_, bitrate_allocator_.get(), video_send_delay_stats_.get(),
std::move(config), std::move(encoder_config), suspended_video_send_ssrcs_, &env_.event_log(), std::move(config), std::move(encoder_config),
suspended_video_payload_states_, std::move(fec_controller), suspended_video_send_ssrcs_, suspended_video_payload_states_,
*config_.trials); std::move(fec_controller), env_.field_trials());
for (uint32_t ssrc : ssrcs) { for (uint32_t ssrc : ssrcs) {
RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
@ -995,7 +984,7 @@ webrtc::VideoReceiveStreamInterface* Call::CreateVideoReceiveStream(
EnsureStarted(); EnsureStarted();
event_log_->Log(std::make_unique<RtcEventVideoReceiveStreamConfig>( env_.event_log().Log(std::make_unique<RtcEventVideoReceiveStreamConfig>(
CreateRtcLogStreamConfig(configuration))); CreateRtcLogStreamConfig(configuration)));
// TODO(bugs.webrtc.org/11993): Move the registration between `receive_stream` // TODO(bugs.webrtc.org/11993): Move the registration between `receive_stream`
@ -1005,10 +994,10 @@ webrtc::VideoReceiveStreamInterface* Call::CreateVideoReceiveStream(
// TODO(crbug.com/1381982): Re-enable decode synchronizer once the Chromium // TODO(crbug.com/1381982): Re-enable decode synchronizer once the Chromium
// API has adapted to the new Metronome interface. // API has adapted to the new Metronome interface.
VideoReceiveStream2* receive_stream = new VideoReceiveStream2( VideoReceiveStream2* receive_stream = new VideoReceiveStream2(
task_queue_factory_, this, num_cpu_cores_, &env_.task_queue_factory(), this, num_cpu_cores_,
transport_send_->packet_router(), std::move(configuration), transport_send_->packet_router(), std::move(configuration),
call_stats_.get(), clock_, std::make_unique<VCMTiming>(clock_, trials()), call_stats_.get(), clock_, std::make_unique<VCMTiming>(clock_, trials()),
&nack_periodic_processor_, decode_sync_.get(), event_log_); &nack_periodic_processor_, decode_sync_.get(), &env_.event_log());
// TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network // TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network
// thread. // thread.
receive_stream->RegisterWithTransport(&video_receiver_controller_); receive_stream->RegisterWithTransport(&video_receiver_controller_);
@ -1115,7 +1104,7 @@ Call::Stats Call::GetStats() const {
} }
const FieldTrialsView& Call::trials() const { const FieldTrialsView& Call::trials() const {
return trials_; return env_.field_trials();
} }
TaskQueueBase* Call::network_thread() const { TaskQueueBase* Call::network_thread() const {
@ -1363,7 +1352,7 @@ void Call::DeliverRtcpPacket(rtc::CopyOnWriteBuffer packet) {
} }
if (rtcp_delivered) { if (rtcp_delivered) {
event_log_->Log(std::make_unique<RtcEventRtcpPacketIncoming>(packet)); env_.event_log().Log(std::make_unique<RtcEventRtcpPacketIncoming>(packet));
} }
} }
@ -1385,7 +1374,7 @@ void Call::DeliverRtpPacket(
NotifyBweOfReceivedPacket(packet, media_type); NotifyBweOfReceivedPacket(packet, media_type);
event_log_->Log(std::make_unique<RtcEventRtpPacketIncoming>(packet)); env_.event_log().Log(std::make_unique<RtcEventRtpPacketIncoming>(packet));
if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) { if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) {
return; return;
} }

View File

@ -10,35 +10,27 @@
#include "call/call_config.h" #include "call/call_config.h"
#include "rtc_base/checks.h" #include "api/environment/environment.h"
#include "api/task_queue/task_queue_base.h"
namespace webrtc { namespace webrtc {
CallConfig::CallConfig(const Environment& env, CallConfig::CallConfig(const Environment& env,
TaskQueueBase* network_task_queue) TaskQueueBase* network_task_queue)
: env(env), : env(env),
event_log(&env.event_log()),
task_queue_factory(&env.task_queue_factory()),
trials(&env.field_trials()),
network_task_queue_(network_task_queue) {} network_task_queue_(network_task_queue) {}
CallConfig::CallConfig(RtcEventLog* event_log,
TaskQueueBase* network_task_queue /* = nullptr*/)
: event_log(event_log), network_task_queue_(network_task_queue) {
RTC_DCHECK(event_log);
}
CallConfig::CallConfig(const CallConfig& config) = default; CallConfig::CallConfig(const CallConfig& config) = default;
RtpTransportConfig CallConfig::ExtractTransportConfig() const { RtpTransportConfig CallConfig::ExtractTransportConfig() const {
RtpTransportConfig transportConfig; RtpTransportConfig transportConfig;
transportConfig.bitrate_config = bitrate_config; transportConfig.bitrate_config = bitrate_config;
transportConfig.event_log = event_log; transportConfig.event_log = &env.event_log();
transportConfig.network_controller_factory = network_controller_factory; transportConfig.network_controller_factory = network_controller_factory;
transportConfig.network_state_predictor_factory = transportConfig.network_state_predictor_factory =
network_state_predictor_factory; network_state_predictor_factory;
transportConfig.task_queue_factory = task_queue_factory; transportConfig.task_queue_factory = &env.task_queue_factory();
transportConfig.trials = trials; transportConfig.trials = &env.field_trials();
return transportConfig; return transportConfig;
} }

View File

@ -10,15 +10,11 @@
#ifndef CALL_CALL_CONFIG_H_ #ifndef CALL_CALL_CONFIG_H_
#define CALL_CALL_CONFIG_H_ #define CALL_CALL_CONFIG_H_
#include "absl/types/optional.h"
#include "api/environment/environment.h" #include "api/environment/environment.h"
#include "api/fec_controller.h" #include "api/fec_controller.h"
#include "api/field_trials_view.h"
#include "api/metronome/metronome.h" #include "api/metronome/metronome.h"
#include "api/neteq/neteq_factory.h" #include "api/neteq/neteq_factory.h"
#include "api/network_state_predictor.h" #include "api/network_state_predictor.h"
#include "api/rtc_error.h"
#include "api/task_queue/task_queue_factory.h"
#include "api/transport/bitrate_settings.h" #include "api/transport/bitrate_settings.h"
#include "api/transport/network_control.h" #include "api/transport/network_control.h"
#include "call/audio_state.h" #include "call/audio_state.h"
@ -28,7 +24,6 @@
namespace webrtc { namespace webrtc {
class AudioProcessing; class AudioProcessing;
class RtcEventLog;
struct CallConfig { struct CallConfig {
// If `network_task_queue` is set to nullptr, Call will assume that network // If `network_task_queue` is set to nullptr, Call will assume that network
@ -37,19 +32,13 @@ struct CallConfig {
explicit CallConfig(const Environment& env, explicit CallConfig(const Environment& env,
TaskQueueBase* network_task_queue = nullptr); TaskQueueBase* network_task_queue = nullptr);
// TODO(bugs.webrtc.org/15656): Deprecate and delete constructor below.
explicit CallConfig(RtcEventLog* event_log,
TaskQueueBase* network_task_queue = nullptr);
CallConfig(const CallConfig&); CallConfig(const CallConfig&);
~CallConfig(); ~CallConfig();
RtpTransportConfig ExtractTransportConfig() const; RtpTransportConfig ExtractTransportConfig() const;
// TODO(bugs.webrtc.org/15656): Make non-optional when constructor that Environment env;
// doesn't pass Environment is removed.
absl::optional<Environment> env;
// Bitrate config used until valid bitrate estimates are calculated. Also // Bitrate config used until valid bitrate estimates are calculated. Also
// used to cap total bitrate used. This comes from the remote connection. // used to cap total bitrate used. This comes from the remote connection.
@ -61,16 +50,9 @@ struct CallConfig {
// Audio Processing Module to be used in this call. // Audio Processing Module to be used in this call.
AudioProcessing* audio_processing = nullptr; AudioProcessing* audio_processing = nullptr;
// RtcEventLog to use for this call. Required.
// Use webrtc::RtcEventLog::CreateNull() for a null implementation.
RtcEventLog* const event_log = nullptr;
// FecController to use for this call. // FecController to use for this call.
FecControllerFactoryInterface* fec_controller_factory = nullptr; FecControllerFactoryInterface* fec_controller_factory = nullptr;
// Task Queue Factory to be used in this call. Required.
TaskQueueFactory* task_queue_factory = nullptr;
// NetworkStatePredictor to use for this call. // NetworkStatePredictor to use for this call.
NetworkStatePredictorFactoryInterface* network_state_predictor_factory = NetworkStatePredictorFactoryInterface* network_state_predictor_factory =
nullptr; nullptr;
@ -81,10 +63,6 @@ struct CallConfig {
// NetEq factory to use for this call. // NetEq factory to use for this call.
NetEqFactory* neteq_factory = nullptr; NetEqFactory* neteq_factory = nullptr;
// Key-value mapping of internal configurations to apply,
// e.g. field trials.
const FieldTrialsView* trials = nullptr;
TaskQueueBase* const network_task_queue_ = nullptr; TaskQueueBase* const network_task_queue_ = nullptr;
// RtpTransportControllerSend to use for this call. // RtpTransportControllerSend to use for this call.
RtpTransportControllerSendFactoryInterface* RtpTransportControllerSendFactoryInterface*

View File

@ -84,13 +84,12 @@ CallFactory::CallFactory() {
std::unique_ptr<Call> CallFactory::CreateCall(const CallConfig& config) { std::unique_ptr<Call> CallFactory::CreateCall(const CallConfig& config) {
RTC_DCHECK_RUN_ON(&call_thread_); RTC_DCHECK_RUN_ON(&call_thread_);
RTC_DCHECK(config.trials);
std::vector<DegradedCall::TimeScopedNetworkConfig> send_degradation_configs = std::vector<DegradedCall::TimeScopedNetworkConfig> send_degradation_configs =
GetNetworkConfigs(*config.trials, /*send=*/true); GetNetworkConfigs(config.env.field_trials(), /*send=*/true);
std::vector<DegradedCall::TimeScopedNetworkConfig> std::vector<DegradedCall::TimeScopedNetworkConfig>
receive_degradation_configs = receive_degradation_configs =
GetNetworkConfigs(*config.trials, /*send=*/false); GetNetworkConfigs(config.env.field_trials(), /*send=*/false);
RtpTransportConfig transportConfig = config.ExtractTransportConfig(); RtpTransportConfig transportConfig = config.ExtractTransportConfig();