peer_connection_interface.h 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499
  1. /*
  2. * Copyright 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * 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.
  9. */
  10. // This file contains the PeerConnection interface as defined in
  11. // https://w3c.github.io/webrtc-pc/#peer-to-peer-connections
  12. //
  13. // The PeerConnectionFactory class provides factory methods to create
  14. // PeerConnection, MediaStream and MediaStreamTrack objects.
  15. //
  16. // The following steps are needed to setup a typical call using WebRTC:
  17. //
  18. // 1. Create a PeerConnectionFactoryInterface. Check constructors for more
  19. // information about input parameters.
  20. //
  21. // 2. Create a PeerConnection object. Provide a configuration struct which
  22. // points to STUN and/or TURN servers used to generate ICE candidates, and
  23. // provide an object that implements the PeerConnectionObserver interface,
  24. // which is used to receive callbacks from the PeerConnection.
  25. //
  26. // 3. Create local MediaStreamTracks using the PeerConnectionFactory and add
  27. // them to PeerConnection by calling AddTrack (or legacy method, AddStream).
  28. //
  29. // 4. Create an offer, call SetLocalDescription with it, serialize it, and send
  30. // it to the remote peer
  31. //
  32. // 5. Once an ICE candidate has been gathered, the PeerConnection will call the
  33. // observer function OnIceCandidate. The candidates must also be serialized and
  34. // sent to the remote peer.
  35. //
  36. // 6. Once an answer is received from the remote peer, call
  37. // SetRemoteDescription with the remote answer.
  38. //
  39. // 7. Once a remote candidate is received from the remote peer, provide it to
  40. // the PeerConnection by calling AddIceCandidate.
  41. //
  42. // The receiver of a call (assuming the application is "call"-based) can decide
  43. // to accept or reject the call; this decision will be taken by the application,
  44. // not the PeerConnection.
  45. //
  46. // If the application decides to accept the call, it should:
  47. //
  48. // 1. Create PeerConnectionFactoryInterface if it doesn't exist.
  49. //
  50. // 2. Create a new PeerConnection.
  51. //
  52. // 3. Provide the remote offer to the new PeerConnection object by calling
  53. // SetRemoteDescription.
  54. //
  55. // 4. Generate an answer to the remote offer by calling CreateAnswer and send it
  56. // back to the remote peer.
  57. //
  58. // 5. Provide the local answer to the new PeerConnection by calling
  59. // SetLocalDescription with the answer.
  60. //
  61. // 6. Provide the remote ICE candidates by calling AddIceCandidate.
  62. //
  63. // 7. Once a candidate has been gathered, the PeerConnection will call the
  64. // observer function OnIceCandidate. Send these candidates to the remote peer.
  65. #ifndef API_PEER_CONNECTION_INTERFACE_H_
  66. #define API_PEER_CONNECTION_INTERFACE_H_
  67. #include <stdio.h>
  68. #include <memory>
  69. #include <string>
  70. #include <vector>
  71. #include "api/adaptation/resource.h"
  72. #include "api/async_resolver_factory.h"
  73. #include "api/audio/audio_mixer.h"
  74. #include "api/audio_codecs/audio_decoder_factory.h"
  75. #include "api/audio_codecs/audio_encoder_factory.h"
  76. #include "api/audio_options.h"
  77. #include "api/call/call_factory_interface.h"
  78. #include "api/crypto/crypto_options.h"
  79. #include "api/data_channel_interface.h"
  80. #include "api/dtls_transport_interface.h"
  81. #include "api/fec_controller.h"
  82. #include "api/ice_transport_interface.h"
  83. #include "api/jsep.h"
  84. #include "api/media_stream_interface.h"
  85. #include "api/neteq/neteq_factory.h"
  86. #include "api/network_state_predictor.h"
  87. #include "api/packet_socket_factory.h"
  88. #include "api/rtc_error.h"
  89. #include "api/rtc_event_log/rtc_event_log_factory_interface.h"
  90. #include "api/rtc_event_log_output.h"
  91. #include "api/rtp_receiver_interface.h"
  92. #include "api/rtp_sender_interface.h"
  93. #include "api/rtp_transceiver_interface.h"
  94. #include "api/sctp_transport_interface.h"
  95. #include "api/set_remote_description_observer_interface.h"
  96. #include "api/stats/rtc_stats_collector_callback.h"
  97. #include "api/stats_types.h"
  98. #include "api/task_queue/task_queue_factory.h"
  99. #include "api/transport/bitrate_settings.h"
  100. #include "api/transport/enums.h"
  101. #include "api/transport/media/media_transport_interface.h"
  102. #include "api/transport/network_control.h"
  103. #include "api/transport/webrtc_key_value_config.h"
  104. #include "api/turn_customizer.h"
  105. #include "media/base/media_config.h"
  106. #include "media/base/media_engine.h"
  107. // TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications
  108. // inject a PacketSocketFactory and/or NetworkManager, and not expose
  109. // PortAllocator in the PeerConnection api.
  110. #include "p2p/base/port_allocator.h" // nogncheck
  111. #include "rtc_base/network.h"
  112. #include "rtc_base/rtc_certificate.h"
  113. #include "rtc_base/rtc_certificate_generator.h"
  114. #include "rtc_base/socket_address.h"
  115. #include "rtc_base/ssl_certificate.h"
  116. #include "rtc_base/ssl_stream_adapter.h"
  117. #include "rtc_base/system/rtc_export.h"
  118. namespace rtc {
  119. class Thread;
  120. } // namespace rtc
  121. namespace webrtc {
  122. // MediaStream container interface.
  123. class StreamCollectionInterface : public rtc::RefCountInterface {
  124. public:
  125. // TODO(ronghuawu): Update the function names to c++ style, e.g. find -> Find.
  126. virtual size_t count() = 0;
  127. virtual MediaStreamInterface* at(size_t index) = 0;
  128. virtual MediaStreamInterface* find(const std::string& label) = 0;
  129. virtual MediaStreamTrackInterface* FindAudioTrack(const std::string& id) = 0;
  130. virtual MediaStreamTrackInterface* FindVideoTrack(const std::string& id) = 0;
  131. protected:
  132. // Dtor protected as objects shouldn't be deleted via this interface.
  133. ~StreamCollectionInterface() override = default;
  134. };
  135. class StatsObserver : public rtc::RefCountInterface {
  136. public:
  137. virtual void OnComplete(const StatsReports& reports) = 0;
  138. protected:
  139. ~StatsObserver() override = default;
  140. };
  141. enum class SdpSemantics { kPlanB, kUnifiedPlan };
  142. class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
  143. public:
  144. // See https://w3c.github.io/webrtc-pc/#dom-rtcsignalingstate
  145. enum SignalingState {
  146. kStable,
  147. kHaveLocalOffer,
  148. kHaveLocalPrAnswer,
  149. kHaveRemoteOffer,
  150. kHaveRemotePrAnswer,
  151. kClosed,
  152. };
  153. // See https://w3c.github.io/webrtc-pc/#dom-rtcicegatheringstate
  154. enum IceGatheringState {
  155. kIceGatheringNew,
  156. kIceGatheringGathering,
  157. kIceGatheringComplete
  158. };
  159. // See https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectionstate
  160. enum class PeerConnectionState {
  161. kNew,
  162. kConnecting,
  163. kConnected,
  164. kDisconnected,
  165. kFailed,
  166. kClosed,
  167. };
  168. // See https://w3c.github.io/webrtc-pc/#dom-rtciceconnectionstate
  169. enum IceConnectionState {
  170. kIceConnectionNew,
  171. kIceConnectionChecking,
  172. kIceConnectionConnected,
  173. kIceConnectionCompleted,
  174. kIceConnectionFailed,
  175. kIceConnectionDisconnected,
  176. kIceConnectionClosed,
  177. kIceConnectionMax,
  178. };
  179. // TLS certificate policy.
  180. enum TlsCertPolicy {
  181. // For TLS based protocols, ensure the connection is secure by not
  182. // circumventing certificate validation.
  183. kTlsCertPolicySecure,
  184. // For TLS based protocols, disregard security completely by skipping
  185. // certificate validation. This is insecure and should never be used unless
  186. // security is irrelevant in that particular context.
  187. kTlsCertPolicyInsecureNoCheck,
  188. };
  189. struct RTC_EXPORT IceServer {
  190. IceServer();
  191. IceServer(const IceServer&);
  192. ~IceServer();
  193. // TODO(jbauch): Remove uri when all code using it has switched to urls.
  194. // List of URIs associated with this server. Valid formats are described
  195. // in RFC7064 and RFC7065, and more may be added in the future. The "host"
  196. // part of the URI may contain either an IP address or a hostname.
  197. std::string uri;
  198. std::vector<std::string> urls;
  199. std::string username;
  200. std::string password;
  201. TlsCertPolicy tls_cert_policy = kTlsCertPolicySecure;
  202. // If the URIs in |urls| only contain IP addresses, this field can be used
  203. // to indicate the hostname, which may be necessary for TLS (using the SNI
  204. // extension). If |urls| itself contains the hostname, this isn't
  205. // necessary.
  206. std::string hostname;
  207. // List of protocols to be used in the TLS ALPN extension.
  208. std::vector<std::string> tls_alpn_protocols;
  209. // List of elliptic curves to be used in the TLS elliptic curves extension.
  210. std::vector<std::string> tls_elliptic_curves;
  211. bool operator==(const IceServer& o) const {
  212. return uri == o.uri && urls == o.urls && username == o.username &&
  213. password == o.password && tls_cert_policy == o.tls_cert_policy &&
  214. hostname == o.hostname &&
  215. tls_alpn_protocols == o.tls_alpn_protocols &&
  216. tls_elliptic_curves == o.tls_elliptic_curves;
  217. }
  218. bool operator!=(const IceServer& o) const { return !(*this == o); }
  219. };
  220. typedef std::vector<IceServer> IceServers;
  221. enum IceTransportsType {
  222. // TODO(pthatcher): Rename these kTransporTypeXXX, but update
  223. // Chromium at the same time.
  224. kNone,
  225. kRelay,
  226. kNoHost,
  227. kAll
  228. };
  229. // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-4.1.1
  230. enum BundlePolicy {
  231. kBundlePolicyBalanced,
  232. kBundlePolicyMaxBundle,
  233. kBundlePolicyMaxCompat
  234. };
  235. // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-4.1.1
  236. enum RtcpMuxPolicy {
  237. kRtcpMuxPolicyNegotiate,
  238. kRtcpMuxPolicyRequire,
  239. };
  240. enum TcpCandidatePolicy {
  241. kTcpCandidatePolicyEnabled,
  242. kTcpCandidatePolicyDisabled
  243. };
  244. enum CandidateNetworkPolicy {
  245. kCandidateNetworkPolicyAll,
  246. kCandidateNetworkPolicyLowCost
  247. };
  248. enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY };
  249. enum class RTCConfigurationType {
  250. // A configuration that is safer to use, despite not having the best
  251. // performance. Currently this is the default configuration.
  252. kSafe,
  253. // An aggressive configuration that has better performance, although it
  254. // may be riskier and may need extra support in the application.
  255. kAggressive
  256. };
  257. // TODO(hbos): Change into class with private data and public getters.
  258. // TODO(nisse): In particular, accessing fields directly from an
  259. // application is brittle, since the organization mirrors the
  260. // organization of the implementation, which isn't stable. So we
  261. // need getters and setters at least for fields which applications
  262. // are interested in.
  263. struct RTC_EXPORT RTCConfiguration {
  264. // This struct is subject to reorganization, both for naming
  265. // consistency, and to group settings to match where they are used
  266. // in the implementation. To do that, we need getter and setter
  267. // methods for all settings which are of interest to applications,
  268. // Chrome in particular.
  269. RTCConfiguration();
  270. RTCConfiguration(const RTCConfiguration&);
  271. explicit RTCConfiguration(RTCConfigurationType type);
  272. ~RTCConfiguration();
  273. bool operator==(const RTCConfiguration& o) const;
  274. bool operator!=(const RTCConfiguration& o) const;
  275. bool dscp() const { return media_config.enable_dscp; }
  276. void set_dscp(bool enable) { media_config.enable_dscp = enable; }
  277. bool cpu_adaptation() const {
  278. return media_config.video.enable_cpu_adaptation;
  279. }
  280. void set_cpu_adaptation(bool enable) {
  281. media_config.video.enable_cpu_adaptation = enable;
  282. }
  283. bool suspend_below_min_bitrate() const {
  284. return media_config.video.suspend_below_min_bitrate;
  285. }
  286. void set_suspend_below_min_bitrate(bool enable) {
  287. media_config.video.suspend_below_min_bitrate = enable;
  288. }
  289. bool prerenderer_smoothing() const {
  290. return media_config.video.enable_prerenderer_smoothing;
  291. }
  292. void set_prerenderer_smoothing(bool enable) {
  293. media_config.video.enable_prerenderer_smoothing = enable;
  294. }
  295. bool experiment_cpu_load_estimator() const {
  296. return media_config.video.experiment_cpu_load_estimator;
  297. }
  298. void set_experiment_cpu_load_estimator(bool enable) {
  299. media_config.video.experiment_cpu_load_estimator = enable;
  300. }
  301. int audio_rtcp_report_interval_ms() const {
  302. return media_config.audio.rtcp_report_interval_ms;
  303. }
  304. void set_audio_rtcp_report_interval_ms(int audio_rtcp_report_interval_ms) {
  305. media_config.audio.rtcp_report_interval_ms =
  306. audio_rtcp_report_interval_ms;
  307. }
  308. int video_rtcp_report_interval_ms() const {
  309. return media_config.video.rtcp_report_interval_ms;
  310. }
  311. void set_video_rtcp_report_interval_ms(int video_rtcp_report_interval_ms) {
  312. media_config.video.rtcp_report_interval_ms =
  313. video_rtcp_report_interval_ms;
  314. }
  315. static const int kUndefined = -1;
  316. // Default maximum number of packets in the audio jitter buffer.
  317. static const int kAudioJitterBufferMaxPackets = 200;
  318. // ICE connection receiving timeout for aggressive configuration.
  319. static const int kAggressiveIceConnectionReceivingTimeout = 1000;
  320. ////////////////////////////////////////////////////////////////////////
  321. // The below few fields mirror the standard RTCConfiguration dictionary:
  322. // https://w3c.github.io/webrtc-pc/#rtcconfiguration-dictionary
  323. ////////////////////////////////////////////////////////////////////////
  324. // TODO(pthatcher): Rename this ice_servers, but update Chromium
  325. // at the same time.
  326. IceServers servers;
  327. // TODO(pthatcher): Rename this ice_transport_type, but update
  328. // Chromium at the same time.
  329. IceTransportsType type = kAll;
  330. BundlePolicy bundle_policy = kBundlePolicyBalanced;
  331. RtcpMuxPolicy rtcp_mux_policy = kRtcpMuxPolicyRequire;
  332. std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
  333. int ice_candidate_pool_size = 0;
  334. //////////////////////////////////////////////////////////////////////////
  335. // The below fields correspond to constraints from the deprecated
  336. // constraints interface for constructing a PeerConnection.
  337. //
  338. // absl::optional fields can be "missing", in which case the implementation
  339. // default will be used.
  340. //////////////////////////////////////////////////////////////////////////
  341. // If set to true, don't gather IPv6 ICE candidates.
  342. // TODO(deadbeef): Remove this? IPv6 support has long stopped being
  343. // experimental
  344. bool disable_ipv6 = false;
  345. // If set to true, don't gather IPv6 ICE candidates on Wi-Fi.
  346. // Only intended to be used on specific devices. Certain phones disable IPv6
  347. // when the screen is turned off and it would be better to just disable the
  348. // IPv6 ICE candidates on Wi-Fi in those cases.
  349. bool disable_ipv6_on_wifi = false;
  350. // By default, the PeerConnection will use a limited number of IPv6 network
  351. // interfaces, in order to avoid too many ICE candidate pairs being created
  352. // and delaying ICE completion.
  353. //
  354. // Can be set to INT_MAX to effectively disable the limit.
  355. int max_ipv6_networks = cricket::kDefaultMaxIPv6Networks;
  356. // Exclude link-local network interfaces
  357. // from consideration for gathering ICE candidates.
  358. bool disable_link_local_networks = false;
  359. // If set to true, use RTP data channels instead of SCTP.
  360. // TODO(deadbeef): Remove this. We no longer commit to supporting RTP data
  361. // channels, though some applications are still working on moving off of
  362. // them.
  363. bool enable_rtp_data_channel = false;
  364. // Minimum bitrate at which screencast video tracks will be encoded at.
  365. // This means adding padding bits up to this bitrate, which can help
  366. // when switching from a static scene to one with motion.
  367. absl::optional<int> screencast_min_bitrate;
  368. // Use new combined audio/video bandwidth estimation?
  369. absl::optional<bool> combined_audio_video_bwe;
  370. // TODO(bugs.webrtc.org/9891) - Move to crypto_options
  371. // Can be used to disable DTLS-SRTP. This should never be done, but can be
  372. // useful for testing purposes, for example in setting up a loopback call
  373. // with a single PeerConnection.
  374. absl::optional<bool> enable_dtls_srtp;
  375. /////////////////////////////////////////////////
  376. // The below fields are not part of the standard.
  377. /////////////////////////////////////////////////
  378. // Can be used to disable TCP candidate generation.
  379. TcpCandidatePolicy tcp_candidate_policy = kTcpCandidatePolicyEnabled;
  380. // Can be used to avoid gathering candidates for a "higher cost" network,
  381. // if a lower cost one exists. For example, if both Wi-Fi and cellular
  382. // interfaces are available, this could be used to avoid using the cellular
  383. // interface.
  384. CandidateNetworkPolicy candidate_network_policy =
  385. kCandidateNetworkPolicyAll;
  386. // The maximum number of packets that can be stored in the NetEq audio
  387. // jitter buffer. Can be reduced to lower tolerated audio latency.
  388. int audio_jitter_buffer_max_packets = kAudioJitterBufferMaxPackets;
  389. // Whether to use the NetEq "fast mode" which will accelerate audio quicker
  390. // if it falls behind.
  391. bool audio_jitter_buffer_fast_accelerate = false;
  392. // The minimum delay in milliseconds for the audio jitter buffer.
  393. int audio_jitter_buffer_min_delay_ms = 0;
  394. // Whether the audio jitter buffer adapts the delay to retransmitted
  395. // packets.
  396. bool audio_jitter_buffer_enable_rtx_handling = false;
  397. // Timeout in milliseconds before an ICE candidate pair is considered to be
  398. // "not receiving", after which a lower priority candidate pair may be
  399. // selected.
  400. int ice_connection_receiving_timeout = kUndefined;
  401. // Interval in milliseconds at which an ICE "backup" candidate pair will be
  402. // pinged. This is a candidate pair which is not actively in use, but may
  403. // be switched to if the active candidate pair becomes unusable.
  404. //
  405. // This is relevant mainly to Wi-Fi/cell handoff; the application may not
  406. // want this backup cellular candidate pair pinged frequently, since it
  407. // consumes data/battery.
  408. int ice_backup_candidate_pair_ping_interval = kUndefined;
  409. // Can be used to enable continual gathering, which means new candidates
  410. // will be gathered as network interfaces change. Note that if continual
  411. // gathering is used, the candidate removal API should also be used, to
  412. // avoid an ever-growing list of candidates.
  413. ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE;
  414. // If set to true, candidate pairs will be pinged in order of most likely
  415. // to work (which means using a TURN server, generally), rather than in
  416. // standard priority order.
  417. bool prioritize_most_likely_ice_candidate_pairs = false;
  418. // Implementation defined settings. A public member only for the benefit of
  419. // the implementation. Applications must not access it directly, and should
  420. // instead use provided accessor methods, e.g., set_cpu_adaptation.
  421. struct cricket::MediaConfig media_config;
  422. // If set to true, only one preferred TURN allocation will be used per
  423. // network interface. UDP is preferred over TCP and IPv6 over IPv4. This
  424. // can be used to cut down on the number of candidate pairings.
  425. // Deprecated. TODO(webrtc:11026) Remove this flag once the downstream
  426. // dependency is removed.
  427. bool prune_turn_ports = false;
  428. // The policy used to prune turn port.
  429. PortPrunePolicy turn_port_prune_policy = NO_PRUNE;
  430. PortPrunePolicy GetTurnPortPrunePolicy() const {
  431. return prune_turn_ports ? PRUNE_BASED_ON_PRIORITY
  432. : turn_port_prune_policy;
  433. }
  434. // If set to true, this means the ICE transport should presume TURN-to-TURN
  435. // candidate pairs will succeed, even before a binding response is received.
  436. // This can be used to optimize the initial connection time, since the DTLS
  437. // handshake can begin immediately.
  438. bool presume_writable_when_fully_relayed = false;
  439. // If true, "renomination" will be added to the ice options in the transport
  440. // description.
  441. // See: https://tools.ietf.org/html/draft-thatcher-ice-renomination-00
  442. bool enable_ice_renomination = false;
  443. // If true, the ICE role is re-determined when the PeerConnection sets a
  444. // local transport description that indicates an ICE restart.
  445. //
  446. // This is standard RFC5245 ICE behavior, but causes unnecessary role
  447. // thrashing, so an application may wish to avoid it. This role
  448. // re-determining was removed in ICEbis (ICE v2).
  449. bool redetermine_role_on_ice_restart = true;
  450. // This flag is only effective when |continual_gathering_policy| is
  451. // GATHER_CONTINUALLY.
  452. //
  453. // If true, after the ICE transport type is changed such that new types of
  454. // ICE candidates are allowed by the new transport type, e.g. from
  455. // IceTransportsType::kRelay to IceTransportsType::kAll, candidates that
  456. // have been gathered by the ICE transport but not matching the previous
  457. // transport type and as a result not observed by PeerConnectionObserver,
  458. // will be surfaced to the observer.
  459. bool surface_ice_candidates_on_ice_transport_type_changed = false;
  460. // The following fields define intervals in milliseconds at which ICE
  461. // connectivity checks are sent.
  462. //
  463. // We consider ICE is "strongly connected" for an agent when there is at
  464. // least one candidate pair that currently succeeds in connectivity check
  465. // from its direction i.e. sending a STUN ping and receives a STUN ping
  466. // response, AND all candidate pairs have sent a minimum number of pings for
  467. // connectivity (this number is implementation-specific). Otherwise, ICE is
  468. // considered in "weak connectivity".
  469. //
  470. // Note that the above notion of strong and weak connectivity is not defined
  471. // in RFC 5245, and they apply to our current ICE implementation only.
  472. //
  473. // 1) ice_check_interval_strong_connectivity defines the interval applied to
  474. // ALL candidate pairs when ICE is strongly connected, and it overrides the
  475. // default value of this interval in the ICE implementation;
  476. // 2) ice_check_interval_weak_connectivity defines the counterpart for ALL
  477. // pairs when ICE is weakly connected, and it overrides the default value of
  478. // this interval in the ICE implementation;
  479. // 3) ice_check_min_interval defines the minimal interval (equivalently the
  480. // maximum rate) that overrides the above two intervals when either of them
  481. // is less.
  482. absl::optional<int> ice_check_interval_strong_connectivity;
  483. absl::optional<int> ice_check_interval_weak_connectivity;
  484. absl::optional<int> ice_check_min_interval;
  485. // The min time period for which a candidate pair must wait for response to
  486. // connectivity checks before it becomes unwritable. This parameter
  487. // overrides the default value in the ICE implementation if set.
  488. absl::optional<int> ice_unwritable_timeout;
  489. // The min number of connectivity checks that a candidate pair must sent
  490. // without receiving response before it becomes unwritable. This parameter
  491. // overrides the default value in the ICE implementation if set.
  492. absl::optional<int> ice_unwritable_min_checks;
  493. // The min time period for which a candidate pair must wait for response to
  494. // connectivity checks it becomes inactive. This parameter overrides the
  495. // default value in the ICE implementation if set.
  496. absl::optional<int> ice_inactive_timeout;
  497. // The interval in milliseconds at which STUN candidates will resend STUN
  498. // binding requests to keep NAT bindings open.
  499. absl::optional<int> stun_candidate_keepalive_interval;
  500. // Optional TurnCustomizer.
  501. // With this class one can modify outgoing TURN messages.
  502. // The object passed in must remain valid until PeerConnection::Close() is
  503. // called.
  504. webrtc::TurnCustomizer* turn_customizer = nullptr;
  505. // Preferred network interface.
  506. // A candidate pair on a preferred network has a higher precedence in ICE
  507. // than one on an un-preferred network, regardless of priority or network
  508. // cost.
  509. absl::optional<rtc::AdapterType> network_preference;
  510. // Configure the SDP semantics used by this PeerConnection. Note that the
  511. // WebRTC 1.0 specification requires kUnifiedPlan semantics. The
  512. // RtpTransceiver API is only available with kUnifiedPlan semantics.
  513. //
  514. // kPlanB will cause PeerConnection to create offers and answers with at
  515. // most one audio and one video m= section with multiple RtpSenders and
  516. // RtpReceivers specified as multiple a=ssrc lines within the section. This
  517. // will also cause PeerConnection to ignore all but the first m= section of
  518. // the same media type.
  519. //
  520. // kUnifiedPlan will cause PeerConnection to create offers and answers with
  521. // multiple m= sections where each m= section maps to one RtpSender and one
  522. // RtpReceiver (an RtpTransceiver), either both audio or both video. This
  523. // will also cause PeerConnection to ignore all but the first a=ssrc lines
  524. // that form a Plan B stream.
  525. //
  526. // For users who wish to send multiple audio/video streams and need to stay
  527. // interoperable with legacy WebRTC implementations or use legacy APIs,
  528. // specify kPlanB.
  529. //
  530. // For all other users, specify kUnifiedPlan.
  531. SdpSemantics sdp_semantics = SdpSemantics::kPlanB;
  532. // TODO(bugs.webrtc.org/9891) - Move to crypto_options or remove.
  533. // Actively reset the SRTP parameters whenever the DTLS transports
  534. // underneath are reset for every offer/answer negotiation.
  535. // This is only intended to be a workaround for crbug.com/835958
  536. // WARNING: This would cause RTP/RTCP packets decryption failure if not used
  537. // correctly. This flag will be deprecated soon. Do not rely on it.
  538. bool active_reset_srtp_params = false;
  539. // DEPRECATED. Do not use. This option is ignored by peer connection.
  540. // TODO(webrtc:9719): Delete this option.
  541. bool use_media_transport = false;
  542. // DEPRECATED. Do not use. This option is ignored by peer connection.
  543. // TODO(webrtc:9719): Delete this option.
  544. bool use_media_transport_for_data_channels = false;
  545. // If MediaTransportFactory is provided in PeerConnectionFactory, this flag
  546. // informs PeerConnection that it should use the DatagramTransportInterface
  547. // for packets instead DTLS. It's invalid to set it to |true| if the
  548. // MediaTransportFactory wasn't provided.
  549. absl::optional<bool> use_datagram_transport;
  550. // If MediaTransportFactory is provided in PeerConnectionFactory, this flag
  551. // informs PeerConnection that it should use the DatagramTransport's
  552. // implementation of DataChannelTransportInterface for data channels instead
  553. // of SCTP-DTLS.
  554. absl::optional<bool> use_datagram_transport_for_data_channels;
  555. // If true, this PeerConnection will only use datagram transport for data
  556. // channels when receiving an incoming offer that includes datagram
  557. // transport parameters. It will not request use of a datagram transport
  558. // when it creates the initial, outgoing offer.
  559. // This setting only applies when |use_datagram_transport_for_data_channels|
  560. // is true.
  561. absl::optional<bool> use_datagram_transport_for_data_channels_receive_only;
  562. // Defines advanced optional cryptographic settings related to SRTP and
  563. // frame encryption for native WebRTC. Setting this will overwrite any
  564. // settings set in PeerConnectionFactory (which is deprecated).
  565. absl::optional<CryptoOptions> crypto_options;
  566. // Configure if we should include the SDP attribute extmap-allow-mixed in
  567. // our offer. Although we currently do support this, it's not included in
  568. // our offer by default due to a previous bug that caused the SDP parser to
  569. // abort parsing if this attribute was present. This is fixed in Chrome 71.
  570. // TODO(webrtc:9985): Change default to true once sufficient time has
  571. // passed.
  572. bool offer_extmap_allow_mixed = false;
  573. // TURN logging identifier.
  574. // This identifier is added to a TURN allocation
  575. // and it intended to be used to be able to match client side
  576. // logs with TURN server logs. It will not be added if it's an empty string.
  577. std::string turn_logging_id;
  578. // Added to be able to control rollout of this feature.
  579. bool enable_implicit_rollback = false;
  580. // Whether network condition based codec switching is allowed.
  581. absl::optional<bool> allow_codec_switching;
  582. //
  583. // Don't forget to update operator== if adding something.
  584. //
  585. };
  586. // See: https://www.w3.org/TR/webrtc/#idl-def-rtcofferansweroptions
  587. struct RTCOfferAnswerOptions {
  588. static const int kUndefined = -1;
  589. static const int kMaxOfferToReceiveMedia = 1;
  590. // The default value for constraint offerToReceiveX:true.
  591. static const int kOfferToReceiveMediaTrue = 1;
  592. // These options are left as backwards compatibility for clients who need
  593. // "Plan B" semantics. Clients who have switched to "Unified Plan" semantics
  594. // should use the RtpTransceiver API (AddTransceiver) instead.
  595. //
  596. // offer_to_receive_X set to 1 will cause a media description to be
  597. // generated in the offer, even if no tracks of that type have been added.
  598. // Values greater than 1 are treated the same.
  599. //
  600. // If set to 0, the generated directional attribute will not include the
  601. // "recv" direction (meaning it will be "sendonly" or "inactive".
  602. int offer_to_receive_video = kUndefined;
  603. int offer_to_receive_audio = kUndefined;
  604. bool voice_activity_detection = true;
  605. bool ice_restart = false;
  606. // If true, will offer to BUNDLE audio/video/data together. Not to be
  607. // confused with RTCP mux (multiplexing RTP and RTCP together).
  608. bool use_rtp_mux = true;
  609. // If true, "a=packetization:<payload_type> raw" attribute will be offered
  610. // in the SDP for all video payload and accepted in the answer if offered.
  611. bool raw_packetization_for_video = false;
  612. // This will apply to all video tracks with a Plan B SDP offer/answer.
  613. int num_simulcast_layers = 1;
  614. // If true: Use SDP format from draft-ietf-mmusic-scdp-sdp-03
  615. // If false: Use SDP format from draft-ietf-mmusic-sdp-sdp-26 or later
  616. bool use_obsolete_sctp_sdp = false;
  617. RTCOfferAnswerOptions() = default;
  618. RTCOfferAnswerOptions(int offer_to_receive_video,
  619. int offer_to_receive_audio,
  620. bool voice_activity_detection,
  621. bool ice_restart,
  622. bool use_rtp_mux)
  623. : offer_to_receive_video(offer_to_receive_video),
  624. offer_to_receive_audio(offer_to_receive_audio),
  625. voice_activity_detection(voice_activity_detection),
  626. ice_restart(ice_restart),
  627. use_rtp_mux(use_rtp_mux) {}
  628. };
  629. // Used by GetStats to decide which stats to include in the stats reports.
  630. // |kStatsOutputLevelStandard| includes the standard stats for Javascript API;
  631. // |kStatsOutputLevelDebug| includes both the standard stats and additional
  632. // stats for debugging purposes.
  633. enum StatsOutputLevel {
  634. kStatsOutputLevelStandard,
  635. kStatsOutputLevelDebug,
  636. };
  637. // Accessor methods to active local streams.
  638. // This method is not supported with kUnifiedPlan semantics. Please use
  639. // GetSenders() instead.
  640. virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams() = 0;
  641. // Accessor methods to remote streams.
  642. // This method is not supported with kUnifiedPlan semantics. Please use
  643. // GetReceivers() instead.
  644. virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams() = 0;
  645. // Add a new MediaStream to be sent on this PeerConnection.
  646. // Note that a SessionDescription negotiation is needed before the
  647. // remote peer can receive the stream.
  648. //
  649. // This has been removed from the standard in favor of a track-based API. So,
  650. // this is equivalent to simply calling AddTrack for each track within the
  651. // stream, with the one difference that if "stream->AddTrack(...)" is called
  652. // later, the PeerConnection will automatically pick up the new track. Though
  653. // this functionality will be deprecated in the future.
  654. //
  655. // This method is not supported with kUnifiedPlan semantics. Please use
  656. // AddTrack instead.
  657. virtual bool AddStream(MediaStreamInterface* stream) = 0;
  658. // Remove a MediaStream from this PeerConnection.
  659. // Note that a SessionDescription negotiation is needed before the
  660. // remote peer is notified.
  661. //
  662. // This method is not supported with kUnifiedPlan semantics. Please use
  663. // RemoveTrack instead.
  664. virtual void RemoveStream(MediaStreamInterface* stream) = 0;
  665. // Add a new MediaStreamTrack to be sent on this PeerConnection, and return
  666. // the newly created RtpSender. The RtpSender will be associated with the
  667. // streams specified in the |stream_ids| list.
  668. //
  669. // Errors:
  670. // - INVALID_PARAMETER: |track| is null, has a kind other than audio or video,
  671. // or a sender already exists for the track.
  672. // - INVALID_STATE: The PeerConnection is closed.
  673. virtual RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
  674. rtc::scoped_refptr<MediaStreamTrackInterface> track,
  675. const std::vector<std::string>& stream_ids) = 0;
  676. // Remove an RtpSender from this PeerConnection.
  677. // Returns true on success.
  678. // TODO(steveanton): Replace with signature that returns RTCError.
  679. virtual bool RemoveTrack(RtpSenderInterface* sender) = 0;
  680. // Plan B semantics: Removes the RtpSender from this PeerConnection.
  681. // Unified Plan semantics: Stop sending on the RtpSender and mark the
  682. // corresponding RtpTransceiver direction as no longer sending.
  683. //
  684. // Errors:
  685. // - INVALID_PARAMETER: |sender| is null or (Plan B only) the sender is not
  686. // associated with this PeerConnection.
  687. // - INVALID_STATE: PeerConnection is closed.
  688. // TODO(bugs.webrtc.org/9534): Rename to RemoveTrack once the other signature
  689. // is removed.
  690. virtual RTCError RemoveTrackNew(
  691. rtc::scoped_refptr<RtpSenderInterface> sender);
  692. // AddTransceiver creates a new RtpTransceiver and adds it to the set of
  693. // transceivers. Adding a transceiver will cause future calls to CreateOffer
  694. // to add a media description for the corresponding transceiver.
  695. //
  696. // The initial value of |mid| in the returned transceiver is null. Setting a
  697. // new session description may change it to a non-null value.
  698. //
  699. // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
  700. //
  701. // Optionally, an RtpTransceiverInit structure can be specified to configure
  702. // the transceiver from construction. If not specified, the transceiver will
  703. // default to having a direction of kSendRecv and not be part of any streams.
  704. //
  705. // These methods are only available when Unified Plan is enabled (see
  706. // RTCConfiguration).
  707. //
  708. // Common errors:
  709. // - INTERNAL_ERROR: The configuration does not have Unified Plan enabled.
  710. // Adds a transceiver with a sender set to transmit the given track. The kind
  711. // of the transceiver (and sender/receiver) will be derived from the kind of
  712. // the track.
  713. // Errors:
  714. // - INVALID_PARAMETER: |track| is null.
  715. virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
  716. AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track) = 0;
  717. virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
  718. AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track,
  719. const RtpTransceiverInit& init) = 0;
  720. // Adds a transceiver with the given kind. Can either be MEDIA_TYPE_AUDIO or
  721. // MEDIA_TYPE_VIDEO.
  722. // Errors:
  723. // - INVALID_PARAMETER: |media_type| is not MEDIA_TYPE_AUDIO or
  724. // MEDIA_TYPE_VIDEO.
  725. virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
  726. AddTransceiver(cricket::MediaType media_type) = 0;
  727. virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
  728. AddTransceiver(cricket::MediaType media_type,
  729. const RtpTransceiverInit& init) = 0;
  730. // Creates a sender without a track. Can be used for "early media"/"warmup"
  731. // use cases, where the application may want to negotiate video attributes
  732. // before a track is available to send.
  733. //
  734. // The standard way to do this would be through "addTransceiver", but we
  735. // don't support that API yet.
  736. //
  737. // |kind| must be "audio" or "video".
  738. //
  739. // |stream_id| is used to populate the msid attribute; if empty, one will
  740. // be generated automatically.
  741. //
  742. // This method is not supported with kUnifiedPlan semantics. Please use
  743. // AddTransceiver instead.
  744. virtual rtc::scoped_refptr<RtpSenderInterface> CreateSender(
  745. const std::string& kind,
  746. const std::string& stream_id) = 0;
  747. // If Plan B semantics are specified, gets all RtpSenders, created either
  748. // through AddStream, AddTrack, or CreateSender. All senders of a specific
  749. // media type share the same media description.
  750. //
  751. // If Unified Plan semantics are specified, gets the RtpSender for each
  752. // RtpTransceiver.
  753. virtual std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
  754. const = 0;
  755. // If Plan B semantics are specified, gets all RtpReceivers created when a
  756. // remote description is applied. All receivers of a specific media type share
  757. // the same media description. It is also possible to have a media description
  758. // with no associated RtpReceivers, if the directional attribute does not
  759. // indicate that the remote peer is sending any media.
  760. //
  761. // If Unified Plan semantics are specified, gets the RtpReceiver for each
  762. // RtpTransceiver.
  763. virtual std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
  764. const = 0;
  765. // Get all RtpTransceivers, created either through AddTransceiver, AddTrack or
  766. // by a remote description applied with SetRemoteDescription.
  767. //
  768. // Note: This method is only available when Unified Plan is enabled (see
  769. // RTCConfiguration).
  770. virtual std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>
  771. GetTransceivers() const = 0;
  772. // The legacy non-compliant GetStats() API. This correspond to the
  773. // callback-based version of getStats() in JavaScript. The returned metrics
  774. // are UNDOCUMENTED and many of them rely on implementation-specific details.
  775. // The goal is to DELETE THIS VERSION but we can't today because it is heavily
  776. // relied upon by third parties. See https://crbug.com/822696.
  777. //
  778. // This version is wired up into Chrome. Any stats implemented are
  779. // automatically exposed to the Web Platform. This has BYPASSED the Chrome
  780. // release processes for years and lead to cross-browser incompatibility
  781. // issues and web application reliance on Chrome-only behavior.
  782. //
  783. // This API is in "maintenance mode", serious regressions should be fixed but
  784. // adding new stats is highly discouraged.
  785. //
  786. // TODO(hbos): Deprecate and remove this when third parties have migrated to
  787. // the spec-compliant GetStats() API. https://crbug.com/822696
  788. virtual bool GetStats(StatsObserver* observer,
  789. MediaStreamTrackInterface* track, // Optional
  790. StatsOutputLevel level) = 0;
  791. // The spec-compliant GetStats() API. This correspond to the promise-based
  792. // version of getStats() in JavaScript. Implementation status is described in
  793. // api/stats/rtcstats_objects.h. For more details on stats, see spec:
  794. // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-getstats
  795. // TODO(hbos): Takes shared ownership, use rtc::scoped_refptr<> instead. This
  796. // requires stop overriding the current version in third party or making third
  797. // party calls explicit to avoid ambiguity during switch. Make the future
  798. // version abstract as soon as third party projects implement it.
  799. virtual void GetStats(RTCStatsCollectorCallback* callback) = 0;
  800. // Spec-compliant getStats() performing the stats selection algorithm with the
  801. // sender. https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getstats
  802. virtual void GetStats(
  803. rtc::scoped_refptr<RtpSenderInterface> selector,
  804. rtc::scoped_refptr<RTCStatsCollectorCallback> callback) = 0;
  805. // Spec-compliant getStats() performing the stats selection algorithm with the
  806. // receiver. https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-getstats
  807. virtual void GetStats(
  808. rtc::scoped_refptr<RtpReceiverInterface> selector,
  809. rtc::scoped_refptr<RTCStatsCollectorCallback> callback) = 0;
  810. // Clear cached stats in the RTCStatsCollector.
  811. // Exposed for testing while waiting for automatic cache clear to work.
  812. // https://bugs.webrtc.org/8693
  813. virtual void ClearStatsCache() {}
  814. // Create a data channel with the provided config, or default config if none
  815. // is provided. Note that an offer/answer negotiation is still necessary
  816. // before the data channel can be used.
  817. //
  818. // Also, calling CreateDataChannel is the only way to get a data "m=" section
  819. // in SDP, so it should be done before CreateOffer is called, if the
  820. // application plans to use data channels.
  821. virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
  822. const std::string& label,
  823. const DataChannelInit* config) = 0;
  824. // Returns the more recently applied description; "pending" if it exists, and
  825. // otherwise "current". See below.
  826. virtual const SessionDescriptionInterface* local_description() const = 0;
  827. virtual const SessionDescriptionInterface* remote_description() const = 0;
  828. // A "current" description the one currently negotiated from a complete
  829. // offer/answer exchange.
  830. virtual const SessionDescriptionInterface* current_local_description()
  831. const = 0;
  832. virtual const SessionDescriptionInterface* current_remote_description()
  833. const = 0;
  834. // A "pending" description is one that's part of an incomplete offer/answer
  835. // exchange (thus, either an offer or a pranswer). Once the offer/answer
  836. // exchange is finished, the "pending" description will become "current".
  837. virtual const SessionDescriptionInterface* pending_local_description()
  838. const = 0;
  839. virtual const SessionDescriptionInterface* pending_remote_description()
  840. const = 0;
  841. // Tells the PeerConnection that ICE should be restarted. This triggers a need
  842. // for negotiation and subsequent CreateOffer() calls will act as if
  843. // RTCOfferAnswerOptions::ice_restart is true.
  844. // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-restartice
  845. // TODO(hbos): Remove default implementation when downstream projects
  846. // implement this.
  847. virtual void RestartIce() = 0;
  848. // Create a new offer.
  849. // The CreateSessionDescriptionObserver callback will be called when done.
  850. virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
  851. const RTCOfferAnswerOptions& options) = 0;
  852. // Create an answer to an offer.
  853. // The CreateSessionDescriptionObserver callback will be called when done.
  854. virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
  855. const RTCOfferAnswerOptions& options) = 0;
  856. // Sets the local session description.
  857. // The PeerConnection takes the ownership of |desc| even if it fails.
  858. // The |observer| callback will be called when done.
  859. // TODO(deadbeef): Change |desc| to be a unique_ptr, to make it clear
  860. // that this method always takes ownership of it.
  861. virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,
  862. SessionDescriptionInterface* desc) = 0;
  863. // Implicitly creates an offer or answer (depending on the current signaling
  864. // state) and performs SetLocalDescription() with the newly generated session
  865. // description.
  866. // TODO(hbos): Make pure virtual when implemented by downstream projects.
  867. virtual void SetLocalDescription(SetSessionDescriptionObserver* observer) {}
  868. // Sets the remote session description.
  869. // The PeerConnection takes the ownership of |desc| even if it fails.
  870. // The |observer| callback will be called when done.
  871. // TODO(hbos): Remove when Chrome implements the new signature.
  872. virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
  873. SessionDescriptionInterface* desc) {}
  874. virtual void SetRemoteDescription(
  875. std::unique_ptr<SessionDescriptionInterface> desc,
  876. rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) = 0;
  877. virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() = 0;
  878. // Sets the PeerConnection's global configuration to |config|.
  879. //
  880. // The members of |config| that may be changed are |type|, |servers|,
  881. // |ice_candidate_pool_size| and |prune_turn_ports| (though the candidate
  882. // pool size can't be changed after the first call to SetLocalDescription).
  883. // Note that this means the BUNDLE and RTCP-multiplexing policies cannot be
  884. // changed with this method.
  885. //
  886. // Any changes to STUN/TURN servers or ICE candidate policy will affect the
  887. // next gathering phase, and cause the next call to createOffer to generate
  888. // new ICE credentials, as described in JSEP. This also occurs when
  889. // |prune_turn_ports| changes, for the same reasoning.
  890. //
  891. // If an error occurs, returns false and populates |error| if non-null:
  892. // - INVALID_MODIFICATION if |config| contains a modified parameter other
  893. // than one of the parameters listed above.
  894. // - INVALID_RANGE if |ice_candidate_pool_size| is out of range.
  895. // - SYNTAX_ERROR if parsing an ICE server URL failed.
  896. // - INVALID_PARAMETER if a TURN server is missing |username| or |password|.
  897. // - INTERNAL_ERROR if an unexpected error occurred.
  898. //
  899. // TODO(nisse): Make this pure virtual once all Chrome subclasses of
  900. // PeerConnectionInterface implement it.
  901. virtual RTCError SetConfiguration(
  902. const PeerConnectionInterface::RTCConfiguration& config);
  903. // Provides a remote candidate to the ICE Agent.
  904. // A copy of the |candidate| will be created and added to the remote
  905. // description. So the caller of this method still has the ownership of the
  906. // |candidate|.
  907. // TODO(hbos): The spec mandates chaining this operation onto the operations
  908. // chain; deprecate and remove this version in favor of the callback-based
  909. // signature.
  910. virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0;
  911. // TODO(hbos): Remove default implementation once implemented by downstream
  912. // projects.
  913. virtual void AddIceCandidate(std::unique_ptr<IceCandidateInterface> candidate,
  914. std::function<void(RTCError)> callback) {}
  915. // Removes a group of remote candidates from the ICE agent. Needed mainly for
  916. // continual gathering, to avoid an ever-growing list of candidates as
  917. // networks come and go.
  918. virtual bool RemoveIceCandidates(
  919. const std::vector<cricket::Candidate>& candidates) = 0;
  920. // 0 <= min <= current <= max should hold for set parameters.
  921. struct BitrateParameters {
  922. BitrateParameters();
  923. ~BitrateParameters();
  924. absl::optional<int> min_bitrate_bps;
  925. absl::optional<int> current_bitrate_bps;
  926. absl::optional<int> max_bitrate_bps;
  927. };
  928. // SetBitrate limits the bandwidth allocated for all RTP streams sent by
  929. // this PeerConnection. Other limitations might affect these limits and
  930. // are respected (for example "b=AS" in SDP).
  931. //
  932. // Setting |current_bitrate_bps| will reset the current bitrate estimate
  933. // to the provided value.
  934. virtual RTCError SetBitrate(const BitrateSettings& bitrate);
  935. // TODO(nisse): Deprecated - use version above. These two default
  936. // implementations require subclasses to implement one or the other
  937. // of the methods.
  938. virtual RTCError SetBitrate(const BitrateParameters& bitrate_parameters);
  939. // Enable/disable playout of received audio streams. Enabled by default. Note
  940. // that even if playout is enabled, streams will only be played out if the
  941. // appropriate SDP is also applied. Setting |playout| to false will stop
  942. // playout of the underlying audio device but starts a task which will poll
  943. // for audio data every 10ms to ensure that audio processing happens and the
  944. // audio statistics are updated.
  945. // TODO(henrika): deprecate and remove this.
  946. virtual void SetAudioPlayout(bool playout) {}
  947. // Enable/disable recording of transmitted audio streams. Enabled by default.
  948. // Note that even if recording is enabled, streams will only be recorded if
  949. // the appropriate SDP is also applied.
  950. // TODO(henrika): deprecate and remove this.
  951. virtual void SetAudioRecording(bool recording) {}
  952. // Looks up the DtlsTransport associated with a MID value.
  953. // In the Javascript API, DtlsTransport is a property of a sender, but
  954. // because the PeerConnection owns the DtlsTransport in this implementation,
  955. // it is better to look them up on the PeerConnection.
  956. virtual rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
  957. const std::string& mid) = 0;
  958. // Returns the SCTP transport, if any.
  959. virtual rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport()
  960. const = 0;
  961. // Returns the current SignalingState.
  962. virtual SignalingState signaling_state() = 0;
  963. // Returns an aggregate state of all ICE *and* DTLS transports.
  964. // This is left in place to avoid breaking native clients who expect our old,
  965. // nonstandard behavior.
  966. // TODO(jonasolsson): deprecate and remove this.
  967. virtual IceConnectionState ice_connection_state() = 0;
  968. // Returns an aggregated state of all ICE transports.
  969. virtual IceConnectionState standardized_ice_connection_state() = 0;
  970. // Returns an aggregated state of all ICE and DTLS transports.
  971. virtual PeerConnectionState peer_connection_state() = 0;
  972. virtual IceGatheringState ice_gathering_state() = 0;
  973. // Returns the current state of canTrickleIceCandidates per
  974. // https://w3c.github.io/webrtc-pc/#attributes-1
  975. virtual absl::optional<bool> can_trickle_ice_candidates() {
  976. // TODO(crbug.com/708484): Remove default implementation.
  977. return absl::nullopt;
  978. }
  979. // When a resource is overused, the PeerConnection will try to reduce the load
  980. // on the sysem, for example by reducing the resolution or frame rate of
  981. // encoded streams. The Resource API allows injecting platform-specific usage
  982. // measurements. The conditions to trigger kOveruse or kUnderuse are up to the
  983. // implementation.
  984. // TODO(hbos): Make pure virtual when implemented by downstream projects.
  985. virtual void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) {}
  986. // Start RtcEventLog using an existing output-sink. Takes ownership of
  987. // |output| and passes it on to Call, which will take the ownership. If the
  988. // operation fails the output will be closed and deallocated. The event log
  989. // will send serialized events to the output object every |output_period_ms|.
  990. // Applications using the event log should generally make their own trade-off
  991. // regarding the output period. A long period is generally more efficient,
  992. // with potential drawbacks being more bursty thread usage, and more events
  993. // lost in case the application crashes. If the |output_period_ms| argument is
  994. // omitted, webrtc selects a default deemed to be workable in most cases.
  995. virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
  996. int64_t output_period_ms) = 0;
  997. virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) = 0;
  998. // Stops logging the RtcEventLog.
  999. virtual void StopRtcEventLog() = 0;
  1000. // Terminates all media, closes the transports, and in general releases any
  1001. // resources used by the PeerConnection. This is an irreversible operation.
  1002. //
  1003. // Note that after this method completes, the PeerConnection will no longer
  1004. // use the PeerConnectionObserver interface passed in on construction, and
  1005. // thus the observer object can be safely destroyed.
  1006. virtual void Close() = 0;
  1007. protected:
  1008. // Dtor protected as objects shouldn't be deleted via this interface.
  1009. ~PeerConnectionInterface() override = default;
  1010. };
  1011. // PeerConnection callback interface, used for RTCPeerConnection events.
  1012. // Application should implement these methods.
  1013. class PeerConnectionObserver {
  1014. public:
  1015. virtual ~PeerConnectionObserver() = default;
  1016. // Triggered when the SignalingState changed.
  1017. virtual void OnSignalingChange(
  1018. PeerConnectionInterface::SignalingState new_state) = 0;
  1019. // Triggered when media is received on a new stream from remote peer.
  1020. virtual void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {}
  1021. // Triggered when a remote peer closes a stream.
  1022. virtual void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
  1023. }
  1024. // Triggered when a remote peer opens a data channel.
  1025. virtual void OnDataChannel(
  1026. rtc::scoped_refptr<DataChannelInterface> data_channel) = 0;
  1027. // Triggered when renegotiation is needed. For example, an ICE restart
  1028. // has begun.
  1029. virtual void OnRenegotiationNeeded() = 0;
  1030. // Called any time the legacy IceConnectionState changes.
  1031. //
  1032. // Note that our ICE states lag behind the standard slightly. The most
  1033. // notable differences include the fact that "failed" occurs after 15
  1034. // seconds, not 30, and this actually represents a combination ICE + DTLS
  1035. // state, so it may be "failed" if DTLS fails while ICE succeeds.
  1036. //
  1037. // TODO(jonasolsson): deprecate and remove this.
  1038. virtual void OnIceConnectionChange(
  1039. PeerConnectionInterface::IceConnectionState new_state) {}
  1040. // Called any time the standards-compliant IceConnectionState changes.
  1041. virtual void OnStandardizedIceConnectionChange(
  1042. PeerConnectionInterface::IceConnectionState new_state) {}
  1043. // Called any time the PeerConnectionState changes.
  1044. virtual void OnConnectionChange(
  1045. PeerConnectionInterface::PeerConnectionState new_state) {}
  1046. // Called any time the IceGatheringState changes.
  1047. virtual void OnIceGatheringChange(
  1048. PeerConnectionInterface::IceGatheringState new_state) = 0;
  1049. // A new ICE candidate has been gathered.
  1050. virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0;
  1051. // Gathering of an ICE candidate failed.
  1052. // See https://w3c.github.io/webrtc-pc/#event-icecandidateerror
  1053. // |host_candidate| is a stringified socket address.
  1054. virtual void OnIceCandidateError(const std::string& host_candidate,
  1055. const std::string& url,
  1056. int error_code,
  1057. const std::string& error_text) {}
  1058. // Gathering of an ICE candidate failed.
  1059. // See https://w3c.github.io/webrtc-pc/#event-icecandidateerror
  1060. virtual void OnIceCandidateError(const std::string& address,
  1061. int port,
  1062. const std::string& url,
  1063. int error_code,
  1064. const std::string& error_text) {}
  1065. // Ice candidates have been removed.
  1066. // TODO(honghaiz): Make this a pure virtual method when all its subclasses
  1067. // implement it.
  1068. virtual void OnIceCandidatesRemoved(
  1069. const std::vector<cricket::Candidate>& candidates) {}
  1070. // Called when the ICE connection receiving status changes.
  1071. virtual void OnIceConnectionReceivingChange(bool receiving) {}
  1072. // Called when the selected candidate pair for the ICE connection changes.
  1073. virtual void OnIceSelectedCandidatePairChanged(
  1074. const cricket::CandidatePairChangeEvent& event) {}
  1075. // This is called when a receiver and its track are created.
  1076. // TODO(zhihuang): Make this pure virtual when all subclasses implement it.
  1077. // Note: This is called with both Plan B and Unified Plan semantics. Unified
  1078. // Plan users should prefer OnTrack, OnAddTrack is only called as backwards
  1079. // compatibility (and is called in the exact same situations as OnTrack).
  1080. virtual void OnAddTrack(
  1081. rtc::scoped_refptr<RtpReceiverInterface> receiver,
  1082. const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {}
  1083. // This is called when signaling indicates a transceiver will be receiving
  1084. // media from the remote endpoint. This is fired during a call to
  1085. // SetRemoteDescription. The receiving track can be accessed by:
  1086. // |transceiver->receiver()->track()| and its associated streams by
  1087. // |transceiver->receiver()->streams()|.
  1088. // Note: This will only be called if Unified Plan semantics are specified.
  1089. // This behavior is specified in section 2.2.8.2.5 of the "Set the
  1090. // RTCSessionDescription" algorithm:
  1091. // https://w3c.github.io/webrtc-pc/#set-description
  1092. virtual void OnTrack(
  1093. rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {}
  1094. // Called when signaling indicates that media will no longer be received on a
  1095. // track.
  1096. // With Plan B semantics, the given receiver will have been removed from the
  1097. // PeerConnection and the track muted.
  1098. // With Unified Plan semantics, the receiver will remain but the transceiver
  1099. // will have changed direction to either sendonly or inactive.
  1100. // https://w3c.github.io/webrtc-pc/#process-remote-track-removal
  1101. // TODO(hbos,deadbeef): Make pure virtual when all subclasses implement it.
  1102. virtual void OnRemoveTrack(
  1103. rtc::scoped_refptr<RtpReceiverInterface> receiver) {}
  1104. // Called when an interesting usage is detected by WebRTC.
  1105. // An appropriate action is to add information about the context of the
  1106. // PeerConnection and write the event to some kind of "interesting events"
  1107. // log function.
  1108. // The heuristics for defining what constitutes "interesting" are
  1109. // implementation-defined.
  1110. virtual void OnInterestingUsage(int usage_pattern) {}
  1111. };
  1112. // PeerConnectionDependencies holds all of PeerConnections dependencies.
  1113. // A dependency is distinct from a configuration as it defines significant
  1114. // executable code that can be provided by a user of the API.
  1115. //
  1116. // All new dependencies should be added as a unique_ptr to allow the
  1117. // PeerConnection object to be the definitive owner of the dependencies
  1118. // lifetime making injection safer.
  1119. struct RTC_EXPORT PeerConnectionDependencies final {
  1120. explicit PeerConnectionDependencies(PeerConnectionObserver* observer_in);
  1121. // This object is not copyable or assignable.
  1122. PeerConnectionDependencies(const PeerConnectionDependencies&) = delete;
  1123. PeerConnectionDependencies& operator=(const PeerConnectionDependencies&) =
  1124. delete;
  1125. // This object is only moveable.
  1126. PeerConnectionDependencies(PeerConnectionDependencies&&);
  1127. PeerConnectionDependencies& operator=(PeerConnectionDependencies&&) = default;
  1128. ~PeerConnectionDependencies();
  1129. // Mandatory dependencies
  1130. PeerConnectionObserver* observer = nullptr;
  1131. // Optional dependencies
  1132. // TODO(bugs.webrtc.org/7447): remove port allocator once downstream is
  1133. // updated. For now, you can only set one of allocator and
  1134. // packet_socket_factory, not both.
  1135. std::unique_ptr<cricket::PortAllocator> allocator;
  1136. std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory;
  1137. std::unique_ptr<webrtc::AsyncResolverFactory> async_resolver_factory;
  1138. std::unique_ptr<webrtc::IceTransportFactory> ice_transport_factory;
  1139. std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator;
  1140. std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier;
  1141. std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
  1142. video_bitrate_allocator_factory;
  1143. };
  1144. // PeerConnectionFactoryDependencies holds all of the PeerConnectionFactory
  1145. // dependencies. All new dependencies should be added here instead of
  1146. // overloading the function. This simplifies dependency injection and makes it
  1147. // clear which are mandatory and optional. If possible please allow the peer
  1148. // connection factory to take ownership of the dependency by adding a unique_ptr
  1149. // to this structure.
  1150. struct RTC_EXPORT PeerConnectionFactoryDependencies final {
  1151. PeerConnectionFactoryDependencies();
  1152. // This object is not copyable or assignable.
  1153. PeerConnectionFactoryDependencies(const PeerConnectionFactoryDependencies&) =
  1154. delete;
  1155. PeerConnectionFactoryDependencies& operator=(
  1156. const PeerConnectionFactoryDependencies&) = delete;
  1157. // This object is only moveable.
  1158. PeerConnectionFactoryDependencies(PeerConnectionFactoryDependencies&&);
  1159. PeerConnectionFactoryDependencies& operator=(
  1160. PeerConnectionFactoryDependencies&&) = default;
  1161. ~PeerConnectionFactoryDependencies();
  1162. // Optional dependencies
  1163. rtc::Thread* network_thread = nullptr;
  1164. rtc::Thread* worker_thread = nullptr;
  1165. rtc::Thread* signaling_thread = nullptr;
  1166. std::unique_ptr<TaskQueueFactory> task_queue_factory;
  1167. std::unique_ptr<cricket::MediaEngineInterface> media_engine;
  1168. std::unique_ptr<CallFactoryInterface> call_factory;
  1169. std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory;
  1170. std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
  1171. std::unique_ptr<NetworkStatePredictorFactoryInterface>
  1172. network_state_predictor_factory;
  1173. std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory;
  1174. std::unique_ptr<MediaTransportFactory> media_transport_factory;
  1175. std::unique_ptr<NetEqFactory> neteq_factory;
  1176. std::unique_ptr<WebRtcKeyValueConfig> trials;
  1177. };
  1178. // PeerConnectionFactoryInterface is the factory interface used for creating
  1179. // PeerConnection, MediaStream and MediaStreamTrack objects.
  1180. //
  1181. // The simplest method for obtaiing one, CreatePeerConnectionFactory will
  1182. // create the required libjingle threads, socket and network manager factory
  1183. // classes for networking if none are provided, though it requires that the
  1184. // application runs a message loop on the thread that called the method (see
  1185. // explanation below)
  1186. //
  1187. // If an application decides to provide its own threads and/or implementation
  1188. // of networking classes, it should use the alternate
  1189. // CreatePeerConnectionFactory method which accepts threads as input, and use
  1190. // the CreatePeerConnection version that takes a PortAllocator as an argument.
  1191. class RTC_EXPORT PeerConnectionFactoryInterface
  1192. : public rtc::RefCountInterface {
  1193. public:
  1194. class Options {
  1195. public:
  1196. Options() {}
  1197. // If set to true, created PeerConnections won't enforce any SRTP
  1198. // requirement, allowing unsecured media. Should only be used for
  1199. // testing/debugging.
  1200. bool disable_encryption = false;
  1201. // Deprecated. The only effect of setting this to true is that
  1202. // CreateDataChannel will fail, which is not that useful.
  1203. bool disable_sctp_data_channels = false;
  1204. // If set to true, any platform-supported network monitoring capability
  1205. // won't be used, and instead networks will only be updated via polling.
  1206. //
  1207. // This only has an effect if a PeerConnection is created with the default
  1208. // PortAllocator implementation.
  1209. bool disable_network_monitor = false;
  1210. // Sets the network types to ignore. For instance, calling this with
  1211. // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
  1212. // loopback interfaces.
  1213. int network_ignore_mask = rtc::kDefaultNetworkIgnoreMask;
  1214. // Sets the maximum supported protocol version. The highest version
  1215. // supported by both ends will be used for the connection, i.e. if one
  1216. // party supports DTLS 1.0 and the other DTLS 1.2, DTLS 1.0 will be used.
  1217. rtc::SSLProtocolVersion ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
  1218. // Sets crypto related options, e.g. enabled cipher suites.
  1219. CryptoOptions crypto_options = CryptoOptions::NoGcm();
  1220. };
  1221. // Set the options to be used for subsequently created PeerConnections.
  1222. virtual void SetOptions(const Options& options) = 0;
  1223. // The preferred way to create a new peer connection. Simply provide the
  1224. // configuration and a PeerConnectionDependencies structure.
  1225. // TODO(benwright): Make pure virtual once downstream mock PC factory classes
  1226. // are updated.
  1227. virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
  1228. const PeerConnectionInterface::RTCConfiguration& configuration,
  1229. PeerConnectionDependencies dependencies);
  1230. // Deprecated; |allocator| and |cert_generator| may be null, in which case
  1231. // default implementations will be used.
  1232. //
  1233. // |observer| must not be null.
  1234. //
  1235. // Note that this method does not take ownership of |observer|; it's the
  1236. // responsibility of the caller to delete it. It can be safely deleted after
  1237. // Close has been called on the returned PeerConnection, which ensures no
  1238. // more observer callbacks will be invoked.
  1239. virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
  1240. const PeerConnectionInterface::RTCConfiguration& configuration,
  1241. std::unique_ptr<cricket::PortAllocator> allocator,
  1242. std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
  1243. PeerConnectionObserver* observer);
  1244. // Returns the capabilities of an RTP sender of type |kind|.
  1245. // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
  1246. // TODO(orphis): Make pure virtual when all subclasses implement it.
  1247. virtual RtpCapabilities GetRtpSenderCapabilities(
  1248. cricket::MediaType kind) const;
  1249. // Returns the capabilities of an RTP receiver of type |kind|.
  1250. // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
  1251. // TODO(orphis): Make pure virtual when all subclasses implement it.
  1252. virtual RtpCapabilities GetRtpReceiverCapabilities(
  1253. cricket::MediaType kind) const;
  1254. virtual rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream(
  1255. const std::string& stream_id) = 0;
  1256. // Creates an AudioSourceInterface.
  1257. // |options| decides audio processing settings.
  1258. virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
  1259. const cricket::AudioOptions& options) = 0;
  1260. // Creates a new local VideoTrack. The same |source| can be used in several
  1261. // tracks.
  1262. virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
  1263. const std::string& label,
  1264. VideoTrackSourceInterface* source) = 0;
  1265. // Creates an new AudioTrack. At the moment |source| can be null.
  1266. virtual rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
  1267. const std::string& label,
  1268. AudioSourceInterface* source) = 0;
  1269. // Starts AEC dump using existing file. Takes ownership of |file| and passes
  1270. // it on to VoiceEngine (via other objects) immediately, which will take
  1271. // the ownerhip. If the operation fails, the file will be closed.
  1272. // A maximum file size in bytes can be specified. When the file size limit is
  1273. // reached, logging is stopped automatically. If max_size_bytes is set to a
  1274. // value <= 0, no limit will be used, and logging will continue until the
  1275. // StopAecDump function is called.
  1276. // TODO(webrtc:6463): Delete default implementation when downstream mocks
  1277. // classes are updated.
  1278. virtual bool StartAecDump(FILE* file, int64_t max_size_bytes) {
  1279. return false;
  1280. }
  1281. // Stops logging the AEC dump.
  1282. virtual void StopAecDump() = 0;
  1283. protected:
  1284. // Dtor and ctor protected as objects shouldn't be created or deleted via
  1285. // this interface.
  1286. PeerConnectionFactoryInterface() {}
  1287. ~PeerConnectionFactoryInterface() override = default;
  1288. };
  1289. // CreateModularPeerConnectionFactory is implemented in the "peerconnection"
  1290. // build target, which doesn't pull in the implementations of every module
  1291. // webrtc may use.
  1292. //
  1293. // If an application knows it will only require certain modules, it can reduce
  1294. // webrtc's impact on its binary size by depending only on the "peerconnection"
  1295. // target and the modules the application requires, using
  1296. // CreateModularPeerConnectionFactory. For example, if an application
  1297. // only uses WebRTC for audio, it can pass in null pointers for the
  1298. // video-specific interfaces, and omit the corresponding modules from its
  1299. // build.
  1300. //
  1301. // If |network_thread| or |worker_thread| are null, the PeerConnectionFactory
  1302. // will create the necessary thread internally. If |signaling_thread| is null,
  1303. // the PeerConnectionFactory will use the thread on which this method is called
  1304. // as the signaling thread, wrapping it in an rtc::Thread object if needed.
  1305. RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
  1306. CreateModularPeerConnectionFactory(
  1307. PeerConnectionFactoryDependencies dependencies);
  1308. } // namespace webrtc
  1309. #endif // API_PEER_CONNECTION_INTERFACE_H_