blob: 29badbd8bb6f8bdc687d8cbe6933adf87ee4a452 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2012 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 */
10
11// This file contains the PeerConnection interface as defined in
12// http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-connections.
13// Applications must use this interface to implement peerconnection.
14// PeerConnectionFactory class provides factory methods to create
15// peerconnection, mediastream and media tracks objects.
16//
17// The Following steps are needed to setup a typical call using Jsep.
18// 1. Create a PeerConnectionFactoryInterface. Check constructors for more
19// information about input parameters.
20// 2. Create a PeerConnection object. Provide a configuration string which
21// points either to stun or turn server to generate ICE candidates and provide
22// an object that implements the PeerConnectionObserver interface.
23// 3. Create local MediaStream and MediaTracks using the PeerConnectionFactory
24// and add it to PeerConnection by calling AddStream.
25// 4. Create an offer and serialize it and send it to the remote peer.
26// 5. Once an ice candidate have been found PeerConnection will call the
27// observer function OnIceCandidate. The candidates must also be serialized and
28// sent to the remote peer.
29// 6. Once an answer is received from the remote peer, call
30// SetLocalSessionDescription with the offer and SetRemoteSessionDescription
31// with the remote answer.
32// 7. Once a remote candidate is received from the remote peer, provide it to
33// the peerconnection by calling AddIceCandidate.
34
35
36// The Receiver of a call can decide to accept or reject the call.
37// This decision will be taken by the application not peerconnection.
38// If application decides to accept the call
39// 1. Create PeerConnectionFactoryInterface if it doesn't exist.
40// 2. Create a new PeerConnection.
41// 3. Provide the remote offer to the new PeerConnection object by calling
42// SetRemoteSessionDescription.
43// 4. Generate an answer to the remote offer by calling CreateAnswer and send it
44// back to the remote peer.
45// 5. Provide the local answer to the new PeerConnection by calling
46// SetLocalSessionDescription with the answer.
47// 6. Provide the remote ice candidates by calling AddIceCandidate.
48// 7. Once a candidate have been found PeerConnection will call the observer
49// function OnIceCandidate. Send these candidates to the remote peer.
50
Henrik Kjellander15583c12016-02-10 10:53:12 +010051#ifndef WEBRTC_API_PEERCONNECTIONINTERFACE_H_
52#define WEBRTC_API_PEERCONNECTIONINTERFACE_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053
kwibergd1fe2812016-04-27 06:47:29 -070054#include <memory>
deadbeef3edec7c2016-12-10 11:44:26 -080055#include <ostream>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000056#include <string>
kwiberg0eb15ed2015-12-17 03:04:15 -080057#include <utility>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000058#include <vector>
59
Henrik Kjellander15583c12016-02-10 10:53:12 +010060#include "webrtc/api/datachannelinterface.h"
Henrik Kjellander15583c12016-02-10 10:53:12 +010061#include "webrtc/api/dtmfsenderinterface.h"
62#include "webrtc/api/jsep.h"
63#include "webrtc/api/mediastreaminterface.h"
hbos74e1a4f2016-09-15 23:33:01 -070064#include "webrtc/api/rtcstatscollector.h"
Henrik Kjellander15583c12016-02-10 10:53:12 +010065#include "webrtc/api/rtpreceiverinterface.h"
66#include "webrtc/api/rtpsenderinterface.h"
67#include "webrtc/api/statstypes.h"
68#include "webrtc/api/umametrics.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000069#include "webrtc/base/fileutils.h"
phoglund@webrtc.org006521d2015-02-12 09:23:59 +000070#include "webrtc/base/network.h"
Henrik Boström87713d02015-08-25 09:53:21 +020071#include "webrtc/base/rtccertificate.h"
Henrik Boströmd03c23b2016-06-01 11:44:18 +020072#include "webrtc/base/rtccertificategenerator.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000073#include "webrtc/base/socketaddress.h"
kjellandera96e2d72016-02-04 23:52:28 -080074#include "webrtc/base/sslstreamadapter.h"
nissec36b31b2016-04-11 23:25:29 -070075#include "webrtc/media/base/mediachannel.h"
deadbeef41b07982015-12-01 15:01:24 -080076#include "webrtc/p2p/base/portallocator.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000077
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000078namespace rtc {
jiayl@webrtc.org61e00b02015-03-04 22:17:38 +000079class SSLIdentity;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080class Thread;
81}
82
83namespace cricket {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000084class WebRtcVideoDecoderFactory;
85class WebRtcVideoEncoderFactory;
86}
87
88namespace webrtc {
89class AudioDeviceModule;
90class MediaConstraintsInterface;
91
92// MediaStream container interface.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000093class StreamCollectionInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000094 public:
95 // TODO(ronghuawu): Update the function names to c++ style, e.g. find -> Find.
96 virtual size_t count() = 0;
97 virtual MediaStreamInterface* at(size_t index) = 0;
98 virtual MediaStreamInterface* find(const std::string& label) = 0;
99 virtual MediaStreamTrackInterface* FindAudioTrack(
100 const std::string& id) = 0;
101 virtual MediaStreamTrackInterface* FindVideoTrack(
102 const std::string& id) = 0;
103
104 protected:
105 // Dtor protected as objects shouldn't be deleted via this interface.
106 ~StreamCollectionInterface() {}
107};
108
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000109class StatsObserver : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000110 public:
tommi@webrtc.orge2e199b2014-12-15 13:22:54 +0000111 virtual void OnComplete(const StatsReports& reports) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000112
113 protected:
114 virtual ~StatsObserver() {}
115};
116
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000117class MetricsObserverInterface : public rtc::RefCountInterface {
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000118 public:
Guo-wei Shieh3d564c12015-08-19 16:51:15 -0700119
120 // |type| is the type of the enum counter to be incremented. |counter|
121 // is the particular counter in that type. |counter_max| is the next sequence
122 // number after the highest counter.
123 virtual void IncrementEnumCounter(PeerConnectionEnumCounterType type,
124 int counter,
125 int counter_max) {}
126
Guo-wei Shieh456696a2015-09-30 21:48:54 -0700127 // This is used to handle sparse counters like SSL cipher suites.
128 // TODO(guoweis): Remove the implementation once the dependency's interface
129 // definition is updated.
130 virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type,
131 int counter) {
132 IncrementEnumCounter(type, counter, 0 /* Ignored */);
133 }
134
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000135 virtual void AddHistogramSample(PeerConnectionMetricsName type,
mallinath@webrtc.orgd37bcfa2014-05-12 23:10:18 +0000136 int value) = 0;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000137
138 protected:
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000139 virtual ~MetricsObserverInterface() {}
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000140};
141
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000142typedef MetricsObserverInterface UMAObserver;
143
deadbeef3edec7c2016-12-10 11:44:26 -0800144// Enumeration to represent distinct classes of errors that an application
145// may wish to act upon differently. These roughly map to DOMExceptions in
146// the web API, as described in the comments below.
147enum class RtcError {
148 // No error.
149 NONE,
150 // A supplied parameter is valid, but currently unsupported.
151 // Maps to InvalidAccessError DOMException.
152 UNSUPPORTED_PARAMETER,
153 // General error indicating that a supplied parameter is invalid.
154 // Maps to InvalidAccessError or TypeError DOMException depending on context.
155 INVALID_PARAMETER,
156 // Slightly more specific than INVALID_PARAMETER; a parameter's value was
157 // outside the allowed range.
158 // Maps to RangeError DOMException.
159 INVALID_RANGE,
160 // Slightly more specific than INVALID_PARAMETER; an error occurred while
161 // parsing string input.
162 // Maps to SyntaxError DOMException.
163 SYNTAX_ERROR,
164 // The object does not support this operation in its current state.
165 // Maps to InvalidStateError DOMException.
166 INVALID_STATE,
167 // An attempt was made to modify the object in an invalid way.
168 // Maps to InvalidModificationError DOMException.
169 INVALID_MODIFICATION,
170 // An error occurred within an underlying network protocol.
171 // Maps to NetworkError DOMException.
172 NETWORK_ERROR,
173 // The operation failed due to an internal error.
174 // Maps to OperationError DOMException.
175 INTERNAL_ERROR,
176};
177
178// Outputs the error as a friendly string.
179// Update this method when adding a new error type.
180std::ostream& operator<<(std::ostream& stream, RtcError error);
181
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000182class PeerConnectionInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000183 public:
184 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions .
185 enum SignalingState {
186 kStable,
187 kHaveLocalOffer,
188 kHaveLocalPrAnswer,
189 kHaveRemoteOffer,
190 kHaveRemotePrAnswer,
191 kClosed,
192 };
193
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000194 enum IceGatheringState {
195 kIceGatheringNew,
196 kIceGatheringGathering,
197 kIceGatheringComplete
198 };
199
200 enum IceConnectionState {
201 kIceConnectionNew,
202 kIceConnectionChecking,
203 kIceConnectionConnected,
204 kIceConnectionCompleted,
205 kIceConnectionFailed,
206 kIceConnectionDisconnected,
207 kIceConnectionClosed,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -0700208 kIceConnectionMax,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000209 };
210
211 struct IceServer {
Joachim Bauch7c4e7452015-05-28 23:06:30 +0200212 // TODO(jbauch): Remove uri when all code using it has switched to urls.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000213 std::string uri;
Joachim Bauch7c4e7452015-05-28 23:06:30 +0200214 std::vector<std::string> urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000215 std::string username;
216 std::string password;
deadbeefd1a38b52016-12-10 13:15:33 -0800217 bool operator==(const IceServer& o) const {
218 return uri == o.uri && urls == o.urls && username == o.username &&
219 password == o.password;
220 }
221 bool operator!=(const IceServer& o) const { return !(*this == o); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000222 };
223 typedef std::vector<IceServer> IceServers;
224
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000225 enum IceTransportsType {
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000226 // TODO(pthatcher): Rename these kTransporTypeXXX, but update
227 // Chromium at the same time.
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000228 kNone,
229 kRelay,
230 kNoHost,
231 kAll
232 };
233
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000234 // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-08#section-4.1.1
235 enum BundlePolicy {
236 kBundlePolicyBalanced,
237 kBundlePolicyMaxBundle,
238 kBundlePolicyMaxCompat
239 };
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000240
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700241 // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-09#section-4.1.1
242 enum RtcpMuxPolicy {
243 kRtcpMuxPolicyNegotiate,
244 kRtcpMuxPolicyRequire,
245 };
246
Jiayang Liucac1b382015-04-30 12:35:24 -0700247 enum TcpCandidatePolicy {
248 kTcpCandidatePolicyEnabled,
249 kTcpCandidatePolicyDisabled
250 };
251
honghaiz60347052016-05-31 18:29:12 -0700252 enum CandidateNetworkPolicy {
253 kCandidateNetworkPolicyAll,
254 kCandidateNetworkPolicyLowCost
255 };
256
honghaiz1f429e32015-09-28 07:57:34 -0700257 enum ContinualGatheringPolicy {
258 GATHER_ONCE,
259 GATHER_CONTINUALLY
260 };
261
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700262 enum class RTCConfigurationType {
263 // A configuration that is safer to use, despite not having the best
264 // performance. Currently this is the default configuration.
265 kSafe,
266 // An aggressive configuration that has better performance, although it
267 // may be riskier and may need extra support in the application.
268 kAggressive
269 };
270
Henrik Boström87713d02015-08-25 09:53:21 +0200271 // TODO(hbos): Change into class with private data and public getters.
nissec36b31b2016-04-11 23:25:29 -0700272 // TODO(nisse): In particular, accessing fields directly from an
273 // application is brittle, since the organization mirrors the
274 // organization of the implementation, which isn't stable. So we
275 // need getters and setters at least for fields which applications
276 // are interested in.
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000277 struct RTCConfiguration {
Niels Möller71bdda02016-03-31 12:59:59 +0200278 // This struct is subject to reorganization, both for naming
279 // consistency, and to group settings to match where they are used
280 // in the implementation. To do that, we need getter and setter
281 // methods for all settings which are of interest to applications,
282 // Chrome in particular.
283
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700284 RTCConfiguration() = default;
285 RTCConfiguration(RTCConfigurationType type) {
286 if (type == RTCConfigurationType::kAggressive) {
Honghai Zhangaecd9822016-09-02 16:58:17 -0700287 // These parameters are also defined in Java and IOS configurations,
288 // so their values may be overwritten by the Java or IOS configuration.
289 bundle_policy = kBundlePolicyMaxBundle;
290 rtcp_mux_policy = kRtcpMuxPolicyRequire;
291 ice_connection_receiving_timeout =
292 kAggressiveIceConnectionReceivingTimeout;
293
294 // These parameters are not defined in Java or IOS configuration,
295 // so their values will not be overwritten.
296 enable_ice_renomination = true;
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700297 redetermine_role_on_ice_restart = false;
298 }
Honghai Zhangbfd398c2016-08-30 22:07:42 -0700299 }
300
nissec36b31b2016-04-11 23:25:29 -0700301 bool dscp() { return media_config.enable_dscp; }
302 void set_dscp(bool enable) { media_config.enable_dscp = enable; }
Niels Möller71bdda02016-03-31 12:59:59 +0200303
304 // TODO(nisse): The corresponding flag in MediaConfig and
305 // elsewhere should be renamed enable_cpu_adaptation.
nissec36b31b2016-04-11 23:25:29 -0700306 bool cpu_adaptation() {
307 return media_config.video.enable_cpu_overuse_detection;
308 }
Niels Möller71bdda02016-03-31 12:59:59 +0200309 void set_cpu_adaptation(bool enable) {
nissec36b31b2016-04-11 23:25:29 -0700310 media_config.video.enable_cpu_overuse_detection = enable;
Niels Möller71bdda02016-03-31 12:59:59 +0200311 }
312
nissec36b31b2016-04-11 23:25:29 -0700313 bool suspend_below_min_bitrate() {
314 return media_config.video.suspend_below_min_bitrate;
315 }
Niels Möller71bdda02016-03-31 12:59:59 +0200316 void set_suspend_below_min_bitrate(bool enable) {
nissec36b31b2016-04-11 23:25:29 -0700317 media_config.video.suspend_below_min_bitrate = enable;
Niels Möller71bdda02016-03-31 12:59:59 +0200318 }
319
320 // TODO(nisse): The negation in the corresponding MediaConfig
321 // attribute is inconsistent, and it should be renamed at some
322 // point.
nissec36b31b2016-04-11 23:25:29 -0700323 bool prerenderer_smoothing() {
324 return !media_config.video.disable_prerenderer_smoothing;
325 }
Niels Möller71bdda02016-03-31 12:59:59 +0200326 void set_prerenderer_smoothing(bool enable) {
nissec36b31b2016-04-11 23:25:29 -0700327 media_config.video.disable_prerenderer_smoothing = !enable;
Niels Möller71bdda02016-03-31 12:59:59 +0200328 }
329
honghaiz4edc39c2015-09-01 09:53:56 -0700330 static const int kUndefined = -1;
331 // Default maximum number of packets in the audio jitter buffer.
332 static const int kAudioJitterBufferMaxPackets = 50;
Honghai Zhangaecd9822016-09-02 16:58:17 -0700333 // ICE connection receiving timeout for aggressive configuration.
334 static const int kAggressiveIceConnectionReceivingTimeout = 1000;
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000335 // TODO(pthatcher): Rename this ice_transport_type, but update
336 // Chromium at the same time.
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700337 IceTransportsType type = kAll;
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000338 // TODO(pthatcher): Rename this ice_servers, but update Chromium
339 // at the same time.
340 IceServers servers;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700341 BundlePolicy bundle_policy = kBundlePolicyBalanced;
zhihuang4dfb8ce2016-11-23 10:30:12 -0800342 RtcpMuxPolicy rtcp_mux_policy = kRtcpMuxPolicyRequire;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700343 TcpCandidatePolicy tcp_candidate_policy = kTcpCandidatePolicyEnabled;
honghaiz60347052016-05-31 18:29:12 -0700344 CandidateNetworkPolicy candidate_network_policy =
345 kCandidateNetworkPolicyAll;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700346 int audio_jitter_buffer_max_packets = kAudioJitterBufferMaxPackets;
347 bool audio_jitter_buffer_fast_accelerate = false;
348 int ice_connection_receiving_timeout = kUndefined; // ms
349 int ice_backup_candidate_pair_ping_interval = kUndefined; // ms
350 ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE;
Henrik Boström87713d02015-08-25 09:53:21 +0200351 std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700352 bool prioritize_most_likely_ice_candidate_pairs = false;
nissec36b31b2016-04-11 23:25:29 -0700353 struct cricket::MediaConfig media_config;
htaa2a49d92016-03-04 02:51:39 -0800354 // Flags corresponding to values set by constraint flags.
355 // rtc::Optional flags can be "missing", in which case the webrtc
356 // default applies.
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700357 bool disable_ipv6 = false;
358 bool enable_rtp_data_channel = false;
zhihuang9763d562016-08-05 11:14:50 -0700359 bool enable_quic = false;
htaa2a49d92016-03-04 02:51:39 -0800360 rtc::Optional<int> screencast_min_bitrate;
361 rtc::Optional<bool> combined_audio_video_bwe;
362 rtc::Optional<bool> enable_dtls_srtp;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700363 int ice_candidate_pool_size = 0;
Honghai Zhangb9e7b4a2016-06-30 20:52:02 -0700364 bool prune_turn_ports = false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700365 // If set to true, this means the ICE transport should presume TURN-to-TURN
366 // candidate pairs will succeed, even before a binding response is received.
367 bool presume_writable_when_fully_relayed = false;
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700368 // If true, "renomination" will be added to the ice options in the transport
369 // description.
370 bool enable_ice_renomination = false;
Honghai Zhangbfd398c2016-08-30 22:07:42 -0700371 // If true, ICE role is redetermined when peerconnection sets a local
372 // transport description that indicates an ICE restart.
373 bool redetermine_role_on_ice_restart = true;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000374 };
375
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000376 struct RTCOfferAnswerOptions {
377 static const int kUndefined = -1;
378 static const int kMaxOfferToReceiveMedia = 1;
379
380 // The default value for constraint offerToReceiveX:true.
381 static const int kOfferToReceiveMediaTrue = 1;
382
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700383 int offer_to_receive_video = kUndefined;
384 int offer_to_receive_audio = kUndefined;
385 bool voice_activity_detection = true;
386 bool ice_restart = false;
387 bool use_rtp_mux = true;
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000388
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700389 RTCOfferAnswerOptions() = default;
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000390
391 RTCOfferAnswerOptions(int offer_to_receive_video,
392 int offer_to_receive_audio,
393 bool voice_activity_detection,
394 bool ice_restart,
395 bool use_rtp_mux)
396 : offer_to_receive_video(offer_to_receive_video),
397 offer_to_receive_audio(offer_to_receive_audio),
398 voice_activity_detection(voice_activity_detection),
399 ice_restart(ice_restart),
400 use_rtp_mux(use_rtp_mux) {}
401 };
402
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +0000403 // Used by GetStats to decide which stats to include in the stats reports.
404 // |kStatsOutputLevelStandard| includes the standard stats for Javascript API;
405 // |kStatsOutputLevelDebug| includes both the standard stats and additional
406 // stats for debugging purposes.
407 enum StatsOutputLevel {
408 kStatsOutputLevelStandard,
409 kStatsOutputLevelDebug,
410 };
411
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000412 // Accessor methods to active local streams.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000413 virtual rtc::scoped_refptr<StreamCollectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000414 local_streams() = 0;
415
416 // Accessor methods to remote streams.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000417 virtual rtc::scoped_refptr<StreamCollectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000418 remote_streams() = 0;
419
420 // Add a new MediaStream to be sent on this PeerConnection.
421 // Note that a SessionDescription negotiation is needed before the
422 // remote peer can receive the stream.
perkj@webrtc.orgfd0efb62014-11-06 12:16:36 +0000423 virtual bool AddStream(MediaStreamInterface* stream) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000424
425 // Remove a MediaStream from this PeerConnection.
426 // Note that a SessionDescription negotiation is need before the
427 // remote peer is notified.
428 virtual void RemoveStream(MediaStreamInterface* stream) = 0;
429
deadbeefe1f9d832016-01-14 15:35:42 -0800430 // TODO(deadbeef): Make the following two methods pure virtual once
431 // implemented by all subclasses of PeerConnectionInterface.
432 // Add a new MediaStreamTrack to be sent on this PeerConnection.
433 // |streams| indicates which stream labels the track should be associated
434 // with.
435 virtual rtc::scoped_refptr<RtpSenderInterface> AddTrack(
436 MediaStreamTrackInterface* track,
437 std::vector<MediaStreamInterface*> streams) {
438 return nullptr;
439 }
440
441 // Remove an RtpSender from this PeerConnection.
442 // Returns true on success.
443 virtual bool RemoveTrack(RtpSenderInterface* sender) {
444 return false;
445 }
446
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000447 // Returns pointer to the created DtmfSender on success.
448 // Otherwise returns NULL.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000449 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000450 AudioTrackInterface* track) = 0;
451
deadbeef70ab1a12015-09-28 16:53:55 -0700452 // TODO(deadbeef): Make these pure virtual once all subclasses implement them.
deadbeeffac06552015-11-25 11:26:01 -0800453 // |kind| must be "audio" or "video".
deadbeefbd7d8f72015-12-18 16:58:44 -0800454 // |stream_id| is used to populate the msid attribute; if empty, one will
455 // be generated automatically.
deadbeeffac06552015-11-25 11:26:01 -0800456 virtual rtc::scoped_refptr<RtpSenderInterface> CreateSender(
deadbeefbd7d8f72015-12-18 16:58:44 -0800457 const std::string& kind,
458 const std::string& stream_id) {
deadbeeffac06552015-11-25 11:26:01 -0800459 return rtc::scoped_refptr<RtpSenderInterface>();
460 }
461
deadbeef70ab1a12015-09-28 16:53:55 -0700462 virtual std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
463 const {
464 return std::vector<rtc::scoped_refptr<RtpSenderInterface>>();
465 }
466
467 virtual std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
468 const {
469 return std::vector<rtc::scoped_refptr<RtpReceiverInterface>>();
470 }
471
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +0000472 virtual bool GetStats(StatsObserver* observer,
473 MediaStreamTrackInterface* track,
474 StatsOutputLevel level) = 0;
hbos74e1a4f2016-09-15 23:33:01 -0700475 // Gets stats using the new stats collection API, see webrtc/api/stats/. These
476 // will replace old stats collection API when the new API has matured enough.
477 // TODO(hbos): Default implementation that does nothing only exists as to not
478 // break third party projects. As soon as they have been updated this should
479 // be changed to "= 0;".
480 virtual void GetStats(RTCStatsCollectorCallback* callback) {}
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +0000481
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000482 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000483 const std::string& label,
484 const DataChannelInit* config) = 0;
485
486 virtual const SessionDescriptionInterface* local_description() const = 0;
487 virtual const SessionDescriptionInterface* remote_description() const = 0;
488
489 // Create a new offer.
490 // The CreateSessionDescriptionObserver callback will be called when done.
491 virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000492 const MediaConstraintsInterface* constraints) {}
493
494 // TODO(jiayl): remove the default impl and the old interface when chromium
495 // code is updated.
496 virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
497 const RTCOfferAnswerOptions& options) {}
498
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000499 // Create an answer to an offer.
500 // The CreateSessionDescriptionObserver callback will be called when done.
501 virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
htaa2a49d92016-03-04 02:51:39 -0800502 const RTCOfferAnswerOptions& options) {}
503 // Deprecated - use version above.
504 // TODO(hta): Remove and remove default implementations when all callers
505 // are updated.
506 virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
507 const MediaConstraintsInterface* constraints) {}
508
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000509 // Sets the local session description.
510 // JsepInterface takes the ownership of |desc| even if it fails.
511 // The |observer| callback will be called when done.
512 virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,
513 SessionDescriptionInterface* desc) = 0;
514 // Sets the remote session description.
515 // JsepInterface takes the ownership of |desc| even if it fails.
516 // The |observer| callback will be called when done.
517 virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
518 SessionDescriptionInterface* desc) = 0;
519 // Restarts or updates the ICE Agent process of gathering local candidates
520 // and pinging remote candidates.
deadbeefa67696b2015-09-29 11:56:26 -0700521 // TODO(deadbeef): Remove once Chrome is moved over to SetConfiguration.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000522 virtual bool UpdateIce(const IceServers& configuration,
deadbeefa67696b2015-09-29 11:56:26 -0700523 const MediaConstraintsInterface* constraints) {
524 return false;
525 }
htaa2a49d92016-03-04 02:51:39 -0800526 virtual bool UpdateIce(const IceServers& configuration) { return false; }
deadbeef46c73892016-11-16 19:42:04 -0800527 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
528 // PeerConnectionInterface implement it.
529 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() {
530 return PeerConnectionInterface::RTCConfiguration();
531 }
deadbeefa67696b2015-09-29 11:56:26 -0700532 // Sets the PeerConnection's global configuration to |config|.
533 // Any changes to STUN/TURN servers or ICE candidate policy will affect the
534 // next gathering phase, and cause the next call to createOffer to generate
535 // new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
536 // cannot be changed with this method.
537 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
538 // PeerConnectionInterface implement it.
539 virtual bool SetConfiguration(
540 const PeerConnectionInterface::RTCConfiguration& config) {
541 return false;
542 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000543 // Provides a remote candidate to the ICE Agent.
544 // A copy of the |candidate| will be created and added to the remote
545 // description. So the caller of this method still has the ownership of the
546 // |candidate|.
547 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will
548 // take the ownership of the |candidate|.
549 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0;
550
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700551 // Removes a group of remote candidates from the ICE agent.
552 virtual bool RemoveIceCandidates(
553 const std::vector<cricket::Candidate>& candidates) {
554 return false;
555 }
556
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000557 virtual void RegisterUMAObserver(UMAObserver* observer) = 0;
558
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000559 // Returns the current SignalingState.
560 virtual SignalingState signaling_state() = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000561 virtual IceConnectionState ice_connection_state() = 0;
562 virtual IceGatheringState ice_gathering_state() = 0;
563
ivoc14d5dbe2016-07-04 07:06:55 -0700564 // Starts RtcEventLog using existing file. Takes ownership of |file| and
565 // passes it on to Call, which will take the ownership. If the
566 // operation fails the file will be closed. The logging will stop
567 // automatically after 10 minutes have passed, or when the StopRtcEventLog
568 // function is called.
569 // TODO(ivoc): Make this pure virtual when Chrome is updated.
570 virtual bool StartRtcEventLog(rtc::PlatformFile file,
571 int64_t max_size_bytes) {
572 return false;
573 }
574
575 // Stops logging the RtcEventLog.
576 // TODO(ivoc): Make this pure virtual when Chrome is updated.
577 virtual void StopRtcEventLog() {}
578
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000579 // Terminates all media and closes the transport.
580 virtual void Close() = 0;
581
582 protected:
583 // Dtor protected as objects shouldn't be deleted via this interface.
584 ~PeerConnectionInterface() {}
585};
586
587// PeerConnection callback interface. Application should implement these
588// methods.
589class PeerConnectionObserver {
590 public:
591 enum StateType {
592 kSignalingState,
593 kIceState,
594 };
595
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000596 // Triggered when the SignalingState changed.
597 virtual void OnSignalingChange(
perkjdfb769d2016-02-09 03:09:43 -0800598 PeerConnectionInterface::SignalingState new_state) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000599
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700600 // TODO(deadbeef): Once all subclasses override the scoped_refptr versions
601 // of the below three methods, make them pure virtual and remove the raw
602 // pointer version.
603
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000604 // Triggered when media is received on a new stream from remote peer.
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700605 virtual void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {}
606 // Deprecated; please use the version that uses a scoped_refptr.
607 virtual void OnAddStream(MediaStreamInterface* stream) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000608
609 // Triggered when a remote peer close a stream.
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700610 virtual void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
611 }
612 // Deprecated; please use the version that uses a scoped_refptr.
613 virtual void OnRemoveStream(MediaStreamInterface* stream) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000614
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700615 // Triggered when a remote peer opens a data channel.
616 virtual void OnDataChannel(
617 rtc::scoped_refptr<DataChannelInterface> data_channel){};
618 // Deprecated; please use the version that uses a scoped_refptr.
619 virtual void OnDataChannel(DataChannelInterface* data_channel) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000620
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700621 // Triggered when renegotiation is needed. For example, an ICE restart
622 // has begun.
fischman@webrtc.orgd7568a02014-01-13 22:04:12 +0000623 virtual void OnRenegotiationNeeded() = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000624
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700625 // Called any time the IceConnectionState changes.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000626 virtual void OnIceConnectionChange(
perkjdfb769d2016-02-09 03:09:43 -0800627 PeerConnectionInterface::IceConnectionState new_state) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000628
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700629 // Called any time the IceGatheringState changes.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000630 virtual void OnIceGatheringChange(
perkjdfb769d2016-02-09 03:09:43 -0800631 PeerConnectionInterface::IceGatheringState new_state) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000632
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700633 // A new ICE candidate has been gathered.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000634 virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0;
635
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700636 // Ice candidates have been removed.
637 // TODO(honghaiz): Make this a pure virtual method when all its subclasses
638 // implement it.
639 virtual void OnIceCandidatesRemoved(
640 const std::vector<cricket::Candidate>& candidates) {}
641
Peter Thatcher54360512015-07-08 11:08:35 -0700642 // Called when the ICE connection receiving status changes.
643 virtual void OnIceConnectionReceivingChange(bool receiving) {}
644
zhihuang81c3a032016-11-17 12:06:24 -0800645 // Called when a track is added to streams.
646 // TODO(zhihuang) Make this a pure virtual method when all its subclasses
647 // implement it.
648 virtual void OnAddTrack(
649 rtc::scoped_refptr<RtpReceiverInterface> receiver,
zhihuangc63b8942016-12-02 15:41:10 -0800650 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {}
zhihuang81c3a032016-11-17 12:06:24 -0800651
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000652 protected:
653 // Dtor protected as objects shouldn't be deleted via this interface.
654 ~PeerConnectionObserver() {}
655};
656
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000657// PeerConnectionFactoryInterface is the factory interface use for creating
658// PeerConnection, MediaStream and media tracks.
659// PeerConnectionFactoryInterface will create required libjingle threads,
660// socket and network manager factory classes for networking.
661// If an application decides to provide its own threads and network
662// implementation of these classes it should use the alternate
663// CreatePeerConnectionFactory method which accepts threads as input and use the
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -0800664// CreatePeerConnection version that takes a PortAllocator as an
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000665// argument.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000666class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000667 public:
wu@webrtc.org97077a32013-10-25 21:18:33 +0000668 class Options {
669 public:
Guo-wei Shieha7446d22016-01-11 15:27:03 -0800670 Options()
671 : disable_encryption(false),
672 disable_sctp_data_channels(false),
673 disable_network_monitor(false),
674 network_ignore_mask(rtc::kDefaultNetworkIgnoreMask),
jbauchcb560652016-08-04 05:20:32 -0700675 ssl_max_version(rtc::SSL_PROTOCOL_DTLS_12),
676 crypto_options(rtc::CryptoOptions::NoGcm()) {}
wu@webrtc.org97077a32013-10-25 21:18:33 +0000677 bool disable_encryption;
678 bool disable_sctp_data_channels;
honghaiz023f3ef2015-10-19 09:39:32 -0700679 bool disable_network_monitor;
phoglund@webrtc.org006521d2015-02-12 09:23:59 +0000680
681 // Sets the network types to ignore. For instance, calling this with
682 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
683 // loopback interfaces.
684 int network_ignore_mask;
Joachim Bauch04e5b492015-05-29 09:40:39 +0200685
686 // Sets the maximum supported protocol version. The highest version
687 // supported by both ends will be used for the connection, i.e. if one
688 // party supports DTLS 1.0 and the other DTLS 1.2, DTLS 1.0 will be used.
689 rtc::SSLProtocolVersion ssl_max_version;
jbauchcb560652016-08-04 05:20:32 -0700690
691 // Sets crypto related options, e.g. enabled cipher suites.
692 rtc::CryptoOptions crypto_options;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000693 };
694
695 virtual void SetOptions(const Options& options) = 0;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000696
deadbeef41b07982015-12-01 15:01:24 -0800697 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
698 const PeerConnectionInterface::RTCConfiguration& configuration,
699 const MediaConstraintsInterface* constraints,
kwibergd1fe2812016-04-27 06:47:29 -0700700 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 11:44:18 +0200701 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
hbosd7973cc2016-05-27 06:08:53 -0700702 PeerConnectionObserver* observer) = 0;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000703
htaa2a49d92016-03-04 02:51:39 -0800704 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
705 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 06:47:29 -0700706 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 11:44:18 +0200707 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
hbosd7973cc2016-05-27 06:08:53 -0700708 PeerConnectionObserver* observer) = 0;
htaa2a49d92016-03-04 02:51:39 -0800709
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000710 virtual rtc::scoped_refptr<MediaStreamInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000711 CreateLocalMediaStream(const std::string& label) = 0;
712
713 // Creates a AudioSourceInterface.
714 // |constraints| decides audio processing settings but can be NULL.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000715 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
htaa2a49d92016-03-04 02:51:39 -0800716 const cricket::AudioOptions& options) = 0;
717 // Deprecated - use version above.
718 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000719 const MediaConstraintsInterface* constraints) = 0;
720
perkja3ede6c2016-03-08 01:27:48 +0100721 // Creates a VideoTrackSourceInterface. The new source take ownership of
htaa2a49d92016-03-04 02:51:39 -0800722 // |capturer|.
perkja3ede6c2016-03-08 01:27:48 +0100723 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
htaa2a49d92016-03-04 02:51:39 -0800724 cricket::VideoCapturer* capturer) = 0;
725 // A video source creator that allows selection of resolution and frame rate.
726 // |constraints| decides video resolution and frame rate but can
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000727 // be NULL.
htaa2a49d92016-03-04 02:51:39 -0800728 // In the NULL case, use the version above.
perkja3ede6c2016-03-08 01:27:48 +0100729 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000730 cricket::VideoCapturer* capturer,
731 const MediaConstraintsInterface* constraints) = 0;
732
733 // Creates a new local VideoTrack. The same |source| can be used in several
734 // tracks.
perkja3ede6c2016-03-08 01:27:48 +0100735 virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
736 const std::string& label,
737 VideoTrackSourceInterface* source) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000738
739 // Creates an new AudioTrack. At the moment |source| can be NULL.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000740 virtual rtc::scoped_refptr<AudioTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000741 CreateAudioTrack(const std::string& label,
742 AudioSourceInterface* source) = 0;
743
wu@webrtc.orga9890802013-12-13 00:21:03 +0000744 // Starts AEC dump using existing file. Takes ownership of |file| and passes
745 // it on to VoiceEngine (via other objects) immediately, which will take
wu@webrtc.orga8910d22014-01-23 22:12:45 +0000746 // the ownerhip. If the operation fails, the file will be closed.
ivocd66b44d2016-01-15 03:06:36 -0800747 // A maximum file size in bytes can be specified. When the file size limit is
748 // reached, logging is stopped automatically. If max_size_bytes is set to a
749 // value <= 0, no limit will be used, and logging will continue until the
750 // StopAecDump function is called.
751 virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) = 0;
wu@webrtc.orga9890802013-12-13 00:21:03 +0000752
ivoc797ef122015-10-22 03:25:41 -0700753 // Stops logging the AEC dump.
754 virtual void StopAecDump() = 0;
755
ivoc14d5dbe2016-07-04 07:06:55 -0700756 // This function is deprecated and will be removed when Chrome is updated to
757 // use the equivalent function on PeerConnectionInterface.
758 // TODO(ivoc) Remove after Chrome is updated.
ivocc1513ee2016-05-13 08:30:39 -0700759 virtual bool StartRtcEventLog(rtc::PlatformFile file,
760 int64_t max_size_bytes) = 0;
ivoc14d5dbe2016-07-04 07:06:55 -0700761 // This function is deprecated and will be removed when Chrome is updated to
762 // use the equivalent function on PeerConnectionInterface.
763 // TODO(ivoc) Remove after Chrome is updated.
ivoc112a3d82015-10-16 02:22:18 -0700764 virtual bool StartRtcEventLog(rtc::PlatformFile file) = 0;
765
ivoc14d5dbe2016-07-04 07:06:55 -0700766 // This function is deprecated and will be removed when Chrome is updated to
767 // use the equivalent function on PeerConnectionInterface.
768 // TODO(ivoc) Remove after Chrome is updated.
ivoc112a3d82015-10-16 02:22:18 -0700769 virtual void StopRtcEventLog() = 0;
770
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000771 protected:
772 // Dtor and ctor protected as objects shouldn't be created or deleted via
773 // this interface.
774 PeerConnectionFactoryInterface() {}
775 ~PeerConnectionFactoryInterface() {} // NOLINT
776};
777
778// Create a new instance of PeerConnectionFactoryInterface.
Taylor Brandstettera8415fe2016-03-23 10:38:07 -0700779//
780// This method relies on the thread it's called on as the "signaling thread"
781// for the PeerConnectionFactory it creates.
782//
783// As such, if the current thread is not already running an rtc::Thread message
784// loop, an application using this method must eventually either call
785// rtc::Thread::Current()->Run(), or call
786// rtc::Thread::Current()->ProcessMessages() within the application's own
787// message loop.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000788rtc::scoped_refptr<PeerConnectionFactoryInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000789CreatePeerConnectionFactory();
790
791// Create a new instance of PeerConnectionFactoryInterface.
Taylor Brandstettera8415fe2016-03-23 10:38:07 -0700792//
danilchape9021a32016-05-17 01:52:02 -0700793// |network_thread|, |worker_thread| and |signaling_thread| are
794// the only mandatory parameters.
Taylor Brandstettera8415fe2016-03-23 10:38:07 -0700795//
796// If non-null, ownership of |default_adm|, |encoder_factory| and
797// |decoder_factory| are transferred to the returned factory.
danilchape9021a32016-05-17 01:52:02 -0700798rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
799 rtc::Thread* network_thread,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000800 rtc::Thread* worker_thread,
801 rtc::Thread* signaling_thread,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000802 AudioDeviceModule* default_adm,
803 cricket::WebRtcVideoEncoderFactory* encoder_factory,
804 cricket::WebRtcVideoDecoderFactory* decoder_factory);
805
danilchape9021a32016-05-17 01:52:02 -0700806// Create a new instance of PeerConnectionFactoryInterface.
807// Same thread is used as worker and network thread.
danilchape9021a32016-05-17 01:52:02 -0700808inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
809CreatePeerConnectionFactory(
810 rtc::Thread* worker_and_network_thread,
811 rtc::Thread* signaling_thread,
812 AudioDeviceModule* default_adm,
813 cricket::WebRtcVideoEncoderFactory* encoder_factory,
814 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
815 return CreatePeerConnectionFactory(
816 worker_and_network_thread, worker_and_network_thread, signaling_thread,
817 default_adm, encoder_factory, decoder_factory);
818}
819
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000820} // namespace webrtc
821
Henrik Kjellander15583c12016-02-10 10:53:12 +0100822#endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_