2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2004 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "pc/peerconnectionfactory.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-12-17 03:04:15 -08:00
|
|
|
#include <utility>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/mediaconstraintsinterface.h"
|
|
|
|
|
#include "api/mediastreamproxy.h"
|
|
|
|
|
#include "api/mediastreamtrackproxy.h"
|
|
|
|
|
#include "api/peerconnectionfactoryproxy.h"
|
|
|
|
|
#include "api/peerconnectionproxy.h"
|
2017-10-10 14:01:40 +02:00
|
|
|
#include "api/turncustomizer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/videosourceproxy.h"
|
|
|
|
|
#include "logging/rtc_event_log/rtc_event_log.h"
|
2017-11-06 15:40:09 -08:00
|
|
|
#include "media/base/rtpdataengine.h"
|
2017-10-23 11:41:54 -07:00
|
|
|
#include "media/sctp/sctptransport.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/bind.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/ptr_util.h"
|
2017-06-15 12:52:32 -07:00
|
|
|
// Adding 'nogncheck' to disable the gn include headers check to support modular
|
|
|
|
|
// WebRTC build targets.
|
|
|
|
|
// TODO(zhihuang): This wouldn't be necessary if the interface and
|
|
|
|
|
// implementation of the media engine were in separate build targets.
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "media/engine/webrtcmediaengine.h" // nogncheck
|
|
|
|
|
#include "media/engine/webrtcvideodecoderfactory.h" // nogncheck
|
|
|
|
|
#include "media/engine/webrtcvideoencoderfactory.h" // nogncheck
|
|
|
|
|
#include "modules/audio_device/include/audio_device.h" // nogncheck
|
|
|
|
|
#include "p2p/base/basicpacketsocketfactory.h"
|
|
|
|
|
#include "p2p/client/basicportallocator.h"
|
|
|
|
|
#include "pc/audiotrack.h"
|
|
|
|
|
#include "pc/localaudiosource.h"
|
|
|
|
|
#include "pc/mediastream.h"
|
|
|
|
|
#include "pc/peerconnection.h"
|
|
|
|
|
#include "pc/videocapturertracksource.h"
|
|
|
|
|
#include "pc/videotrack.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2017-01-31 01:48:08 -08:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
2017-06-15 12:52:32 -07:00
|
|
|
CreateModularPeerConnectionFactory(
|
2016-12-13 14:06:26 -08:00
|
|
|
rtc::Thread* network_thread,
|
|
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
2017-06-15 12:52:32 -07:00
|
|
|
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
|
|
|
|
std::unique_ptr<CallFactoryInterface> call_factory,
|
|
|
|
|
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) {
|
2016-12-13 14:06:26 -08:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
|
|
|
|
new rtc::RefCountedObject<PeerConnectionFactory>(
|
2017-09-23 16:14:25 +02:00
|
|
|
network_thread, worker_thread, signaling_thread,
|
2017-09-23 17:21:32 +02:00
|
|
|
std::move(media_engine), std::move(call_factory),
|
|
|
|
|
std::move(event_log_factory)));
|
2016-12-13 14:06:26 -08:00
|
|
|
|
|
|
|
|
// Call Initialize synchronously but make sure it is executed on
|
|
|
|
|
// |signaling_thread|.
|
|
|
|
|
MethodCall0<PeerConnectionFactory, bool> call(
|
|
|
|
|
pc_factory.get(), &PeerConnectionFactory::Initialize);
|
2017-06-15 12:52:32 -07:00
|
|
|
bool result = call.Marshal(RTC_FROM_HERE, pc_factory->signaling_thread());
|
2016-12-13 14:06:26 -08:00
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2017-06-15 12:52:32 -07:00
|
|
|
return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
|
|
|
|
|
pc_factory);
|
2017-01-31 01:48:08 -08:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
PeerConnectionFactory::PeerConnectionFactory(
|
2016-05-17 01:52:02 -07:00
|
|
|
rtc::Thread* network_thread,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
2017-06-15 12:52:32 -07:00
|
|
|
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
|
|
|
|
std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
|
|
|
|
|
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory)
|
|
|
|
|
: wraps_current_thread_(false),
|
2016-05-17 01:52:02 -07:00
|
|
|
network_thread_(network_thread),
|
2013-07-10 00:45:36 +00:00
|
|
|
worker_thread_(worker_thread),
|
2016-05-17 01:52:02 -07:00
|
|
|
signaling_thread_(signaling_thread),
|
2017-06-15 12:52:32 -07:00
|
|
|
media_engine_(std::move(media_engine)),
|
|
|
|
|
call_factory_(std::move(call_factory)),
|
|
|
|
|
event_log_factory_(std::move(event_log_factory)) {
|
|
|
|
|
if (!network_thread_) {
|
|
|
|
|
owned_network_thread_ = rtc::Thread::CreateWithSocketServer();
|
2017-11-13 10:54:45 +01:00
|
|
|
owned_network_thread_->SetName("pc_network_thread", nullptr);
|
2017-06-15 12:52:32 -07:00
|
|
|
owned_network_thread_->Start();
|
|
|
|
|
network_thread_ = owned_network_thread_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!worker_thread_) {
|
|
|
|
|
owned_worker_thread_ = rtc::Thread::Create();
|
2017-11-13 10:54:45 +01:00
|
|
|
owned_worker_thread_->SetName("pc_worker_thread", nullptr);
|
2017-06-15 12:52:32 -07:00
|
|
|
owned_worker_thread_->Start();
|
|
|
|
|
worker_thread_ = owned_worker_thread_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!signaling_thread_) {
|
|
|
|
|
signaling_thread_ = rtc::Thread::Current();
|
|
|
|
|
if (!signaling_thread_) {
|
|
|
|
|
// If this thread isn't already wrapped by an rtc::Thread, create a
|
|
|
|
|
// wrapper and own it in this class.
|
|
|
|
|
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
|
|
|
|
|
wraps_current_thread_ = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 09:57:42 -07:00
|
|
|
// TODO(deadbeef): Currently there is no way to create an external adm in
|
2013-07-10 00:45:36 +00:00
|
|
|
// libjingle source tree. So we can 't currently assert if this is NULL.
|
2017-01-12 05:15:36 -08:00
|
|
|
// RTC_DCHECK(default_adm != NULL);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PeerConnectionFactory::~PeerConnectionFactory() {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2015-08-11 10:33:13 +02:00
|
|
|
channel_manager_.reset(nullptr);
|
2015-03-13 21:26:12 +00:00
|
|
|
|
|
|
|
|
// Make sure |worker_thread_| and |signaling_thread_| outlive
|
2016-06-01 15:45:30 +02:00
|
|
|
// |default_socket_factory_| and |default_network_manager_|.
|
2015-12-01 15:01:24 -08:00
|
|
|
default_socket_factory_ = nullptr;
|
|
|
|
|
default_network_manager_ = nullptr;
|
2015-03-13 21:26:12 +00:00
|
|
|
|
2017-06-15 12:52:32 -07:00
|
|
|
if (wraps_current_thread_)
|
|
|
|
|
rtc::ThreadManager::Instance()->UnwrapCurrentThread();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PeerConnectionFactory::Initialize() {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2016-05-06 11:29:15 -07:00
|
|
|
rtc::InitRandom(rtc::Time32());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-12-01 15:01:24 -08:00
|
|
|
default_network_manager_.reset(new rtc::BasicNetworkManager());
|
|
|
|
|
if (!default_network_manager_) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default_socket_factory_.reset(
|
2016-05-17 01:52:02 -07:00
|
|
|
new rtc::BasicPacketSocketFactory(network_thread_));
|
2015-12-01 15:01:24 -08:00
|
|
|
if (!default_socket_factory_) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-11-06 15:40:09 -08:00
|
|
|
channel_manager_ = rtc::MakeUnique<cricket::ChannelManager>(
|
|
|
|
|
std::move(media_engine_), rtc::MakeUnique<cricket::RtpDataEngine>(),
|
|
|
|
|
worker_thread_, network_thread_);
|
2015-02-11 08:38:35 +00:00
|
|
|
|
2014-06-09 12:51:39 +00:00
|
|
|
channel_manager_->SetVideoRtxEnabled(true);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!channel_manager_->Init()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-04 22:17:38 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-04 05:20:32 -07:00
|
|
|
void PeerConnectionFactory::SetOptions(const Options& options) {
|
|
|
|
|
options_ = options;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<AudioSourceInterface>
|
2015-01-12 08:30:16 +00:00
|
|
|
PeerConnectionFactory::CreateAudioSource(
|
2013-07-10 00:45:36 +00:00
|
|
|
const MediaConstraintsInterface* constraints) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<LocalAudioSource> source(
|
2017-02-10 21:26:48 -08:00
|
|
|
LocalAudioSource::Create(constraints));
|
2013-07-10 00:45:36 +00:00
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-04 02:51:39 -08:00
|
|
|
rtc::scoped_refptr<AudioSourceInterface>
|
|
|
|
|
PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) {
|
|
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
|
|
|
|
rtc::scoped_refptr<LocalAudioSource> source(
|
2017-02-10 21:26:48 -08:00
|
|
|
LocalAudioSource::Create(&options));
|
2016-03-04 02:51:39 -08:00
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface>
|
2015-01-12 08:30:16 +00:00
|
|
|
PeerConnectionFactory::CreateVideoSource(
|
2017-02-10 20:13:37 -08:00
|
|
|
std::unique_ptr<cricket::VideoCapturer> capturer,
|
2013-07-10 00:45:36 +00:00
|
|
|
const MediaConstraintsInterface* constraints) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface> source(
|
2017-02-10 20:13:37 -08:00
|
|
|
VideoCapturerTrackSource::Create(worker_thread_, std::move(capturer),
|
|
|
|
|
constraints, false));
|
2016-04-07 07:45:54 -07:00
|
|
|
return VideoTrackSourceProxy::Create(signaling_thread_, worker_thread_,
|
|
|
|
|
source);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface>
|
2017-02-10 20:13:37 -08:00
|
|
|
PeerConnectionFactory::CreateVideoSource(
|
|
|
|
|
std::unique_ptr<cricket::VideoCapturer> capturer) {
|
2016-03-04 02:51:39 -08:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface> source(
|
2017-02-10 20:13:37 -08:00
|
|
|
VideoCapturerTrackSource::Create(worker_thread_, std::move(capturer),
|
|
|
|
|
false));
|
2016-04-07 07:45:54 -07:00
|
|
|
return VideoTrackSourceProxy::Create(signaling_thread_, worker_thread_,
|
|
|
|
|
source);
|
2016-03-04 02:51:39 -08:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 03:06:36 -08:00
|
|
|
bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file,
|
|
|
|
|
int64_t max_size_bytes) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2016-01-15 03:06:36 -08:00
|
|
|
return channel_manager_->StartAecDump(file, max_size_bytes);
|
2013-12-13 00:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-22 03:25:41 -07:00
|
|
|
void PeerConnectionFactory::StopAecDump() {
|
|
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
|
|
|
|
channel_manager_->StopAecDump();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 15:01:24 -08:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface>
|
|
|
|
|
PeerConnectionFactory::CreatePeerConnection(
|
2016-03-04 02:51:39 -08:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration_in,
|
2015-12-01 15:01:24 -08:00
|
|
|
const MediaConstraintsInterface* constraints,
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::PortAllocator> allocator,
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
2015-12-01 15:01:24 -08:00
|
|
|
PeerConnectionObserver* observer) {
|
|
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
|
|
|
|
|
2016-03-04 02:51:39 -08:00
|
|
|
// We merge constraints and configuration into a single configuration.
|
|
|
|
|
PeerConnectionInterface::RTCConfiguration configuration = configuration_in;
|
|
|
|
|
CopyConstraintsIntoRtcConfiguration(constraints, &configuration);
|
|
|
|
|
|
|
|
|
|
return CreatePeerConnection(configuration, std::move(allocator),
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::move(cert_generator), observer);
|
2016-03-04 02:51:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<PeerConnectionInterface>
|
|
|
|
|
PeerConnectionFactory::CreatePeerConnection(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::PortAllocator> allocator,
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
2016-03-04 02:51:39 -08:00
|
|
|
PeerConnectionObserver* observer) {
|
|
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
|
|
|
|
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
if (!cert_generator.get()) {
|
2016-06-01 15:45:30 +02:00
|
|
|
// No certificate generator specified, use the default one.
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
cert_generator.reset(
|
2016-06-01 15:45:30 +02:00
|
|
|
new rtc::RTCCertificateGenerator(signaling_thread_, network_thread_));
|
2015-12-01 15:01:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!allocator) {
|
|
|
|
|
allocator.reset(new cricket::BasicPortAllocator(
|
2017-10-10 14:01:40 +02:00
|
|
|
default_network_manager_.get(), default_socket_factory_.get(),
|
|
|
|
|
configuration.turn_customizer));
|
2015-12-01 15:01:24 -08:00
|
|
|
}
|
2016-05-18 16:55:30 -07:00
|
|
|
network_thread_->Invoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask,
|
|
|
|
|
allocator.get(), options_.network_ignore_mask));
|
2015-12-01 15:01:24 -08:00
|
|
|
|
2017-09-05 04:30:30 -07:00
|
|
|
std::unique_ptr<RtcEventLog> event_log =
|
2017-09-06 05:18:15 -07:00
|
|
|
worker_thread_->Invoke<std::unique_ptr<RtcEventLog>>(
|
|
|
|
|
RTC_FROM_HERE,
|
|
|
|
|
rtc::Bind(&PeerConnectionFactory::CreateRtcEventLog_w, this));
|
Revert of Add logging of host lookups made by TurnPort to the RtcEventLog. (patchset #11 id:200001 of https://codereview.webrtc.org/2996933003/ )
Reason for revert:
Breaks Chromium build due to the changed constructor in webrtc/p2p/client/basicportallocator.h.
Build (example): https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/19739.
Log:
FAILED: obj/remoting/protocol/protocol/port_allocator.o
/b/c/goma_client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/protocol/protocol/port_allocator.o.d -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"310694-2\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCOMPONENT_BUILD -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_GLIBCXX_DEBUG=1 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DEXPAT_RELATIVE_PATH -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DFEATURE_ENABLE_VOICEMAIL -DGTEST_RELATIVE_PATH -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DBORINGSSL_SHARED_LIBRARY -I../.. -Igen -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/glib-2.0 -I../../build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../third_party/libwebp/src -I../../third_party/khronos -I../../gpu -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/protobuf/src -I../../third_party/webrtc_overrides -I../../testing/gtest/include -I../../third_party -I../../third_party/webrtc_overrides -I../../third_party -I../../third_party/boringssl/src/include -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr -I../../third_party/libyuv/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fdebug-prefix-map=/b/c/b/Linux_Builder__dbg_/src=. -m64 -march=x86-64 -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-auto-raw-pointer -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wno-header-guard -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=gnu++14 -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_jessie_amd64-sysroot -fno-exceptions -fvisibility-inlines-hidden -c ../../remoting/protocol/port_allocator.cc -o obj/remoting/protocol/protocol/port_allocator.o
../../remoting/protocol/port_allocator.cc:48:7: error: no matching constructor for initialization of 'cricket::BasicPortAllocator'
: BasicPortAllocator(network_manager.get(), socket_factory.get()),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/p2p/client/basicportallocator.h:35:12: note: candidate constructor not viable: requires single argument 'network_manager', but 2 arguments were provided
explicit BasicPortAllocator(rtc::NetworkManager* network_manager);
^
../../third_party/webrtc/p2p/client/basicportallocator.h:30:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class BasicPortAllocator : public PortAllocator {
^
../../third_party/webrtc/p2p/client/basicportallocator.h:32:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided
BasicPortAllocator(rtc::NetworkManager* network_manager,
^
../../third_party/webrtc/p2p/client/basicportallocator.h:36:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided
BasicPortAllocator(rtc::NetworkManager* network_manager,
^
../../third_party/webrtc/p2p/client/basicportallocator.h:39:3: note: candidate constructor not viable: requires 5 arguments, but 2 were provided
BasicPortAllocator(rtc::NetworkManager* network_manager,
^
1 error generated.
Original issue's description:
> Add logging host lookups made by TurnPort to the RtcEventLog.
>
> The following fields are logged:
> - error, if there was an error.
> - elapsed time in milliseconds
>
> BUG=webrtc:8100
>
> Review-Url: https://codereview.webrtc.org/2996933003
> Cr-Commit-Position: refs/heads/master@{#19574}
> Committed: https://chromium.googlesource.com/external/webrtc/+/c251cb13c08aba710ba3a12588beb4aa172c7323
TBR=terelius@webrtc.org,pthatcher@webrtc.org,jonaso@google.com,pthatcher@google.com,solenberg@webrtc.org,deadbeef@webrtc.org,jonaso@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:8100
Review-Url: https://codereview.webrtc.org/3012473002
Cr-Commit-Position: refs/heads/master@{#19578}
2017-08-29 04:49:00 -07:00
|
|
|
|
2017-06-15 12:52:32 -07:00
|
|
|
std::unique_ptr<Call> call = worker_thread_->Invoke<std::unique_ptr<Call>>(
|
|
|
|
|
RTC_FROM_HERE,
|
|
|
|
|
rtc::Bind(&PeerConnectionFactory::CreateCall_w, this, event_log.get()));
|
|
|
|
|
|
2015-12-01 15:01:24 -08:00
|
|
|
rtc::scoped_refptr<PeerConnection> pc(
|
2017-06-15 12:52:32 -07:00
|
|
|
new rtc::RefCountedObject<PeerConnection>(this, std::move(event_log),
|
|
|
|
|
std::move(call)));
|
2016-03-04 02:51:39 -08:00
|
|
|
|
2016-04-11 23:25:29 -07:00
|
|
|
if (!pc->Initialize(configuration, std::move(allocator),
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::move(cert_generator), observer)) {
|
2015-12-01 15:01:24 -08:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
return PeerConnectionProxy::Create(signaling_thread(), pc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<MediaStreamInterface>
|
2013-07-10 00:45:36 +00:00
|
|
|
PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
return MediaStreamProxy::Create(signaling_thread_,
|
|
|
|
|
MediaStream::Create(label));
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackInterface> PeerConnectionFactory::CreateVideoTrack(
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& id,
|
2016-03-08 01:27:48 +01:00
|
|
|
VideoTrackSourceInterface* source) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<VideoTrackInterface> track(
|
2017-07-31 23:22:01 -07:00
|
|
|
VideoTrack::Create(id, source, worker_thread_));
|
2016-04-07 07:45:54 -07:00
|
|
|
return VideoTrackProxy::Create(signaling_thread_, worker_thread_, track);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<AudioTrackInterface>
|
2014-05-13 11:07:01 +00:00
|
|
|
PeerConnectionFactory::CreateAudioTrack(const std::string& id,
|
|
|
|
|
AudioSourceInterface* source) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2015-12-15 04:27:11 -08:00
|
|
|
rtc::scoped_refptr<AudioTrackInterface> track(AudioTrack::Create(id, source));
|
2013-07-10 00:45:36 +00:00
|
|
|
return AudioTrackProxy::Create(signaling_thread_, track);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-27 11:07:25 -07:00
|
|
|
cricket::TransportController* PeerConnectionFactory::CreateTransportController(
|
2016-08-30 22:07:42 -07:00
|
|
|
cricket::PortAllocator* port_allocator,
|
|
|
|
|
bool redetermine_role_on_ice_restart) {
|
2016-07-27 11:07:25 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
Negotiate the same SRTP crypto suites for every DTLS association formed.
Before this CL, we would negotiate:
- No crypto suites for data m= sections.
- A full set for audio m= sections.
- The full set, minus SRTP_AES128_CM_SHA1_32 for video m= sections.
However, this doesn't make sense with BUNDLE, since any DTLS
association could end up being used for any type of media. If
video is "bundled on" the audio transport (which is typical), it
will actually end up using SRTP_AES128_CM_SHA1_32.
So, this CL moves the responsibility of deciding SRTP crypto suites out
of BaseChannel and into DtlsTransport. The only two possibilities are
now "normal set" or "normal set + GCM", if enabled by the PC factory
options.
This fixes an issue (see linked bug) that was occurring when audio/video
were "bundled onto" the data transport. Since the data transport
wasn't negotiating any SRTP crypto suites, none were available to use
for audio/video, so the application would get black video/no audio.
This CL doesn't affect the SDES SRTP crypto suite negotiation;
it only affects the negotiation in the DLTS handshake, through
the use_srtp extension.
BUG=chromium:711243
Review-Url: https://codereview.webrtc.org/2815513012
Cr-Commit-Position: refs/heads/master@{#17810}
2017-04-21 03:23:33 -07:00
|
|
|
return new cricket::TransportController(
|
|
|
|
|
signaling_thread_, network_thread_, port_allocator,
|
|
|
|
|
redetermine_role_on_ice_restart, options_.crypto_options);
|
2016-07-27 11:07:25 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-23 11:41:54 -07:00
|
|
|
std::unique_ptr<cricket::SctpTransportInternalFactory>
|
|
|
|
|
PeerConnectionFactory::CreateSctpTransportInternalFactory() {
|
|
|
|
|
#ifdef HAVE_SCTP
|
|
|
|
|
return rtc::MakeUnique<cricket::SctpTransportFactory>(network_thread());
|
|
|
|
|
#else
|
|
|
|
|
return nullptr;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-05 02:23:02 -07:00
|
|
|
cricket::ChannelManager* PeerConnectionFactory::channel_manager() {
|
|
|
|
|
return channel_manager_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* PeerConnectionFactory::signaling_thread() {
|
2015-01-12 08:30:16 +00:00
|
|
|
// This method can be called on a different thread when the factory is
|
|
|
|
|
// created in CreatePeerConnectionFactory().
|
2013-07-10 00:45:36 +00:00
|
|
|
return signaling_thread_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* PeerConnectionFactory::worker_thread() {
|
2013-07-10 00:45:36 +00:00
|
|
|
return worker_thread_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-17 01:52:02 -07:00
|
|
|
rtc::Thread* PeerConnectionFactory::network_thread() {
|
|
|
|
|
return network_thread_;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 05:18:15 -07:00
|
|
|
std::unique_ptr<RtcEventLog> PeerConnectionFactory::CreateRtcEventLog_w() {
|
2017-09-06 12:33:43 -07:00
|
|
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
2017-10-03 16:11:34 +02:00
|
|
|
const auto encoding_type = RtcEventLog::EncodingType::Legacy;
|
|
|
|
|
return event_log_factory_
|
|
|
|
|
? event_log_factory_->CreateRtcEventLog(encoding_type)
|
|
|
|
|
: rtc::MakeUnique<RtcEventLogNullImpl>();
|
2017-09-06 05:18:15 -07:00
|
|
|
}
|
|
|
|
|
|
2017-06-15 12:52:32 -07:00
|
|
|
std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
|
|
|
|
|
RtcEventLog* event_log) {
|
2017-09-06 12:33:43 -07:00
|
|
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
|
|
|
|
|
2017-06-15 12:52:32 -07:00
|
|
|
const int kMinBandwidthBps = 30000;
|
|
|
|
|
const int kStartBandwidthBps = 300000;
|
|
|
|
|
const int kMaxBandwidthBps = 2000000;
|
|
|
|
|
|
|
|
|
|
webrtc::Call::Config call_config(event_log);
|
|
|
|
|
if (!channel_manager_->media_engine() || !call_factory_) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
call_config.audio_state = channel_manager_->media_engine()->GetAudioState();
|
|
|
|
|
call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
|
|
|
|
|
call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
|
|
|
|
|
call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
|
|
|
|
|
|
|
|
|
|
return std::unique_ptr<Call>(call_factory_->CreateCall(call_config));
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|