Adds injectable trials from peerconnection down to transport controller.

This will be immediately useful to guarantee consistent state across
components referencing the pacer, but will be a net benefit overall
imo.

Bug: webrtc:10809
Change-Id: I49630696f757a832ccf2e4c8597193bf087ce53b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159885
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29859}
This commit is contained in:
Erik Språng 2019-11-15 17:18:52 +01:00 committed by Commit Bot
parent ac7fd87375
commit 662678dbf7
14 changed files with 49 additions and 16 deletions

View File

@ -188,6 +188,7 @@ rtc_library("libjingle_peerconnection_api") {
"transport:datagram_transport_interface",
"transport:enums",
"transport:network_control",
"transport:webrtc_key_value_config",
"transport/media:audio_interfaces",
"transport/media:media_transport_interface",
"transport/media:video_interfaces",

View File

@ -104,6 +104,7 @@
#include "api/transport/enums.h"
#include "api/transport/media/media_transport_interface.h"
#include "api/transport/network_control.h"
#include "api/transport/webrtc_key_value_config.h"
#include "api/turn_customizer.h"
#include "media/base/media_config.h"
#include "media/base/media_engine.h"
@ -1329,6 +1330,7 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final {
std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory;
std::unique_ptr<MediaTransportFactory> media_transport_factory;
std::unique_ptr<NetEqFactory> neteq_factory;
std::unique_ptr<WebRtcKeyValueConfig> trials;
};
// PeerConnectionFactoryInterface is the factory interface used for creating

View File

@ -54,6 +54,7 @@ rtc_source_set("webrtc_key_value_config") {
"webrtc_key_value_config.h",
]
deps = [
"../../rtc_base/system:rtc_export",
"//third_party/abseil-cpp/absl/strings",
]
}

View File

@ -13,6 +13,7 @@
#include <string>
#include "absl/strings/string_view.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@ -21,7 +22,7 @@ namespace webrtc {
// particular key value mapping will be preserved over time and no announcements
// will be made if they are changed. It's up to the library user to ensure that
// the behavior does not break.
class WebRtcKeyValueConfig {
class RTC_EXPORT WebRtcKeyValueConfig {
public:
virtual ~WebRtcKeyValueConfig() = default;
// The configured value for the given key. Defaults to an empty string.

View File

@ -129,10 +129,11 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
send_config.encoder_factory = CreateAudioEncoderFactory<AudioEncoderOpus>();
std::unique_ptr<ProcessThread> send_process_thread =
ProcessThread::Create("audio send thread");
FieldTrialBasedConfig field_trials;
RtpTransportControllerSend rtp_transport(
Clock::GetRealTimeClock(), &null_event_log, nullptr, nullptr,
BitrateConstraints(), ProcessThread::Create("Pacer"),
task_queue_factory.get());
task_queue_factory.get(), &field_trials);
webrtc::internal::AudioSendStream send_stream(
Clock::GetRealTimeClock(), send_config, audio_state,
task_queue_factory.get(), send_process_thread.get(), &rtp_transport,

View File

@ -46,6 +46,7 @@ rtc_library("call_interfaces") {
"../api/task_queue",
"../api/transport:bitrate_settings",
"../api/transport:network_control",
"../api/transport:webrtc_key_value_config",
"../api/transport/media:media_transport_interface",
"../api/transport/rtp:rtp_source",
"../modules/audio_device",

View File

@ -415,7 +415,7 @@ Call* Call::Create(const Call::Config& config,
std::make_unique<RtpTransportControllerSend>(
clock, config.event_log, config.network_state_predictor_factory,
config.network_controller_factory, config.bitrate_config,
std::move(pacer_thread), config.task_queue_factory),
std::move(pacer_thread), config.task_queue_factory, config.trials),
std::move(call_thread), config.task_queue_factory);
}

View File

@ -17,6 +17,7 @@
#include "api/task_queue/task_queue_factory.h"
#include "api/transport/bitrate_settings.h"
#include "api/transport/network_control.h"
#include "api/transport/webrtc_key_value_config.h"
#include "call/audio_state.h"
namespace webrtc {
@ -60,6 +61,10 @@ 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 WebRtcKeyValueConfig* trials = nullptr;
};
} // namespace webrtc

