blob: 58424dbac0e959377dc1f9c7f40259f7052f6c00 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
henrike@webrtc.org28e20752013-07-10 00:45:369 */
10
Steve Anton10542f22019-01-11 17:11:0011#ifndef PC_PEER_CONNECTION_H_
12#define PC_PEER_CONNECTION_H_
henrike@webrtc.org28e20752013-07-10 00:45:3613
Harald Alvestrand1f7eab62020-10-18 16:51:4714#include <stdint.h>
Artem Titovd15a5752021-02-10 13:31:2415
Tomas Gunnarsson1e40a0c2020-09-28 08:39:3116#include <functional>
perkjd61bf802016-03-24 10:16:1917#include <map>
kwibergd1fe2812016-04-27 13:47:2918#include <memory>
Steve Anton75737c02017-11-06 18:37:1719#include <set>
20#include <string>
Henrik Boström79b69802019-07-18 09:16:5621#include <utility>
perkjd61bf802016-03-24 10:16:1922#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:3623
Harald Alvestrand1f7eab62020-10-18 16:51:4724#include "absl/types/optional.h"
25#include "api/adaptation/resource.h"
26#include "api/async_resolver_factory.h"
27#include "api/audio_options.h"
28#include "api/candidate.h"
29#include "api/crypto/crypto_options.h"
30#include "api/data_channel_interface.h"
31#include "api/dtls_transport_interface.h"
32#include "api/ice_transport_interface.h"
33#include "api/jsep.h"
34#include "api/media_stream_interface.h"
35#include "api/media_types.h"
36#include "api/packet_socket_factory.h"
Steve Anton10542f22019-01-11 17:11:0037#include "api/peer_connection_interface.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4738#include "api/rtc_error.h"
39#include "api/rtc_event_log/rtc_event_log.h"
40#include "api/rtc_event_log_output.h"
41#include "api/rtp_parameters.h"
42#include "api/rtp_receiver_interface.h"
43#include "api/rtp_sender_interface.h"
44#include "api/rtp_transceiver_interface.h"
45#include "api/scoped_refptr.h"
46#include "api/sctp_transport_interface.h"
Artem Titovd15a5752021-02-10 13:31:2447#include "api/sequence_checker.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4748#include "api/set_local_description_observer_interface.h"
49#include "api/set_remote_description_observer_interface.h"
50#include "api/stats/rtc_stats_collector_callback.h"
51#include "api/transport/bitrate_settings.h"
Niels Möller65f17ca2019-09-12 11:59:3652#include "api/transport/data_channel_transport_interface.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4753#include "api/transport/enums.h"
Steve Anton10542f22019-01-11 17:11:0054#include "api/turn_customizer.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4755#include "api/video/video_bitrate_allocator_factory.h"
56#include "call/call.h"
57#include "media/base/media_channel.h"
58#include "media/base/media_engine.h"
59#include "p2p/base/ice_transport_internal.h"
60#include "p2p/base/port.h"
61#include "p2p/base/port_allocator.h"
62#include "p2p/base/transport_description.h"
63#include "pc/channel.h"
64#include "pc/channel_interface.h"
65#include "pc/channel_manager.h"
Harald Alvestranda39689c2020-10-15 08:34:3166#include "pc/connection_context.h"
Harald Alvestrand05e4d082019-12-03 13:04:2167#include "pc/data_channel_controller.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4768#include "pc/data_channel_utils.h"
69#include "pc/dtls_transport.h"
Steve Anton10542f22019-01-11 17:11:0070#include "pc/jsep_transport_controller.h"
Steve Anton10542f22019-01-11 17:11:0071#include "pc/peer_connection_internal.h"
Harald Alvestrand1090e442020-10-05 07:01:0972#include "pc/peer_connection_message_handler.h"
Steve Anton10542f22019-01-11 17:11:0073#include "pc/rtc_stats_collector.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4774#include "pc/rtp_data_channel.h"
75#include "pc/rtp_receiver.h"
Guido Urdaneta1ff16c82019-05-20 17:31:5376#include "pc/rtp_sender.h"
Steve Anton10542f22019-01-11 17:11:0077#include "pc/rtp_transceiver.h"
Harald Alvestrande15fb152020-10-19 13:28:0578#include "pc/rtp_transmission_manager.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4779#include "pc/rtp_transport_internal.h"
80#include "pc/sctp_data_channel.h"
Harald Alvestrande15fb152020-10-19 13:28:0581#include "pc/sctp_transport.h"
Harald Alvestrandcdcfab02020-09-28 13:02:0782#include "pc/sdp_offer_answer.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4783#include "pc/session_description.h"
Steve Anton10542f22019-01-11 17:11:0084#include "pc/stats_collector.h"
85#include "pc/stream_collection.h"
Harald Alvestrand38b768c2020-09-29 11:54:0586#include "pc/transceiver_list.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4787#include "pc/transport_stats.h"
Harald Alvestrand44d0dff2020-10-09 05:43:5388#include "pc/usage_pattern.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4789#include "rtc_base/checks.h"
90#include "rtc_base/copy_on_write_buffer.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4791#include "rtc_base/network/sent_packet.h"
92#include "rtc_base/rtc_certificate.h"
93#include "rtc_base/ssl_certificate.h"
94#include "rtc_base/ssl_stream_adapter.h"
Tomas Gunnarsson1e40a0c2020-09-28 08:39:3195#include "rtc_base/task_utils/pending_task_safety_flag.h"
Harald Alvestrand1f7eab62020-10-18 16:51:4796#include "rtc_base/third_party/sigslot/sigslot.h"
97#include "rtc_base/thread.h"
98#include "rtc_base/thread_annotations.h"
Amit Hilbuchdbb49df2019-01-23 22:54:2499#include "rtc_base/unique_id_generator.h"
henrike@webrtc.org28e20752013-07-10 00:45:36100
101namespace webrtc {
henrike@webrtc.org28e20752013-07-10 00:45:36102
Steve Anton75737c02017-11-06 18:37:17103// PeerConnection is the implementation of the PeerConnection object as defined
104// by the PeerConnectionInterface API surface.
105// The class currently is solely responsible for the following:
106// - Managing the session state machine (signaling state).
107// - Creating and initializing lower-level objects, like PortAllocator and
108// BaseChannels.
109// - Owning and managing the life cycle of the RtpSender/RtpReceiver and track
110// objects.
111// - Tracking the current and pending local/remote session descriptions.
112// The class currently is jointly responsible for the following:
113// - Parsing and interpreting SDP.
114// - Generating offers and answers based on the current state.
115// - The ICE state machine.
116// - Generating stats.
Steve Anton2d8609c2018-01-24 00:38:46117class PeerConnection : public PeerConnectionInternal,
Zhi Huang365381f2018-04-13 23:44:34118 public JsepTransportController::Observer,
henrike@webrtc.org28e20752013-07-10 00:45:36119 public sigslot::has_slots<> {
120 public:
Harald Alvestrand62166932020-10-26 08:30:41121 // Creates a PeerConnection and initializes it with the given values.
122 // If the initialization fails, the function releases the PeerConnection
123 // and returns nullptr.
124 //
125 // Note that the function takes ownership of dependencies, and will
126 // either use them or release them, whether it succeeds or fails.
Harald Alvestranda3dd7722020-11-27 08:05:42127 static RTCErrorOr<rtc::scoped_refptr<PeerConnection>> Create(
Harald Alvestrand62166932020-10-26 08:30:41128 rtc::scoped_refptr<ConnectionContext> context,
Harald Alvestrand4da4a872020-11-04 10:34:21129 const PeerConnectionFactoryInterface::Options& options,
Harald Alvestrand62166932020-10-26 08:30:41130 std::unique_ptr<RtcEventLog> event_log,
131 std::unique_ptr<Call> call,
deadbeef653b8e02015-11-11 20:55:10132 const PeerConnectionInterface::RTCConfiguration& configuration,
Benjamin Wrightcab588882018-05-02 22:12:47133 PeerConnectionDependencies dependencies);
deadbeef653b8e02015-11-11 20:55:10134
deadbeefa67696b2015-09-29 18:56:26135 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
136 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
137 bool AddStream(MediaStreamInterface* local_stream) override;
138 void RemoveStream(MediaStreamInterface* local_stream) override;
henrike@webrtc.org28e20752013-07-10 00:45:36139
Steve Anton2d6c76a2018-01-06 01:10:52140 RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
Steve Antonf9381f02017-12-14 18:23:57141 rtc::scoped_refptr<MediaStreamTrackInterface> track,
Seth Hampson845e8782018-03-02 19:34:10142 const std::vector<std::string>& stream_ids) override;
deadbeefe1f9d832016-01-14 23:35:42143 bool RemoveTrack(RtpSenderInterface* sender) override;
Steve Anton24db5732018-07-23 17:27:33144 RTCError RemoveTrackNew(
145 rtc::scoped_refptr<RtpSenderInterface> sender) override;
deadbeefe1f9d832016-01-14 23:35:42146
Steve Anton9158ef62017-11-27 21:01:52147 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
148 rtc::scoped_refptr<MediaStreamTrackInterface> track) override;
149 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
150 rtc::scoped_refptr<MediaStreamTrackInterface> track,
151 const RtpTransceiverInit& init) override;
152 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
153 cricket::MediaType media_type) override;
154 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
155 cricket::MediaType media_type,
156 const RtpTransceiverInit& init) override;
157
deadbeeffac06552015-11-25 19:26:01158 rtc::scoped_refptr<RtpSenderInterface> CreateSender(
deadbeefbd7d8f72015-12-19 00:58:44159 const std::string& kind,
160 const std::string& stream_id) override;
deadbeeffac06552015-11-25 19:26:01161
deadbeef70ab1a12015-09-28 23:53:55162 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
163 const override;
164 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
165 const override;
Steve Anton9158ef62017-11-27 21:01:52166 std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
167 const override;
deadbeef70ab1a12015-09-28 23:53:55168
deadbeefa67696b2015-09-29 18:56:26169 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
henrike@webrtc.org28e20752013-07-10 00:45:36170 const std::string& label,
deadbeefa67696b2015-09-29 18:56:26171 const DataChannelInit* config) override;
Henrik Boström1df1bf82018-03-20 12:24:20172 // WARNING: LEGACY. See peerconnectioninterface.h
deadbeefa67696b2015-09-29 18:56:26173 bool GetStats(StatsObserver* observer,
174 webrtc::MediaStreamTrackInterface* track,
175 StatsOutputLevel level) override;
Henrik Boström1df1bf82018-03-20 12:24:20176 // Spec-complaint GetStats(). See peerconnectioninterface.h
hbos74e1a4f2016-09-16 06:33:01177 void GetStats(RTCStatsCollectorCallback* callback) override;
Henrik Boström1df1bf82018-03-20 12:24:20178 void GetStats(
179 rtc::scoped_refptr<RtpSenderInterface> selector,
180 rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override;
181 void GetStats(
182 rtc::scoped_refptr<RtpReceiverInterface> selector,
183 rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override;
Harald Alvestrand89061872018-01-02 13:08:34184 void ClearStatsCache() override;
henrike@webrtc.org28e20752013-07-10 00:45:36185
deadbeefa67696b2015-09-29 18:56:26186 SignalingState signaling_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:36187
deadbeefa67696b2015-09-29 18:56:26188 IceConnectionState ice_connection_state() override;
Jonas Olsson12046902018-12-06 10:25:14189 IceConnectionState standardized_ice_connection_state() override;
Jonas Olsson635474e2018-10-18 13:58:17190 PeerConnectionState peer_connection_state() override;
deadbeefa67696b2015-09-29 18:56:26191 IceGatheringState ice_gathering_state() override;
Harald Alvestrand61f74d92020-03-02 10:20:00192 absl::optional<bool> can_trickle_ice_candidates() override;
henrike@webrtc.org28e20752013-07-10 00:45:36193
deadbeefa67696b2015-09-29 18:56:26194 const SessionDescriptionInterface* local_description() const override;
195 const SessionDescriptionInterface* remote_description() const override;
deadbeeffe4a8a42016-12-21 01:56:17196 const SessionDescriptionInterface* current_local_description() const override;
197 const SessionDescriptionInterface* current_remote_description()
198 const override;
199 const SessionDescriptionInterface* pending_local_description() const override;
200 const SessionDescriptionInterface* pending_remote_description()
201 const override;
henrike@webrtc.org28e20752013-07-10 00:45:36202
Henrik Boström79b69802019-07-18 09:16:56203 void RestartIce() override;
204
henrike@webrtc.org28e20752013-07-10 00:45:36205 // JSEP01
deadbeefa67696b2015-09-29 18:56:26206 void CreateOffer(CreateSessionDescriptionObserver* observer,
207 const RTCOfferAnswerOptions& options) override;
htaa2a49d92016-03-04 10:51:39208 void CreateAnswer(CreateSessionDescriptionObserver* observer,
209 const RTCOfferAnswerOptions& options) override;
Henrik Boström831ae4e2020-07-29 10:04:00210
211 void SetLocalDescription(
212 std::unique_ptr<SessionDescriptionInterface> desc,
213 rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
214 override;
215 void SetLocalDescription(
216 rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
217 override;
218 // TODO(https://crbug.com/webrtc/11798): Delete these methods in favor of the
219 // ones taking SetLocalDescriptionObserverInterface as argument.
deadbeefa67696b2015-09-29 18:56:26220 void SetLocalDescription(SetSessionDescriptionObserver* observer,
221 SessionDescriptionInterface* desc) override;
Henrik Boström4e196702019-10-30 09:35:50222 void SetLocalDescription(SetSessionDescriptionObserver* observer) override;
Henrik Boström831ae4e2020-07-29 10:04:00223
Henrik Boström31638672017-11-23 16:48:32224 void SetRemoteDescription(
225 std::unique_ptr<SessionDescriptionInterface> desc,
226 rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
227 override;
Henrik Boström831ae4e2020-07-29 10:04:00228 // TODO(https://crbug.com/webrtc/11798): Delete this methods in favor of the
229 // ones taking SetRemoteDescriptionObserverInterface as argument.
230 void SetRemoteDescription(SetSessionDescriptionObserver* observer,
231 SessionDescriptionInterface* desc) override;
232
deadbeef46c73892016-11-17 03:42:04233 PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
Niels Möller2579f0c2019-08-19 07:58:17234 RTCError SetConfiguration(
235 const PeerConnectionInterface::RTCConfiguration& configuration) override;
deadbeefa67696b2015-09-29 18:56:26236 bool AddIceCandidate(const IceCandidateInterface* candidate) override;
Henrik Boströmee6f4f62019-11-06 11:36:12237 void AddIceCandidate(std::unique_ptr<IceCandidateInterface> candidate,
238 std::function<void(RTCError)> callback) override;
Honghai Zhang7fb69db2016-03-14 18:59:18239 bool RemoveIceCandidates(
240 const std::vector<cricket::Candidate>& candidates) override;
henrike@webrtc.org28e20752013-07-10 00:45:36241
Niels Möller0c4f7be2018-05-07 12:01:37242 RTCError SetBitrate(const BitrateSettings& bitrate) override;
zstein4b979802017-06-02 21:37:37243
henrika5f6bf242017-11-01 10:06:56244 void SetAudioPlayout(bool playout) override;
245 void SetAudioRecording(bool recording) override;
246
Harald Alvestrandad88c882018-11-28 15:47:46247 rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
248 const std::string& mid) override;
Harald Alvestrand4a7b3ac2019-01-17 09:39:40249 rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMidInternal(
250 const std::string& mid);
Harald Alvestrandad88c882018-11-28 15:47:46251
Harald Alvestrandc85328f2019-02-28 06:51:00252 rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const override;
253
Henrik Boström4c1e7cc2020-06-11 10:26:53254 void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override;
255
Bjorn Tereliusde939432017-11-20 16:38:14256 bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
257 int64_t output_period_ms) override;
Niels Möllerf00ca1a2019-05-10 09:33:12258 bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override;
ivoc14d5dbe2016-07-04 14:06:55259 void StopRtcEventLog() override;
260
deadbeefa67696b2015-09-29 18:56:26261 void Close() override;
henrike@webrtc.org28e20752013-07-10 00:45:36262
Taylor Brandstetterc88fe702020-08-03 23:36:16263 rtc::Thread* signaling_thread() const final {
Harald Alvestranda39689c2020-10-15 08:34:31264 return context_->signaling_thread();
Taylor Brandstetterc88fe702020-08-03 23:36:16265 }
266
Steve Anton2d8609c2018-01-24 00:38:46267 // PeerConnectionInternal implementation.
Karl Wiberg4ae63472019-02-21 23:57:06268 rtc::Thread* network_thread() const final {
Harald Alvestranda39689c2020-10-15 08:34:31269 return context_->network_thread();
Steve Anton2d8609c2018-01-24 00:38:46270 }
Harald Alvestranda39689c2020-10-15 08:34:31271 rtc::Thread* worker_thread() const final { return context_->worker_thread(); }
deadbeefab9b2d12015-10-14 18:33:11272
Karl Wiberga58e1692019-03-26 12:33:43273 std::string session_id() const override {
274 RTC_DCHECK_RUN_ON(signaling_thread());
275 return session_id_;
276 }
Steve Anton75737c02017-11-06 18:37:17277
Steve Anton2d8609c2018-01-24 00:38:46278 bool initial_offerer() const override {
Karl Wiberg2cc368f2019-04-02 09:31:56279 RTC_DCHECK_RUN_ON(signaling_thread());
Zhi Huange830e682018-03-30 17:48:35280 return transport_controller_ && transport_controller_->initial_offerer();
Steve Anton2d8609c2018-01-24 00:38:46281 }
Steve Anton75737c02017-11-06 18:37:17282
Steve Anton2d8609c2018-01-24 00:38:46283 std::vector<
284 rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
Steve Antonb8867112018-02-13 18:07:54285 GetTransceiversInternal() const override {
Karl Wiberga58e1692019-03-26 12:33:43286 RTC_DCHECK_RUN_ON(signaling_thread());
Harald Alvestrande15fb152020-10-19 13:28:05287 return rtp_manager()->transceivers()->List();
Steve Anton2d8609c2018-01-24 00:38:46288 }
289
Taylor Brandstetter3a034e12020-07-09 22:32:34290 sigslot::signal1<RtpDataChannel*>& SignalRtpDataChannelCreated() override {
291 return data_channel_controller_.SignalRtpDataChannelCreated();
292 }
293
294 sigslot::signal1<SctpDataChannel*>& SignalSctpDataChannelCreated() override {
295 return data_channel_controller_.SignalSctpDataChannelCreated();
Steve Anton2d8609c2018-01-24 00:38:46296 }
297
298 cricket::RtpDataChannel* rtp_data_channel() const override {
Harald Alvestrand00cf34c2019-12-02 08:56:02299 return data_channel_controller_.rtp_data_channel();
Steve Anton978b8762017-09-29 19:15:02300 }
Steve Anton2d8609c2018-01-24 00:38:46301
Taylor Brandstetter3a034e12020-07-09 22:32:34302 std::vector<DataChannelStats> GetDataChannelStats() const override;
Steve Anton2d8609c2018-01-24 00:38:46303
Danil Chapovalov66cadcc2018-06-19 14:47:43304 absl::optional<std::string> sctp_transport_name() const override;
Steve Anton75737c02017-11-06 18:37:17305
Qingsi Wang72a43a12018-02-21 00:03:18306 cricket::CandidateStatsList GetPooledCandidateStats() const override;
Steve Anton5dfde182018-02-06 18:34:40307 std::map<std::string, std::string> GetTransportNamesByMid() const override;
308 std::map<std::string, cricket::TransportStats> GetTransportStatsByNames(
309 const std::set<std::string>& transport_names) override;
Steve Anton2d8609c2018-01-24 00:38:46310 Call::Stats GetCallStats() override;
Steve Anton75737c02017-11-06 18:37:17311
Steve Anton2d8609c2018-01-24 00:38:46312 bool GetLocalCertificate(
313 const std::string& transport_name,
314 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override;
Taylor Brandstetterc3928662018-02-23 21:04:51315 std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
Steve Anton2d8609c2018-01-24 00:38:46316 const std::string& transport_name) override;
317 bool IceRestartPending(const std::string& content_name) const override;
318 bool NeedsIceRestart(const std::string& content_name) const override;
319 bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override;
Steve Anton7464fca2018-01-19 19:10:37320
Harald Alvestrand05e4d082019-12-03 13:04:21321 // Functions needed by DataChannelController
322 void NoteDataAddedEvent() { NoteUsageEvent(UsageEvent::DATA_ADDED); }
323 // Returns the observer. Will crash on CHECK if the observer is removed.
324 PeerConnectionObserver* Observer() const;
325 bool IsClosed() const {
326 RTC_DCHECK_RUN_ON(signaling_thread());
Harald Alvestrand9cd199d2020-10-27 07:10:43327 return sdp_handler_->signaling_state() == PeerConnectionInterface::kClosed;
Harald Alvestrand05e4d082019-12-03 13:04:21328 }
329 // Get current SSL role used by SCTP's underlying transport.
330 bool GetSctpSslRole(rtc::SSLRole* role);
331 // Handler for the "channel closed" signal
Taylor Brandstetter3a034e12020-07-09 22:32:34332 void OnSctpDataChannelClosed(DataChannelInterface* channel);
Harald Alvestrand05e4d082019-12-03 13:04:21333
Henrik Boströme574a312020-08-25 08:20:11334 bool ShouldFireNegotiationNeededEvent(uint32_t event_id) override;
335
Harald Alvestrandcdcfab02020-09-28 13:02:07336 // Functions needed by SdpOfferAnswerHandler
337 StatsCollector* stats() {
338 RTC_DCHECK_RUN_ON(signaling_thread());
339 return stats_.get();
340 }
341 DataChannelController* data_channel_controller() {
342 RTC_DCHECK_RUN_ON(signaling_thread());
343 return &data_channel_controller_;
344 }
345 bool dtls_enabled() const {
346 RTC_DCHECK_RUN_ON(signaling_thread());
347 return dtls_enabled_;
348 }
349 const PeerConnectionInterface::RTCConfiguration* configuration() const {
350 RTC_DCHECK_RUN_ON(signaling_thread());
351 return &configuration_;
352 }
Harald Alvestranda474fbf2020-10-01 16:47:23353 absl::optional<std::string> sctp_mid() {
354 RTC_DCHECK_RUN_ON(signaling_thread());
355 return sctp_mid_s_;
356 }
Harald Alvestrand1090e442020-10-05 07:01:09357 PeerConnectionMessageHandler* message_handler() {
358 RTC_DCHECK_RUN_ON(signaling_thread());
359 return &message_handler_;
360 }
Harald Alvestrandcdcfab02020-09-28 13:02:07361
Harald Alvestrande15fb152020-10-19 13:28:05362 RtpTransmissionManager* rtp_manager() { return rtp_manager_.get(); }
363 const RtpTransmissionManager* rtp_manager() const {
364 return rtp_manager_.get();
365 }
Harald Alvestrand653429c2020-10-19 16:05:20366 cricket::ChannelManager* channel_manager() const;
367
368 JsepTransportController* transport_controller() {
369 return transport_controller_.get();
370 }
371 cricket::PortAllocator* port_allocator() { return port_allocator_.get(); }
372 Call* call_ptr() { return call_ptr_; }
Harald Alvestrand763f5a92020-10-22 10:39:40373
374 ConnectionContext* context() { return context_.get(); }
Harald Alvestrand4da4a872020-11-04 10:34:21375 const PeerConnectionFactoryInterface::Options* options() const {
376 return &options_;
377 }
Harald Alvestrand653429c2020-10-19 16:05:20378 cricket::DataChannelType data_channel_type() const;
379 void SetIceConnectionState(IceConnectionState new_state);
380 void NoteUsageEvent(UsageEvent event);
381
Tomas Gunnarsson8cb97062021-02-08 17:57:04382 // Asynchronously adds a remote candidate on the network thread.
383 void AddRemoteCandidate(const std::string& mid,
384 const cricket::Candidate& candidate);
385
Philipp Hancke844c7592021-01-18 10:25:31386 // Report the UMA metric SdpFormatReceived for the given remote description.
387 void ReportSdpFormatReceived(
388 const SessionDescriptionInterface& remote_description);
Harald Alvestrand653429c2020-10-19 16:05:20389
Philipp Hancke54b925c2021-01-28 08:56:39390 // Report the UMA metric BundleUsage for the given remote description.
391 void ReportSdpBundleUsage(
392 const SessionDescriptionInterface& remote_description);
393
Harald Alvestrand653429c2020-10-19 16:05:20394 // Returns true if the PeerConnection is configured to use Unified Plan
395 // semantics for creating offers/answers and setting local/remote
396 // descriptions. If this is true the RtpTransceiver API will also be available
397 // to the user. If this is false, Plan B semantics are assumed.
398 // TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once
399 // sufficient time has passed.
400 bool IsUnifiedPlan() const {
401 RTC_DCHECK_RUN_ON(signaling_thread());
Harald Alvestrand62166932020-10-26 08:30:41402 return is_unified_plan_;
Harald Alvestrand653429c2020-10-19 16:05:20403 }
404 bool ValidateBundleSettings(const cricket::SessionDescription* desc);
405
406 // Returns the MID for the data section associated with either the
407 // RtpDataChannel or SCTP data channel, if it has been set. If no data
408 // channels are configured this will return nullopt.
409 absl::optional<std::string> GetDataMid() const;
410
Tomas Gunnarsson92eebef2021-02-10 12:05:44411 void SetSctpDataMid(const std::string& mid);
412
413 void ResetSctpDataMid();
414
415 // Asynchronously calls SctpTransport::Start() on the network thread for
416 // |sctp_mid()| if set. Called as part of setting the local description.
417 void StartSctpTransport(int local_port,
418 int remote_port,
419 int max_message_size);
Harald Alvestrand653429c2020-10-19 16:05:20420
421 // Returns the CryptoOptions for this PeerConnection. This will always
422 // return the RTCConfiguration.crypto_options if set and will only default
423 // back to the PeerConnectionFactory settings if nothing was set.
424 CryptoOptions GetCryptoOptions();
425
426 // Internal implementation for AddTransceiver family of methods. If
427 // |fire_callback| is set, fires OnRenegotiationNeeded callback if successful.
428 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
429 cricket::MediaType media_type,
430 rtc::scoped_refptr<MediaStreamTrackInterface> track,
431 const RtpTransceiverInit& init,
432 bool fire_callback = true);
433
434 // Returns rtp transport, result can not be nullptr.
Tomas Gunnarsson92eebef2021-02-10 12:05:44435 RtpTransportInternal* GetRtpTransport(const std::string& mid);
Harald Alvestrand653429c2020-10-19 16:05:20436
437 // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by
438 // this session.
Tomas Gunnarsson3278a712021-03-30 15:23:42439 bool SrtpRequired() const;
Harald Alvestrand653429c2020-10-19 16:05:20440
441 void OnSentPacket_w(const rtc::SentPacket& sent_packet);
442
443 bool SetupDataChannelTransport_n(const std::string& mid)
444 RTC_RUN_ON(network_thread());
445 void TeardownDataChannelTransport_n() RTC_RUN_ON(network_thread());
446 cricket::ChannelInterface* GetChannel(const std::string& content_name);
Harald Alvestrande15fb152020-10-19 13:28:05447
Harald Alvestrand05e4d082019-12-03 13:04:21448 // Functions made public for testing.
Harald Alvestrand19793842018-06-25 10:03:50449 void ReturnHistogramVeryQuicklyForTesting() {
Karl Wibergf73f7d62019-04-08 13:36:53450 RTC_DCHECK_RUN_ON(signaling_thread());
Harald Alvestrand19793842018-06-25 10:03:50451 return_histogram_very_quickly_ = true;
452 }
Harald Alvestrand7a1c7f72018-08-01 08:50:16453 void RequestUsagePatternReportForTesting();
Harald Alvestrand19793842018-06-25 10:03:50454
henrike@webrtc.org28e20752013-07-10 00:45:36455 protected:
Harald Alvestrand62166932020-10-26 08:30:41456 // Available for rtc::scoped_refptr creation
Harald Alvestrand4da4a872020-11-04 10:34:21457 PeerConnection(rtc::scoped_refptr<ConnectionContext> context,
458 const PeerConnectionFactoryInterface::Options& options,
459 bool is_unified_plan,
460 std::unique_ptr<RtcEventLog> event_log,
461 std::unique_ptr<Call> call,
Tommic3257d02021-02-10 17:40:08462 PeerConnectionDependencies& dependencies,
463 bool dtls_enabled);
Harald Alvestrand62166932020-10-26 08:30:41464
deadbeefa67696b2015-09-29 18:56:26465 ~PeerConnection() override;
henrike@webrtc.org28e20752013-07-10 00:45:36466
467 private:
Harald Alvestranda3dd7722020-11-27 08:05:42468 RTCError Initialize(
Harald Alvestrand62166932020-10-26 08:30:41469 const PeerConnectionInterface::RTCConfiguration& configuration,
470 PeerConnectionDependencies dependencies);
Tommic3257d02021-02-10 17:40:08471 void InitializeTransportController_n(
472 const RTCConfiguration& configuration,
473 const PeerConnectionDependencies& dependencies)
474 RTC_RUN_ON(network_thread());
Harald Alvestrand62166932020-10-26 08:30:41475
Steve Antonf9381f02017-12-14 18:23:57476 rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
Karl Wiberga58e1692019-03-26 12:33:43477 FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender)
478 RTC_RUN_ON(signaling_thread());
Steve Antonf9381f02017-12-14 18:23:57479
Jonas Olsson635474e2018-10-18 13:58:17480 void SetStandardizedIceConnectionState(
Karl Wiberg744310f2019-02-14 09:18:56481 PeerConnectionInterface::IceConnectionState new_state)
482 RTC_RUN_ON(signaling_thread());
Jonas Olsson635474e2018-10-18 13:58:17483 void SetConnectionState(
Karl Wiberg744310f2019-02-14 09:18:56484 PeerConnectionInterface::PeerConnectionState new_state)
485 RTC_RUN_ON(signaling_thread());
Jonas Olsson635474e2018-10-18 13:58:17486
Eldar Relloda13ea22019-06-01 09:23:43487 // Called any time the IceGatheringState changes.
Karl Wiberg744310f2019-02-14 09:18:56488 void OnIceGatheringChange(IceGatheringState new_state)
489 RTC_RUN_ON(signaling_thread());
Steve Antonba818672017-11-06 18:21:57490 // New ICE candidate has been gathered.
Karl Wiberg744310f2019-02-14 09:18:56491 void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate)
492 RTC_RUN_ON(signaling_thread());
Eldar Relloda13ea22019-06-01 09:23:43493 // Gathering of an ICE candidate failed.
Eldar Rello0095d372019-12-02 20:22:07494 void OnIceCandidateError(const std::string& address,
495 int port,
Eldar Relloda13ea22019-06-01 09:23:43496 const std::string& url,
497 int error_code,
498 const std::string& error_text)
499 RTC_RUN_ON(signaling_thread());
Steve Antonba818672017-11-06 18:21:57500 // Some local ICE candidates have been removed.
Karl Wiberg744310f2019-02-14 09:18:56501 void OnIceCandidatesRemoved(const std::vector<cricket::Candidate>& candidates)
502 RTC_RUN_ON(signaling_thread());
henrike@webrtc.org28e20752013-07-10 00:45:36503
Alex Drake00c7ecf2019-08-06 17:54:47504 void OnSelectedCandidatePairChanged(
505 const cricket::CandidatePairChangeEvent& event)
506 RTC_RUN_ON(signaling_thread());
507
Steve Anton52d86772018-02-20 23:48:12508 void OnNegotiationNeeded();
509
deadbeefab9b2d12015-10-14 18:33:11510 // Returns the specified SCTP DataChannel in sctp_data_channels_,
511 // or nullptr if not found.
Taylor Brandstetter3a034e12020-07-09 22:32:34512 SctpDataChannel* FindDataChannelBySid(int sid) const
Karl Wiberg85a4a932019-03-22 14:29:58513 RTC_RUN_ON(signaling_thread());
deadbeefab9b2d12015-10-14 18:33:11514
Taylor Brandstettera1c30352016-05-13 15:15:11515 // Called when first configuring the port allocator.
Karl Wibergfb3be392019-03-22 13:13:22516 struct InitializePortAllocatorResult {
517 bool enable_ipv6;
518 };
519 InitializePortAllocatorResult InitializePortAllocator_n(
Harald Alvestrandb2a74782018-06-28 11:54:07520 const cricket::ServerAddresses& stun_servers,
521 const std::vector<cricket::RelayServerConfig>& turn_servers,
522 const RTCConfiguration& configuration);
deadbeef293e9262017-01-11 20:28:30523 // Called when SetConfiguration is called to apply the supported subset
524 // of the configuration on the network thread.
525 bool ReconfigurePortAllocator_n(
526 const cricket::ServerAddresses& stun_servers,
527 const std::vector<cricket::RelayServerConfig>& turn_servers,
528 IceTransportsType type,
529 int candidate_pool_size,
Honghai Zhangf8998cf2019-10-14 18:27:50530 PortPrunePolicy turn_port_prune_policy,
Qingsi Wangdb53f8e2018-02-20 22:45:49531 webrtc::TurnCustomizer* turn_customizer,
Karl Wiberg739506e2019-04-03 09:37:28532 absl::optional<int> stun_candidate_keepalive_interval,
533 bool have_local_description);
Taylor Brandstettera1c30352016-05-13 15:15:11534
Elad Alon99c3fe52017-10-13 14:29:40535 // Starts output of an RTC event log to the given output object.
ivoc14d5dbe2016-07-04 14:06:55536 // This function should only be called from the worker thread.
Bjorn Tereliusde939432017-11-20 16:38:14537 bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output,
538 int64_t output_period_ms);
Elad Alon99c3fe52017-10-13 14:29:40539
Elad Alonacb24172017-10-06 12:32:13540 // Stops recording an RTC event log.
ivoc14d5dbe2016-07-04 14:06:55541 // This function should only be called from the worker thread.
542 void StopRtcEventLog_w();
543
Steve Anton75737c02017-11-06 18:37:17544 // Returns true and the TransportInfo of the given |content_name|
545 // from |description|. Returns false if it's not available.
546 static bool GetTransportDescription(
547 const cricket::SessionDescription* description,
548 const std::string& content_name,
549 cricket::TransportDescription* info);
550
Steve Anton75737c02017-11-06 18:37:17551 // Returns the media index for a local ice candidate given the content name.
552 // Returns false if the local session description does not have a media
553 // content called |content_name|.
554 bool GetLocalCandidateMediaIndex(const std::string& content_name,
Karl Wiberg739506e2019-04-03 09:37:28555 int* sdp_mline_index)
556 RTC_RUN_ON(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17557
Zhi Huange830e682018-03-30 17:48:35558 // JsepTransportController signal handlers.
Karl Wiberg744310f2019-02-14 09:18:56559 void OnTransportControllerConnectionState(cricket::IceConnectionState state)
560 RTC_RUN_ON(signaling_thread());
561 void OnTransportControllerGatheringState(cricket::IceGatheringState state)
562 RTC_RUN_ON(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17563 void OnTransportControllerCandidatesGathered(
564 const std::string& transport_name,
Karl Wiberg744310f2019-02-14 09:18:56565 const std::vector<cricket::Candidate>& candidates)
566 RTC_RUN_ON(signaling_thread());
Eldar Relloda13ea22019-06-01 09:23:43567 void OnTransportControllerCandidateError(
568 const cricket::IceCandidateErrorEvent& event)
569 RTC_RUN_ON(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17570 void OnTransportControllerCandidatesRemoved(
Karl Wiberg744310f2019-02-14 09:18:56571 const std::vector<cricket::Candidate>& candidates)
572 RTC_RUN_ON(signaling_thread());
Alex Drake00c7ecf2019-08-06 17:54:47573 void OnTransportControllerCandidateChanged(
574 const cricket::CandidatePairChangeEvent& event)
575 RTC_RUN_ON(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17576 void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error);
577
Steve Anton75737c02017-11-06 18:37:17578 // Invoked when TransportController connection completion is signaled.
579 // Reports stats for all transports in use.
Karl Wiberga58e1692019-03-26 12:33:43580 void ReportTransportStats() RTC_RUN_ON(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17581
582 // Gather the usage of IPv4/IPv6 as best connection.
Tommic3257d02021-02-10 17:40:08583 static void ReportBestConnectionState(const cricket::TransportStats& stats);
Steve Anton75737c02017-11-06 18:37:17584
Tommic3257d02021-02-10 17:40:08585 static void ReportNegotiatedCiphers(
586 bool dtls_enabled,
587 const cricket::TransportStats& stats,
588 const std::set<cricket::MediaType>& media_types);
Qingsi Wang1ba5dec2019-08-19 18:57:17589 void ReportIceCandidateCollected(const cricket::Candidate& candidate)
590 RTC_RUN_ON(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17591
Karl Wiberg744310f2019-02-14 09:18:56592 void ReportUsagePattern() const RTC_RUN_ON(signaling_thread());
Harald Alvestrand8ebba742018-05-31 12:00:34593
Tomas Gunnarsson8cb97062021-02-08 17:57:04594 void ReportRemoteIceCandidateAdded(const cricket::Candidate& candidate);
595
Zhi Huang365381f2018-04-13 23:44:34596 // JsepTransportController::Observer override.
Taylor Brandstettercbaa2542018-04-16 23:42:14597 //
598 // Called by |transport_controller_| when processing transport information
599 // from a session description, and the mapping from m= sections to transports
600 // changed (as a result of BUNDLE negotiation, or m= sections being
601 // rejected).
Bjorn A Mellemb689af42019-08-21 17:44:59602 bool OnTransportChanged(
603 const std::string& mid,
604 RtpTransportInternal* rtp_transport,
605 rtc::scoped_refptr<DtlsTransport> dtls_transport,
Bjorn A Mellembc3eebc2019-09-23 21:53:54606 DataChannelTransportInterface* data_channel_transport) override;
Zhi Huange830e682018-03-30 17:48:35607
Tomas Gunnarsson1e40a0c2020-09-28 08:39:31608 std::function<void(const rtc::CopyOnWriteBuffer& packet,
609 int64_t packet_time_us)>
610 InitializeRtcpCallback();
611
Harald Alvestranda39689c2020-10-15 08:34:31612 const rtc::scoped_refptr<ConnectionContext> context_;
Harald Alvestrand4da4a872020-11-04 10:34:21613 const PeerConnectionFactoryInterface::Options options_;
Karl Wiberg744310f2019-02-14 09:18:56614 PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) =
615 nullptr;
terelius33860252017-05-13 06:37:18616
Harald Alvestrand62166932020-10-26 08:30:41617 const bool is_unified_plan_;
618
terelius33860252017-05-13 06:37:18619 // The EventLog needs to outlive |call_| (and any other object that uses it).
Karl Wibergb03ab712019-02-14 10:59:57620 std::unique_ptr<RtcEventLog> event_log_ RTC_GUARDED_BY(worker_thread());
621
622 // Points to the same thing as `event_log_`. Since it's const, we may read the
623 // pointer (but not touch the object) from any thread.
624 RtcEventLog* const event_log_ptr_ RTC_PT_GUARDED_BY(worker_thread());
terelius33860252017-05-13 06:37:18625
Karl Wiberg8d2e2282019-02-17 12:00:07626 IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) =
627 kIceConnectionNew;
628 PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_
629 RTC_GUARDED_BY(signaling_thread()) = kIceConnectionNew;
630 PeerConnectionInterface::PeerConnectionState connection_state_
631 RTC_GUARDED_BY(signaling_thread()) = PeerConnectionState::kNew;
Jonas Olsson635474e2018-10-18 13:58:17632
Karl Wiberg8d2e2282019-02-17 12:00:07633 IceGatheringState ice_gathering_state_ RTC_GUARDED_BY(signaling_thread()) =
634 kIceGatheringNew;
Karl Wiberg5966c502019-02-21 22:55:09635 PeerConnectionInterface::RTCConfiguration configuration_
636 RTC_GUARDED_BY(signaling_thread());
637
Mirko Bonadei5a40b372021-03-30 07:49:41638 // TODO(zstein): |async_resolver_factory_| can currently be nullptr if it
639 // is not injected. It should be required once chromium supplies it.
640 // This member variable is only used by JsepTransportController so we should
641 // consider moving ownership to there.
642 const std::unique_ptr<AsyncResolverFactory> async_resolver_factory_;
Karl Wibergfb3be392019-03-22 13:13:22643 std::unique_ptr<cricket::PortAllocator>
644 port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both
645 // signaling and network thread.
Harald Alvestrandfd9a8f82020-10-26 14:17:02646 const std::unique_ptr<webrtc::IceTransportFactory>
Qingsi Wang25ec8882019-11-15 20:33:05647 ice_transport_factory_; // TODO(bugs.webrtc.org/9987): Accessed on the
648 // signaling thread but the underlying raw
649 // pointer is given to
650 // |jsep_transport_controller_| and used on the
651 // network thread.
Harald Alvestrandf598e492020-11-04 05:54:10652 const std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier_
653 RTC_GUARDED_BY(network_thread());
deadbeefab9b2d12015-10-14 18:33:11654
Karl Wibergac025892019-03-26 12:08:37655 // The unique_ptr belongs to the worker thread, but the Call object manages
656 // its own thread safety.
Karl Wiberg6cab5c82019-03-26 08:57:01657 std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread());
Tomas Gunnarsson92eebef2021-02-10 12:05:44658 ScopedTaskSafety signaling_thread_safety_;
659 rtc::scoped_refptr<PendingTaskSafetyFlag> network_thread_safety_;
Tommic3257d02021-02-10 17:40:08660 rtc::scoped_refptr<PendingTaskSafetyFlag> worker_thread_safety_;
Sebastian Jansson1b83a9e2019-09-18 16:22:12661
Karl Wiberg6cab5c82019-03-26 08:57:01662 // Points to the same thing as `call_`. Since it's const, we may read the
Karl Wibergac025892019-03-26 12:08:37663 // pointer from any thread.
Tomas Gunnarsson1e40a0c2020-09-28 08:39:31664 // TODO(bugs.webrtc.org/11992): Remove this workaround (and potential dangling
665 // pointer).
Karl Wibergac025892019-03-26 12:08:37666 Call* const call_ptr_;
Karl Wiberg6cab5c82019-03-26 08:57:01667
668 std::unique_ptr<StatsCollector> stats_
669 RTC_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_
670 rtc::scoped_refptr<RTCStatsCollector> stats_collector_
671 RTC_GUARDED_BY(signaling_thread());
Karl Wiberg2cc368f2019-04-02 09:31:56672
Karl Wiberga58e1692019-03-26 12:33:43673 std::string session_id_ RTC_GUARDED_BY(signaling_thread());
Steve Anton75737c02017-11-06 18:37:17674
Karl Wiberg2cc368f2019-04-02 09:31:56675 std::unique_ptr<JsepTransportController>
676 transport_controller_; // TODO(bugs.webrtc.org/9987): Accessed on both
677 // signaling and network thread.
Steve Anton75737c02017-11-06 18:37:17678
Zhi Huange830e682018-03-30 17:48:35679 // |sctp_mid_| is the content name (MID) in SDP.
Bjorn A Mellemb689af42019-08-21 17:44:59680 // Note: this is used as the data channel MID by both SCTP and data channel
681 // transports. It is set when either transport is initialized and unset when
682 // both transports are deleted.
Harald Alvestrand7a829a82020-02-12 06:38:21683 // There is one copy on the signaling thread and another copy on the
684 // networking thread. Changes are always initiated from the signaling
685 // thread, but applied first on the networking thread via an invoke().
686 absl::optional<std::string> sctp_mid_s_ RTC_GUARDED_BY(signaling_thread());
687 absl::optional<std::string> sctp_mid_n_ RTC_GUARDED_BY(network_thread());
Tomas Gunnarsson92eebef2021-02-10 12:05:44688 std::string sctp_transport_name_s_ RTC_GUARDED_BY(signaling_thread());
Karl Wiberg2cc368f2019-04-02 09:31:56689
Harald Alvestrand9cd199d2020-10-27 07:10:43690 // The machinery for handling offers and answers. Const after initialization.
691 std::unique_ptr<SdpOfferAnswerHandler> sdp_handler_
692 RTC_GUARDED_BY(signaling_thread());
Bjorn Mellem175aa2e2018-11-08 19:23:22693
Tommic3257d02021-02-10 17:40:08694 const bool dtls_enabled_;
Steve Anton75737c02017-11-06 18:37:17695
Harald Alvestrand44d0dff2020-10-09 05:43:53696 UsagePattern usage_pattern_ RTC_GUARDED_BY(signaling_thread());
Karl Wibergf73f7d62019-04-08 13:36:53697 bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) =
698 false;
Amit Hilbuchbcd39d42019-01-26 01:13:56699
Harald Alvestrand00cf34c2019-12-02 08:56:02700 DataChannelController data_channel_controller_;
Harald Alvestrand1090e442020-10-05 07:01:09701
702 // Machinery for handling messages posted to oneself
703 PeerConnectionMessageHandler message_handler_;
Harald Alvestrande15fb152020-10-19 13:28:05704
705 // Administration of senders, receivers and transceivers
706 // Accessed on both signaling and network thread. Const after Initialize().
707 std::unique_ptr<RtpTransmissionManager> rtp_manager_;
Lahiru Ginnaliya Gamathige70f9e242021-01-28 07:32:46708
709 rtc::WeakPtrFactory<PeerConnection> weak_factory_;
Philipp Hanckecd0373f2021-02-24 10:04:30710
711 // Did the connectionState ever change to `connected`?
712 // Used to gather metrics only the first such state change.
713 bool was_ever_connected_ RTC_GUARDED_BY(signaling_thread()) = false;
henrike@webrtc.org28e20752013-07-10 00:45:36714};
715
716} // namespace webrtc
717
Steve Anton10542f22019-01-11 17:11:00718#endif // PC_PEER_CONNECTION_H_