Allows injection of network controller factory into peer connection factory.

Bug: webrtc:9155
Change-Id: I0a17024042f154297aba20f5d2dc766feb27f3f7
Reviewed-on: https://webrtc-review.googlesource.com/73123
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23313}
This commit is contained in:
Sebastian Jansson
2018-05-18 18:05:10 +02:00
committed by Commit Bot
parent 78b0a60223
commit dfce03af6e
21 changed files with 105 additions and 50 deletions

View File

@ -108,6 +108,7 @@ rtc_static_library("libjingle_peerconnection_api") {
"audio:audio_mixer_api", "audio:audio_mixer_api",
"audio_codecs:audio_codecs_api", "audio_codecs:audio_codecs_api",
"transport:bitrate_settings", "transport:bitrate_settings",
"transport:network_control",
"video:video_frame", "video:video_frame",
# Basically, don't add stuff here. You might break sensitive downstream # Basically, don't add stuff here. You might break sensitive downstream

View File

@ -91,6 +91,7 @@
#include "api/stats/rtcstatscollectorcallback.h" #include "api/stats/rtcstatscollectorcallback.h"
#include "api/statstypes.h" #include "api/statstypes.h"
#include "api/transport/bitrate_settings.h" #include "api/transport/bitrate_settings.h"
#include "api/transport/network_control.h"
#include "api/turncustomizer.h" #include "api/turncustomizer.h"
#include "api/umametrics.h" #include "api/umametrics.h"
#include "logging/rtc_event_log/rtc_event_log_factory_interface.h" #include "logging/rtc_event_log/rtc_event_log_factory_interface.h"
@ -1424,6 +1425,8 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
// created and used. // created and used.
// If |fec_controller_factory| is null, an internal fec controller module will // If |fec_controller_factory| is null, an internal fec controller module will
// be created and used. // be created and used.
// If |network_controller_factory| is provided, it will be used if enabled via
// field trial.
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
rtc::Thread* network_thread, rtc::Thread* network_thread,
rtc::Thread* worker_thread, rtc::Thread* worker_thread,
@ -1435,7 +1438,9 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
cricket::WebRtcVideoDecoderFactory* video_decoder_factory, cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
rtc::scoped_refptr<AudioMixer> audio_mixer, rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> audio_processing, rtc::scoped_refptr<AudioProcessing> audio_processing,
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory); std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
std::unique_ptr<NetworkControllerFactoryInterface>
network_controller_factory = nullptr);
// Create a new instance of PeerConnectionFactoryInterface with optional video // Create a new instance of PeerConnectionFactoryInterface with optional video
// codec factories. These video factories represents all video codecs, i.e. no // codec factories. These video factories represents all video codecs, i.e. no
@ -1536,7 +1541,9 @@ CreateModularPeerConnectionFactory(
std::unique_ptr<cricket::MediaEngineInterface> media_engine, std::unique_ptr<cricket::MediaEngineInterface> media_engine,
std::unique_ptr<CallFactoryInterface> call_factory, std::unique_ptr<CallFactoryInterface> call_factory,
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory, std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory,
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory); std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
std::unique_ptr<NetworkControllerFactoryInterface>
network_controller_factory = nullptr);
} // namespace webrtc } // namespace webrtc

View File

