blob: 6cc8be7112b691f03409d06e0cdf4f4e4f913562 [file] [log] [blame]
Henrik Kjellanderbd0ae452016-02-10 09:53:121/*
kjellander95ed4e62016-02-10 15:54:432 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
Henrik Kjellanderbd0ae452016-02-10 09:53:123 *
kjellander95ed4e62016-02-10 15:54:434 * 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.
Henrik Kjellanderbd0ae452016-02-10 09:53:129 */
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
51#ifndef WEBRTC_API_PEERCONNECTIONINTERFACE_H_
52#define WEBRTC_API_PEERCONNECTIONINTERFACE_H_
53
kwibergb4bfca42016-04-27 13:47:2954#include <memory>
deadbeef7fc93ae2016-12-10 19:44:2655#include <ostream>
Henrik Kjellanderbd0ae452016-02-10 09:53:1256#include <string>
57#include <utility>
58#include <vector>
59
60#include "webrtc/api/datachannelinterface.h"
Henrik Kjellanderbd0ae452016-02-10 09:53:1261#include "webrtc/api/dtmfsenderinterface.h"
62#include "webrtc/api/jsep.h"
63#include "webrtc/api/mediastreaminterface.h"
ossu25e4ac72017-01-23 12:56:2564#include "webrtc/api/stats/rtcstatscollectorcallback.h"
Henrik Kjellanderbd0ae452016-02-10 09:53:1265#include "webrtc/api/rtpreceiverinterface.h"
66#include "webrtc/api/rtpsenderinterface.h"
67#include "webrtc/api/statstypes.h"
68#include "webrtc/api/umametrics.h"
69#include "webrtc/base/fileutils.h"
70#include "webrtc/base/network.h"
71#include "webrtc/base/rtccertificate.h"
Henrik Boströmb8942012016-06-01 09:44:1872#include "webrtc/base/rtccertificategenerator.h"
Henrik Kjellanderbd0ae452016-02-10 09:53:1273#include "webrtc/base/socketaddress.h"
74#include "webrtc/base/sslstreamadapter.h"
nisse0acedfe2016-04-12 06:25:2975#include "webrtc/media/base/mediachannel.h"
kwiberg780e2022017-01-31 09:48:0876#include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h"
Henrik Kjellanderbd0ae452016-02-10 09:53:1277#include "webrtc/p2p/base/portallocator.h"
78
79namespace rtc {
80class SSLIdentity;
81class Thread;
82}
83
84namespace cricket {
85class WebRtcVideoDecoderFactory;
86class WebRtcVideoEncoderFactory;
87}
88
89namespace webrtc {
90class AudioDeviceModule;
gyzhou800a8f12016-12-13 22:06:2691class AudioMixer;
Henrik Kjellanderbd0ae452016-02-10 09:53:1292class MediaConstraintsInterface;
93
94// MediaStream container interface.
95class StreamCollectionInterface : public rtc::RefCountInterface {
96 public:
97 // TODO(ronghuawu): Update the function names to c++ style, e.g. find -> Find.
98 virtual size_t count() = 0;
99 virtual MediaStreamInterface* at(size_t index) = 0;
100 virtual MediaStreamInterface* find(const std::string& label) = 0;
101 virtual MediaStreamTrackInterface* FindAudioTrack(
102 const std::string& id) = 0;
103 virtual MediaStreamTrackInterface* FindVideoTrack(
104 const std::string& id) = 0;
105
106 protected:
107 // Dtor protected as objects shouldn't be deleted via this interface.
108 ~StreamCollectionInterface() {}
109};
110
111class StatsObserver : public rtc::RefCountInterface {
112 public:
nissecd00ec92017-01-18 13:00:34113 virtual void OnComplete(const StatsReports& reports) = 0;
Henrik Kjellanderbd0ae452016-02-10 09:53:12114
115 protected:
116 virtual ~StatsObserver() {}
117};
118
deadbeef7fc93ae2016-12-10 19:44:26119// Enumeration to represent distinct classes of errors that an application
deadbeefa496afa2017-01-11 20:28:30120// may wish to act upon differently. These roughly map to DOMExceptions or
121// RTCError "errorDetailEnum" values in the web API, as described in the
122// comments below.
123enum class RTCErrorType {
deadbeef7fc93ae2016-12-10 19:44:26124 // No error.
125 NONE,
126 // A supplied parameter is valid, but currently unsupported.
127 // Maps to InvalidAccessError DOMException.
128 UNSUPPORTED_PARAMETER,
129 // General error indicating that a supplied parameter is invalid.
130 // Maps to InvalidAccessError or TypeError DOMException depending on context.
131 INVALID_PARAMETER,
132 // Slightly more specific than INVALID_PARAMETER; a parameter's value was
133 // outside the allowed range.
134 // Maps to RangeError DOMException.
135 INVALID_RANGE,
136 // Slightly more specific than INVALID_PARAMETER; an error occurred while
137 // parsing string input.
138 // Maps to SyntaxError DOMException.
139 SYNTAX_ERROR,
140 // The object does not support this operation in its current state.
141 // Maps to InvalidStateError DOMException.
142 INVALID_STATE,
143 // An attempt was made to modify the object in an invalid way.
144 // Maps to InvalidModificationError DOMException.
145 INVALID_MODIFICATION,
146 // An error occurred within an underlying network protocol.
147 // Maps to NetworkError DOMException.
148 NETWORK_ERROR,
149 // The operation failed due to an internal error.
150 // Maps to OperationError DOMException.
151 INTERNAL_ERROR,
152};
153
deadbeefa496afa2017-01-11 20:28:30154// Roughly corresponds to RTCError in the web api. Holds an error type and
155// possibly additional information specific to that error.
156//
157// Doesn't contain anything beyond a type now, but will in the future as more
158// errors are implemented.
159class RTCError {
160 public:
161 RTCError() : type_(RTCErrorType::NONE) {}
162 explicit RTCError(RTCErrorType type) : type_(type) {}
163
164 RTCErrorType type() const { return type_; }
165 void set_type(RTCErrorType type) { type_ = type; }
166
167 private:
168 RTCErrorType type_;
169};
170
deadbeef7fc93ae2016-12-10 19:44:26171// Outputs the error as a friendly string.
172// Update this method when adding a new error type.
deadbeefa496afa2017-01-11 20:28:30173std::ostream& operator<<(std::ostream& stream, RTCErrorType error);
deadbeef7fc93ae2016-12-10 19:44:26174
Henrik Kjellanderbd0ae452016-02-10 09:53:12175class PeerConnectionInterface : public rtc::RefCountInterface {
176 public:
177 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions .
178 enum SignalingState {
179 kStable,
180 kHaveLocalOffer,
181 kHaveLocalPrAnswer,
182 kHaveRemoteOffer,
183 kHaveRemotePrAnswer,
184 kClosed,
185 };
186
Henrik Kjellanderbd0ae452016-02-10 09:53:12187 enum IceGatheringState {
188 kIceGatheringNew,
189 kIceGatheringGathering,
190 kIceGatheringComplete
191 };
192
193 enum IceConnectionState {
194 kIceConnectionNew,
195 kIceConnectionChecking,
196 kIceConnectionConnected,
197 kIceConnectionCompleted,
198 kIceConnectionFailed,
199 kIceConnectionDisconnected,
200 kIceConnectionClosed,
201 kIceConnectionMax,
202 };
203
hnsl38377622017-01-09 16:35:45204 // TLS certificate policy.
205 enum TlsCertPolicy {
206 // For TLS based protocols, ensure the connection is secure by not
207 // circumventing certificate validation.
208 kTlsCertPolicySecure,
209 // For TLS based protocols, disregard security completely by skipping
210 // certificate validation. This is insecure and should never be used unless
211 // security is irrelevant in that particular context.
212 kTlsCertPolicyInsecureNoCheck,
213 };
214
Henrik Kjellanderbd0ae452016-02-10 09:53:12215 struct IceServer {
216 // TODO(jbauch): Remove uri when all code using it has switched to urls.
217 std::string uri;
218 std::vector<std::string> urls;
219 std::string username;
220 std::string password;
hnsl38377622017-01-09 16:35:45221 TlsCertPolicy tls_cert_policy = kTlsCertPolicySecure;
222
deadbeef3ef98dc2016-12-10 21:15:33223 bool operator==(const IceServer& o) const {
224 return uri == o.uri && urls == o.urls && username == o.username &&
hnsl38377622017-01-09 16:35:45225 password == o.password && tls_cert_policy == o.tls_cert_policy;
deadbeef3ef98dc2016-12-10 21:15:33226 }
227 bool operator!=(const IceServer& o) const { return !(*this == o); }
Henrik Kjellanderbd0ae452016-02-10 09:53:12228 };
229 typedef std::vector<IceServer> IceServers;
230
231 enum IceTransportsType {
232 // TODO(pthatcher): Rename these kTransporTypeXXX, but update
233 // Chromium at the same time.
234 kNone,
235 kRelay,
236 kNoHost,
237 kAll
238 };
239
240 // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-08#section-4.1.1
241 enum BundlePolicy {
242 kBundlePolicyBalanced,
243 kBundlePolicyMaxBundle,
244 kBundlePolicyMaxCompat
245 };
246
247 // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-09#section-4.1.1
248 enum RtcpMuxPolicy {
249 kRtcpMuxPolicyNegotiate,
250 kRtcpMuxPolicyRequire,
251 };
252
253 enum TcpCandidatePolicy {
254 kTcpCandidatePolicyEnabled,
255 kTcpCandidatePolicyDisabled
256 };
257
honghaiz5f9f4ae2016-06-01 01:29:12258 enum CandidateNetworkPolicy {
259 kCandidateNetworkPolicyAll,
260 kCandidateNetworkPolicyLowCost
261 };
262
Henrik Kjellanderbd0ae452016-02-10 09:53:12263 enum ContinualGatheringPolicy {
264 GATHER_ONCE,
265 GATHER_CONTINUALLY
266 };
267
Honghai Zhang21c93a22016-09-01 22:34:01268 enum class RTCConfigurationType {
269 // A configuration that is safer to use, despite not having the best
270 // performance. Currently this is the default configuration.
271 kSafe,
272 // An aggressive configuration that has better performance, although it
273 // may be riskier and may need extra support in the application.
274 kAggressive
275 };
276
Henrik Kjellanderbd0ae452016-02-10 09:53:12277 // TODO(hbos): Change into class with private data and public getters.
nisse0acedfe2016-04-12 06:25:29278 // TODO(nisse): In particular, accessing fields directly from an
279 // application is brittle, since the organization mirrors the
280 // organization of the implementation, which isn't stable. So we
281 // need getters and setters at least for fields which applications
282 // are interested in.
Henrik Kjellanderbd0ae452016-02-10 09:53:12283 struct RTCConfiguration {
Niels Möller7c6a74f2016-03-31 10:59:59284 // This struct is subject to reorganization, both for naming
285 // consistency, and to group settings to match where they are used
286 // in the implementation. To do that, we need getter and setter
287 // methods for all settings which are of interest to applications,
288 // Chrome in particular.
289
Honghai Zhang21c93a22016-09-01 22:34:01290 RTCConfiguration() = default;
oprypin13c97c72017-02-01 09:55:59291 explicit RTCConfiguration(RTCConfigurationType type) {
Honghai Zhang21c93a22016-09-01 22:34:01292 if (type == RTCConfigurationType::kAggressive) {
Honghai Zhanga9ca1202016-09-02 23:58:17293 // These parameters are also defined in Java and IOS configurations,
294 // so their values may be overwritten by the Java or IOS configuration.
295 bundle_policy = kBundlePolicyMaxBundle;
296 rtcp_mux_policy = kRtcpMuxPolicyRequire;
297 ice_connection_receiving_timeout =
298 kAggressiveIceConnectionReceivingTimeout;
299
300 // These parameters are not defined in Java or IOS configuration,
301 // so their values will not be overwritten.
302 enable_ice_renomination = true;
Honghai Zhang21c93a22016-09-01 22:34:01303 redetermine_role_on_ice_restart = false;
304 }
Honghai Zhangbbdec842016-08-31 05:07:42305 }
306
deadbeefa496afa2017-01-11 20:28:30307 bool operator==(const RTCConfiguration& o) const;
308 bool operator!=(const RTCConfiguration& o) const;
309
nisse0acedfe2016-04-12 06:25:29310 bool dscp() { return media_config.enable_dscp; }
311 void set_dscp(bool enable) { media_config.enable_dscp = enable; }
Niels Möller7c6a74f2016-03-31 10:59:59312
313 // TODO(nisse): The corresponding flag in MediaConfig and
314 // elsewhere should be renamed enable_cpu_adaptation.
nisse0acedfe2016-04-12 06:25:29315 bool cpu_adaptation() {
316 return media_config.video.enable_cpu_overuse_detection;
317 }
Niels Möller7c6a74f2016-03-31 10:59:59318 void set_cpu_adaptation(bool enable) {
nisse0acedfe2016-04-12 06:25:29319 media_config.video.enable_cpu_overuse_detection = enable;
Niels Möller7c6a74f2016-03-31 10:59:59320 }
321
nisse0acedfe2016-04-12 06:25:29322 bool suspend_below_min_bitrate() {
323 return media_config.video.suspend_below_min_bitrate;
324 }
Niels Möller7c6a74f2016-03-31 10:59:59325 void set_suspend_below_min_bitrate(bool enable) {
nisse0acedfe2016-04-12 06:25:29326 media_config.video.suspend_below_min_bitrate = enable;
Niels Möller7c6a74f2016-03-31 10:59:59327 }
328
329 // TODO(nisse): The negation in the corresponding MediaConfig
330 // attribute is inconsistent, and it should be renamed at some
331 // point.
nisse0acedfe2016-04-12 06:25:29332 bool prerenderer_smoothing() {
333 return !media_config.video.disable_prerenderer_smoothing;
334 }
Niels Möller7c6a74f2016-03-31 10:59:59335 void set_prerenderer_smoothing(bool enable) {
nisse0acedfe2016-04-12 06:25:29336 media_config.video.disable_prerenderer_smoothing = !enable;
Niels Möller7c6a74f2016-03-31 10:59:59337 }
338
Henrik Kjellanderbd0ae452016-02-10 09:53:12339 static const int kUndefined = -1;
340 // Default maximum number of packets in the audio jitter buffer.
341 static const int kAudioJitterBufferMaxPackets = 50;
Honghai Zhanga9ca1202016-09-02 23:58:17342 // ICE connection receiving timeout for aggressive configuration.
343 static const int kAggressiveIceConnectionReceivingTimeout = 1000;
Henrik Kjellanderbd0ae452016-02-10 09:53:12344 // TODO(pthatcher): Rename this ice_transport_type, but update
345 // Chromium at the same time.
Taylor Brandstettera52f9db2016-05-13 15:15:11346 IceTransportsType type = kAll;
Henrik Kjellanderbd0ae452016-02-10 09:53:12347 // TODO(pthatcher): Rename this ice_servers, but update Chromium
348 // at the same time.
349 IceServers servers;
Taylor Brandstettera52f9db2016-05-13 15:15:11350 BundlePolicy bundle_policy = kBundlePolicyBalanced;
zhihuang67442bd2016-11-23 18:30:12351 RtcpMuxPolicy rtcp_mux_policy = kRtcpMuxPolicyRequire;
Taylor Brandstettera52f9db2016-05-13 15:15:11352 TcpCandidatePolicy tcp_candidate_policy = kTcpCandidatePolicyEnabled;
honghaiz5f9f4ae2016-06-01 01:29:12353 CandidateNetworkPolicy candidate_network_policy =
354 kCandidateNetworkPolicyAll;
Taylor Brandstettera52f9db2016-05-13 15:15:11355 int audio_jitter_buffer_max_packets = kAudioJitterBufferMaxPackets;
356 bool audio_jitter_buffer_fast_accelerate = false;
357 int ice_connection_receiving_timeout = kUndefined; // ms
358 int ice_backup_candidate_pair_ping_interval = kUndefined; // ms
359 ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE;
Henrik Kjellanderbd0ae452016-02-10 09:53:12360 std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
Taylor Brandstettera52f9db2016-05-13 15:15:11361 bool prioritize_most_likely_ice_candidate_pairs = false;
nisse0acedfe2016-04-12 06:25:29362 struct cricket::MediaConfig media_config;
htadbc360d2016-03-04 10:51:39363 // Flags corresponding to values set by constraint flags.
364 // rtc::Optional flags can be "missing", in which case the webrtc
365 // default applies.
Taylor Brandstettera52f9db2016-05-13 15:15:11366 bool disable_ipv6 = false;
367 bool enable_rtp_data_channel = false;
zhihuanga722f712016-08-05 18:14:50368 bool enable_quic = false;
htadbc360d2016-03-04 10:51:39369 rtc::Optional<int> screencast_min_bitrate;
370 rtc::Optional<bool> combined_audio_video_bwe;
371 rtc::Optional<bool> enable_dtls_srtp;
Taylor Brandstettera52f9db2016-05-13 15:15:11372 int ice_candidate_pool_size = 0;
Honghai Zhang772e3222016-07-01 03:52:02373 bool prune_turn_ports = false;
Taylor Brandstetter327b5082016-07-01 18:11:13374 // If set to true, this means the ICE transport should presume TURN-to-TURN
375 // candidate pairs will succeed, even before a binding response is received.
376 bool presume_writable_when_fully_relayed = false;
Honghai Zhang774bc412016-08-31 15:18:11377 // If true, "renomination" will be added to the ice options in the transport
378 // description.
379 bool enable_ice_renomination = false;
Honghai Zhangbbdec842016-08-31 05:07:42380 // If true, ICE role is redetermined when peerconnection sets a local
381 // transport description that indicates an ICE restart.
382 bool redetermine_role_on_ice_restart = true;
skvlad00f3b652017-02-02 19:50:14383 // If set, the min interval (max rate) at which we will send ICE checks
384 // (STUN pings), in milliseconds.
385 rtc::Optional<int> ice_check_min_interval;
deadbeefa496afa2017-01-11 20:28:30386 //
387 // Don't forget to update operator== if adding something.
388 //
Henrik Kjellanderbd0ae452016-02-10 09:53:12389 };
390
391 struct RTCOfferAnswerOptions {
392 static const int kUndefined = -1;
393 static const int kMaxOfferToReceiveMedia = 1;
394
395 // The default value for constraint offerToReceiveX:true.
396 static const int kOfferToReceiveMediaTrue = 1;
397
Honghai Zhang774bc412016-08-31 15:18:11398 int offer_to_receive_video = kUndefined;
399 int offer_to_receive_audio = kUndefined;
400 bool voice_activity_detection = true;
401 bool ice_restart = false;
402 bool use_rtp_mux = true;
Henrik Kjellanderbd0ae452016-02-10 09:53:12403
Honghai Zhang774bc412016-08-31 15:18:11404 RTCOfferAnswerOptions() = default;
Henrik Kjellanderbd0ae452016-02-10 09:53:12405
406 RTCOfferAnswerOptions(int offer_to_receive_video,
407 int offer_to_receive_audio,
408 bool voice_activity_detection,
409 bool ice_restart,
410 bool use_rtp_mux)
411 : offer_to_receive_video(offer_to_receive_video),
412 offer_to_receive_audio(offer_to_receive_audio),
413 voice_activity_detection(voice_activity_detection),
414 ice_restart(ice_restart),
415 use_rtp_mux(use_rtp_mux) {}
416 };
417
418 // Used by GetStats to decide which stats to include in the stats reports.
419 // |kStatsOutputLevelStandard| includes the standard stats for Javascript API;
420 // |kStatsOutputLevelDebug| includes both the standard stats and additional
421 // stats for debugging purposes.
422 enum StatsOutputLevel {
423 kStatsOutputLevelStandard,
424 kStatsOutputLevelDebug,
425 };
426
427 // Accessor methods to active local streams.
428 virtual rtc::scoped_refptr<StreamCollectionInterface>
429 local_streams() = 0;
430
431 // Accessor methods to remote streams.
432 virtual rtc::scoped_refptr<StreamCollectionInterface>
433 remote_streams() = 0;
434
435 // Add a new MediaStream to be sent on this PeerConnection.
436 // Note that a SessionDescription negotiation is needed before the
437 // remote peer can receive the stream.
438 virtual bool AddStream(MediaStreamInterface* stream) = 0;
439
440 // Remove a MediaStream from this PeerConnection.
441 // Note that a SessionDescription negotiation is need before the
442 // remote peer is notified.
443 virtual void RemoveStream(MediaStreamInterface* stream) = 0;
444
445 // TODO(deadbeef): Make the following two methods pure virtual once
446 // implemented by all subclasses of PeerConnectionInterface.
447 // Add a new MediaStreamTrack to be sent on this PeerConnection.
448 // |streams| indicates which stream labels the track should be associated
449 // with.
450 virtual rtc::scoped_refptr<RtpSenderInterface> AddTrack(
451 MediaStreamTrackInterface* track,
452 std::vector<MediaStreamInterface*> streams) {
453 return nullptr;
454 }
455
456 // Remove an RtpSender from this PeerConnection.
457 // Returns true on success.
458 virtual bool RemoveTrack(RtpSenderInterface* sender) {
459 return false;
460 }
461
462 // Returns pointer to the created DtmfSender on success.
463 // Otherwise returns NULL.
464 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
465 AudioTrackInterface* track) = 0;
466
467 // TODO(deadbeef): Make these pure virtual once all subclasses implement them.
468 // |kind| must be "audio" or "video".
469 // |stream_id| is used to populate the msid attribute; if empty, one will
470 // be generated automatically.
471 virtual rtc::scoped_refptr<RtpSenderInterface> CreateSender(
472 const std::string& kind,
473 const std::string& stream_id) {
474 return rtc::scoped_refptr<RtpSenderInterface>();
475 }
476
477 virtual std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
478 const {
479 return std::vector<rtc::scoped_refptr<RtpSenderInterface>>();
480 }
481
482 virtual std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
483 const {
484 return std::vector<rtc::scoped_refptr<RtpReceiverInterface>>();
485 }
486
487 virtual bool GetStats(StatsObserver* observer,
488 MediaStreamTrackInterface* track,
489 StatsOutputLevel level) = 0;
hbos42204212016-09-16 06:33:01490 // Gets stats using the new stats collection API, see webrtc/api/stats/. These
491 // will replace old stats collection API when the new API has matured enough.
hbosf522e032016-12-13 10:35:19492 // TODO(hbos): Default implementation that does nothing only exists as to not
493 // break third party projects. As soon as they have been updated this should
494 // be changed to "= 0;".
495 virtual void GetStats(RTCStatsCollectorCallback* callback) {}
Henrik Kjellanderbd0ae452016-02-10 09:53:12496
497 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
498 const std::string& label,
499 const DataChannelInit* config) = 0;
500
501 virtual const SessionDescriptionInterface* local_description() const = 0;
502 virtual const SessionDescriptionInterface* remote_description() const = 0;
deadbeefc7d4f492016-12-21 01:56:17503 // A "current" description the one currently negotiated from a complete
504 // offer/answer exchange.
505 virtual const SessionDescriptionInterface* current_local_description() const {
506 return nullptr;
507 }
508 virtual const SessionDescriptionInterface* current_remote_description()
509 const {
510 return nullptr;
511 }
512 // A "pending" description is one that's part of an incomplete offer/answer
513 // exchange (thus, either an offer or a pranswer). Once the offer/answer
514 // exchange is finished, the "pending" description will become "current".
515 virtual const SessionDescriptionInterface* pending_local_description() const {
516 return nullptr;
517 }
518 virtual const SessionDescriptionInterface* pending_remote_description()
519 const {
520 return nullptr;
521 }
Henrik Kjellanderbd0ae452016-02-10 09:53:12522
523 // Create a new offer.
524 // The CreateSessionDescriptionObserver callback will be called when done.
525 virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
526 const MediaConstraintsInterface* constraints) {}
527
528 // TODO(jiayl): remove the default impl and the old interface when chromium
529 // code is updated.
530 virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
531 const RTCOfferAnswerOptions& options) {}
532
533 // Create an answer to an offer.
534 // The CreateSessionDescriptionObserver callback will be called when done.
535 virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
htadbc360d2016-03-04 10:51:39536 const RTCOfferAnswerOptions& options) {}
537 // Deprecated - use version above.
538 // TODO(hta): Remove and remove default implementations when all callers
539 // are updated.
540 virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
541 const MediaConstraintsInterface* constraints) {}
542
Henrik Kjellanderbd0ae452016-02-10 09:53:12543 // Sets the local session description.
544 // JsepInterface takes the ownership of |desc| even if it fails.
545 // The |observer| callback will be called when done.
546 virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,
547 SessionDescriptionInterface* desc) = 0;
548 // Sets the remote session description.
549 // JsepInterface takes the ownership of |desc| even if it fails.
550 // The |observer| callback will be called when done.
551 virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
552 SessionDescriptionInterface* desc) = 0;
553 // Restarts or updates the ICE Agent process of gathering local candidates
554 // and pinging remote candidates.
555 // TODO(deadbeef): Remove once Chrome is moved over to SetConfiguration.
556 virtual bool UpdateIce(const IceServers& configuration,
557 const MediaConstraintsInterface* constraints) {
558 return false;
559 }
htadbc360d2016-03-04 10:51:39560 virtual bool UpdateIce(const IceServers& configuration) { return false; }
deadbeef4d0d0122016-11-17 03:42:04561 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
562 // PeerConnectionInterface implement it.
563 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() {
564 return PeerConnectionInterface::RTCConfiguration();
565 }
deadbeefa496afa2017-01-11 20:28:30566
Henrik Kjellanderbd0ae452016-02-10 09:53:12567 // Sets the PeerConnection's global configuration to |config|.
deadbeefa496afa2017-01-11 20:28:30568 //
569 // The members of |config| that may be changed are |type|, |servers|,
570 // |ice_candidate_pool_size| and |prune_turn_ports| (though the candidate
571 // pool size can't be changed after the first call to SetLocalDescription).
572 // Note that this means the BUNDLE and RTCP-multiplexing policies cannot be
573 // changed with this method.
574 //
Henrik Kjellanderbd0ae452016-02-10 09:53:12575 // Any changes to STUN/TURN servers or ICE candidate policy will affect the
576 // next gathering phase, and cause the next call to createOffer to generate
deadbeefa496afa2017-01-11 20:28:30577 // new ICE credentials, as described in JSEP. This also occurs when
578 // |prune_turn_ports| changes, for the same reasoning.
579 //
580 // If an error occurs, returns false and populates |error| if non-null:
581 // - INVALID_MODIFICATION if |config| contains a modified parameter other
582 // than one of the parameters listed above.
583 // - INVALID_RANGE if |ice_candidate_pool_size| is out of range.
584 // - SYNTAX_ERROR if parsing an ICE server URL failed.
585 // - INVALID_PARAMETER if a TURN server is missing |username| or |password|.
586 // - INTERNAL_ERROR if an unexpected error occurred.
587 //
Henrik Kjellanderbd0ae452016-02-10 09:53:12588 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
589 // PeerConnectionInterface implement it.
590 virtual bool SetConfiguration(
deadbeefa496afa2017-01-11 20:28:30591 const PeerConnectionInterface::RTCConfiguration& config,
592 RTCError* error) {
593 return false;
594 }
595 // Version without error output param for backwards compatibility.
596 // TODO(deadbeef): Remove once chromium is updated.
597 virtual bool SetConfiguration(
deadbeef6c8666b2016-12-24 09:43:32598 const PeerConnectionInterface::RTCConfiguration& config) {
Henrik Kjellanderbd0ae452016-02-10 09:53:12599 return false;
600 }
601 // Provides a remote candidate to the ICE Agent.
602 // A copy of the |candidate| will be created and added to the remote
603 // description. So the caller of this method still has the ownership of the
604 // |candidate|.
605 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will
606 // take the ownership of the |candidate|.
607 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0;
608
Honghai Zhang615cf0b2016-03-14 18:59:18609 // Removes a group of remote candidates from the ICE agent.
610 virtual bool RemoveIceCandidates(
611 const std::vector<cricket::Candidate>& candidates) {
612 return false;
613 }
614
Henrik Kjellanderbd0ae452016-02-10 09:53:12615 virtual void RegisterUMAObserver(UMAObserver* observer) = 0;
616
617 // Returns the current SignalingState.
618 virtual SignalingState signaling_state() = 0;
Henrik Kjellanderbd0ae452016-02-10 09:53:12619 virtual IceConnectionState ice_connection_state() = 0;
620 virtual IceGatheringState ice_gathering_state() = 0;
621
ivoc23ea12e2016-07-04 14:06:55622 // Starts RtcEventLog using existing file. Takes ownership of |file| and
623 // passes it on to Call, which will take the ownership. If the
624 // operation fails the file will be closed. The logging will stop
625 // automatically after 10 minutes have passed, or when the StopRtcEventLog
626 // function is called.
627 // TODO(ivoc): Make this pure virtual when Chrome is updated.
628 virtual bool StartRtcEventLog(rtc::PlatformFile file,
629 int64_t max_size_bytes) {
630 return false;
631 }
632
633 // Stops logging the RtcEventLog.
634 // TODO(ivoc): Make this pure virtual when Chrome is updated.
635 virtual void StopRtcEventLog() {}
636
Henrik Kjellanderbd0ae452016-02-10 09:53:12637 // Terminates all media and closes the transport.
638 virtual void Close() = 0;
639
640 protected:
641 // Dtor protected as objects shouldn't be deleted via this interface.
642 ~PeerConnectionInterface() {}
643};
644
645// PeerConnection callback interface. Application should implement these
646// methods.
647class PeerConnectionObserver {
648 public:
649 enum StateType {
650 kSignalingState,
651 kIceState,
652 };
653
654 // Triggered when the SignalingState changed.
655 virtual void OnSignalingChange(
656 PeerConnectionInterface::SignalingState new_state) = 0;
657
Taylor Brandstettere7b6e812016-05-31 20:02:21658 // TODO(deadbeef): Once all subclasses override the scoped_refptr versions
659 // of the below three methods, make them pure virtual and remove the raw
660 // pointer version.
661
Henrik Kjellanderbd0ae452016-02-10 09:53:12662 // Triggered when media is received on a new stream from remote peer.
Taylor Brandstettere7b6e812016-05-31 20:02:21663 virtual void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {}
664 // Deprecated; please use the version that uses a scoped_refptr.
665 virtual void OnAddStream(MediaStreamInterface* stream) {}
Henrik Kjellanderbd0ae452016-02-10 09:53:12666
667 // Triggered when a remote peer close a stream.
Taylor Brandstettere7b6e812016-05-31 20:02:21668 virtual void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
669 }
670 // Deprecated; please use the version that uses a scoped_refptr.
671 virtual void OnRemoveStream(MediaStreamInterface* stream) {}
Henrik Kjellanderbd0ae452016-02-10 09:53:12672
Taylor Brandstettere7b6e812016-05-31 20:02:21673 // Triggered when a remote peer opens a data channel.
674 virtual void OnDataChannel(
oprypin13c97c72017-02-01 09:55:59675 rtc::scoped_refptr<DataChannelInterface> data_channel) {}
Taylor Brandstettere7b6e812016-05-31 20:02:21676 // Deprecated; please use the version that uses a scoped_refptr.
677 virtual void OnDataChannel(DataChannelInterface* data_channel) {}
Henrik Kjellanderbd0ae452016-02-10 09:53:12678
Taylor Brandstettere7b6e812016-05-31 20:02:21679 // Triggered when renegotiation is needed. For example, an ICE restart
680 // has begun.
Henrik Kjellanderbd0ae452016-02-10 09:53:12681 virtual void OnRenegotiationNeeded() = 0;
682
Taylor Brandstettere7b6e812016-05-31 20:02:21683 // Called any time the IceConnectionState changes.
Henrik Kjellanderbd0ae452016-02-10 09:53:12684 virtual void OnIceConnectionChange(
685 PeerConnectionInterface::IceConnectionState new_state) = 0;
686
Taylor Brandstettere7b6e812016-05-31 20:02:21687 // Called any time the IceGatheringState changes.
Henrik Kjellanderbd0ae452016-02-10 09:53:12688 virtual void OnIceGatheringChange(
689 PeerConnectionInterface::IceGatheringState new_state) = 0;
690
Taylor Brandstettere7b6e812016-05-31 20:02:21691 // A new ICE candidate has been gathered.
Henrik Kjellanderbd0ae452016-02-10 09:53:12692 virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0;
693
Honghai Zhang615cf0b2016-03-14 18:59:18694 // Ice candidates have been removed.
695 // TODO(honghaiz): Make this a pure virtual method when all its subclasses
696 // implement it.
697 virtual void OnIceCandidatesRemoved(
698 const std::vector<cricket::Candidate>& candidates) {}
699
Henrik Kjellanderbd0ae452016-02-10 09:53:12700 // Called when the ICE connection receiving status changes.
701 virtual void OnIceConnectionReceivingChange(bool receiving) {}
702
zhihuang3f3a6862016-11-17 20:06:24703 // Called when a track is added to streams.
704 // TODO(zhihuang) Make this a pure virtual method when all its subclasses
705 // implement it.
706 virtual void OnAddTrack(
707 rtc::scoped_refptr<RtpReceiverInterface> receiver,
zhihuang135817c2016-12-02 23:41:10708 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {}
zhihuang3f3a6862016-11-17 20:06:24709
Henrik Kjellanderbd0ae452016-02-10 09:53:12710 protected:
711 // Dtor protected as objects shouldn't be deleted via this interface.
712 ~PeerConnectionObserver() {}
713};
714
715// PeerConnectionFactoryInterface is the factory interface use for creating
716// PeerConnection, MediaStream and media tracks.
717// PeerConnectionFactoryInterface will create required libjingle threads,
718// socket and network manager factory classes for networking.
719// If an application decides to provide its own threads and network
720// implementation of these classes it should use the alternate
721// CreatePeerConnectionFactory method which accepts threads as input and use the
722// CreatePeerConnection version that takes a PortAllocator as an
723// argument.
724class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
725 public:
726 class Options {
727 public:
728 Options()
729 : disable_encryption(false),
730 disable_sctp_data_channels(false),
731 disable_network_monitor(false),
732 network_ignore_mask(rtc::kDefaultNetworkIgnoreMask),
jbauch4443dc42016-08-04 12:20:32733 ssl_max_version(rtc::SSL_PROTOCOL_DTLS_12),
734 crypto_options(rtc::CryptoOptions::NoGcm()) {}
Henrik Kjellanderbd0ae452016-02-10 09:53:12735 bool disable_encryption;
736 bool disable_sctp_data_channels;
737 bool disable_network_monitor;
738
739 // Sets the network types to ignore. For instance, calling this with
740 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
741 // loopback interfaces.
742 int network_ignore_mask;
743
744 // Sets the maximum supported protocol version. The highest version
745 // supported by both ends will be used for the connection, i.e. if one
746 // party supports DTLS 1.0 and the other DTLS 1.2, DTLS 1.0 will be used.
747 rtc::SSLProtocolVersion ssl_max_version;
jbauch4443dc42016-08-04 12:20:32748
749 // Sets crypto related options, e.g. enabled cipher suites.
750 rtc::CryptoOptions crypto_options;
Henrik Kjellanderbd0ae452016-02-10 09:53:12751 };
752
753 virtual void SetOptions(const Options& options) = 0;
754
755 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
756 const PeerConnectionInterface::RTCConfiguration& configuration,
757 const MediaConstraintsInterface* constraints,
kwibergb4bfca42016-04-27 13:47:29758 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmb8942012016-06-01 09:44:18759 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
hbosf0f1dc42016-05-27 13:08:53760 PeerConnectionObserver* observer) = 0;
Henrik Kjellanderbd0ae452016-02-10 09:53:12761
htadbc360d2016-03-04 10:51:39762 virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
763 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergb4bfca42016-04-27 13:47:29764 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmb8942012016-06-01 09:44:18765 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
hbosf0f1dc42016-05-27 13:08:53766 PeerConnectionObserver* observer) = 0;
htadbc360d2016-03-04 10:51:39767
Henrik Kjellanderbd0ae452016-02-10 09:53:12768 virtual rtc::scoped_refptr<MediaStreamInterface>
769 CreateLocalMediaStream(const std::string& label) = 0;
770
771 // Creates a AudioSourceInterface.
772 // |constraints| decides audio processing settings but can be NULL.
773 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
htadbc360d2016-03-04 10:51:39774 const cricket::AudioOptions& options) = 0;
775 // Deprecated - use version above.
deadbeef1df3f512017-01-13 19:47:56776 // Can use CopyConstraintsIntoAudioOptions to bridge the gap.
htadbc360d2016-03-04 10:51:39777 virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
Henrik Kjellanderbd0ae452016-02-10 09:53:12778 const MediaConstraintsInterface* constraints) = 0;
779
perkj2a4ff982016-03-08 00:27:48780 // Creates a VideoTrackSourceInterface. The new source take ownership of
htadbc360d2016-03-04 10:51:39781 // |capturer|.
perkj2a4ff982016-03-08 00:27:48782 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
htadbc360d2016-03-04 10:51:39783 cricket::VideoCapturer* capturer) = 0;
784 // A video source creator that allows selection of resolution and frame rate.
785 // |constraints| decides video resolution and frame rate but can
Henrik Kjellanderbd0ae452016-02-10 09:53:12786 // be NULL.
htadbc360d2016-03-04 10:51:39787 // In the NULL case, use the version above.
perkj2a4ff982016-03-08 00:27:48788 virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
Henrik Kjellanderbd0ae452016-02-10 09:53:12789 cricket::VideoCapturer* capturer,
790 const MediaConstraintsInterface* constraints) = 0;
791
792 // Creates a new local VideoTrack. The same |source| can be used in several
793 // tracks.
perkj2a4ff982016-03-08 00:27:48794 virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
795 const std::string& label,
796 VideoTrackSourceInterface* source) = 0;
Henrik Kjellanderbd0ae452016-02-10 09:53:12797
798 // Creates an new AudioTrack. At the moment |source| can be NULL.
799 virtual rtc::scoped_refptr<AudioTrackInterface>
800 CreateAudioTrack(const std::string& label,
801 AudioSourceInterface* source) = 0;
802
803 // Starts AEC dump using existing file. Takes ownership of |file| and passes
804 // it on to VoiceEngine (via other objects) immediately, which will take
805 // the ownerhip. If the operation fails, the file will be closed.
806 // A maximum file size in bytes can be specified. When the file size limit is
807 // reached, logging is stopped automatically. If max_size_bytes is set to a
808 // value <= 0, no limit will be used, and logging will continue until the
809 // StopAecDump function is called.
810 virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) = 0;
811
812 // Stops logging the AEC dump.
813 virtual void StopAecDump() = 0;
814
ivoc23ea12e2016-07-04 14:06:55815 // This function is deprecated and will be removed when Chrome is updated to
816 // use the equivalent function on PeerConnectionInterface.
817 // TODO(ivoc) Remove after Chrome is updated.
ivoc18d82842016-05-13 15:30:39818 virtual bool StartRtcEventLog(rtc::PlatformFile file,
819 int64_t max_size_bytes) = 0;
ivoc23ea12e2016-07-04 14:06:55820 // This function is deprecated and will be removed when Chrome is updated to
821 // use the equivalent function on PeerConnectionInterface.
822 // TODO(ivoc) Remove after Chrome is updated.
Henrik Kjellanderbd0ae452016-02-10 09:53:12823 virtual bool StartRtcEventLog(rtc::PlatformFile file) = 0;
824
ivoc23ea12e2016-07-04 14:06:55825 // This function is deprecated and will be removed when Chrome is updated to
826 // use the equivalent function on PeerConnectionInterface.
827 // TODO(ivoc) Remove after Chrome is updated.
Henrik Kjellanderbd0ae452016-02-10 09:53:12828 virtual void StopRtcEventLog() = 0;
829
830 protected:
831 // Dtor and ctor protected as objects shouldn't be created or deleted via
832 // this interface.
833 PeerConnectionFactoryInterface() {}
834 ~PeerConnectionFactoryInterface() {} // NOLINT
835};
836
kwiberg780e2022017-01-31 09:48:08837// TODO(ossu): Remove these and define a real builtin audio encoder factory
838// instead.
839class AudioEncoderFactory : public rtc::RefCountInterface {};
840inline rtc::scoped_refptr<AudioEncoderFactory>
841CreateBuiltinAudioEncoderFactory() {
842 return nullptr;
843}
844
Henrik Kjellanderbd0ae452016-02-10 09:53:12845// Create a new instance of PeerConnectionFactoryInterface.
Taylor Brandstettera600add2016-03-23 17:38:07846//
847// This method relies on the thread it's called on as the "signaling thread"
848// for the PeerConnectionFactory it creates.
849//
850// As such, if the current thread is not already running an rtc::Thread message
851// loop, an application using this method must eventually either call
852// rtc::Thread::Current()->Run(), or call
853// rtc::Thread::Current()->ProcessMessages() within the application's own
854// message loop.
kwiberg780e2022017-01-31 09:48:08855rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
856 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
857 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory);
858
859// Deprecated variant of the above.
860// TODO(kwiberg): Remove.
Henrik Kjellanderbd0ae452016-02-10 09:53:12861rtc::scoped_refptr<PeerConnectionFactoryInterface>
862CreatePeerConnectionFactory();
863
864// Create a new instance of PeerConnectionFactoryInterface.
Taylor Brandstettera600add2016-03-23 17:38:07865//
danilchapd2e35082016-05-17 08:52:02866// |network_thread|, |worker_thread| and |signaling_thread| are
867// the only mandatory parameters.
Taylor Brandstettera600add2016-03-23 17:38:07868//
869// If non-null, ownership of |default_adm|, |encoder_factory| and
870// |decoder_factory| are transferred to the returned factory.
danilchapd2e35082016-05-17 08:52:02871rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
872 rtc::Thread* network_thread,
Henrik Kjellanderbd0ae452016-02-10 09:53:12873 rtc::Thread* worker_thread,
874 rtc::Thread* signaling_thread,
875 AudioDeviceModule* default_adm,
kwiberg780e2022017-01-31 09:48:08876 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
877 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
878 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
879 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
880
881// Deprecated variant of the above.
882// TODO(kwiberg): Remove.
883rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
884 rtc::Thread* network_thread,
885 rtc::Thread* worker_thread,
886 rtc::Thread* signaling_thread,
887 AudioDeviceModule* default_adm,
Henrik Kjellanderbd0ae452016-02-10 09:53:12888 cricket::WebRtcVideoEncoderFactory* encoder_factory,
889 cricket::WebRtcVideoDecoderFactory* decoder_factory);
890
gyzhou800a8f12016-12-13 22:06:26891// Create a new instance of PeerConnectionFactoryInterface with external audio
892// mixer.
893//
894// If |audio_mixer| is null, an internal audio mixer will be created and used.
895rtc::scoped_refptr<PeerConnectionFactoryInterface>
896CreatePeerConnectionFactoryWithAudioMixer(
897 rtc::Thread* network_thread,
898 rtc::Thread* worker_thread,
899 rtc::Thread* signaling_thread,
900 AudioDeviceModule* default_adm,
kwiberg780e2022017-01-31 09:48:08901 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
902 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
903 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
904 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
905 rtc::scoped_refptr<AudioMixer> audio_mixer);
906
907// Deprecated variant of the above.
908// TODO(kwiberg): Remove.
909rtc::scoped_refptr<PeerConnectionFactoryInterface>
910CreatePeerConnectionFactoryWithAudioMixer(
911 rtc::Thread* network_thread,
912 rtc::Thread* worker_thread,
913 rtc::Thread* signaling_thread,
914 AudioDeviceModule* default_adm,
gyzhou800a8f12016-12-13 22:06:26915 cricket::WebRtcVideoEncoderFactory* encoder_factory,
916 cricket::WebRtcVideoDecoderFactory* decoder_factory,
917 rtc::scoped_refptr<AudioMixer> audio_mixer);
918
danilchapd2e35082016-05-17 08:52:02919// Create a new instance of PeerConnectionFactoryInterface.
920// Same thread is used as worker and network thread.
danilchapd2e35082016-05-17 08:52:02921inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
922CreatePeerConnectionFactory(
923 rtc::Thread* worker_and_network_thread,
924 rtc::Thread* signaling_thread,
925 AudioDeviceModule* default_adm,
kwiberg780e2022017-01-31 09:48:08926 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
927 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
928 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
929 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
930 return CreatePeerConnectionFactory(
931 worker_and_network_thread, worker_and_network_thread, signaling_thread,
932 default_adm, audio_encoder_factory, audio_decoder_factory,
933 video_encoder_factory, video_decoder_factory);
934}
935
936// Deprecated variant of the above.
937// TODO(kwiberg): Remove.
938inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
939CreatePeerConnectionFactory(
940 rtc::Thread* worker_and_network_thread,
941 rtc::Thread* signaling_thread,
942 AudioDeviceModule* default_adm,
danilchapd2e35082016-05-17 08:52:02943 cricket::WebRtcVideoEncoderFactory* encoder_factory,
944 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
945 return CreatePeerConnectionFactory(
946 worker_and_network_thread, worker_and_network_thread, signaling_thread,
947 default_adm, encoder_factory, decoder_factory);
948}
949
Henrik Kjellanderbd0ae452016-02-10 09:53:12950} // namespace webrtc
951
952#endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_