blob: 078db8a2ba045e22529bc350862094cd53386eb2 [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;
gyzhou95aa9642016-12-13 14:06:26 -080090class AudioMixer;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091class MediaConstraintsInterface;
92
93// MediaStream container interface.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000094class StreamCollectionInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000095 public:
96 // TODO(ronghuawu): Update the function names to c++ style, e.g. find -> Find.
97 virtual size_t count() = 0;
98 virtual MediaStreamInterface* at(size_t index) = 0;
99 virtual MediaStreamInterface* find(const std::string& label) = 0;
100 virtual MediaStreamTrackInterface* FindAudioTrack(
101 const std::string& id) = 0;
102 virtual MediaStreamTrackInterface* FindVideoTrack(
103 const std::string& id) = 0;
104
105 protected:
106 // Dtor protected as objects shouldn't be deleted via this interface.
107 ~StreamCollectionInterface() {}
108};
109
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000110class StatsObserver : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000111 public:
tommi@webrtc.orge2e199b2014-12-15 13:22:54 +0000112 virtual void OnComplete(const StatsReports& reports) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000113
114 protected:
115 virtual ~StatsObserver() {}
116};
117
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000118class MetricsObserverInterface : public rtc::RefCountInterface {
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000119 public:
Guo-wei Shieh3d564c12015-08-19 16:51:15 -0700120
121 // |type| is the type of the enum counter to be incremented. |counter|
122 // is the particular counter in that type. |counter_max| is the next sequence
123 // number after the highest counter.
124 virtual void IncrementEnumCounter(PeerConnectionEnumCounterType type,
125 int counter,
126 int counter_max) {}
127
Guo-wei Shieh456696a2015-09-30 21:48:54 -0700128 // This is used to handle sparse counters like SSL cipher suites.
129 // TODO(guoweis): Remove the implementation once the dependency's interface
130 // definition is updated.
131 virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type,
132 int counter) {
133 IncrementEnumCounter(type, counter, 0 /* Ignored */);
134 }
135
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000136 virtual void AddHistogramSample(PeerConnectionMetricsName type,
mallinath@webrtc.orgd37bcfa2014-05-12 23:10:18 +0000137 int value) = 0;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000138
139 protected:
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000140 virtual ~MetricsObserverInterface() {}
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000141};
142
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +0000143typedef MetricsObserverInterface UMAObserver;
144
deadbeef3edec7c2016-12-10 11:44:26 -0800145// Enumeration to represent distinct classes of errors that an application
146// may wish to act upon differently. These roughly map to DOMExceptions in
147// the web API, as described in the comments below.
148enum class RtcError {
149 // No error.
150 NONE,
151 // A supplied parameter is valid, but currently unsupported.
152 // Maps to InvalidAccessError DOMException.
153 UNSUPPORTED_PARAMETER,
154 // General error indicating that a supplied parameter is invalid.
155 // Maps to InvalidAccessError or TypeError DOMException depending on context.
156 INVALID_PARAMETER,
157 // Slightly more specific than INVALID_PARAMETER; a parameter's value was
158 // outside the allowed range.
159 // Maps to RangeError DOMException.
160 INVALID_RANGE,
161 // Slightly more specific than INVALID_PARAMETER; an error occurred while
162 // parsing string input.
163 // Maps to SyntaxError DOMException.
164 SYNTAX_ERROR,
165 // The object does not support this operation in its current state.
166 // Maps to InvalidStateError DOMException.
167 INVALID_STATE,
168 // An attempt was made to modify the object in an invalid way.
169 // Maps to InvalidModificationError DOMException.
170 INVALID_MODIFICATION,
171 // An error occurred within an underlying network protocol.
172 // Maps to NetworkError DOMException.
173 NETWORK_ERROR,
174 // The operation failed due to an internal error.
175 // Maps to OperationError DOMException.
176 INTERNAL_ERROR,
177};
178
179// Outputs the error as a friendly string.
180// Update this method when adding a new error type.
181std::ostream& operator<<(std::ostream& stream, RtcError error);
182
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000183class PeerConnectionInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000184 public:
185 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions .
186 enum SignalingState {
187 kStable,
188 kHaveLocalOffer,
189 kHaveLocalPrAnswer,
190 kHaveRemoteOffer,
191 kHaveRemotePrAnswer,
192 kClosed,
193 };
194
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000195 enum IceGatheringState {
196 kIceGatheringNew,
197 kIceGatheringGathering,
198 kIceGatheringComplete
199 };
200
201 enum IceConnectionState {
202 kIceConnectionNew,
203 kIceConnectionChecking,
204 kIceConnectionConnected,
205 kIceConnectionCompleted,
206 kIceConnectionFailed,
207 kIceConnectionDisconnected,
208 kIceConnectionClosed,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -0700209 kIceConnectionMax,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000210 };
211
hnslb0f04fd2016-12-19 04:10:30 -0800212 // TLS certificate policy.
213 enum TlsCertPolicy {
214 // For TLS based protocols, ensure the connection is secure by not
215 // circumventing certificate validation.
216 kTlsCertPolicySecure,
217 // For TLS based protocols, disregard security completely by skipping
218 // certificate validation. This is insecure and should never be used unless
219 // security is irrelevant in that particular context.
220 kTlsCertPolicyInsecureNoCheck,
221 };
222
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000223 struct IceServer {
Joachim Bauch7c4e7452015-05-28 23:06:30 +0200224 // TODO(jbauch): Remove uri when all code using it has switched to urls.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000225 std::string uri;
Joachim Bauch7c4e7452015-05-28 23:06:30 +0200226 std::vector<std::string> urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000227 std::string username;
228 std::string password;
hnslb0f04fd2016-12-19 04:10:30 -0800229 TlsCertPolicy tls_cert_policy = kTlsCertPolicySecure;
230
deadbeefd1a38b52016-12-10 13:15:33 -0800231 bool operator==(const IceServer& o) const {
232 return uri == o.uri && urls == o.urls && username == o.username &&
hnslb0f04fd2016-12-19 04:10:30 -0800233 password == o.password && tls_cert_policy == o.tls_cert_policy;
deadbeefd1a38b52016-12-10 13:15:33 -0800234 }
235 bool operator!=(const IceServer& o) const { return !(*this == o); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000236 };
237 typedef std::vector<IceServer> IceServers;
238
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000239 enum IceTransportsType {
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000240 // TODO(pthatcher): Rename these kTransporTypeXXX, but update
241 // Chromium at the same time.
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000242 kNone,
243 kRelay,
244 kNoHost,
245 kAll
246 };
247
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000248 // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-08#section-4.1.1
249 enum BundlePolicy {
250 kBundlePolicyBalanced,
251 kBundlePolicyMaxBundle,
252 kBundlePolicyMaxCompat
253 };
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000254
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700255 // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-09#section-4.1.1
256 enum RtcpMuxPolicy {
257 kRtcpMuxPolicyNegotiate,
258 kRtcpMuxPolicyRequire,
259 };
260
Jiayang Liucac1b382015-04-30 12:35:24 -0700261 enum TcpCandidatePolicy {
262 kTcpCandidatePolicyEnabled,
263 kTcpCandidatePolicyDisabled
264 };
265
honghaiz60347052016-05-31 18:29:12 -0700266 enum CandidateNetworkPolicy {
267 kCandidateNetworkPolicyAll,
268 kCandidateNetworkPolicyLowCost
269 };
270
honghaiz1f429e32015-09-28 07:57:34 -0700271 enum ContinualGatheringPolicy {
272 GATHER_ONCE,
273 GATHER_CONTINUALLY
274 };
275
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700276 enum class RTCConfigurationType {
277 // A configuration that is safer to use, despite not having the best
278 // performance. Currently this is the default configuration.
279 kSafe,
280 // An aggressive configuration that has better performance, although it
281 // may be riskier and may need extra support in the application.
282 kAggressive
283 };
284
Henrik Boström87713d02015-08-25 09:53:21 +0200285 // TODO(hbos): Change into class with private data and public getters.
nissec36b31b2016-04-11 23:25:29 -0700286 // TODO(nisse): In particular, accessing fields directly from an
287 // application is brittle, since the organization mirrors the
288 // organization of the implementation, which isn't stable. So we
289 // need getters and setters at least for fields which applications
290 // are interested in.
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000291 struct RTCConfiguration {
Niels Möller71bdda02016-03-31 12:59:59 +0200292 // This struct is subject to reorganization, both for naming
293 // consistency, and to group settings to match where they are used
294 // in the implementation. To do that, we need getter and setter
295 // methods for all settings which are of interest to applications,
296 // Chrome in particular.
297
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700298 RTCConfiguration() = default;
299 RTCConfiguration(RTCConfigurationType type) {
300 if (type == RTCConfigurationType::kAggressive) {
Honghai Zhangaecd9822016-09-02 16:58:17 -0700301 // These parameters are also defined in Java and IOS configurations,
302 // so their values may be overwritten by the Java or IOS configuration.
303 bundle_policy = kBundlePolicyMaxBundle;
304 rtcp_mux_policy = kRtcpMuxPolicyRequire;
305 ice_connection_receiving_timeout =
306 kAggressiveIceConnectionReceivingTimeout;
307
308 // These parameters are not defined in Java or IOS configuration,
309 // so their values will not be overwritten.
310 enable_ice_renomination = true;
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700311 redetermine_role_on_ice_restart = false;
312 }
Honghai Zhangbfd398c2016-08-30 22:07:42 -0700313 }
314
nissec36b31b2016-04-11 23:25:29 -0700315 bool dscp() { return media_config.enable_dscp; }
316 void set_dscp(bool enable) { media_config.enable_dscp = enable; }
Niels Möller71bdda02016-03-31 12:59:59 +0200317
318 // TODO(nisse): The corresponding flag in MediaConfig and
319 // elsewhere should be renamed enable_cpu_adaptation.
nissec36b31b2016-04-11 23:25:29 -0700320 bool cpu_adaptation() {
321 return media_config.video.enable_cpu_overuse_detection;
322 }
Niels Möller71bdda02016-03-31 12:59:59 +0200323 void set_cpu_adaptation(bool enable) {
nissec36b31b2016-04-11 23:25:29 -0700324 media_config.video.enable_cpu_overuse_detection = enable;
Niels Möller71bdda02016-03-31 12:59:59 +0200325 }
326
nissec36b31b2016-04-11 23:25:29 -0700327 bool suspend_below_min_bitrate() {
328 return media_config.video.suspend_below_min_bitrate;
329 }
Niels Möller71bdda02016-03-31 12:59:59 +0200330 void set_suspend_below_min_bitrate(bool enable) {
nissec36b31b2016-04-11 23:25:29 -0700331 media_config.video.suspend_below_min_bitrate = enable;
Niels Möller71bdda02016-03-31 12:59:59 +0200332 }
333
334 // TODO(nisse): The negation in the corresponding MediaConfig
335 // attribute is inconsistent, and it should be renamed at some
336 // point.
nissec36b31b2016-04-11 23:25:29 -0700337 bool prerenderer_smoothing() {
338 return !media_config.video.disable_prerenderer_smoothing;
339 }
Niels Möller71bdda02016-03-31 12:59:59 +0200340 void set_prerenderer_smoothing(bool enable) {
nissec36b31b2016-04-11 23:25:29 -0700341 media_config.video.disable_prerenderer_smoothing = !enable;
Niels Möller71bdda02016-03-31 12:59:59 +0200342 }
343
honghaiz4edc39c2015-09-01 09:53:56 -0700344 static const int kUndefined = -1;
345 // Default maximum number of packets in the audio jitter buffer.
346 static const int kAudioJitterBufferMaxPackets = 50;
Honghai Zhangaecd9822016-09-02 16:58:17 -0700347 // ICE connection receiving timeout for aggressive configuration.
348 static const int kAggressiveIceConnectionReceivingTimeout = 1000;
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000349 // TODO(pthatcher): Rename this ice_transport_type, but update
350 // Chromium at the same time.
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700351 IceTransportsType type = kAll;
pthatcher@webrtc.orgfd630a52015-01-14 23:19:06 +0000352 // TODO(pthatcher): Rename this ice_servers, but update Chromium
353 // at the same time.
354 IceServers servers;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700355 BundlePolicy bundle_policy = kBundlePolicyBalanced;
zhihuang4dfb8ce2016-11-23 10:30:12 -0800356 RtcpMuxPolicy rtcp_mux_policy = kRtcpMuxPolicyRequire;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700357 TcpCandidatePolicy tcp_candidate_policy = kTcpCandidatePolicyEnabled;
honghaiz60347052016-05-31 18:29:12 -0700358 CandidateNetworkPolicy candidate_network_policy =
359 kCandidateNetworkPolicyAll;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700360 int audio_jitter_buffer_max_packets = kAudioJitterBufferMaxPackets;
361 bool audio_jitter_buffer_fast_accelerate = false;
362 int ice_connection_receiving_timeout = kUndefined; // ms
363 int ice_backup_candidate_pair_ping_interval = kUndefined; // ms
364 ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE;
Henrik Boström87713d02015-08-25 09:53:21 +0200365 std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700366 bool prioritize_most_likely_ice_candidate_pairs = false;
nissec36b31b2016-04-11 23:25:29 -0700367 struct cricket::MediaConfig media_config;
htaa2a49d92016-03-04 02:51:39 -0800368 // Flags corresponding to values set by constraint flags.
369 // rtc::Optional flags can be "missing", in which case the webrtc
370 // default applies.
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700371 bool disable_ipv6 = false;
372 bool enable_rtp_data_channel = false;
zhihuang9763d562016-08-05 11:14:50 -0700373 bool enable_quic = false;
htaa2a49d92016-03-04 02:51:39 -0800374 rtc::Optional<int> screencast_min_bitrate;
375 rtc::Optional<bool> combined_audio_video_bwe;
376 rtc::Optional<bool> enable_dtls_srtp;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700377 int ice_candidate_pool_size = 0;
Honghai Zhangb9e7b4a2016-06-30 20:52:02 -0700378 bool prune_turn_ports = false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700379 // If set to true, this means the ICE transport should presume TURN-to-TURN
380 // candidate pairs will succeed, even before a binding response is received.
381 bool presume_writable_when_fully_relayed = false;
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700382 // If true, "renomination" will be added to the ice options in the transport
383 // description.
384 bool enable_ice_renomination = false;
Honghai Zhangbfd398c2016-08-30 22:07:42 -0700385 // If true, ICE role is redetermined when peerconnection sets a local
386 // transport description that indicates an ICE restart.
387 bool redetermine_role_on_ice_restart = true;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000388 };
389
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000390 struct RTCOfferAnswerOptions {
391 static const int kUndefined = -1;
392 static const int kMaxOfferToReceiveMedia = 1;
393
394 // The default value for constraint offerToReceiveX:true.
395 static const int kOfferToReceiveMediaTrue = 1;
396
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700397 int offer_to_receive_video = kUndefined;
398 int offer_to_receive_audio = kUndefined;
399 bool voice_activity_detection = true;
400 bool ice_restart = false;
401 bool use_rtp_mux = true;
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000402
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700403 RTCOfferAnswerOptions() = default;
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000404
405 RTCOfferAnswerOptions(int offer_to_receive_video,
406 int offer_to_receive_audio,
407 bool voice_activity_detection,
408 bool ice_restart,
409 bool use_rtp_mux)
410 : offer_to_receive_video(offer_to_receive_video),
411 offer_to_receive_audio(offer_to_receive_audio),
412 voice_activity_detection(voice_activity_detection),
413 ice_restart(ice_restart),
414 use_rtp_mux(use_rtp_mux) {}
415 };
416
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +0000417 // Used by GetStats to decide which stats to include in the stats reports.
418 // |kStatsOutputLevelStandard| includes the standard stats for Javascript API;
419 // |kStatsOutputLevelDebug| includes both the standard stats and additional
420 // stats for debugging purposes.
421 enum StatsOutputLevel {
422 kStatsOutputLevelStandard,
423 kStatsOutputLevelDebug,
424 };
425
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000426 // Accessor methods to active local streams.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000427 virtual rtc::scoped_refptr<StreamCollectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000428 local_streams() = 0;
429
430 // Accessor methods to remote streams.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000431 virtual rtc::scoped_refptr<StreamCollectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000432 remote_streams() = 0;
433
434 // Add a new MediaStream to be sent on this PeerConnection.
435 // Note that a SessionDescription negotiation is needed before the
436 // remote peer can receive the stream.
perkj@webrtc.orgfd0efb62014-11-06 12:16:36 +0000437 virtual bool AddStream(MediaStreamInterface* stream) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000438
439 // Remove a MediaStream from this PeerConnection.
440 // Note that a SessionDescription negotiation is need before the
441 // remote peer is notified.
442 virtual void RemoveStream(MediaStreamInterface* stream) = 0;
443
deadbeefe1f9d832016-01-14 15:35:42 -0800444 // TODO(deadbeef): Make the following two methods pure virtual once
445 // implemented by all subclasses of PeerConnectionInterface.
446 // Add a new MediaStreamTrack to be sent on this PeerConnection.
447 // |streams| indicates which stream labels the track should be associated
448 // with.
449 virtual rtc::scoped_refptr<RtpSenderInterface> AddTrack(
450 MediaStreamTrackInterface* track,
451 std::vector<MediaStreamInterface*> streams) {
452 return nullptr;
453 }
454
455 // Remove an RtpSender from this PeerConnection.
456 // Returns true on success.
457 virtual bool RemoveTrack(RtpSenderInterface* sender) {
458 return false;
459 }
460
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000461 // Returns pointer to the created DtmfSender on success.
462 // Otherwise returns NULL.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000463 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000464 AudioTrackInterface* track) = 0;
465
deadbeef70ab1a12015-09-28 16:53:55 -0700466 // TODO(deadbeef): Make these pure virtual once all subclasses implement them.
deadbeeffac06552015-11-25 11:26:01 -0800467 // |kind| must be "audio" or "video".
deadbeefbd7d8f72015-12-18 16:58:44 -0800468 // |stream_id| is used to populate the msid attribute; if empty, one will
469 // be generated automatically.
deadbeeffac06552015-11-25 11:26:01 -0800470 virtual rtc::scoped_refptr<RtpSenderInterface> CreateSender(
deadbeefbd7d8f72015-12-18 16:58:44 -0800471 const std::string& kind,
472 const std::string& stream_id) {
deadbeeffac06552015-11-25 11:26:01 -0800473 return rtc::scoped_refptr<RtpSenderInterface>();
474 }
475
deadbeef70ab1a12015-09-28 16:53:55 -0700476 virtual std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
477 const {
478 return std::vector<rtc::scoped_refptr<RtpSenderInterface>>();
479 }
480
481 virtual std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
482 const {
483 return std::vector<rtc::scoped_refptr<RtpReceiverInterface>>();
484 }
485
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +0000486 virtual bool GetStats(StatsObserver* observer,
487 MediaStreamTrackInterface* track,
488 StatsOutputLevel level) = 0;
hbos74e1a4f2016-09-15 23:33:01 -0700489 // Gets stats using the new stats collection API, see webrtc/api/stats/. These
490 // will replace old stats collection API when the new API has matured enough.
hbose3810152016-12-13 02:35:19 -0800491 // TODO(hbos): Default implementation that does nothing only exists as to not
492 // break third party projects. As soon as they have been updated this should
493 // be changed to "= 0;".
494 virtual void GetStats(RTCStatsCollectorCallback* callback) {}
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +0000495
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000496 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000497 const std::string& label,
498 const DataChannelInit* config) = 0;
499
500 virtual const SessionDescriptionInterface* local_description() const = 0;
501 virtual const SessionDescriptionInterface* remote_description() const = 0;
502
503 // Create a new offer.
504 // The CreateSessionDescriptionObserver callback will be called when done.
505 virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
jiayl@webrtc.orgb18bf5e2014-08-04 18:34:16 +0000506 const MediaConstraintsInterface* constraints) {}
507
508 // TODO(jiayl): remove the default impl and the old interface when chromium
509 // code is updated.
510 virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
511 const RTCOfferAnswerOptions& options) {}
512
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000513 // Create an answer to an offer.
514 // The CreateSessionDescriptionObserver callback will be called when done.
515 virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
htaa2a49d92016-03-04 02:51:39 -0800516 const RTCOfferAnswerOptions& options) {}
517 // Deprecated - use version above.
518 // TODO(hta): Remove and remove default implementations when all callers
519 // are updated.
520 virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
521 const MediaConstraintsInterface* constraints) {}
522
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000523 // Sets the local session description.
524 // JsepInterface takes the ownership of |desc| even if it fails.
525 // The |observer| callback will be called when done.
526 virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,
527 SessionDescriptionInterface* desc) = 0;
528 // Sets the remote session description.
529 // JsepInterface takes the ownership of |desc| even if it fails.
530 // The |observer| callback will be called when done.
531 virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
532 SessionDescriptionInterface* desc) = 0;
533 // Restarts or updates the ICE Agent process of gathering local candidates
534 // and pinging remote candidates.
deadbeefa67696b2015-09-29 11:56:26 -0700535 // TODO(deadbeef): Remove once Chrome is moved over to SetConfiguration.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000536 virtual bool UpdateIce(const IceServers& configuration,
deadbeefa67696b2015-09-29 11:56:26 -0700537 const MediaConstraintsInterface* constraints) {
538 return false;
539 }
htaa2a49d92016-03-04 02:51:39 -0800540 virtual bool UpdateIce(const IceServers& configuration) { return false; }
deadbeef46c73892016-11-16 19:42:04 -0800541 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
542 // PeerConnectionInterface implement it.
543 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() {
544 return PeerConnectionInterface::RTCConfiguration();
545 }
deadbeefa67696b2015-09-29 11:56:26 -0700546 // Sets the PeerConnection's global configuration to |config|.
547 // Any changes to STUN/TURN servers or ICE candidate policy will affect the
548 // next gathering phase, and cause the next call to createOffer to generate
549 // new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
550 // cannot be changed with this method.
551 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
552 // PeerConnectionInterface implement it.
553 virtual bool SetConfiguration(
554 const PeerConnectionInterface::RTCConfiguration& config) {
555 return false;
556 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000557 // Provides a remote candidate to the ICE Agent.
558 // A copy of the |candidate| will be created and added to the remote
559 // description. So the caller of this method still has the ownership of the
560 // |candidate|.
561 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will
562 // take the ownership of the |candidate|.
563 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0;
564
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700565 // Removes a group of remote candidates from the ICE agent.
566 virtual bool RemoveIceCandidates(
567 const std::vector<cricket::Candidate>& candidates) {
568 return false;
569 }
570
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000571 virtual void RegisterUMAObserver(UMAObserver* observer) = 0;
572
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000573 // Returns the current SignalingState.
574 virtual SignalingState signaling_state() = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000575 virtual IceConnectionState ice_connection_state() = 0;
576 virtual IceGatheringState ice_gathering_state() = 0;
577
ivoc14d5dbe2016-07-04 07:06:55 -0700578 // Starts RtcEventLog using existing file. Takes ownership of |file| and
579 // passes it on to Call, which will take the ownership. If the
580 // operation fails the file will be closed. The logging will stop
581 // automatically after 10 minutes have passed, or when the StopRtcEventLog
582 // function is called.
583 // TODO(ivoc): Make this pure virtual when Chrome is updated.
584 virtual bool StartRtcEventLog(rtc::PlatformFile file,
585 int64_t max_size_bytes) {
586 return false;
587 }
588
589 // Stops logging the RtcEventLog.
590 // TODO(ivoc): Make this pure virtual when Chrome is updated.
591 virtual void StopRtcEventLog() {}
592
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000593 // Terminates all media and closes the transport.
594 virtual void Close() = 0;
595
596 protected:
597 // Dtor protected as objects shouldn't be deleted via this interface.
598 ~PeerConnectionInterface() {}
599};
600
601// PeerConnection callback interface. Application should implement these
602// methods.
603class PeerConnectionObserver {
604 public:
605 enum StateType {
606 kSignalingState,
607 kIceState,
608 };
609
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000610 // Triggered when the SignalingState changed.
611 virtual void OnSignalingChange(
perkjdfb769d2016-02-09 03:09:43 -0800612 PeerConnectionInterface::SignalingState new_state) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000613
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700614 // TODO(deadbeef): Once all subclasses override the scoped_refptr versions
615 // of the below three methods, make them pure virtual and remove the raw
616 // pointer version.
617
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000618 // Triggered when media is received on a new stream from remote peer.
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700619 virtual void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {}
620 // Deprecated; please use the version that uses a scoped_refptr.
621 virtual void OnAddStream(MediaStreamInterface* stream) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000622
623 // Triggered when a remote peer close a stream.
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700624 virtual void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
625 }
626 // Deprecated; please use the version that uses a scoped_refptr.
627 virtual void OnRemoveStream(MediaStreamInterface* stream) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000628
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700629 // Triggered when a remote peer opens a data channel.
630 virtual void OnDataChannel(
631 rtc::scoped_refptr<DataChannelInterface> data_channel){};
632 // Deprecated; please use the version that uses a scoped_refptr.
633 virtual void OnDataChannel(DataChannelInterface* data_channel) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000634
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700635 // Triggered when renegotiation is needed. For example, an ICE restart
636 // has begun.
fischman@webrtc.orgd7568a02014-01-13 22:04:12 +0000637 virtual void OnRenegotiationNeeded() = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000638
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700639 // Called any time the IceConnectionState changes.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000640 virtual void OnIceConnectionChange(
perkjdfb769d2016-02-09 03:09:43 -0800641 PeerConnectionInterface::IceConnectionState new_state) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000642
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700643 // Called any time the IceGatheringState changes.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000644 virtual void OnIceGatheringChange(
perkjdfb769d2016-02-09 03:09:43 -0800645 PeerConnectionInterface::IceGatheringState new_state) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000646
Taylor Brandstetter98cde262016-05-31 13:02:21 -0700647 // A new ICE candidate has been gathered.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000648 virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0;
649
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700650 // Ice candidates have been removed.
651 // TODO(honghaiz): Make this a pure virtual method when all its subclasses
652 // implement it.
653 virtual void OnIceCandidatesRemoved(
654 const std::vector<cricket::Candidate>& candidates) {}
655
Peter Thatcher54360512015-07-08 11:08:35 -0700656 // Called when the ICE connection receiving status changes.
657 virtual void OnIceConnectionReceivingChange(bool receiving) {}
658
zhihuang81c3a032016-11-17 12:06:24 -0800659 // Called when a track is added to streams.
660 // TODO(zhihuang) Make this a pure virtual method when all its subclasses
661 // implement it.
662 virtual void OnAddTrack(
663 rtc::scoped_refptr<RtpReceiverInterface> receiver,
zhihuangc63b8942016-12-02 15:41:10 -0800664 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {}
zhihuang81c3a032016-11-17 12:06:24 -0800665
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000666 protected:
667 // Dtor protected as objects shouldn't be deleted via this interface.
668 ~PeerConnectionObserver() {}
669};
670
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000671// PeerConnectionFactoryInterface is the factory interface use for creating
672// PeerConnection, MediaStream and media tracks.
673// PeerConnectionFactoryInterface will create required libjingle threads,
674// socket and network manager factory classes for networking.
675// If an application decides to provide its own threads and network
676// implementation of these classes it should use the alternate
677// CreatePeerConnectionFactory method which accepts threads as input and use the
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -0800678// CreatePeerConnection version that takes a PortAllocator as an
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000679// argument.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000680class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000681 public:
wu@webrtc.org97077a32013-10-25 21:18:33 +0000682 class Options {
683 public:
Guo-wei Shieha7446d22016-01-11 15:27:03 -0800684 Options()
685 : disable_encryption(false),
686 disable_sctp_data_channels(false),
687 disable_network_monitor(false),
688 network_ignore_mask(rtc::kDefaultNetworkIgnoreMask),
jbauchcb560652016-08-04 05:20:32 -0700689 ssl_max_version(rtc::SSL_PROTOCOL_DTLS_12),
690 crypto_options(rtc::CryptoOptions::NoGcm()) {}
wu@webrtc.org97077a32013-10-25 21:18:33 +0000691 bool disable_encryption;
692 bool disable_sctp_data_channels;
honghaiz023f3ef2015-10-19 09:39:32 -0700693 bool disable_network_monitor;
phoglund@webrtc.org006521d2015-02-12 09:23:59 +0000694
695 // Sets the network types to ignore. For instance, calling this with
696 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
697 // loopback interfaces.
698 int network_ignore_mask;
Joachim Bauch04e5b492015-05-29 09:40:39 +0200699
700 // Sets the maximum supported protocol version. The highest version
701 // supported by both ends will be used for the connection, i.e. if one
702 // party supports DTLS 1.0 and the other DTLS 1.2, DTLS 1.0 will be used.
703 rtc::SSLProtocolVersion ssl_max_version;
jbauchcb560652016-08-04 05:20:32 -0700704
705 // Sets crypto related options, e.g. enabled cipher suites.
706 rtc::CryptoOptions crypto_options;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000707 };
708
709 virtual void SetOptions(const Options& options) = 0;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000710
deadbeef41b07982015-12-01 15:01:24 -0800711 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
712 const PeerConnectionInterface::RTCConfiguration& configuration,
713 const MediaConstraintsInterface* constraints,
kwibergd1fe2812016-04-27 06:47:29 -0700714 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 11:44:18 +0200715 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
hbosd7973cc2016-05-27 06:08:53 -0700716 PeerConnectionObserver* observer) = 0;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000717
htaa2a49d92016-03-04 02:51:39 -0800718 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
719 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 06:47:29 -0700720 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 11:44:18 +0200721 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
hbosd7973cc2016-05-27 06:08:53 -0700722 PeerConnectionObserver* observer) = 0;
htaa2a49d92016-03-04 02:51:39 -0800723
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000724 virtual rtc::scoped_refptr<MediaStreamInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000725 CreateLocalMediaStream(const std::string& label) = 0;
726
727 // Creates a AudioSourceInterface.
728 // |constraints| decides audio processing settings but can be NULL.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000729 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
htaa2a49d92016-03-04 02:51:39 -0800730 const cricket::AudioOptions& options) = 0;
731 // Deprecated - use version above.
732 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000733 const MediaConstraintsInterface* constraints) = 0;
734
perkja3ede6c2016-03-08 01:27:48 +0100735 // Creates a VideoTrackSourceInterface. The new source take ownership of
htaa2a49d92016-03-04 02:51:39 -0800736 // |capturer|.
perkja3ede6c2016-03-08 01:27:48 +0100737 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
htaa2a49d92016-03-04 02:51:39 -0800738 cricket::VideoCapturer* capturer) = 0;
739 // A video source creator that allows selection of resolution and frame rate.
740 // |constraints| decides video resolution and frame rate but can
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000741 // be NULL.
htaa2a49d92016-03-04 02:51:39 -0800742 // In the NULL case, use the version above.
perkja3ede6c2016-03-08 01:27:48 +0100743 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000744 cricket::VideoCapturer* capturer,
745 const MediaConstraintsInterface* constraints) = 0;
746
747 // Creates a new local VideoTrack. The same |source| can be used in several
748 // tracks.
perkja3ede6c2016-03-08 01:27:48 +0100749 virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
750 const std::string& label,
751 VideoTrackSourceInterface* source) = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000752
753 // Creates an new AudioTrack. At the moment |source| can be NULL.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000754 virtual rtc::scoped_refptr<AudioTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000755 CreateAudioTrack(const std::string& label,
756 AudioSourceInterface* source) = 0;
757
wu@webrtc.orga9890802013-12-13 00:21:03 +0000758 // Starts AEC dump using existing file. Takes ownership of |file| and passes
759 // it on to VoiceEngine (via other objects) immediately, which will take
wu@webrtc.orga8910d22014-01-23 22:12:45 +0000760 // the ownerhip. If the operation fails, the file will be closed.
ivocd66b44d2016-01-15 03:06:36 -0800761 // A maximum file size in bytes can be specified. When the file size limit is
762 // reached, logging is stopped automatically. If max_size_bytes is set to a
763 // value <= 0, no limit will be used, and logging will continue until the
764 // StopAecDump function is called.
765 virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) = 0;
wu@webrtc.orga9890802013-12-13 00:21:03 +0000766
ivoc797ef122015-10-22 03:25:41 -0700767 // Stops logging the AEC dump.
768 virtual void StopAecDump() = 0;
769
ivoc14d5dbe2016-07-04 07:06:55 -0700770 // This function is deprecated and will be removed when Chrome is updated to
771 // use the equivalent function on PeerConnectionInterface.
772 // TODO(ivoc) Remove after Chrome is updated.
ivocc1513ee2016-05-13 08:30:39 -0700773 virtual bool StartRtcEventLog(rtc::PlatformFile file,
774 int64_t max_size_bytes) = 0;
ivoc14d5dbe2016-07-04 07:06:55 -0700775 // This function is deprecated and will be removed when Chrome is updated to
776 // use the equivalent function on PeerConnectionInterface.
777 // TODO(ivoc) Remove after Chrome is updated.
ivoc112a3d82015-10-16 02:22:18 -0700778 virtual bool StartRtcEventLog(rtc::PlatformFile file) = 0;
779
ivoc14d5dbe2016-07-04 07:06:55 -0700780 // This function is deprecated and will be removed when Chrome is updated to
781 // use the equivalent function on PeerConnectionInterface.
782 // TODO(ivoc) Remove after Chrome is updated.
ivoc112a3d82015-10-16 02:22:18 -0700783 virtual void StopRtcEventLog() = 0;
784
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000785 protected:
786 // Dtor and ctor protected as objects shouldn't be created or deleted via
787 // this interface.
788 PeerConnectionFactoryInterface() {}
789 ~PeerConnectionFactoryInterface() {} // NOLINT
790};
791
792// Create a new instance of PeerConnectionFactoryInterface.
Taylor Brandstettera8415fe2016-03-23 10:38:07 -0700793//
794// This method relies on the thread it's called on as the "signaling thread"
795// for the PeerConnectionFactory it creates.
796//
797// As such, if the current thread is not already running an rtc::Thread message
798// loop, an application using this method must eventually either call
799// rtc::Thread::Current()->Run(), or call
800// rtc::Thread::Current()->ProcessMessages() within the application's own
801// message loop.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000802rtc::scoped_refptr<PeerConnectionFactoryInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000803CreatePeerConnectionFactory();
804
805// Create a new instance of PeerConnectionFactoryInterface.
Taylor Brandstettera8415fe2016-03-23 10:38:07 -0700806//
danilchape9021a32016-05-17 01:52:02 -0700807// |network_thread|, |worker_thread| and |signaling_thread| are
808// the only mandatory parameters.
Taylor Brandstettera8415fe2016-03-23 10:38:07 -0700809//
810// If non-null, ownership of |default_adm|, |encoder_factory| and
811// |decoder_factory| are transferred to the returned factory.
danilchape9021a32016-05-17 01:52:02 -0700812rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
813 rtc::Thread* network_thread,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000814 rtc::Thread* worker_thread,
815 rtc::Thread* signaling_thread,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000816 AudioDeviceModule* default_adm,
817 cricket::WebRtcVideoEncoderFactory* encoder_factory,
818 cricket::WebRtcVideoDecoderFactory* decoder_factory);
819
gyzhou95aa9642016-12-13 14:06:26 -0800820// Create a new instance of PeerConnectionFactoryInterface with external audio
821// mixer.
822//
823// If |audio_mixer| is null, an internal audio mixer will be created and used.
824rtc::scoped_refptr<PeerConnectionFactoryInterface>
825CreatePeerConnectionFactoryWithAudioMixer(
826 rtc::Thread* network_thread,
827 rtc::Thread* worker_thread,
828 rtc::Thread* signaling_thread,
829 AudioDeviceModule* default_adm,
830 cricket::WebRtcVideoEncoderFactory* encoder_factory,
831 cricket::WebRtcVideoDecoderFactory* decoder_factory,
832 rtc::scoped_refptr<AudioMixer> audio_mixer);
833
danilchape9021a32016-05-17 01:52:02 -0700834// Create a new instance of PeerConnectionFactoryInterface.
835// Same thread is used as worker and network thread.
danilchape9021a32016-05-17 01:52:02 -0700836inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
837CreatePeerConnectionFactory(
838 rtc::Thread* worker_and_network_thread,
839 rtc::Thread* signaling_thread,
840 AudioDeviceModule* default_adm,
841 cricket::WebRtcVideoEncoderFactory* encoder_factory,
842 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
843 return CreatePeerConnectionFactory(
844 worker_and_network_thread, worker_and_network_thread, signaling_thread,
845 default_adm, encoder_factory, decoder_factory);
846}
847
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000848} // namespace webrtc
849
Henrik Kjellander15583c12016-02-10 10:53:12 +0100850#endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_