@ -37,6 +37,7 @@ rtc_source_set("call_interfaces") {
"../api:transport_api", "../api:transport_api",
"../api/audio:audio_mixer_api", "../api/audio:audio_mixer_api",
"../api/audio_codecs:audio_codecs_api", "../api/audio_codecs:audio_codecs_api",
"../api/transport:network_control",
"../modules/audio_device:audio_device", "../modules/audio_device:audio_device",
"../modules/audio_processing:audio_processing", "../modules/audio_processing:audio_processing",
"../modules/audio_processing:audio_processing_statistics", "../modules/audio_processing:audio_processing_statistics",

View File

@ -396,9 +396,9 @@ std::string Call::Stats::ToString(int64_t time_ms) const {
Call* Call::Create(const Call::Config& config) { Call* Call::Create(const Call::Config& config) {
return new internal::Call( return new internal::Call(
config, config, rtc::MakeUnique<RtpTransportControllerSend>(
rtc::MakeUnique<RtpTransportControllerSend>( Clock::GetRealTimeClock(), config.event_log,
Clock::GetRealTimeClock(), config.event_log, config.bitrate_config)); config.network_controller_factory, config.bitrate_config));
} }
Call* Call::Create( Call* Call::Create(

View File

@ -12,6 +12,7 @@
#include "api/fec_controller.h" #include "api/fec_controller.h"
#include "api/rtcerror.h" #include "api/rtcerror.h"
#include "api/transport/network_control.h"
#include "call/audio_state.h" #include "call/audio_state.h"
#include "call/bitrate_constraints.h" #include "call/bitrate_constraints.h"
#include "rtc_base/platform_file.h" #include "rtc_base/platform_file.h"
@ -45,6 +46,9 @@ struct CallConfig {
// FecController to use for this call. // FecController to use for this call.
FecControllerFactoryInterface* fec_controller_factory = nullptr; FecControllerFactoryInterface* fec_controller_factory = nullptr;
// Network controller factory to use for this call.
NetworkControllerFactoryInterface* network_controller_factory = nullptr;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -33,12 +33,14 @@ std::unique_ptr<SendSideCongestionControllerInterface> CreateController(
webrtc::RtcEventLog* event_log, webrtc::RtcEventLog* event_log,
PacedSender* pacer, PacedSender* pacer,
const BitrateConstraints& bitrate_config, const BitrateConstraints& bitrate_config,
bool task_queue_controller) { bool task_queue_controller,
NetworkControllerFactoryInterface* controller_factory) {
if (task_queue_controller) { if (task_queue_controller) {
RTC_LOG(LS_INFO) << "Using TaskQueue based SSCC"; RTC_LOG(LS_INFO) << "Using TaskQueue based SSCC";
return rtc::MakeUnique<webrtc::webrtc_cc::SendSideCongestionController>( return rtc::MakeUnique<webrtc::webrtc_cc::SendSideCongestionController>(
clock, task_queue, event_log, pacer, bitrate_config.start_bitrate_bps, clock, task_queue, event_log, pacer, bitrate_config.start_bitrate_bps,
bitrate_config.min_bitrate_bps, bitrate_config.max_bitrate_bps); bitrate_config.min_bitrate_bps, bitrate_config.max_bitrate_bps,
controller_factory);
} }
RTC_LOG(LS_INFO) << "Using Legacy SSCC"; RTC_LOG(LS_INFO) << "Using Legacy SSCC";
auto cc = rtc::MakeUnique<webrtc::SendSideCongestionController>( auto cc = rtc::MakeUnique<webrtc::SendSideCongestionController>(
@ -54,6 +56,7 @@ std::unique_ptr<SendSideCongestionControllerInterface> CreateController(
RtpTransportControllerSend::RtpTransportControllerSend( RtpTransportControllerSend::RtpTransportControllerSend(
Clock* clock, Clock* clock,
webrtc::RtcEventLog* event_log, webrtc::RtcEventLog* event_log,
NetworkControllerFactoryInterface* controller_factory,
const BitrateConstraints& bitrate_config) const BitrateConstraints& bitrate_config)
: clock_(clock), : clock_(clock),
pacer_(clock, &packet_router_, event_log), pacer_(clock, &packet_router_, event_log),
@ -64,7 +67,7 @@ RtpTransportControllerSend::RtpTransportControllerSend(
// Created after task_queue to be able to post to the task queue internally. // Created after task_queue to be able to post to the task queue internally.
send_side_cc_ = send_side_cc_ =
CreateController(clock, &task_queue_, event_log, &pacer_, bitrate_config, CreateController(clock, &task_queue_, event_log, &pacer_, bitrate_config,
TaskQueueExperimentEnabled()); TaskQueueExperimentEnabled(), controller_factory);
process_thread_->RegisterModule(&pacer_, RTC_FROM_HERE); process_thread_->RegisterModule(&pacer_, RTC_FROM_HERE);
process_thread_->RegisterModule(send_side_cc_.get(), RTC_FROM_HERE); process_thread_->RegisterModule(send_side_cc_.get(), RTC_FROM_HERE);

View File

@ -15,6 +15,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "api/transport/network_control.h"
#include "call/rtp_bitrate_configurator.h" #include "call/rtp_bitrate_configurator.h"
#include "call/rtp_transport_controller_send_interface.h" #include "call/rtp_transport_controller_send_interface.h"
#include "common_types.h" // NOLINT(build/include) #include "common_types.h" // NOLINT(build/include)
@ -36,9 +37,11 @@ class RtpTransportControllerSend final
: public RtpTransportControllerSendInterface, : public RtpTransportControllerSendInterface,
public NetworkChangedObserver { public NetworkChangedObserver {
public: public:
RtpTransportControllerSend(Clock* clock, RtpTransportControllerSend(
RtcEventLog* event_log, Clock* clock,
const BitrateConstraints& bitrate_config); RtcEventLog* event_log,
NetworkControllerFactoryInterface* controller_factory,
const BitrateConstraints& bitrate_config);
~RtpTransportControllerSend() override; ~RtpTransportControllerSend() override;
// Implements NetworkChangedObserver interface. // Implements NetworkChangedObserver interface.

View File

@ -177,6 +177,7 @@ BbrNetworkController::BbrNetworkController(NetworkControllerConfig config)
congestion_window_gain_constant_(kProbeBWCongestionWindowGain), congestion_window_gain_constant_(kProbeBWCongestionWindowGain),
rtt_variance_weight_(kBbrRttVariationWeight), rtt_variance_weight_(kBbrRttVariationWeight),
recovery_window_(max_congestion_window_) { recovery_window_(max_congestion_window_) {
RTC_LOG(LS_INFO) << "Creating BBR controller";
config_ = BbrControllerConfig::ExperimentConfig(); config_ = BbrControllerConfig::ExperimentConfig();
if (config.starting_bandwidth.IsFinite()) if (config.starting_bandwidth.IsFinite())
default_bandwidth_ = config.starting_bandwidth; default_bandwidth_ = config.starting_bandwidth;

View File

@ -53,7 +53,6 @@ rtc_static_library("congestion_controller") {
"../../pacing", "../../pacing",
"../../remote_bitrate_estimator", "../../remote_bitrate_estimator",
"../../rtp_rtcp:rtp_rtcp_format", "../../rtp_rtcp:rtp_rtcp_format",
"../bbr",
"../goog_cc", "../goog_cc",
] ]

View File

@ -65,13 +65,16 @@ class SendSideCongestionController
: public SendSideCongestionControllerInterface, : public SendSideCongestionControllerInterface,
public RtcpBandwidthObserver { public RtcpBandwidthObserver {
public: public:
SendSideCongestionController(const Clock* clock, SendSideCongestionController(
rtc::TaskQueue* task_queue, const Clock* clock,
RtcEventLog* event_log, rtc::TaskQueue* task_queue,
PacedSender* pacer, RtcEventLog* event_log,
int start_bitrate_bps, PacedSender* pacer,
int min_bitrate_bps, int start_bitrate_bps,
int max_bitrate_bps); int min_bitrate_bps,
int max_bitrate_bps,
NetworkControllerFactoryInterface* controller_factory);
~SendSideCongestionController() override; ~SendSideCongestionController() override;
void RegisterPacketFeedbackObserver( void RegisterPacketFeedbackObserver(
@ -170,8 +173,8 @@ class SendSideCongestionController
// TODO(srte): Move all access to feedback adapter to task queue. // TODO(srte): Move all access to feedback adapter to task queue.
TransportFeedbackAdapter transport_feedback_adapter_; TransportFeedbackAdapter transport_feedback_adapter_;
const std::unique_ptr<NetworkControllerFactoryInterface> NetworkControllerFactoryInterface* const controller_factory_with_feedback_
controller_factory_with_feedback_ RTC_GUARDED_BY(task_queue_); RTC_GUARDED_BY(task_queue_);
const std::unique_ptr<NetworkControllerFactoryInterface> const std::unique_ptr<NetworkControllerFactoryInterface>
controller_factory_fallback_ RTC_GUARDED_BY(task_queue_); controller_factory_fallback_ RTC_GUARDED_BY(task_queue_);

View File

@ -15,12 +15,10 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "api/transport/network_types.h" #include "api/transport/network_types.h"
#include "modules/congestion_controller/bbr/bbr_factory.h"
#include "modules/congestion_controller/goog_cc/include/goog_cc_factory.h" #include "modules/congestion_controller/goog_cc/include/goog_cc_factory.h"
#include "modules/remote_bitrate_estimator/include/bwe_defines.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
#include "rtc_base/bind.h" #include "rtc_base/bind.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/experiments/congestion_controller_experiment.h"
#include "rtc_base/format_macros.h" #include "rtc_base/format_macros.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_conversions.h"
@ -50,16 +48,6 @@ bool IsPacerPushbackExperimentEnabled() {
webrtc::runtime_enabled_features::kDualStreamModeFeatureName)); webrtc::runtime_enabled_features::kDualStreamModeFeatureName));
} }
std::unique_ptr<NetworkControllerFactoryInterface> MaybeCreateBbrFactory() {
if (CongestionControllerExperiment::BbrControllerEnabled()) {
RTC_LOG(LS_INFO) << "Creating BBR factory";
return rtc::MakeUnique<BbrNetworkControllerFactory>();
} else {
RTC_LOG(LS_INFO) << "Not creating BBR factory";
return nullptr;
}
}
void SortPacketFeedbackVector(std::vector<webrtc::PacketFeedback>* input) { void SortPacketFeedbackVector(std::vector<webrtc::PacketFeedback>* input) {
std::sort(input->begin(), input->end(), PacketFeedbackComparator()); std::sort(input->begin(), input->end(), PacketFeedbackComparator());
} }
@ -310,11 +298,12 @@ SendSideCongestionController::SendSideCongestionController(
PacedSender* pacer, PacedSender* pacer,
int start_bitrate_bps, int start_bitrate_bps,
int min_bitrate_bps, int min_bitrate_bps,
int max_bitrate_bps) int max_bitrate_bps,
NetworkControllerFactoryInterface* controller_factory)
: clock_(clock), : clock_(clock),
pacer_(pacer), pacer_(pacer),
transport_feedback_adapter_(clock_), transport_feedback_adapter_(clock_),
controller_factory_with_feedback_(MaybeCreateBbrFactory()), controller_factory_with_feedback_(controller_factory),
controller_factory_fallback_( controller_factory_fallback_(
rtc::MakeUnique<GoogCcNetworkControllerFactory>(event_log)), rtc::MakeUnique<GoogCcNetworkControllerFactory>(event_log)),
pacer_controller_(MakeUnique<PacerController>(pacer_)), pacer_controller_(MakeUnique<PacerController>(pacer_)),

View File

@ -77,7 +77,7 @@ class SendSideCongestionControllerTest : public ::testing::Test {
task_queue_ = rtc::MakeUnique<rtc::TaskQueue>("SSCC Test"); task_queue_ = rtc::MakeUnique<rtc::TaskQueue>("SSCC Test");
controller_.reset(new SendSideCongestionControllerForTest( controller_.reset(new SendSideCongestionControllerForTest(
&clock_, task_queue_.get(), &event_log_, pacer_.get(), &clock_, task_queue_.get(), &event_log_, pacer_.get(),
kInitialBitrateBps, 0, 5 * kInitialBitrateBps)); kInitialBitrateBps, 0, 5 * kInitialBitrateBps, nullptr));
controller_->DisablePeriodicTasks(); controller_->DisablePeriodicTasks();
controller_->RegisterNetworkObserver(&observer_); controller_->RegisterNetworkObserver(&observer_);
controller_->SignalNetworkState(NetworkState::kNetworkUp); controller_->SignalNetworkState(NetworkState::kNetworkUp);
@ -97,7 +97,7 @@ class SendSideCongestionControllerTest : public ::testing::Test {
task_queue_ = rtc::MakeUnique<rtc::TaskQueue>("SSCC Test"); task_queue_ = rtc::MakeUnique<rtc::TaskQueue>("SSCC Test");
controller_.reset(new SendSideCongestionControllerForTest( controller_.reset(new SendSideCongestionControllerForTest(
&clock_, task_queue_.get(), &event_log_, pacer_.get(), &clock_, task_queue_.get(), &event_log_, pacer_.get(),
kInitialBitrateBps, 0, 5 * kInitialBitrateBps)); kInitialBitrateBps, 0, 5 * kInitialBitrateBps, nullptr));
controller_->DisablePeriodicTasks(); controller_->DisablePeriodicTasks();
controller_->RegisterNetworkObserver(&target_bitrate_observer_); controller_->RegisterNetworkObserver(&target_bitrate_observer_);
controller_->SignalNetworkState(NetworkState::kNetworkUp); controller_->SignalNetworkState(NetworkState::kNetworkUp);

View File

@ -657,7 +657,8 @@ void RtpTransportControllerAdapter::Init_w() {
call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
std::unique_ptr<RtpTransportControllerSend> controller_send = std::unique_ptr<RtpTransportControllerSend> controller_send =
rtc::MakeUnique<RtpTransportControllerSend>( rtc::MakeUnique<RtpTransportControllerSend>(
Clock::GetRealTimeClock(), event_log_, call_config.bitrate_config); Clock::GetRealTimeClock(), event_log_,
call_config.network_controller_factory, call_config.bitrate_config);
call_send_rtp_transport_controller_ = controller_send.get(); call_send_rtp_transport_controller_ = controller_send.get();
call_.reset(webrtc::Call::Create(call_config, std::move(controller_send))); call_.reset(webrtc::Call::Create(call_config, std::move(controller_send)));
} }

View File

@ -204,11 +204,13 @@ rtc_static_library("peerconnection") {
"../logging:rtc_event_log_impl_output", "../logging:rtc_event_log_impl_output",
"../media:rtc_data", "../media:rtc_data",
"../media:rtc_media_base", "../media:rtc_media_base",
"../modules/congestion_controller/bbr",
"../p2p:rtc_p2p", "../p2p:rtc_p2p",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:stringutils", "../rtc_base:stringutils",
"../rtc_base/experiments:congestion_controller_experiment",
"../stats", "../stats",
"../system_wrappers", "../system_wrappers",
"../system_wrappers:field_trial_api", "../system_wrappers:field_trial_api",

View File

@ -8,6 +8,7 @@ include_rules = [
"+media", "+media",
"+modules/audio_device", "+modules/audio_device",
"+modules/audio_processing", "+modules/audio_processing",
"+modules/congestion_controller",
"+modules/rtp_rtcp", "+modules/rtp_rtcp",
"+modules/video_coding", "+modules/video_coding",
"+modules/video_render", "+modules/video_render",

View File

@ -79,7 +79,9 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
cricket::WebRtcVideoDecoderFactory* video_decoder_factory, cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
rtc::scoped_refptr<AudioMixer> audio_mixer, rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> audio_processing, rtc::scoped_refptr<AudioProcessing> audio_processing,
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory) { std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
std::unique_ptr<NetworkControllerFactoryInterface>
network_controller_factory) {
rtc::scoped_refptr<AudioProcessing> audio_processing_use = audio_processing; rtc::scoped_refptr<AudioProcessing> audio_processing_use = audio_processing;
if (!audio_processing_use) { if (!audio_processing_use) {
audio_processing_use = AudioProcessingBuilder().Create(); audio_processing_use = AudioProcessingBuilder().Create();
@ -99,7 +101,7 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
return CreateModularPeerConnectionFactory( return CreateModularPeerConnectionFactory(
network_thread, worker_thread, signaling_thread, std::move(media_engine), network_thread, worker_thread, signaling_thread, std::move(media_engine),
std::move(call_factory), std::move(event_log_factory), std::move(call_factory), std::move(event_log_factory),
std::move(fec_controller_factory)); std::move(fec_controller_factory), std::move(network_controller_factory));
} }
#endif #endif

View File

@ -34,6 +34,7 @@
#include "media/engine/webrtcvideodecoderfactory.h" // nogncheck #include "media/engine/webrtcvideodecoderfactory.h" // nogncheck
#include "media/engine/webrtcvideoencoderfactory.h" // nogncheck #include "media/engine/webrtcvideoencoderfactory.h" // nogncheck
#include "modules/audio_device/include/audio_device.h" // nogncheck #include "modules/audio_device/include/audio_device.h" // nogncheck
#include "modules/congestion_controller/bbr/bbr_factory.h"
#include "p2p/base/basicpacketsocketfactory.h" #include "p2p/base/basicpacketsocketfactory.h"
#include "p2p/client/basicportallocator.h" #include "p2p/client/basicportallocator.h"
#include "pc/audiotrack.h" #include "pc/audiotrack.h"
@ -42,6 +43,7 @@
#include "pc/peerconnection.h" #include "pc/peerconnection.h"
#include "pc/videocapturertracksource.h" #include "pc/videocapturertracksource.h"
#include "pc/videotrack.h" #include "pc/videotrack.h"
#include "rtc_base/experiments/congestion_controller_experiment.h"
namespace webrtc { namespace webrtc {
@ -55,7 +57,7 @@ CreateModularPeerConnectionFactory(
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) { std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) {
return CreateModularPeerConnectionFactory( return CreateModularPeerConnectionFactory(
network_thread, worker_thread, signaling_thread, std::move(media_engine), network_thread, worker_thread, signaling_thread, std::move(media_engine),
std::move(call_factory), std::move(event_log_factory), nullptr); std::move(call_factory), std::move(event_log_factory), nullptr, nullptr);
} }
rtc::scoped_refptr<PeerConnectionFactoryInterface> rtc::scoped_refptr<PeerConnectionFactoryInterface>
@ -66,12 +68,15 @@ CreateModularPeerConnectionFactory(
std::unique_ptr<cricket::MediaEngineInterface> media_engine, std::unique_ptr<cricket::MediaEngineInterface> media_engine,
std::unique_ptr<CallFactoryInterface> call_factory, std::unique_ptr<CallFactoryInterface> call_factory,
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory, std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory,
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory) { std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
std::unique_ptr<NetworkControllerFactoryInterface>
network_controller_factory) {
rtc::scoped_refptr<PeerConnectionFactory> pc_factory( rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
new rtc::RefCountedObject<PeerConnectionFactory>( new rtc::RefCountedObject<PeerConnectionFactory>(
network_thread, worker_thread, signaling_thread, network_thread, worker_thread, signaling_thread,
std::move(media_engine), std::move(call_factory), std::move(media_engine), std::move(call_factory),
std::move(event_log_factory), std::move(fec_controller_factory))); std::move(event_log_factory), std::move(fec_controller_factory),
std::move(network_controller_factory)));
// Call Initialize synchronously but make sure it is executed on // Call Initialize synchronously but make sure it is executed on
// |signaling_thread|. // |signaling_thread|.
@ -99,6 +104,7 @@ PeerConnectionFactory::PeerConnectionFactory(
std::move(media_engine), std::move(media_engine),
std::move(call_factory), std::move(call_factory),
std::move(event_log_factory), std::move(event_log_factory),
nullptr,
nullptr) {} nullptr) {}
PeerConnectionFactory::PeerConnectionFactory( PeerConnectionFactory::PeerConnectionFactory(
@ -108,7 +114,9 @@ PeerConnectionFactory::PeerConnectionFactory(
std::unique_ptr<cricket::MediaEngineInterface> media_engine, std::unique_ptr<cricket::MediaEngineInterface> media_engine,
std::unique_ptr<webrtc::CallFactoryInterface> call_factory, std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory, std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory,
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory) std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
std::unique_ptr<NetworkControllerFactoryInterface>
network_controller_factory)
: wraps_current_thread_(false), : wraps_current_thread_(false),
network_thread_(network_thread), network_thread_(network_thread),
worker_thread_(worker_thread), worker_thread_(worker_thread),
@ -116,7 +124,11 @@ PeerConnectionFactory::PeerConnectionFactory(
media_engine_(std::move(media_engine)), media_engine_(std::move(media_engine)),
call_factory_(std::move(call_factory)), call_factory_(std::move(call_factory)),
event_log_factory_(std::move(event_log_factory)), event_log_factory_(std::move(event_log_factory)),
fec_controller_factory_(std::move(fec_controller_factory)) { fec_controller_factory_(std::move(fec_controller_factory)),
injected_network_controller_factory_(
std::move(network_controller_factory)),
bbr_network_controller_factory_(
rtc::MakeUnique<BbrNetworkControllerFactory>()) {
if (!network_thread_) { if (!network_thread_) {
owned_network_thread_ = rtc::Thread::CreateWithSocketServer(); owned_network_thread_ = rtc::Thread::CreateWithSocketServer();
owned_network_thread_->SetName("pc_network_thread", nullptr); owned_network_thread_->SetName("pc_network_thread", nullptr);
@ -391,6 +403,18 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
call_config.fec_controller_factory = fec_controller_factory_.get(); call_config.fec_controller_factory = fec_controller_factory_.get();
if (CongestionControllerExperiment::BbrControllerEnabled()) {
RTC_LOG(LS_INFO) << "Using BBR network controller factory";
call_config.network_controller_factory =
bbr_network_controller_factory_.get();
} else if (CongestionControllerExperiment::InjectedControllerEnabled()) {
RTC_LOG(LS_INFO) << "Using injected network controller factory";
call_config.network_controller_factory =
injected_network_controller_factory_.get();
} else {
RTC_LOG(LS_INFO) << "Using default network controller factory";
}
return std::unique_ptr<Call>(call_factory_->CreateCall(call_config)); return std::unique_ptr<Call>(call_factory_->CreateCall(call_config));
} }

View File

@ -116,7 +116,9 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
std::unique_ptr<cricket::MediaEngineInterface> media_engine, std::unique_ptr<cricket::MediaEngineInterface> media_engine,
std::unique_ptr<webrtc::CallFactoryInterface> call_factory, std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory, std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory,
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory); std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
std::unique_ptr<NetworkControllerFactoryInterface>
network_controller_factory);
virtual ~PeerConnectionFactory(); virtual ~PeerConnectionFactory();
private: private:
@ -137,6 +139,10 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
std::unique_ptr<webrtc::CallFactoryInterface> call_factory_; std::unique_ptr<webrtc::CallFactoryInterface> call_factory_;
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_; std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_;
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_; std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
std::unique_ptr<NetworkControllerFactoryInterface>
injected_network_controller_factory_;
std::unique_ptr<NetworkControllerFactoryInterface>
bbr_network_controller_factory_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -16,21 +16,27 @@
namespace webrtc { namespace webrtc {
namespace { namespace {
const char kBbrControllerExperiment[] = "WebRTC-BweCongestionController"; const char kControllerExperiment[] = "WebRTC-BweCongestionController";
} // namespace } // namespace
bool CongestionControllerExperiment::BbrControllerEnabled() { bool CongestionControllerExperiment::BbrControllerEnabled() {
std::string trial_string = std::string trial_string =
webrtc::field_trial::FindFullName(kBbrControllerExperiment); webrtc::field_trial::FindFullName(kControllerExperiment);
return trial_string.find("Enabled,BBR") == 0; return trial_string.find("Enabled,BBR") == 0;
} }
bool CongestionControllerExperiment::InjectedControllerEnabled() {
std::string trial_string =
webrtc::field_trial::FindFullName(kControllerExperiment);
return trial_string.find("Enabled,Injected") == 0;
}
rtc::Optional<CongestionControllerExperiment::BbrExperimentConfig> rtc::Optional<CongestionControllerExperiment::BbrExperimentConfig>
CongestionControllerExperiment::GetBbrExperimentConfig() { CongestionControllerExperiment::GetBbrExperimentConfig() {
if (!BbrControllerEnabled()) if (!BbrControllerEnabled())
return rtc::nullopt; return rtc::nullopt;
std::string trial_string = std::string trial_string =
webrtc::field_trial::FindFullName(kBbrControllerExperiment); webrtc::field_trial::FindFullName(kControllerExperiment);
BbrExperimentConfig config; BbrExperimentConfig config;
if (sscanf( if (sscanf(
trial_string.c_str(), trial_string.c_str(),

View File

@ -33,6 +33,7 @@ class CongestionControllerExperiment {
double probe_rtt_congestion_window_gain; double probe_rtt_congestion_window_gain;
}; };
static bool BbrControllerEnabled(); static bool BbrControllerEnabled();
static bool InjectedControllerEnabled();
static rtc::Optional<BbrExperimentConfig> GetBbrExperimentConfig(); static rtc::Optional<BbrExperimentConfig> GetBbrExperimentConfig();
}; };

View File

@ -178,7 +178,8 @@ void CallTest::CreateCalls(const Call::Config& sender_config,
void CallTest::CreateSenderCall(const Call::Config& config) { void CallTest::CreateSenderCall(const Call::Config& config) {
std::unique_ptr<RtpTransportControllerSend> controller_send = std::unique_ptr<RtpTransportControllerSend> controller_send =
rtc::MakeUnique<RtpTransportControllerSend>( rtc::MakeUnique<RtpTransportControllerSend>(
Clock::GetRealTimeClock(), config.event_log, config.bitrate_config); Clock::GetRealTimeClock(), config.event_log,
config.network_controller_factory, config.bitrate_config);
sender_call_transport_controller_ = controller_send.get(); sender_call_transport_controller_ = controller_send.get();
sender_call_.reset(Call::Create(config, std::move(controller_send))); sender_call_.reset(Call::Create(config, std::move(controller_send)));
} }