2018-03-02 11:34:10 -08:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2011 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
|
|
|
*/
|
2015-01-20 21:36:13 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef PC_PEERCONNECTIONFACTORY_H_
|
|
|
|
|
#define PC_PEERCONNECTIONFACTORY_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
#include <memory>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/mediastreaminterface.h"
|
|
|
|
|
#include "api/peerconnectioninterface.h"
|
2017-10-23 11:41:54 -07:00
|
|
|
#include "media/sctp/sctptransportinternal.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "pc/channelmanager.h"
|
|
|
|
|
#include "rtc_base/rtccertificategenerator.h"
|
|
|
|
|
#include "rtc_base/scoped_ref_ptr.h"
|
|
|
|
|
#include "rtc_base/thread.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-12-01 15:01:24 -08:00
|
|
|
namespace rtc {
|
|
|
|
|
class BasicNetworkManager;
|
|
|
|
|
class BasicPacketSocketFactory;
|
|
|
|
|
} // namespace rtc
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2016-10-07 11:53:05 -07:00
|
|
|
class RtcEventLog;
|
|
|
|
|
|
2015-01-12 08:30:16 +00:00
|
|
|
class PeerConnectionFactory : public PeerConnectionFactoryInterface {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2017-02-10 20:13:37 -08:00
|
|
|
// Use the overloads of CreateVideoSource that take raw VideoCapturer
|
|
|
|
|
// pointers from PeerConnectionFactoryInterface.
|
|
|
|
|
// TODO(deadbeef): Remove this using statement once those overloads are
|
|
|
|
|
// removed.
|
|
|
|
|
using PeerConnectionFactoryInterface::CreateVideoSource;
|
|
|
|
|
|
2016-08-04 05:20:32 -07:00
|
|
|
void SetOptions(const Options& options) override;
|
2013-10-25 21:18:33 +00:00
|
|
|
|
2017-10-30 09:57:42 -07:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
|
2016-03-04 02:51:39 -08:00
|
|
|
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) override;
|
|
|
|
|
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
|
|
|
|
PeerConnectionDependencies dependencies) override;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool Initialize();
|
|
|
|
|
|
2018-06-28 14:09:33 +02:00
|
|
|
RtpCapabilities GetRtpSenderCapabilities(
|
|
|
|
|
cricket::MediaType kind) const override;
|
|
|
|
|
|
|
|
|
|
RtpCapabilities GetRtpReceiverCapabilities(
|
|
|
|
|
cricket::MediaType kind) const override;
|
|
|
|
|
|
2018-03-02 11:34:10 -08:00
|
|
|
rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream(
|
|
|
|
|
const std::string& stream_id) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-10-30 09:57:42 -07:00
|
|
|
rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
|
2016-03-04 02:51:39 -08:00
|
|
|
const cricket::AudioOptions& options) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-10-30 09:57:42 -07:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
|
2017-02-10 20:13:37 -08:00
|
|
|
std::unique_ptr<cricket::VideoCapturer> capturer) override;
|
2016-03-04 02:51:39 -08:00
|
|
|
// This version supports filtering on width, height and frame rate.
|
|
|
|
|
// For the "constraints=null" case, use the version without constraints.
|
|
|
|
|
// TODO(hta): Design a version without MediaConstraintsInterface.
|
|
|
|
|
// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
|
2017-02-10 20:13:37 -08:00
|
|
|
std::unique_ptr<cricket::VideoCapturer> capturer,
|
2015-01-12 08:30:16 +00:00
|
|
|
const MediaConstraintsInterface* constraints) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
|
|
|
|
|
const std::string& id,
|
|
|
|
|
VideoTrackSourceInterface* video_source) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-01-12 08:30:16 +00:00
|
|
|
rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& id,
|
2015-01-12 08:30:16 +00:00
|
|
|
AudioSourceInterface* audio_source) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-01-15 03:06:36 -08:00
|
|
|
bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
|
2015-10-22 03:25:41 -07:00
|
|
|
void StopAecDump() override;
|
2013-12-13 00:21:03 +00:00
|
|
|
|
2017-10-23 11:41:54 -07:00
|
|
|
virtual std::unique_ptr<cricket::SctpTransportInternalFactory>
|
|
|
|
|
CreateSctpTransportInternalFactory();
|
|
|
|
|
|
2017-05-05 02:23:02 -07:00
|
|
|
virtual cricket::ChannelManager* channel_manager();
|
2014-07-29 17:36:52 +00:00
|
|
|
virtual rtc::Thread* signaling_thread();
|
|
|
|
|
virtual rtc::Thread* worker_thread();
|
2016-05-17 01:52:02 -07:00
|
|
|
virtual rtc::Thread* network_thread();
|
2013-10-25 21:18:33 +00:00
|
|
|
const Options& options() const { return options_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
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);
|
Revert "Revert "Enables PeerConnectionFactory using external fec controller""
This reverts commit 00733015fafbbc61ddc12dfdc88b21a9fcd9d122.
Reason for revert: The reason for a downstream test failure on the original commit and a workaround has been found. Solution is to keep a PeerConnectionFactory constructor implementation as the same as before.
Original change's description:
> Revert "Enables PeerConnectionFactory using external fec controller"
>
> This reverts commit 4f07bdb25567d8ef528311e0b50a62c61d543fc3.
>
> Reason for revert: Speculatively reverting, because downstream test is now hitting "PeerConnectionFactory.initialize was not called before creating a PeerConnectionFactory" error, even though it did call initialize. I don't see how any change in this CL could cause that, but it's the only CL on the blamelist, and it does modify PeerConnectionFactory.java
>
> Original change's description:
> > Enables PeerConnectionFactory using external fec controller
> >
> > Bug: webrtc:8799
> > Change-Id: Ieb2cf6163b9a83844ab9ed4822b4a7f1db4c24b8
> > Reviewed-on: https://webrtc-review.googlesource.com/43961
> > Commit-Queue: Ying Wang <yinwa@webrtc.org>
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22038}
>
> TBR=sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
>
> Change-Id: I95868c35d6f9973e0ebf563814cd71d0fcbd433d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8799
> Reviewed-on: https://webrtc-review.googlesource.com/54080
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22040}
TBR=deadbeef@webrtc.org,sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
Bug: webrtc:8799
Change-Id: If9f3292bfcc739782967530c49f006d0abbc38a8
Reviewed-on: https://webrtc-review.googlesource.com/55400
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Ying Wang <yinwa@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22100}
2018-02-20 12:50:27 +01:00
|
|
|
PeerConnectionFactory(
|
|
|
|
|
rtc::Thread* network_thread,
|
|
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
|
|
|
|
std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
|
|
|
|
|
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory,
|
2018-05-18 18:05:10 +02:00
|
|
|
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
|
|
|
|
|
std::unique_ptr<NetworkControllerFactoryInterface>
|
|
|
|
|
network_controller_factory);
|
2018-05-29 15:04:32 -07:00
|
|
|
// Use this implementation for all future use. This structure allows simple
|
|
|
|
|
// management of all new dependencies being added to the
|
|
|
|
|
// PeerConnectionFactory.
|
|
|
|
|
explicit PeerConnectionFactory(
|
|
|
|
|
PeerConnectionFactoryDependencies dependencies);
|
|
|
|
|
|
2018-06-25 12:03:50 +02:00
|
|
|
// Hook to let testing framework insert actions between
|
|
|
|
|
// "new RTCPeerConnection" and "pc.Initialize"
|
|
|
|
|
virtual void ActionsBeforeInitializeForTesting(PeerConnectionInterface*) {}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual ~PeerConnectionFactory();
|
|
|
|
|
|
|
|
|
|
private:
|
2017-09-06 05:18:15 -07:00
|
|
|
std::unique_ptr<RtcEventLog> CreateRtcEventLog_w();
|
2017-06-15 12:52:32 -07:00
|
|
|
std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log);
|
|
|
|
|
|
2015-01-12 08:30:16 +00:00
|
|
|
bool wraps_current_thread_;
|
2016-05-17 01:52:02 -07:00
|
|
|
rtc::Thread* network_thread_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* worker_thread_;
|
2016-05-17 01:52:02 -07:00
|
|
|
rtc::Thread* signaling_thread_;
|
2017-06-15 12:52:32 -07:00
|
|
|
std::unique_ptr<rtc::Thread> owned_network_thread_;
|
|
|
|
|
std::unique_ptr<rtc::Thread> owned_worker_thread_;
|
2013-10-25 21:18:33 +00:00
|
|
|
Options options_;
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::ChannelManager> channel_manager_;
|
|
|
|
|
std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_;
|
|
|
|
|
std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_;
|
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_;
|
Revert "Revert "Enables PeerConnectionFactory using external fec controller""
This reverts commit 00733015fafbbc61ddc12dfdc88b21a9fcd9d122.
Reason for revert: The reason for a downstream test failure on the original commit and a workaround has been found. Solution is to keep a PeerConnectionFactory constructor implementation as the same as before.
Original change's description:
> Revert "Enables PeerConnectionFactory using external fec controller"
>
> This reverts commit 4f07bdb25567d8ef528311e0b50a62c61d543fc3.
>
> Reason for revert: Speculatively reverting, because downstream test is now hitting "PeerConnectionFactory.initialize was not called before creating a PeerConnectionFactory" error, even though it did call initialize. I don't see how any change in this CL could cause that, but it's the only CL on the blamelist, and it does modify PeerConnectionFactory.java
>
> Original change's description:
> > Enables PeerConnectionFactory using external fec controller
> >
> > Bug: webrtc:8799
> > Change-Id: Ieb2cf6163b9a83844ab9ed4822b4a7f1db4c24b8
> > Reviewed-on: https://webrtc-review.googlesource.com/43961
> > Commit-Queue: Ying Wang <yinwa@webrtc.org>
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22038}
>
> TBR=sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
>
> Change-Id: I95868c35d6f9973e0ebf563814cd71d0fcbd433d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8799
> Reviewed-on: https://webrtc-review.googlesource.com/54080
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22040}
TBR=deadbeef@webrtc.org,sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
Bug: webrtc:8799
Change-Id: If9f3292bfcc739782967530c49f006d0abbc38a8
Reviewed-on: https://webrtc-review.googlesource.com/55400
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Ying Wang <yinwa@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22100}
2018-02-20 12:50:27 +01:00
|
|
|
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
|
2018-05-18 18:05:10 +02:00
|
|
|
std::unique_ptr<NetworkControllerFactoryInterface>
|
|
|
|
|
injected_network_controller_factory_;
|
|
|
|
|
std::unique_ptr<NetworkControllerFactoryInterface>
|
|
|
|
|
bbr_network_controller_factory_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // PC_PEERCONNECTIONFACTORY_H_
|