blob: 377ad73ec8c197b78250b847b6ccc304ed9f09ef [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +000010
Henrik Kjellander15583c12016-02-10 10:53:12 +010011#ifndef WEBRTC_API_PEERCONNECTIONFACTORY_H_
12#define WEBRTC_API_PEERCONNECTIONFACTORY_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
kwibergd1fe2812016-04-27 06:47:29 -070014#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015#include <string>
16
Henrik Kjellander15583c12016-02-10 10:53:12 +010017#include "webrtc/api/mediacontroller.h"
18#include "webrtc/api/mediastreaminterface.h"
19#include "webrtc/api/peerconnectioninterface.h"
Henrik Boström5e56c592015-08-11 10:33:13 +020020#include "webrtc/base/scoped_ref_ptr.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000021#include "webrtc/base/thread.h"
Henrik Boströmd03c23b2016-06-01 11:44:18 +020022#include "webrtc/base/rtccertificategenerator.h"
kjellander@webrtc.org9b8df252016-02-12 06:47:59 +010023#include "webrtc/pc/channelmanager.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000024
deadbeef41b07982015-12-01 15:01:24 -080025namespace rtc {
26class BasicNetworkManager;
27class BasicPacketSocketFactory;
28}
29
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030namespace webrtc {
31
perkj@webrtc.org81134d02015-01-12 08:30:16 +000032class PeerConnectionFactory : public PeerConnectionFactoryInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033 public:
jbauchcb560652016-08-04 05:20:32 -070034 void SetOptions(const Options& options) override;
wu@webrtc.org97077a32013-10-25 21:18:33 +000035
htaa2a49d92016-03-04 02:51:39 -080036 // Deprecated, use version without constraints.
deadbeef41b07982015-12-01 15:01:24 -080037 rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
38 const PeerConnectionInterface::RTCConfiguration& configuration,
39 const MediaConstraintsInterface* constraints,
kwibergd1fe2812016-04-27 06:47:29 -070040 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 11:44:18 +020041 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
deadbeef41b07982015-12-01 15:01:24 -080042 PeerConnectionObserver* observer) override;
43
htaa2a49d92016-03-04 02:51:39 -080044 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
45 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 06:47:29 -070046 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 11:44:18 +020047 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
htaa2a49d92016-03-04 02:51:39 -080048 PeerConnectionObserver* observer) override;
49
henrike@webrtc.org28e20752013-07-10 00:45:36 +000050 bool Initialize();
51
perkj@webrtc.org81134d02015-01-12 08:30:16 +000052 rtc::scoped_refptr<MediaStreamInterface>
53 CreateLocalMediaStream(const std::string& label) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000054
htaa2a49d92016-03-04 02:51:39 -080055 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
56 const cricket::AudioOptions& options) override;
57 // Deprecated, use version without constraints.
perkj@webrtc.org81134d02015-01-12 08:30:16 +000058 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
59 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000060
perkja3ede6c2016-03-08 01:27:48 +010061 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
htaa2a49d92016-03-04 02:51:39 -080062 cricket::VideoCapturer* capturer) override;
63 // This version supports filtering on width, height and frame rate.
64 // For the "constraints=null" case, use the version without constraints.
65 // TODO(hta): Design a version without MediaConstraintsInterface.
66 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
perkja3ede6c2016-03-08 01:27:48 +010067 rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068 cricket::VideoCapturer* capturer,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000069 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070
perkja3ede6c2016-03-08 01:27:48 +010071 rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
72 const std::string& id,
73 VideoTrackSourceInterface* video_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000074
perkj@webrtc.org81134d02015-01-12 08:30:16 +000075 rtc::scoped_refptr<AudioTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076 CreateAudioTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000077 AudioSourceInterface* audio_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000078
ivocd66b44d2016-01-15 03:06:36 -080079 bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
ivoc797ef122015-10-22 03:25:41 -070080 void StopAecDump() override;
ivoc14d5dbe2016-07-04 07:06:55 -070081 // TODO(ivoc) Remove after Chrome is updated.
82 bool StartRtcEventLog(rtc::PlatformFile file) override { return false; }
83 // TODO(ivoc) Remove after Chrome is updated.
ivoc9e03c3b2016-06-30 00:59:43 -070084 bool StartRtcEventLog(rtc::PlatformFile file,
ivoc14d5dbe2016-07-04 07:06:55 -070085 int64_t max_size_bytes) override {
86 return false;
87 }
88 // TODO(ivoc) Remove after Chrome is updated.
89 void StopRtcEventLog() override {}
wu@webrtc.orga9890802013-12-13 00:21:03 +000090
nisse51542be2016-02-12 02:27:06 -080091 virtual webrtc::MediaControllerInterface* CreateMediaController(
92 const cricket::MediaConfig& config) const;
zhihuang29ff8442016-07-27 11:07:25 -070093 virtual cricket::TransportController* CreateTransportController(
94 cricket::PortAllocator* port_allocator);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000095 virtual rtc::Thread* signaling_thread();
96 virtual rtc::Thread* worker_thread();
danilchape9021a32016-05-17 01:52:02 -070097 virtual rtc::Thread* network_thread();
wu@webrtc.org97077a32013-10-25 21:18:33 +000098 const Options& options() const { return options_; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000099
100 protected:
101 PeerConnectionFactory();
102 PeerConnectionFactory(
danilchape9021a32016-05-17 01:52:02 -0700103 rtc::Thread* network_thread,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000104 rtc::Thread* worker_thread,
105 rtc::Thread* signaling_thread,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000106 AudioDeviceModule* default_adm,
ossu29b1a8d2016-06-13 07:34:51 -0700107 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
108 audio_decoder_factory,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000109 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
110 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
111 virtual ~PeerConnectionFactory();
112
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000113 private:
henrika@webrtc.org62f6e752015-02-11 08:38:35 +0000114 cricket::MediaEngineInterface* CreateMediaEngine_w();
115
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000116 bool owns_ptrs_;
perkj@webrtc.org81134d02015-01-12 08:30:16 +0000117 bool wraps_current_thread_;
danilchape9021a32016-05-17 01:52:02 -0700118 rtc::Thread* network_thread_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000119 rtc::Thread* worker_thread_;
danilchape9021a32016-05-17 01:52:02 -0700120 rtc::Thread* signaling_thread_;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000121 Options options_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000122 // External Audio device used for audio playback.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000123 rtc::scoped_refptr<AudioDeviceModule> default_adm_;
ossu29b1a8d2016-06-13 07:34:51 -0700124 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory_;
kwibergd1fe2812016-04-27 06:47:29 -0700125 std::unique_ptr<cricket::ChannelManager> channel_manager_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000126 // External Video encoder factory. This can be NULL if the client has not
127 // injected any. In that case, video engine will use the internal SW encoder.
kwibergd1fe2812016-04-27 06:47:29 -0700128 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> video_encoder_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000129 // External Video decoder factory. This can be NULL if the client has not
130 // injected any. In that case, video engine will use the internal SW decoder.
kwibergd1fe2812016-04-27 06:47:29 -0700131 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> video_decoder_factory_;
132 std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_;
133 std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000134};
135
136} // namespace webrtc
137
Henrik Kjellander15583c12016-02-10 10:53:12 +0100138#endif // WEBRTC_API_PEERCONNECTIONFACTORY_H_