View File

@ -25,7 +25,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/rate_limiter.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
@ -55,6 +54,11 @@ TargetRateConstraints ConvertConstraints(const BitrateConstraints& contraints,
contraints.max_bitrate_bps,
contraints.start_bitrate_bps, clock);
}
bool IsEnabled(const WebRtcKeyValueConfig* trials, absl::string_view key) {
return trials && trials->Lookup(key).find("Enabled") == 0;
}
} // namespace
RtpTransportControllerSend::RtpTransportControllerSend(
@ -64,12 +68,13 @@ RtpTransportControllerSend::RtpTransportControllerSend(
NetworkControllerFactoryInterface* controller_factory,
const BitrateConstraints& bitrate_config,
std::unique_ptr<ProcessThread> process_thread,
TaskQueueFactory* task_queue_factory)
TaskQueueFactory* task_queue_factory,
const WebRtcKeyValueConfig* trials)
: clock_(clock),
event_log_(event_log),
bitrate_configurator_(bitrate_config),
process_thread_(std::move(process_thread)),
pacer_(clock, &packet_router_, event_log, nullptr, process_thread_.get()),
pacer_(clock, &packet_router_, event_log, trials, process_thread_.get()),
observer_(nullptr),
controller_factory_override_(controller_factory),
controller_factory_fallback_(
@ -77,11 +82,11 @@ RtpTransportControllerSend::RtpTransportControllerSend(
process_interval_(controller_factory_fallback_->GetProcessInterval()),
last_report_block_time_(Timestamp::ms(clock_->TimeInMilliseconds())),
reset_feedback_on_route_change_(
!field_trial::IsEnabled("WebRTC-Bwe-NoFeedbackReset")),
!IsEnabled(trials, "WebRTC-Bwe-NoFeedbackReset")),
send_side_bwe_with_overhead_(
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
IsEnabled(trials, "WebRTC-SendSideBwe-WithOverhead")),
add_pacing_to_cwin_(
field_trial::IsEnabled("WebRTC-AddPacingToCongestionWindowPushback")),
IsEnabled(trials, "WebRTC-AddPacingToCongestionWindowPushback")),
transport_overhead_bytes_per_packet_(0),
network_available_(false),
retransmission_rate_limiter_(clock, kRetransmitWindowSizeMs),

View File

