2020-08-14 16:58:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2004 The WebRTC project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pc/peer_connection_factory.h"
|
|
|
|
|
2022-03-13 01:58:00 +00:00
|
|
|
#include <memory>
|
2020-08-14 16:58:22 +00:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "absl/strings/match.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "api/async_resolver_factory.h"
|
|
|
|
#include "api/call/call_factory_interface.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "api/fec_controller.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "api/ice_transport_interface.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "api/network_state_predictor.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "api/packet_socket_factory.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "api/rtc_event_log/rtc_event_log.h"
|
2021-06-25 00:43:10 +00:00
|
|
|
#include "api/sequence_checker.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "api/transport/bitrate_settings.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "api/units/data_rate.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "call/audio_state.h"
|
2022-03-11 16:49:54 +00:00
|
|
|
#include "call/rtp_transport_controller_send_factory.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "media/base/media_engine.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "p2p/base/basic_async_resolver_factory.h"
|
|
|
|
#include "p2p/base/basic_packet_socket_factory.h"
|
|
|
|
#include "p2p/base/default_ice_transport_factory.h"
|
2021-06-25 00:43:10 +00:00
|
|
|
#include "p2p/base/port_allocator.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "p2p/client/basic_port_allocator.h"
|
|
|
|
#include "pc/audio_track.h"
|
|
|
|
#include "pc/local_audio_source.h"
|
|
|
|
#include "pc/media_stream.h"
|
2022-03-11 16:49:54 +00:00
|
|
|
#include "pc/media_stream_proxy.h"
|
|
|
|
#include "pc/media_stream_track_proxy.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "pc/peer_connection.h"
|
2022-03-11 16:49:54 +00:00
|
|
|
#include "pc/peer_connection_factory_proxy.h"
|
|
|
|
#include "pc/peer_connection_proxy.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "pc/rtp_parameters_conversion.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "pc/session_description.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "pc/video_track.h"
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
#include "rtc_base/experiments/field_trial_parser.h"
|
|
|
|
#include "rtc_base/experiments/field_trial_units.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "rtc_base/location.h"
|
|
|
|
#include "rtc_base/logging.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "rtc_base/numerics/safe_conversions.h"
|
2020-12-23 07:48:30 +00:00
|
|
|
#include "rtc_base/ref_counted_object.h"
|
2021-06-25 00:43:10 +00:00
|
|
|
#include "rtc_base/rtc_certificate_generator.h"
|
2020-08-14 16:58:22 +00:00
|
|
|
#include "rtc_base/system/file_wrapper.h"
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
|
|
|
CreateModularPeerConnectionFactory(
|
|
|
|
PeerConnectionFactoryDependencies dependencies) {
|
2020-12-23 07:48:30 +00:00
|
|
|
// The PeerConnectionFactory must be created on the signaling thread.
|
|
|
|
if (dependencies.signaling_thread &&
|
|
|
|
!dependencies.signaling_thread->IsCurrent()) {
|
|
|
|
return dependencies.signaling_thread
|
|
|
|
->Invoke<rtc::scoped_refptr<PeerConnectionFactoryInterface>>(
|
|
|
|
RTC_FROM_HERE, [&dependencies] {
|
|
|
|
return CreateModularPeerConnectionFactory(
|
|
|
|
std::move(dependencies));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
|
|
|
|
if (!pc_factory) {
|
2020-08-14 16:58:22 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2020-12-23 07:48:30 +00:00
|
|
|
// Verify that the invocation and the initialization ended up agreeing on the
|
|
|
|
// thread.
|
|
|
|
RTC_DCHECK_RUN_ON(pc_factory->signaling_thread());
|
2021-06-25 00:43:10 +00:00
|
|
|
return PeerConnectionFactoryProxy::Create(
|
|
|
|
pc_factory->signaling_thread(), pc_factory->worker_thread(), pc_factory);
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
2020-12-23 07:48:30 +00:00
|
|
|
// Static
|
|
|
|
rtc::scoped_refptr<PeerConnectionFactory> PeerConnectionFactory::Create(
|
|
|
|
PeerConnectionFactoryDependencies dependencies) {
|
|
|
|
auto context = ConnectionContext::Create(&dependencies);
|
|
|
|
if (!context) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2021-06-25 00:43:10 +00:00
|
|
|
return rtc::make_ref_counted<PeerConnectionFactory>(context, &dependencies);
|
2020-12-23 07:48:30 +00:00
|
|
|
}
|
|
|
|
|
2020-08-14 16:58:22 +00:00
|
|
|
PeerConnectionFactory::PeerConnectionFactory(
|
2020-12-23 07:48:30 +00:00
|
|
|
rtc::scoped_refptr<ConnectionContext> context,
|
|
|
|
PeerConnectionFactoryDependencies* dependencies)
|
|
|
|
: context_(context),
|
|
|
|
task_queue_factory_(std::move(dependencies->task_queue_factory)),
|
|
|
|
event_log_factory_(std::move(dependencies->event_log_factory)),
|
|
|
|
fec_controller_factory_(std::move(dependencies->fec_controller_factory)),
|
2020-08-14 16:58:22 +00:00
|
|
|
network_state_predictor_factory_(
|
2020-12-23 07:48:30 +00:00
|
|
|
std::move(dependencies->network_state_predictor_factory)),
|
2020-08-14 16:58:22 +00:00
|
|
|
injected_network_controller_factory_(
|
2020-12-23 07:48:30 +00:00
|
|
|
std::move(dependencies->network_controller_factory)),
|
2022-03-11 16:49:54 +00:00
|
|
|
neteq_factory_(std::move(dependencies->neteq_factory)),
|
|
|
|
transport_controller_send_factory_(
|
|
|
|
(dependencies->transport_controller_send_factory)
|
|
|
|
? std::move(dependencies->transport_controller_send_factory)
|
2022-03-13 01:58:00 +00:00
|
|
|
: std::make_unique<RtpTransportControllerSendFactory>()) {}
|
2020-08-14 16:58:22 +00:00
|
|
|
|
2020-12-23 07:48:30 +00:00
|
|
|
PeerConnectionFactory::PeerConnectionFactory(
|
|
|
|
PeerConnectionFactoryDependencies dependencies)
|
|
|
|
: PeerConnectionFactory(ConnectionContext::Create(&dependencies),
|
|
|
|
&dependencies) {}
|
2020-08-14 16:58:22 +00:00
|
|
|
|
|
|
|
PeerConnectionFactory::~PeerConnectionFactory() {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PeerConnectionFactory::SetOptions(const Options& options) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
options_ = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtpCapabilities PeerConnectionFactory::GetRtpSenderCapabilities(
|
|
|
|
cricket::MediaType kind) const {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
switch (kind) {
|
|
|
|
case cricket::MEDIA_TYPE_AUDIO: {
|
|
|
|
cricket::AudioCodecs cricket_codecs;
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetSupportedAudioSendCodecs(&cricket_codecs);
|
2020-08-14 16:58:22 +00:00
|
|
|
return ToRtpCapabilities(
|
|
|
|
cricket_codecs,
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetDefaultEnabledAudioRtpHeaderExtensions());
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
case cricket::MEDIA_TYPE_VIDEO: {
|
|
|
|
cricket::VideoCodecs cricket_codecs;
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetSupportedVideoSendCodecs(&cricket_codecs);
|
2020-08-14 16:58:22 +00:00
|
|
|
return ToRtpCapabilities(
|
|
|
|
cricket_codecs,
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetDefaultEnabledVideoRtpHeaderExtensions());
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
case cricket::MEDIA_TYPE_DATA:
|
|
|
|
return RtpCapabilities();
|
2020-12-23 07:48:30 +00:00
|
|
|
case cricket::MEDIA_TYPE_UNSUPPORTED:
|
|
|
|
return RtpCapabilities();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
2021-06-25 00:43:10 +00:00
|
|
|
RTC_DLOG(LS_ERROR) << "Got unexpected MediaType " << kind;
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_CHECK_NOTREACHED();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RtpCapabilities PeerConnectionFactory::GetRtpReceiverCapabilities(
|
|
|
|
cricket::MediaType kind) const {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
switch (kind) {
|
|
|
|
case cricket::MEDIA_TYPE_AUDIO: {
|
|
|
|
cricket::AudioCodecs cricket_codecs;
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetSupportedAudioReceiveCodecs(&cricket_codecs);
|
2020-08-14 16:58:22 +00:00
|
|
|
return ToRtpCapabilities(
|
|
|
|
cricket_codecs,
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetDefaultEnabledAudioRtpHeaderExtensions());
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
case cricket::MEDIA_TYPE_VIDEO: {
|
|
|
|
cricket::VideoCodecs cricket_codecs;
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetSupportedVideoReceiveCodecs(&cricket_codecs);
|
2020-08-14 16:58:22 +00:00
|
|
|
return ToRtpCapabilities(
|
|
|
|
cricket_codecs,
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->GetDefaultEnabledVideoRtpHeaderExtensions());
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
case cricket::MEDIA_TYPE_DATA:
|
|
|
|
return RtpCapabilities();
|
2020-12-23 07:48:30 +00:00
|
|
|
case cricket::MEDIA_TYPE_UNSUPPORTED:
|
|
|
|
return RtpCapabilities();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
2021-06-25 00:43:10 +00:00
|
|
|
RTC_DLOG(LS_ERROR) << "Got unexpected MediaType " << kind;
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_CHECK_NOTREACHED();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioSourceInterface>
|
|
|
|
PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK(signaling_thread()->IsCurrent());
|
2020-08-14 16:58:22 +00:00
|
|
|
rtc::scoped_refptr<LocalAudioSource> source(
|
|
|
|
LocalAudioSource::Create(&options));
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PeerConnectionFactory::StartAecDump(FILE* file, int64_t max_size_bytes) {
|
2021-06-25 00:43:10 +00:00
|
|
|
RTC_DCHECK_RUN_ON(worker_thread());
|
2020-12-23 07:48:30 +00:00
|
|
|
return channel_manager()->StartAecDump(FileWrapper(file), max_size_bytes);
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PeerConnectionFactory::StopAecDump() {
|
2021-06-25 00:43:10 +00:00
|
|
|
RTC_DCHECK_RUN_ON(worker_thread());
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->StopAecDump();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 00:43:10 +00:00
|
|
|
RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>
|
|
|
|
PeerConnectionFactory::CreatePeerConnectionOrError(
|
2020-08-14 16:58:22 +00:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
|
|
|
PeerConnectionDependencies dependencies) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
RTC_DCHECK(!(dependencies.allocator && dependencies.packet_socket_factory))
|
|
|
|
<< "You can't set both allocator and packet_socket_factory; "
|
|
|
|
"the former is going away (see bugs.webrtc.org/7447";
|
|
|
|
|
|
|
|
// Set internal defaults if optional dependencies are not set.
|
|
|
|
if (!dependencies.cert_generator) {
|
|
|
|
dependencies.cert_generator =
|
2020-12-23 07:48:30 +00:00
|
|
|
std::make_unique<rtc::RTCCertificateGenerator>(signaling_thread(),
|
|
|
|
network_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
if (!dependencies.allocator) {
|
|
|
|
rtc::PacketSocketFactory* packet_socket_factory;
|
|
|
|
if (dependencies.packet_socket_factory)
|
|
|
|
packet_socket_factory = dependencies.packet_socket_factory.get();
|
|
|
|
else
|
2020-12-23 07:48:30 +00:00
|
|
|
packet_socket_factory = context_->default_socket_factory();
|
2020-08-14 16:58:22 +00:00
|
|
|
|
|
|
|
dependencies.allocator = std::make_unique<cricket::BasicPortAllocator>(
|
2020-12-23 07:48:30 +00:00
|
|
|
context_->default_network_manager(), packet_socket_factory,
|
2020-08-14 16:58:22 +00:00
|
|
|
configuration.turn_customizer);
|
2022-03-11 16:49:54 +00:00
|
|
|
dependencies.allocator->SetPortRange(
|
|
|
|
configuration.port_allocator_config.min_port,
|
|
|
|
configuration.port_allocator_config.max_port);
|
|
|
|
dependencies.allocator->set_flags(
|
|
|
|
configuration.port_allocator_config.flags);
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!dependencies.async_resolver_factory) {
|
|
|
|
dependencies.async_resolver_factory =
|
|
|
|
std::make_unique<webrtc::BasicAsyncResolverFactory>();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dependencies.ice_transport_factory) {
|
|
|
|
dependencies.ice_transport_factory =
|
|
|
|
std::make_unique<DefaultIceTransportFactory>();
|
|
|
|
}
|
|
|
|
|
2020-12-23 07:48:30 +00:00
|
|
|
dependencies.allocator->SetNetworkIgnoreMask(options().network_ignore_mask);
|
2022-03-11 16:49:54 +00:00
|
|
|
dependencies.allocator->SetVpnList(configuration.vpn_list);
|
2020-08-14 16:58:22 +00:00
|
|
|
|
|
|
|
std::unique_ptr<RtcEventLog> event_log =
|
2020-12-23 07:48:30 +00:00
|
|
|
worker_thread()->Invoke<std::unique_ptr<RtcEventLog>>(
|
2021-06-25 00:43:10 +00:00
|
|
|
RTC_FROM_HERE, [this] { return CreateRtcEventLog_w(); });
|
2020-08-14 16:58:22 +00:00
|
|
|
|
2020-12-23 07:48:30 +00:00
|
|
|
std::unique_ptr<Call> call = worker_thread()->Invoke<std::unique_ptr<Call>>(
|
2020-08-14 16:58:22 +00:00
|
|
|
RTC_FROM_HERE,
|
2021-06-25 00:43:10 +00:00
|
|
|
[this, &event_log] { return CreateCall_w(event_log.get()); });
|
2020-08-14 16:58:22 +00:00
|
|
|
|
2021-06-25 00:43:10 +00:00
|
|
|
auto result = PeerConnection::Create(context_, options_, std::move(event_log),
|
|
|
|
std::move(call), configuration,
|
|
|
|
std::move(dependencies));
|
|
|
|
if (!result.ok()) {
|
|
|
|
return result.MoveError();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
2021-06-25 00:43:10 +00:00
|
|
|
// We configure the proxy with a pointer to the network thread for methods
|
|
|
|
// that need to be invoked there rather than on the signaling thread.
|
2022-03-11 16:49:54 +00:00
|
|
|
// Internally, the proxy object has a member variable named `worker_thread_`
|
2021-06-25 00:43:10 +00:00
|
|
|
// which will point to the network thread (and not the factory's
|
|
|
|
// worker_thread()). All such methods have thread checks though, so the code
|
|
|
|
// should still be clear (outside of macro expansion).
|
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> result_proxy =
|
|
|
|
PeerConnectionProxy::Create(signaling_thread(), network_thread(),
|
|
|
|
result.MoveValue());
|
|
|
|
return result_proxy;
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtc::scoped_refptr<MediaStreamInterface>
|
|
|
|
PeerConnectionFactory::CreateLocalMediaStream(const std::string& stream_id) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK(signaling_thread()->IsCurrent());
|
|
|
|
return MediaStreamProxy::Create(signaling_thread(),
|
2020-08-14 16:58:22 +00:00
|
|
|
MediaStream::Create(stream_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
rtc::scoped_refptr<VideoTrackInterface> PeerConnectionFactory::CreateVideoTrack(
|
|
|
|
const std::string& id,
|
|
|
|
VideoTrackSourceInterface* source) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK(signaling_thread()->IsCurrent());
|
2020-08-14 16:58:22 +00:00
|
|
|
rtc::scoped_refptr<VideoTrackInterface> track(
|
2020-12-23 07:48:30 +00:00
|
|
|
VideoTrack::Create(id, source, worker_thread()));
|
|
|
|
return VideoTrackProxy::Create(signaling_thread(), worker_thread(), track);
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> PeerConnectionFactory::CreateAudioTrack(
|
|
|
|
const std::string& id,
|
|
|
|
AudioSourceInterface* source) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK(signaling_thread()->IsCurrent());
|
2022-03-13 01:58:00 +00:00
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track(AudioTrack::Create(id, source));
|
2020-12-23 07:48:30 +00:00
|
|
|
return AudioTrackProxy::Create(signaling_thread(), track);
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cricket::ChannelManager* PeerConnectionFactory::channel_manager() {
|
2020-12-23 07:48:30 +00:00
|
|
|
return context_->channel_manager();
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<RtcEventLog> PeerConnectionFactory::CreateRtcEventLog_w() {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(worker_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
|
|
|
|
auto encoding_type = RtcEventLog::EncodingType::Legacy;
|
|
|
|
if (IsTrialEnabled("WebRTC-RtcEventLogNewFormat"))
|
|
|
|
encoding_type = RtcEventLog::EncodingType::NewFormat;
|
|
|
|
return event_log_factory_
|
|
|
|
? event_log_factory_->CreateRtcEventLog(encoding_type)
|
|
|
|
: std::make_unique<RtcEventLogNull>();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
|
|
|
|
RtcEventLog* event_log) {
|
2020-12-23 07:48:30 +00:00
|
|
|
RTC_DCHECK_RUN_ON(worker_thread());
|
2020-08-14 16:58:22 +00:00
|
|
|
|
2021-06-25 00:43:10 +00:00
|
|
|
webrtc::Call::Config call_config(event_log, network_thread());
|
2020-12-23 07:48:30 +00:00
|
|
|
if (!channel_manager()->media_engine() || !context_->call_factory()) {
|
2020-08-14 16:58:22 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
call_config.audio_state =
|
2020-12-23 07:48:30 +00:00
|
|
|
channel_manager()->media_engine()->voice().GetAudioState();
|
2020-08-14 16:58:22 +00:00
|
|
|
|
|
|
|
FieldTrialParameter<DataRate> min_bandwidth("min",
|
|
|
|
DataRate::KilobitsPerSec(30));
|
|
|
|
FieldTrialParameter<DataRate> start_bandwidth("start",
|
|
|
|
DataRate::KilobitsPerSec(300));
|
|
|
|
FieldTrialParameter<DataRate> max_bandwidth("max",
|
|
|
|
DataRate::KilobitsPerSec(2000));
|
|
|
|
ParseFieldTrial({&min_bandwidth, &start_bandwidth, &max_bandwidth},
|
2020-12-23 07:48:30 +00:00
|
|
|
trials().Lookup("WebRTC-PcFactoryDefaultBitrates"));
|
2020-08-14 16:58:22 +00:00
|
|
|
|
|
|
|
call_config.bitrate_config.min_bitrate_bps =
|
|
|
|
rtc::saturated_cast<int>(min_bandwidth->bps());
|
|
|
|
call_config.bitrate_config.start_bitrate_bps =
|
|
|
|
rtc::saturated_cast<int>(start_bandwidth->bps());
|
|
|
|
call_config.bitrate_config.max_bitrate_bps =
|
|
|
|
rtc::saturated_cast<int>(max_bandwidth->bps());
|
|
|
|
|
|
|
|
call_config.fec_controller_factory = fec_controller_factory_.get();
|
|
|
|
call_config.task_queue_factory = task_queue_factory_.get();
|
|
|
|
call_config.network_state_predictor_factory =
|
|
|
|
network_state_predictor_factory_.get();
|
|
|
|
call_config.neteq_factory = neteq_factory_.get();
|
|
|
|
|
|
|
|
if (IsTrialEnabled("WebRTC-Bwe-InjectedCongestionController")) {
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2020-12-23 07:48:30 +00:00
|
|
|
call_config.trials = &trials();
|
2022-03-11 16:49:54 +00:00
|
|
|
call_config.rtp_transport_controller_send_factory =
|
|
|
|
transport_controller_send_factory_.get();
|
2020-12-23 07:48:30 +00:00
|
|
|
return std::unique_ptr<Call>(
|
|
|
|
context_->call_factory()->CreateCall(call_config));
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const {
|
2020-12-23 07:48:30 +00:00
|
|
|
return absl::StartsWith(trials().Lookup(key), "Enabled");
|
2020-08-14 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace webrtc
|