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
|
|
|
*/
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/peerconnectionfactory.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-12-17 03:04:15 -08:00
|
|
|
#include <utility>
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/audiotrack.h"
|
|
|
|
|
#include "webrtc/api/localaudiosource.h"
|
2016-03-04 02:51:39 -08:00
|
|
|
#include "webrtc/api/mediaconstraintsinterface.h"
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/mediastream.h"
|
|
|
|
|
#include "webrtc/api/mediastreamproxy.h"
|
|
|
|
|
#include "webrtc/api/mediastreamtrackproxy.h"
|
|
|
|
|
#include "webrtc/api/peerconnection.h"
|
|
|
|
|
#include "webrtc/api/peerconnectionfactoryproxy.h"
|
|
|
|
|
#include "webrtc/api/peerconnectionproxy.h"
|
2016-03-08 01:27:48 +01:00
|
|
|
#include "webrtc/api/videocapturertracksource.h"
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/videosourceproxy.h"
|
|
|
|
|
#include "webrtc/api/videotrack.h"
|
2014-09-24 17:14:05 +00:00
|
|
|
#include "webrtc/base/bind.h"
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/webrtcmediaengine.h"
|
|
|
|
|
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
|
|
|
|
|
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
2016-06-13 07:34:51 -07:00
|
|
|
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
#include "webrtc/modules/audio_device/include/audio_device.h"
|
2015-12-01 15:01:24 -08:00
|
|
|
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
|
|
|
|
|
#include "webrtc/p2p/client/basicportallocator.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
2013-07-10 00:45:36 +00:00
|
|
|
CreatePeerConnectionFactory() {
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
|
|
|
|
new rtc::RefCountedObject<PeerConnectionFactory>());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-23 10:38:07 -07:00
|
|
|
RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread());
|
|
|
|
|
// The signaling thread is the current thread so we can
|
|
|
|
|
// safely call Initialize directly.
|
|
|
|
|
if (!pc_factory->Initialize()) {
|
|
|
|
|
return nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-01-12 08:30:16 +00:00
|
|
|
return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
|
|
|
|
|
pc_factory);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-17 01:52:02 -07:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
|
|
|
|
rtc::Thread* network_thread,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
2013-07-10 00:45:36 +00:00
|
|
|
AudioDeviceModule* default_adm,
|
|
|
|
|
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
|
|
|
|
cricket::WebRtcVideoDecoderFactory* decoder_factory) {
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
2016-05-17 01:52:02 -07:00
|
|
|
new rtc::RefCountedObject<PeerConnectionFactory>(
|
2016-06-13 07:34:51 -07:00
|
|
|
network_thread,
|
|
|
|
|
worker_thread,
|
|
|
|
|
signaling_thread,
|
|
|
|
|
default_adm,
|
|
|
|
|
CreateBuiltinAudioDecoderFactory(),
|
|
|
|
|
encoder_factory,
|
|
|
|
|
decoder_factory));
|
2015-01-12 08:30:16 +00:00
|
|
|
|
|
|
|
|
// Call Initialize synchronously but make sure its executed on
|
|
|
|
|
// |signaling_thread|.
|
|
|
|
|
MethodCall0<PeerConnectionFactory, bool> call(
|
|
|
|
|
pc_factory.get(),
|
|
|
|
|
&PeerConnectionFactory::Initialize);
|
2016-06-10 14:17:27 -07:00
|
|
|
bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
|
2015-01-12 08:30:16 +00:00
|
|
|
|
|
|
|
|
if (!result) {
|
2016-03-23 10:38:07 -07:00
|
|
|
return nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-01-12 08:30:16 +00:00
|
|
|
return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PeerConnectionFactory::PeerConnectionFactory()
|
|
|
|
|
: owns_ptrs_(true),
|
2015-01-12 08:30:16 +00:00
|
|
|
wraps_current_thread_(false),
|
2016-05-17 01:52:02 -07:00
|
|
|
network_thread_(rtc::Thread::CreateWithSocketServer().release()),
|
|
|
|
|
worker_thread_(rtc::Thread::Create().release()),
|
2016-06-17 04:16:24 -07:00
|
|
|
signaling_thread_(rtc::Thread::Current()),
|
|
|
|
|
audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) {
|
2015-01-12 08:30:16 +00:00
|
|
|
if (!signaling_thread_) {
|
|
|
|
|
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
|
|
|
|
|
wraps_current_thread_ = true;
|
|
|
|
|
}
|
2016-05-17 01:52:02 -07:00
|
|
|
network_thread_->Start();
|
2015-01-12 08:30:16 +00:00
|
|
|
worker_thread_->Start();
|
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,
|
2013-07-10 00:45:36 +00:00
|
|
|
AudioDeviceModule* default_adm,
|
2016-06-13 07:34:51 -07:00
|
|
|
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
|
|
|
|
audio_decoder_factory,
|
2013-07-10 00:45:36 +00:00
|
|
|
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
|
|
|
|
cricket::WebRtcVideoDecoderFactory* video_decoder_factory)
|
|
|
|
|
: owns_ptrs_(false),
|
2015-01-12 08:30:16 +00:00
|
|
|
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),
|
2013-07-10 00:45:36 +00:00
|
|
|
default_adm_(default_adm),
|
2016-06-13 07:34:51 -07:00
|
|
|
audio_decoder_factory_(audio_decoder_factory),
|
2013-07-10 00:45:36 +00:00
|
|
|
video_encoder_factory_(video_encoder_factory),
|
|
|
|
|
video_decoder_factory_(video_decoder_factory) {
|
2016-05-17 01:52:02 -07:00
|
|
|
RTC_DCHECK(network_thread);
|
|
|
|
|
RTC_DCHECK(worker_thread);
|
|
|
|
|
RTC_DCHECK(signaling_thread);
|
2013-07-10 00:45:36 +00:00
|
|
|
// TODO: Currently there is no way creating an external adm in
|
|
|
|
|
// libjingle source tree. So we can 't currently assert if this is NULL.
|
|
|
|
|
// ASSERT(default_adm != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
if (owns_ptrs_) {
|
2015-01-12 08:30:16 +00:00
|
|
|
if (wraps_current_thread_)
|
|
|
|
|
rtc::ThreadManager::Instance()->UnwrapCurrentThread();
|
2014-04-17 22:54:30 +00:00
|
|
|
delete worker_thread_;
|
2016-05-17 01:52:02 -07:00
|
|
|
delete network_thread_;
|
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
|
|
|
|
|
|
|
|
// TODO: Need to make sure only one VoE is created inside
|
|
|
|
|
// WebRtcMediaEngine.
|
2015-02-11 08:38:35 +00:00
|
|
|
cricket::MediaEngineInterface* media_engine =
|
2016-06-10 14:17:27 -07:00
|
|
|
worker_thread_->Invoke<cricket::MediaEngineInterface*>(
|
|
|
|
|
RTC_FROM_HERE,
|
|
|
|
|
rtc::Bind(&PeerConnectionFactory::CreateMediaEngine_w, this));
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
channel_manager_.reset(new cricket::ChannelManager(
|
2016-05-17 01:52:02 -07:00
|
|
|
media_engine, worker_thread_, network_thread_));
|
2015-02-11 08:38:35 +00:00
|
|
|
|
2014-06-09 12:51:39 +00:00
|
|
|
channel_manager_->SetVideoRtxEnabled(true);
|
2016-08-04 05:20:32 -07:00
|
|
|
channel_manager_->SetCryptoOptions(options_.crypto_options);
|
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;
|
|
|
|
|
if (channel_manager_) {
|
|
|
|
|
channel_manager_->SetCryptoOptions(options.crypto_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(
|
2013-10-25 21:18:33 +00:00
|
|
|
LocalAudioSource::Create(options_, 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(
|
|
|
|
|
LocalAudioSource::Create(options_, &options));
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface>
|
2015-01-12 08:30:16 +00:00
|
|
|
PeerConnectionFactory::CreateVideoSource(
|
2013-07-10 00:45:36 +00:00
|
|
|
cricket::VideoCapturer* capturer,
|
|
|
|
|
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(
|
|
|
|
|
VideoCapturerTrackSource::Create(worker_thread_, 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>
|
2016-03-04 02:51:39 -08:00
|
|
|
PeerConnectionFactory::CreateVideoSource(cricket::VideoCapturer* capturer) {
|
|
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface> source(
|
|
|
|
|
VideoCapturerTrackSource::Create(worker_thread_, 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(
|
|
|
|
|
default_network_manager_.get(), default_socket_factory_.get()));
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
rtc::scoped_refptr<PeerConnection> pc(
|
|
|
|
|
new rtc::RefCountedObject<PeerConnection>(this));
|
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(
|
2013-07-10 00:45:36 +00:00
|
|
|
VideoTrack::Create(id, source));
|
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-02-12 02:27:06 -08:00
|
|
|
webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController(
|
2016-10-07 11:53:05 -07:00
|
|
|
const cricket::MediaConfig& config,
|
|
|
|
|
webrtc::RtcEventLog* event_log) const {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
2016-02-12 02:27:06 -08:00
|
|
|
return MediaControllerInterface::Create(config, worker_thread_,
|
2016-10-07 11:53:05 -07:00
|
|
|
channel_manager_.get(), event_log);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
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());
|
|
|
|
|
return new cricket::TransportController(signaling_thread_, network_thread_,
|
2016-08-30 22:07:42 -07:00
|
|
|
port_allocator,
|
|
|
|
|
redetermine_role_on_ice_restart);
|
2016-07-27 11:07:25 -07:00
|
|
|
}
|
|
|
|
|
|
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() {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
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_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-11 08:38:35 +00:00
|
|
|
cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
|
|
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
return cricket::WebRtcMediaEngineFactory::Create(
|
2016-06-13 07:34:51 -07:00
|
|
|
default_adm_.get(),
|
|
|
|
|
audio_decoder_factory_,
|
|
|
|
|
video_encoder_factory_.get(),
|
2015-02-11 08:38:35 +00:00
|
|
|
video_decoder_factory_.get());
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|