@ -54,7 +54,8 @@ class RtpTransportControllerSend final
NetworkControllerFactoryInterface* controller_factory,
const BitrateConstraints& bitrate_config,
std::unique_ptr<ProcessThread> process_thread,
TaskQueueFactory* task_queue_factory);
TaskQueueFactory* task_queue_factory,
const WebRtcKeyValueConfig* trials);
~RtpTransportControllerSend() override;
RtpVideoSenderInterface* CreateRtpVideoSender(

View File

@ -128,7 +128,8 @@ class RtpVideoSenderTestFixture {
nullptr,
bitrate_config_,
ProcessThread::Create("PacerThread"),
task_queue_factory_.get()),
task_queue_factory_.get(),
&field_trials_),
process_thread_(ProcessThread::Create("test_thread")),
call_stats_(&clock_, process_thread_.get()),
stats_proxy_(&clock_,
@ -171,6 +172,7 @@ class RtpVideoSenderTestFixture {
SendDelayStats send_delay_stats_;
BitrateConstraints bitrate_config_;
const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
const FieldTrialBasedConfig field_trials_;
RtpTransportControllerSend transport_controller_;
std::unique_ptr<ProcessThread> process_thread_;
CallStats call_stats_;

View File

@ -241,6 +241,7 @@ rtc_library("peerconnection") {
"../api/rtc_event_log",
"../api/task_queue",
"../api/transport:datagram_transport_interface",
"../api/transport:field_trial_based_config",
"../api/transport/media:media_transport_interface",
"../api/units:data_rate",
"../api/video:builtin_video_bitrate_allocator_factory",

View File

@ -21,6 +21,7 @@
#include "api/peer_connection_factory_proxy.h"
#include "api/peer_connection_proxy.h"
#include "api/rtc_event_log/rtc_event_log.h"
#include "api/transport/field_trial_based_config.h"
#include "api/transport/media/media_transport_interface.h"
#include "api/turn_customizer.h"
#include "api/units/data_rate.h"
@ -42,7 +43,6 @@
#include "rtc_base/experiments/field_trial_units.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/system/file_wrapper.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
@ -81,7 +81,9 @@ PeerConnectionFactory::PeerConnectionFactory(
injected_network_controller_factory_(
std::move(dependencies.network_controller_factory)),
media_transport_factory_(std::move(dependencies.media_transport_factory)),
neteq_factory_(std::move(dependencies.neteq_factory)) {
neteq_factory_(std::move(dependencies.neteq_factory)),
trials_(dependencies.trials ? std::move(dependencies.trials)
: std::make_unique<FieldTrialBasedConfig>()) {
if (!network_thread_) {
owned_network_thread_ = rtc::Thread::CreateWithSocketServer();
owned_network_thread_->SetName("pc_network_thread", nullptr);
@ -342,7 +344,7 @@ std::unique_ptr<RtcEventLog> PeerConnectionFactory::CreateRtcEventLog_w() {
RTC_DCHECK_RUN_ON(worker_thread_);
auto encoding_type = RtcEventLog::EncodingType::Legacy;
if (field_trial::IsEnabled("WebRTC-RtcEventLogNewFormat"))
if (IsTrialEnabled("WebRTC-RtcEventLogNewFormat"))
encoding_type = RtcEventLog::EncodingType::NewFormat;
return event_log_factory_
? event_log_factory_->CreateRtcEventLog(encoding_type)
@ -364,7 +366,7 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
FieldTrialParameter<DataRate> start_bandwidth("start", DataRate::kbps(300));
FieldTrialParameter<DataRate> max_bandwidth("max", DataRate::kbps(2000));
ParseFieldTrial({&min_bandwidth, &start_bandwidth, &max_bandwidth},
field_trial::FindFullName("WebRTC-PcFactoryDefaultBitrates"));
trials_->Lookup("WebRTC-PcFactoryDefaultBitrates"));
call_config.bitrate_config.min_bitrate_bps =
rtc::saturated_cast<int>(min_bandwidth->bps());
@ -379,7 +381,7 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
network_state_predictor_factory_.get();
call_config.neteq_factory = neteq_factory_.get();
if (field_trial::IsEnabled("WebRTC-Bwe-InjectedCongestionController")) {
if (IsTrialEnabled("WebRTC-Bwe-InjectedCongestionController")) {
RTC_LOG(LS_INFO) << "Using injected network controller factory";
call_config.network_controller_factory =
injected_network_controller_factory_.get();
@ -387,7 +389,14 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
RTC_LOG(LS_INFO) << "Using default network controller factory";
}
call_config.trials = trials_.get();
return std::unique_ptr<Call>(call_factory_->CreateCall(call_config));
}
bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const {
RTC_DCHECK(trials_);
return trials_->Lookup(key).find("Enabled") == 0;
}
} // namespace webrtc

View File

@ -104,6 +104,8 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
virtual ~PeerConnectionFactory();
private:
bool IsTrialEnabled(absl::string_view key) const;
std::unique_ptr<RtcEventLog> CreateRtcEventLog_w();
std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log);
@ -128,6 +130,7 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
injected_network_controller_factory_;
std::unique_ptr<MediaTransportFactory> media_transport_factory_;
std::unique_ptr<NetEqFactory> neteq_factory_;
const std::unique_ptr<WebRtcKeyValueConfig> trials_;
};
} // namespace webrtc