You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1466 lines
65 KiB

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