blob: 40706cecd513c0579238102ae132ff6a2b6a619c [file] [log] [blame]
Seth Hampson845e8782018-03-02 19:34:101
henrike@webrtc.org28e20752013-07-10 00:45:362/*
kjellanderb24317b2016-02-10 15:54:433 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:364 *
kjellanderb24317b2016-02-10 15:54:435 * Use of this source code is governed by a BSD-style license
6 * that can be found in the LICENSE file in the root of the source
7 * tree. An additional intellectual property rights grant can be found
8 * in the file PATENTS. All contributing project authors may
9 * be found in the AUTHORS file in the root of the source tree.
henrike@webrtc.org28e20752013-07-10 00:45:3610 */
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:1311
Steve Anton10542f22019-01-11 17:11:0012#ifndef PC_PEER_CONNECTION_FACTORY_H_
13#define PC_PEER_CONNECTION_FACTORY_H_
henrike@webrtc.org28e20752013-07-10 00:45:3614
kwibergd1fe2812016-04-27 13:47:2915#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:3616#include <string>
17
Steve Anton10542f22019-01-11 17:11:0018#include "api/media_stream_interface.h"
Piotr (Peter) Slatalae0c2e972018-10-08 16:43:2119#include "api/media_transport_interface.h"
Steve Anton10542f22019-01-11 17:11:0020#include "api/peer_connection_interface.h"
Mirko Bonadeid9708072019-01-25 19:26:4821#include "api/scoped_refptr.h"
Steve Anton10542f22019-01-11 17:11:0022#include "media/sctp/sctp_transport_internal.h"
23#include "pc/channel_manager.h"
24#include "rtc_base/rtc_certificate_generator.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3125#include "rtc_base/thread.h"
henrike@webrtc.org28e20752013-07-10 00:45:3626
deadbeef41b07982015-12-01 23:01:2427namespace rtc {
28class BasicNetworkManager;
29class BasicPacketSocketFactory;
Yves Gerey665174f2018-06-19 13:03:0530} // namespace rtc
deadbeef41b07982015-12-01 23:01:2431
henrike@webrtc.org28e20752013-07-10 00:45:3632namespace webrtc {
33
skvlad11a9cbf2016-10-07 18:53:0534class RtcEventLog;
35
perkj@webrtc.org81134d02015-01-12 08:30:1636class PeerConnectionFactory : public PeerConnectionFactoryInterface {
henrike@webrtc.org28e20752013-07-10 00:45:3637 public:
jbauchcb560652016-08-04 12:20:3238 void SetOptions(const Options& options) override;
wu@webrtc.org97077a32013-10-25 21:18:3339
Steve Anton36b29d12017-10-30 16:57:4240 rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
htaa2a49d92016-03-04 10:51:3941 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 13:47:2942 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 09:44:1843 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
htaa2a49d92016-03-04 10:51:3944 PeerConnectionObserver* observer) override;
45
Benjamin Wright6f7e6d62018-05-02 20:46:3146 rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
47 const PeerConnectionInterface::RTCConfiguration& configuration,
48 PeerConnectionDependencies dependencies) override;
49
henrike@webrtc.org28e20752013-07-10 00:45:3650 bool Initialize();
51
Florent Castelli72b751a2018-06-28 12:09:3352 RtpCapabilities GetRtpSenderCapabilities(
53 cricket::MediaType kind) const override;
54
55 RtpCapabilities GetRtpReceiverCapabilities(
56 cricket::MediaType kind) const override;
57
Seth Hampson845e8782018-03-02 19:34:1058 rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream(
59 const std::string& stream_id) override;
henrike@webrtc.org28e20752013-07-10 00:45:3660
Steve Anton36b29d12017-10-30 16:57:4261 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
htaa2a49d92016-03-04 10:51:3962 const cricket::AudioOptions& options) override;
henrike@webrtc.org28e20752013-07-10 00:45:3663
perkja3ede6c2016-03-08 00:27:4864 rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
65 const std::string& id,
66 VideoTrackSourceInterface* video_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:3667
Yves Gerey665174f2018-06-19 13:03:0568 rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
69 const std::string& id,
70 AudioSourceInterface* audio_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:3671
ivocd66b44d2016-01-15 11:06:3672 bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
ivoc797ef122015-10-22 10:25:4173 void StopAecDump() override;
wu@webrtc.orga9890802013-12-13 00:21:0374
Steve Antonda6c0952017-10-23 18:41:5475 virtual std::unique_ptr<cricket::SctpTransportInternalFactory>
76 CreateSctpTransportInternalFactory();
77
nisseeaabdf62017-05-05 09:23:0278 virtual cricket::ChannelManager* channel_manager();
Karl Wiberg4ae63472019-02-21 23:57:0679
80 rtc::Thread* signaling_thread() {
81 // This method can be called on a different thread when the factory is
82 // created in CreatePeerConnectionFactory().
83 return signaling_thread_;
84 }
85 rtc::Thread* worker_thread() { return worker_thread_; }
86 rtc::Thread* network_thread() { return network_thread_; }
87
wu@webrtc.org97077a32013-10-25 21:18:3388 const Options& options() const { return options_; }
henrike@webrtc.org28e20752013-07-10 00:45:3689
Piotr (Peter) Slatalae0c2e972018-10-08 16:43:2190 MediaTransportFactory* media_transport_factory() {
91 return media_transport_factory_.get();
92 }
93
henrike@webrtc.org28e20752013-07-10 00:45:3694 protected:
kwiberg1e4e8cb2017-01-31 09:48:0895 PeerConnectionFactory(
danilchape9021a32016-05-17 08:52:0296 rtc::Thread* network_thread,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:5297 rtc::Thread* worker_thread,
98 rtc::Thread* signaling_thread,
zhihuang38ede132017-06-15 19:52:3299 std::unique_ptr<cricket::MediaEngineInterface> media_engine,
100 std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
101 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory);
Ying Wang0dd1b0a2018-02-20 11:50:27102 PeerConnectionFactory(
103 rtc::Thread* network_thread,
104 rtc::Thread* worker_thread,
105 rtc::Thread* signaling_thread,
106 std::unique_ptr<cricket::MediaEngineInterface> media_engine,
107 std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
108 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory,
Sebastian Janssondfce03a2018-05-18 16:05:10109 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
110 std::unique_ptr<NetworkControllerFactoryInterface>
111 network_controller_factory);
Benjamin Wright5234a492018-05-29 22:04:32112 // Use this implementation for all future use. This structure allows simple
113 // management of all new dependencies being added to the
114 // PeerConnectionFactory.
115 explicit PeerConnectionFactory(
116 PeerConnectionFactoryDependencies dependencies);
117
Harald Alvestrand19793842018-06-25 10:03:50118 // Hook to let testing framework insert actions between
119 // "new RTCPeerConnection" and "pc.Initialize"
120 virtual void ActionsBeforeInitializeForTesting(PeerConnectionInterface*) {}
121
henrike@webrtc.org28e20752013-07-10 00:45:36122 virtual ~PeerConnectionFactory();
123
henrike@webrtc.org28e20752013-07-10 00:45:36124 private:
eladalon248fd4f2017-09-06 12:18:15125 std::unique_ptr<RtcEventLog> CreateRtcEventLog_w();
zhihuang38ede132017-06-15 19:52:32126 std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log);
127
perkj@webrtc.org81134d02015-01-12 08:30:16128 bool wraps_current_thread_;
danilchape9021a32016-05-17 08:52:02129 rtc::Thread* network_thread_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52130 rtc::Thread* worker_thread_;
danilchape9021a32016-05-17 08:52:02131 rtc::Thread* signaling_thread_;
zhihuang38ede132017-06-15 19:52:32132 std::unique_ptr<rtc::Thread> owned_network_thread_;
133 std::unique_ptr<rtc::Thread> owned_worker_thread_;
wu@webrtc.org97077a32013-10-25 21:18:33134 Options options_;
kwibergd1fe2812016-04-27 13:47:29135 std::unique_ptr<cricket::ChannelManager> channel_manager_;
kwibergd1fe2812016-04-27 13:47:29136 std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_;
137 std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_;
zhihuang38ede132017-06-15 19:52:32138 std::unique_ptr<cricket::MediaEngineInterface> media_engine_;
139 std::unique_ptr<webrtc::CallFactoryInterface> call_factory_;
140 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_;
Ying Wang0dd1b0a2018-02-20 11:50:27141 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
Sebastian Janssondfce03a2018-05-18 16:05:10142 std::unique_ptr<NetworkControllerFactoryInterface>
143 injected_network_controller_factory_;
Piotr (Peter) Slatalae0c2e972018-10-08 16:43:21144 std::unique_ptr<MediaTransportFactory> media_transport_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36145};
146
147} // namespace webrtc
148
Steve Anton10542f22019-01-11 17:11:00149#endif // PC_PEER_CONNECTION_FACTORY_H_