aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanil Chapovalov <danilchap@webrtc.org>2023-12-04 18:53:09 +0100
committerWebRTC LUCI CQ <webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-12-05 09:33:40 +0000
commite79e7228346f0331e18f9cc84c9d0baee5c10aa9 (patch)
tree4ff9b0f5c64ab5b41537cd46dbfc568f9ebe6848
parentece5cb83715dea85617114b6d4e981fdee2623ba (diff)
downloadwebrtc-e79e7228346f0331e18f9cc84c9d0baee5c10aa9.tar.gz
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}
-rw-r--r--call/BUILD.gn2
-rw-r--r--call/call.cc61
-rw-r--r--call/call_config.cc18
-rw-r--r--call/call_config.h24
-rw-r--r--call/call_factory.cc5
5 files changed, 33 insertions, 77 deletions
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 9a7be88892..0f6af985b3 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -42,10 +42,8 @@ rtc_library("call_interfaces") {
":rtp_interfaces",
":video_stream_api",
"../api:fec_controller_api",
- "../api:field_trials_view",
"../api:frame_transformer_interface",
"../api:network_state_predictor_api",
- "../api:rtc_error",
"../api:rtp_headers",
"../api:rtp_parameters",
"../api:rtp_sender_interface",
diff --git a/call/call.cc b/call/call.cc
index 42b3b988ea..05d25b2fa1 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -185,8 +185,7 @@ class Call final : public webrtc::Call,
public:
Call(Clock* clock,
const CallConfig& config,
- std::unique_ptr<RtpTransportControllerSendInterface> transport_send,
- TaskQueueFactory* task_queue_factory);
+ std::unique_ptr<RtpTransportControllerSendInterface> transport_send);
~Call() override;
Call(const Call&) = delete;
@@ -345,8 +344,10 @@ class Call final : public webrtc::Call,
// callbacks have been registered.
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_;
- TaskQueueFactory* const task_queue_factory_;
+ const Environment env_;
TaskQueueBase* const worker_thread_;
TaskQueueBase* const network_thread_;
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<BitrateAllocator> bitrate_allocator_;
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 video_network_state_ RTC_GUARDED_BY(worker_thread_);
@@ -413,8 +412,6 @@ class Call final : public webrtc::Call,
RtpPayloadStateMap suspended_video_payload_states_
RTC_GUARDED_BY(worker_thread_);
- webrtc::RtcEventLog* const event_log_;
-
// TODO(bugs.webrtc.org/11993) ready to move stats access to the network
// 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) {
- Clock* clock =
- config.env.has_value() ? &config.env->clock() : Clock::GetRealTimeClock();
+ Clock* clock = &config.env.clock();
return Create(config, clock,
RtpTransportControllerSendFactory().Create(
config.ExtractTransportConfig(), clock));
@@ -486,10 +482,8 @@ std::unique_ptr<Call> Call::Create(
Clock* clock,
std::unique_ptr<RtpTransportControllerSendInterface>
transportControllerSend) {
- RTC_DCHECK(config.task_queue_factory);
return std::make_unique<internal::Call>(clock, config,
- std::move(transportControllerSend),
- config.task_queue_factory);
+ std::move(transportControllerSend));
}
// 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,
const CallConfig& config,
- std::unique_ptr<RtpTransportControllerSendInterface> transport_send,
- TaskQueueFactory* task_queue_factory)
+ std::unique_ptr<RtpTransportControllerSendInterface> transport_send)
: clock_(clock),
- task_queue_factory_(task_queue_factory),
+ env_(config.env),
worker_thread_(GetCurrentTaskQueueOrThread()),
// 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).
@@ -675,11 +668,9 @@ Call::Call(Clock* clock,
call_stats_(new CallStats(clock_, worker_thread_)),
bitrate_allocator_(new BitrateAllocator(this)),
config_(config),
- trials_(*config.trials),
audio_network_state_(kNetworkDown),
video_network_state_(kNetworkDown),
aggregate_network_up_(false),
- event_log_(config.event_log),
receive_stats_(clock_),
send_stats_(clock_),
receive_side_cc_(clock,
@@ -689,13 +680,11 @@ Call::Call(Clock* clock,
transport_send->packet_router()),
/*network_state_estimator=*/nullptr),
receive_time_calculator_(
- ReceiveTimeCalculator::CreateFromFieldTrial(*config.trials)),
+ ReceiveTimeCalculator::CreateFromFieldTrial(env_.field_trials())),
video_send_delay_stats_(new SendDelayStats(clock_)),
start_of_call_(clock_->CurrentTime()),
transport_send_ptr_(transport_send.get()),
transport_send_(std::move(transport_send)) {
- RTC_DCHECK(config.event_log != nullptr);
- RTC_DCHECK(config.trials != nullptr);
RTC_DCHECK(network_thread_);
RTC_DCHECK(worker_thread_->IsCurrent());
@@ -776,8 +765,8 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream(
}
AudioSendStream* send_stream = new AudioSendStream(
- clock_, config, config_.audio_state, task_queue_factory_,
- transport_send_.get(), bitrate_allocator_.get(), event_log_,
+ clock_, config, config_.audio_state, &env_.task_queue_factory(),
+ transport_send_.get(), bitrate_allocator_.get(), &env_.event_log(),
call_stats_->AsRtcpRttStats(), suspended_rtp_state, trials());
RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
audio_send_ssrcs_.end());
@@ -829,12 +818,12 @@ webrtc::AudioReceiveStreamInterface* Call::CreateAudioReceiveStream(
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
RTC_DCHECK_RUN_ON(worker_thread_);
EnsureStarted();
- event_log_->Log(std::make_unique<RtcEventAudioReceiveStreamConfig>(
+ env_.event_log().Log(std::make_unique<RtcEventAudioReceiveStreamConfig>(
CreateRtcLogStreamConfig(config)));
AudioReceiveStreamImpl* receive_stream = new AudioReceiveStreamImpl(
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);
// 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);
for (size_t ssrc_index = 0; ssrc_index < config.rtp.ssrcs.size();
++ssrc_index) {
- event_log_->Log(std::make_unique<RtcEventVideoSendStreamConfig>(
+ env_.event_log().Log(std::make_unique<RtcEventVideoSendStreamConfig>(
CreateRtcLogStreamConfig(config, ssrc_index)));
}
@@ -906,12 +895,12 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
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(),
- bitrate_allocator_.get(), video_send_delay_stats_.get(), event_log_,
- std::move(config), std::move(encoder_config), suspended_video_send_ssrcs_,
- suspended_video_payload_states_, std::move(fec_controller),
- *config_.trials);
+ bitrate_allocator_.get(), video_send_delay_stats_.get(),
+ &env_.event_log(), std::move(config), std::move(encoder_config),
+ suspended_video_send_ssrcs_, suspended_video_payload_states_,
+ std::move(fec_controller), env_.field_trials());
for (uint32_t ssrc : ssrcs) {
RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
@@ -995,7 +984,7 @@ webrtc::VideoReceiveStreamInterface* Call::CreateVideoReceiveStream(
EnsureStarted();
- event_log_->Log(std::make_unique<RtcEventVideoReceiveStreamConfig>(
+ env_.event_log().Log(std::make_unique<RtcEventVideoReceiveStreamConfig>(
CreateRtcLogStreamConfig(configuration)));
// 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
// API has adapted to the new Metronome interface.
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),
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
// thread.
receive_stream->RegisterWithTransport(&video_receiver_controller_);
@@ -1115,7 +1104,7 @@ Call::Stats Call::GetStats() const {
}
const FieldTrialsView& Call::trials() const {
- return trials_;
+ return env_.field_trials();
}
TaskQueueBase* Call::network_thread() const {
@@ -1363,7 +1352,7 @@ void Call::DeliverRtcpPacket(rtc::CopyOnWriteBuffer packet) {
}
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);
- 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) {
return;
}
diff --git a/call/call_config.cc b/call/call_config.cc
index 5832969b9c..5f77714956 100644
--- a/call/call_config.cc
+++ b/call/call_config.cc
@@ -10,35 +10,27 @@
#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 {
CallConfig::CallConfig(const Environment& env,
TaskQueueBase* network_task_queue)
: env(env),
- event_log(&env.event_log()),
- task_queue_factory(&env.task_queue_factory()),
- trials(&env.field_trials()),
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;
RtpTransportConfig CallConfig::ExtractTransportConfig() const {
RtpTransportConfig transportConfig;
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_state_predictor_factory =
network_state_predictor_factory;
- transportConfig.task_queue_factory = task_queue_factory;
- transportConfig.trials = trials;
+ transportConfig.task_queue_factory = &env.task_queue_factory();
+ transportConfig.trials = &env.field_trials();
return transportConfig;
}
diff --git a/call/call_config.h b/call/call_config.h
index 1b1f696fee..24b9910ee7 100644
--- a/call/call_config.h
+++ b/call/call_config.h
@@ -10,15 +10,11 @@
#ifndef CALL_CALL_CONFIG_H_
#define CALL_CALL_CONFIG_H_
-#include "absl/types/optional.h"
#include "api/environment/environment.h"
#include "api/fec_controller.h"
-#include "api/field_trials_view.h"
#include "api/metronome/metronome.h"
#include "api/neteq/neteq_factory.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/network_control.h"
#include "call/audio_state.h"
@@ -28,7 +24,6 @@
namespace webrtc {
class AudioProcessing;
-class RtcEventLog;
struct CallConfig {
// If `network_task_queue` is set to nullptr, Call will assume that network
@@ -37,19 +32,13 @@ struct CallConfig {
explicit CallConfig(const Environment& env,
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();
RtpTransportConfig ExtractTransportConfig() const;
- // TODO(bugs.webrtc.org/15656): Make non-optional when constructor that
- // doesn't pass Environment is removed.
- absl::optional<Environment> env;
+ Environment env;
// Bitrate config used until valid bitrate estimates are calculated. Also
// 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.
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.
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.
NetworkStatePredictorFactoryInterface* network_state_predictor_factory =
nullptr;
@@ -81,10 +63,6 @@ struct CallConfig {
// NetEq factory to use for this call.
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;
// RtpTransportControllerSend to use for this call.
RtpTransportControllerSendFactoryInterface*
diff --git a/call/call_factory.cc b/call/call_factory.cc
index 043b11da37..d97940fc3c 100644
--- a/call/call_factory.cc
+++ b/call/call_factory.cc
@@ -84,13 +84,12 @@ CallFactory::CallFactory() {
std::unique_ptr<Call> CallFactory::CreateCall(const CallConfig& config) {
RTC_DCHECK_RUN_ON(&call_thread_);
- RTC_DCHECK(config.trials);
std::vector<DegradedCall::TimeScopedNetworkConfig> send_degradation_configs =
- GetNetworkConfigs(*config.trials, /*send=*/true);
+ GetNetworkConfigs(config.env.field_trials(), /*send=*/true);
std::vector<DegradedCall::TimeScopedNetworkConfig>
receive_degradation_configs =
- GetNetworkConfigs(*config.trials, /*send=*/false);
+ GetNetworkConfigs(config.env.field_trials(), /*send=*/false);
RtpTransportConfig transportConfig = config.ExtractTransportConfig();