henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #ifndef PC_PEER_CONNECTION_H_ |
| 12 | #define PC_PEER_CONNECTION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 13 | |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 14 | #include <stdint.h> |
Artem Titov | d15a575 | 2021-02-10 13:31:24 | [diff] [blame] | 15 | |
Tomas Gunnarsson | 1e40a0c | 2020-09-28 08:39:31 | [diff] [blame] | 16 | #include <functional> |
perkj | d61bf80 | 2016-03-24 10:16:19 | [diff] [blame] | 17 | #include <map> |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 18 | #include <memory> |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 19 | #include <set> |
| 20 | #include <string> |
perkj | d61bf80 | 2016-03-24 10:16:19 | [diff] [blame] | 21 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 22 | |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 23 | #include "absl/types/optional.h" |
| 24 | #include "api/adaptation/resource.h" |
Harald Alvestrand | 0ccfbd2 | 2021-04-08 07:25:04 | [diff] [blame] | 25 | #include "api/async_dns_resolver.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 26 | #include "api/candidate.h" |
| 27 | #include "api/crypto/crypto_options.h" |
| 28 | #include "api/data_channel_interface.h" |
| 29 | #include "api/dtls_transport_interface.h" |
Danil Chapovalov | 3bdb49b | 2023-11-30 07:59:39 | [diff] [blame] | 30 | #include "api/environment/environment.h" |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 31 | #include "api/field_trials_view.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 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" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 36 | #include "api/peer_connection_interface.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 37 | #include "api/rtc_error.h" |
| 38 | #include "api/rtc_event_log/rtc_event_log.h" |
| 39 | #include "api/rtc_event_log_output.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 40 | #include "api/rtp_receiver_interface.h" |
| 41 | #include "api/rtp_sender_interface.h" |
| 42 | #include "api/rtp_transceiver_interface.h" |
| 43 | #include "api/scoped_refptr.h" |
| 44 | #include "api/sctp_transport_interface.h" |
Artem Titov | d15a575 | 2021-02-10 13:31:24 | [diff] [blame] | 45 | #include "api/sequence_checker.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 46 | #include "api/set_local_description_observer_interface.h" |
| 47 | #include "api/set_remote_description_observer_interface.h" |
| 48 | #include "api/stats/rtc_stats_collector_callback.h" |
Artem Titov | c374d11 | 2022-06-16 19:27:45 | [diff] [blame] | 49 | #include "api/task_queue/pending_task_safety_flag.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 50 | #include "api/transport/bitrate_settings.h" |
Niels Möller | 65f17ca | 2019-09-12 11:59:36 | [diff] [blame] | 51 | #include "api/transport/data_channel_transport_interface.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 52 | #include "api/transport/enums.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 53 | #include "api/turn_customizer.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 54 | #include "call/call.h" |
Per K | e1e94ad | 2023-03-30 14:53:59 | [diff] [blame] | 55 | #include "modules/rtp_rtcp/source/rtp_packet_received.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 56 | #include "p2p/base/ice_transport_internal.h" |
| 57 | #include "p2p/base/port.h" |
| 58 | #include "p2p/base/port_allocator.h" |
| 59 | #include "p2p/base/transport_description.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 60 | #include "pc/channel_interface.h" |
Harald Alvestrand | a39689c | 2020-10-15 08:34:31 | [diff] [blame] | 61 | #include "pc/connection_context.h" |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 62 | #include "pc/data_channel_controller.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 63 | #include "pc/data_channel_utils.h" |
| 64 | #include "pc/dtls_transport.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 65 | #include "pc/jsep_transport_controller.h" |
Henrik Boström | f785989 | 2022-07-04 12:36:37 | [diff] [blame] | 66 | #include "pc/legacy_stats_collector.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 67 | #include "pc/peer_connection_internal.h" |
Harald Alvestrand | 1090e44 | 2020-10-05 07:01:09 | [diff] [blame] | 68 | #include "pc/peer_connection_message_handler.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 69 | #include "pc/rtc_stats_collector.h" |
| 70 | #include "pc/rtp_transceiver.h" |
Harald Alvestrand | e15fb15 | 2020-10-19 13:28:05 | [diff] [blame] | 71 | #include "pc/rtp_transmission_manager.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 72 | #include "pc/rtp_transport_internal.h" |
| 73 | #include "pc/sctp_data_channel.h" |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 74 | #include "pc/sdp_offer_answer.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 75 | #include "pc/session_description.h" |
Harald Alvestrand | 38b768c | 2020-09-29 11:54:05 | [diff] [blame] | 76 | #include "pc/transceiver_list.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 77 | #include "pc/transport_stats.h" |
Harald Alvestrand | 44d0dff | 2020-10-09 05:43:53 | [diff] [blame] | 78 | #include "pc/usage_pattern.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 79 | #include "rtc_base/checks.h" |
| 80 | #include "rtc_base/copy_on_write_buffer.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 81 | #include "rtc_base/rtc_certificate.h" |
| 82 | #include "rtc_base/ssl_certificate.h" |
| 83 | #include "rtc_base/ssl_stream_adapter.h" |
Harald Alvestrand | 1f7eab6 | 2020-10-18 16:51:47 | [diff] [blame] | 84 | #include "rtc_base/thread.h" |
| 85 | #include "rtc_base/thread_annotations.h" |
Harald Alvestrand | 8546666 | 2021-04-19 21:21:36 | [diff] [blame] | 86 | #include "rtc_base/weak_ptr.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 87 | |
| 88 | namespace webrtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 89 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 90 | // PeerConnection is the implementation of the PeerConnection object as defined |
| 91 | // by the PeerConnectionInterface API surface. |
| 92 | // The class currently is solely responsible for the following: |
| 93 | // - Managing the session state machine (signaling state). |
| 94 | // - Creating and initializing lower-level objects, like PortAllocator and |
| 95 | // BaseChannels. |
| 96 | // - Owning and managing the life cycle of the RtpSender/RtpReceiver and track |
| 97 | // objects. |
| 98 | // - Tracking the current and pending local/remote session descriptions. |
| 99 | // The class currently is jointly responsible for the following: |
| 100 | // - Parsing and interpreting SDP. |
| 101 | // - Generating offers and answers based on the current state. |
| 102 | // - The ICE state machine. |
| 103 | // - Generating stats. |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 104 | class PeerConnection : public PeerConnectionInternal, |
Harald Alvestrand | 5b84f38 | 2022-02-08 10:49:09 | [diff] [blame] | 105 | public JsepTransportController::Observer { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 106 | public: |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 107 | // Creates a PeerConnection and initializes it with the given values. |
| 108 | // If the initialization fails, the function releases the PeerConnection |
| 109 | // and returns nullptr. |
| 110 | // |
| 111 | // Note that the function takes ownership of dependencies, and will |
| 112 | // either use them or release them, whether it succeeds or fails. |
Harald Alvestrand | a3dd772 | 2020-11-27 08:05:42 | [diff] [blame] | 113 | static RTCErrorOr<rtc::scoped_refptr<PeerConnection>> Create( |
Danil Chapovalov | 3bdb49b | 2023-11-30 07:59:39 | [diff] [blame] | 114 | const Environment& env, |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 115 | rtc::scoped_refptr<ConnectionContext> context, |
Harald Alvestrand | 4da4a87 | 2020-11-04 10:34:21 | [diff] [blame] | 116 | const PeerConnectionFactoryInterface::Options& options, |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 117 | std::unique_ptr<Call> call, |
deadbeef | 653b8e0 | 2015-11-11 20:55:10 | [diff] [blame] | 118 | const PeerConnectionInterface::RTCConfiguration& configuration, |
Benjamin Wright | cab58888 | 2018-05-02 22:12:47 | [diff] [blame] | 119 | PeerConnectionDependencies dependencies); |
deadbeef | 653b8e0 | 2015-11-11 20:55:10 | [diff] [blame] | 120 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 121 | rtc::scoped_refptr<StreamCollectionInterface> local_streams() override; |
| 122 | rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override; |
| 123 | bool AddStream(MediaStreamInterface* local_stream) override; |
| 124 | void RemoveStream(MediaStreamInterface* local_stream) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 125 | |
Steve Anton | 2d6c76a | 2018-01-06 01:10:52 | [diff] [blame] | 126 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack( |
Steve Anton | f9381f0 | 2017-12-14 18:23:57 | [diff] [blame] | 127 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Seth Hampson | 845e878 | 2018-03-02 19:34:10 | [diff] [blame] | 128 | const std::vector<std::string>& stream_ids) override; |
Jonas Oreland | 4b2a106 | 2022-10-19 07:24:42 | [diff] [blame] | 129 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack( |
| 130 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 131 | const std::vector<std::string>& stream_ids, |
| 132 | const std::vector<RtpEncodingParameters>& init_send_encodings) override; |
| 133 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack( |
| 134 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 135 | const std::vector<std::string>& stream_ids, |
| 136 | const std::vector<RtpEncodingParameters>* init_send_encodings); |
Harald Alvestrand | 09a0d01 | 2022-01-04 19:42:07 | [diff] [blame] | 137 | RTCError RemoveTrackOrError( |
Steve Anton | 24db573 | 2018-07-23 17:27:33 | [diff] [blame] | 138 | rtc::scoped_refptr<RtpSenderInterface> sender) override; |
deadbeef | e1f9d83 | 2016-01-14 23:35:42 | [diff] [blame] | 139 | |
Steve Anton | 9158ef6 | 2017-11-27 21:01:52 | [diff] [blame] | 140 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 141 | rtc::scoped_refptr<MediaStreamTrackInterface> track) override; |
| 142 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 143 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 144 | const RtpTransceiverInit& init) override; |
| 145 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 146 | cricket::MediaType media_type) override; |
| 147 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 148 | cricket::MediaType media_type, |
| 149 | const RtpTransceiverInit& init) override; |
| 150 | |
deadbeef | fac0655 | 2015-11-25 19:26:01 | [diff] [blame] | 151 | rtc::scoped_refptr<RtpSenderInterface> CreateSender( |
deadbeef | bd7d8f7 | 2015-12-19 00:58:44 | [diff] [blame] | 152 | const std::string& kind, |
| 153 | const std::string& stream_id) override; |
deadbeef | fac0655 | 2015-11-25 19:26:01 | [diff] [blame] | 154 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 155 | std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() |
| 156 | const override; |
| 157 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers() |
| 158 | const override; |
Steve Anton | 9158ef6 | 2017-11-27 21:01:52 | [diff] [blame] | 159 | std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers() |
| 160 | const override; |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 161 | |
Harald Alvestrand | a9af50f | 2021-05-21 13:33:51 | [diff] [blame] | 162 | RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>> CreateDataChannelOrError( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 163 | const std::string& label, |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 164 | const DataChannelInit* config) override; |
Henrik Boström | 1df1bf8 | 2018-03-20 12:24:20 | [diff] [blame] | 165 | // WARNING: LEGACY. See peerconnectioninterface.h |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 166 | bool GetStats(StatsObserver* observer, |
Harald Alvestrand | a654437 | 2023-11-13 09:33:56 | [diff] [blame] | 167 | MediaStreamTrackInterface* track, |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 168 | StatsOutputLevel level) override; |
Henrik Boström | 1df1bf8 | 2018-03-20 12:24:20 | [diff] [blame] | 169 | // Spec-complaint GetStats(). See peerconnectioninterface.h |
hbos | 74e1a4f | 2016-09-16 06:33:01 | [diff] [blame] | 170 | void GetStats(RTCStatsCollectorCallback* callback) override; |
Henrik Boström | 1df1bf8 | 2018-03-20 12:24:20 | [diff] [blame] | 171 | void GetStats( |
| 172 | rtc::scoped_refptr<RtpSenderInterface> selector, |
| 173 | rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override; |
| 174 | void GetStats( |
| 175 | rtc::scoped_refptr<RtpReceiverInterface> selector, |
| 176 | rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override; |
Harald Alvestrand | 8906187 | 2018-01-02 13:08:34 | [diff] [blame] | 177 | void ClearStatsCache() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 178 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 179 | SignalingState signaling_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 180 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 181 | IceConnectionState ice_connection_state() override; |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 182 | IceConnectionState ice_connection_state_internal() override { |
| 183 | return ice_connection_state(); |
| 184 | } |
Jonas Olsson | 1204690 | 2018-12-06 10:25:14 | [diff] [blame] | 185 | IceConnectionState standardized_ice_connection_state() override; |
Jonas Olsson | 635474e | 2018-10-18 13:58:17 | [diff] [blame] | 186 | PeerConnectionState peer_connection_state() override; |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 187 | IceGatheringState ice_gathering_state() override; |
Harald Alvestrand | 61f74d9 | 2020-03-02 10:20:00 | [diff] [blame] | 188 | absl::optional<bool> can_trickle_ice_candidates() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 189 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 190 | const SessionDescriptionInterface* local_description() const override; |
| 191 | const SessionDescriptionInterface* remote_description() const override; |
deadbeef | fe4a8a4 | 2016-12-21 01:56:17 | [diff] [blame] | 192 | const SessionDescriptionInterface* current_local_description() const override; |
| 193 | const SessionDescriptionInterface* current_remote_description() |
| 194 | const override; |
| 195 | const SessionDescriptionInterface* pending_local_description() const override; |
| 196 | const SessionDescriptionInterface* pending_remote_description() |
| 197 | const override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 198 | |
Henrik Boström | 79b6980 | 2019-07-18 09:16:56 | [diff] [blame] | 199 | void RestartIce() override; |
| 200 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 201 | // JSEP01 |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 202 | void CreateOffer(CreateSessionDescriptionObserver* observer, |
| 203 | const RTCOfferAnswerOptions& options) override; |
hta | a2a49d9 | 2016-03-04 10:51:39 | [diff] [blame] | 204 | void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 205 | const RTCOfferAnswerOptions& options) override; |
Henrik Boström | 831ae4e | 2020-07-29 10:04:00 | [diff] [blame] | 206 | |
| 207 | void SetLocalDescription( |
| 208 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 209 | rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer) |
| 210 | override; |
| 211 | void SetLocalDescription( |
| 212 | rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer) |
| 213 | override; |
| 214 | // TODO(https://crbug.com/webrtc/11798): Delete these methods in favor of the |
| 215 | // ones taking SetLocalDescriptionObserverInterface as argument. |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 216 | void SetLocalDescription(SetSessionDescriptionObserver* observer, |
| 217 | SessionDescriptionInterface* desc) override; |
Henrik Boström | 4e19670 | 2019-10-30 09:35:50 | [diff] [blame] | 218 | void SetLocalDescription(SetSessionDescriptionObserver* observer) override; |
Henrik Boström | 831ae4e | 2020-07-29 10:04:00 | [diff] [blame] | 219 | |
Henrik Boström | 3163867 | 2017-11-23 16:48:32 | [diff] [blame] | 220 | void SetRemoteDescription( |
| 221 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 222 | rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) |
| 223 | override; |
Henrik Boström | 831ae4e | 2020-07-29 10:04:00 | [diff] [blame] | 224 | // TODO(https://crbug.com/webrtc/11798): Delete this methods in favor of the |
| 225 | // ones taking SetRemoteDescriptionObserverInterface as argument. |
| 226 | void SetRemoteDescription(SetSessionDescriptionObserver* observer, |
| 227 | SessionDescriptionInterface* desc) override; |
| 228 | |
deadbeef | 46c7389 | 2016-11-17 03:42:04 | [diff] [blame] | 229 | PeerConnectionInterface::RTCConfiguration GetConfiguration() override; |
Niels Möller | 2579f0c | 2019-08-19 07:58:17 | [diff] [blame] | 230 | RTCError SetConfiguration( |
| 231 | const PeerConnectionInterface::RTCConfiguration& configuration) override; |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 232 | bool AddIceCandidate(const IceCandidateInterface* candidate) override; |
Henrik Boström | ee6f4f6 | 2019-11-06 11:36:12 | [diff] [blame] | 233 | void AddIceCandidate(std::unique_ptr<IceCandidateInterface> candidate, |
| 234 | std::function<void(RTCError)> callback) override; |
Honghai Zhang | 7fb69db | 2016-03-14 18:59:18 | [diff] [blame] | 235 | bool RemoveIceCandidates( |
| 236 | const std::vector<cricket::Candidate>& candidates) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 237 | |
Niels Möller | 0c4f7be | 2018-05-07 12:01:37 | [diff] [blame] | 238 | RTCError SetBitrate(const BitrateSettings& bitrate) override; |
Per K | 39ac25d | 2024-02-07 13:16:20 | [diff] [blame] | 239 | void ReconfigureBandwidthEstimation( |
| 240 | const BandwidthEstimationSettings& settings) override; |
zstein | 4b97980 | 2017-06-02 21:37:37 | [diff] [blame] | 241 | |
henrika | 5f6bf24 | 2017-11-01 10:06:56 | [diff] [blame] | 242 | void SetAudioPlayout(bool playout) override; |
| 243 | void SetAudioRecording(bool recording) override; |
| 244 | |
Harald Alvestrand | ad88c88 | 2018-11-28 15:47:46 | [diff] [blame] | 245 | rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid( |
| 246 | const std::string& mid) override; |
Harald Alvestrand | 4a7b3ac | 2019-01-17 09:39:40 | [diff] [blame] | 247 | rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMidInternal( |
| 248 | const std::string& mid); |
Harald Alvestrand | ad88c88 | 2018-11-28 15:47:46 | [diff] [blame] | 249 | |
Harald Alvestrand | c85328f | 2019-02-28 06:51:00 | [diff] [blame] | 250 | rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const override; |
| 251 | |
Henrik Boström | 4c1e7cc | 2020-06-11 10:26:53 | [diff] [blame] | 252 | void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override; |
| 253 | |
Bjorn Terelius | de93943 | 2017-11-20 16:38:14 | [diff] [blame] | 254 | bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output, |
| 255 | int64_t output_period_ms) override; |
Niels Möller | f00ca1a | 2019-05-10 09:33:12 | [diff] [blame] | 256 | bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override; |
ivoc | 14d5dbe | 2016-07-04 14:06:55 | [diff] [blame] | 257 | void StopRtcEventLog() override; |
| 258 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 259 | void Close() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 260 | |
Taylor Brandstetter | c88fe70 | 2020-08-03 23:36:16 | [diff] [blame] | 261 | rtc::Thread* signaling_thread() const final { |
Harald Alvestrand | a39689c | 2020-10-15 08:34:31 | [diff] [blame] | 262 | return context_->signaling_thread(); |
Taylor Brandstetter | c88fe70 | 2020-08-03 23:36:16 | [diff] [blame] | 263 | } |
| 264 | |
Karl Wiberg | 4ae6347 | 2019-02-21 23:57:06 | [diff] [blame] | 265 | rtc::Thread* network_thread() const final { |
Harald Alvestrand | a39689c | 2020-10-15 08:34:31 | [diff] [blame] | 266 | return context_->network_thread(); |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 267 | } |
Harald Alvestrand | a39689c | 2020-10-15 08:34:31 | [diff] [blame] | 268 | rtc::Thread* worker_thread() const final { return context_->worker_thread(); } |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 269 | |
Jared Siskin | bceec84 | 2023-04-20 21:10:51 | [diff] [blame] | 270 | std::string session_id() const override { return session_id_; } |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 271 | |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 272 | bool initial_offerer() const override { |
Karl Wiberg | 2cc368f | 2019-04-02 09:31:56 | [diff] [blame] | 273 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Harald Alvestrand | bc32c56 | 2022-02-09 12:08:47 | [diff] [blame] | 274 | return sdp_handler_->initial_offerer(); |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 275 | } |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 276 | |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 277 | std::vector< |
| 278 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>> |
Steve Anton | b886711 | 2018-02-13 18:07:54 | [diff] [blame] | 279 | GetTransceiversInternal() const override { |
Karl Wiberg | a58e169 | 2019-03-26 12:33:43 | [diff] [blame] | 280 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Harald Alvestrand | 8101e7b | 2022-05-23 14:57:47 | [diff] [blame] | 281 | if (!ConfiguredForMedia()) { |
| 282 | return {}; |
| 283 | } |
Harald Alvestrand | e15fb15 | 2020-10-19 13:28:05 | [diff] [blame] | 284 | return rtp_manager()->transceivers()->List(); |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 285 | } |
| 286 | |
Taylor Brandstetter | 3a034e1 | 2020-07-09 22:32:34 | [diff] [blame] | 287 | std::vector<DataChannelStats> GetDataChannelStats() const override; |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 288 | |
Danil Chapovalov | 66cadcc | 2018-06-19 14:47:43 | [diff] [blame] | 289 | absl::optional<std::string> sctp_transport_name() const override; |
Tomas Gunnarsson | bfd9ba8 | 2021-04-18 09:55:57 | [diff] [blame] | 290 | absl::optional<std::string> sctp_mid() const override; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 291 | |
Qingsi Wang | 72a43a1 | 2018-02-21 00:03:18 | [diff] [blame] | 292 | cricket::CandidateStatsList GetPooledCandidateStats() const override; |
Steve Anton | 5dfde18 | 2018-02-06 18:34:40 | [diff] [blame] | 293 | std::map<std::string, cricket::TransportStats> GetTransportStatsByNames( |
| 294 | const std::set<std::string>& transport_names) override; |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 295 | Call::Stats GetCallStats() override; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 296 | |
Fredrik Hernqvist | efbe753 | 2023-01-13 15:42:36 | [diff] [blame] | 297 | absl::optional<AudioDeviceModule::Stats> GetAudioDeviceStats() override; |
| 298 | |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 299 | bool GetLocalCertificate( |
| 300 | const std::string& transport_name, |
| 301 | rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override; |
Taylor Brandstetter | c392866 | 2018-02-23 21:04:51 | [diff] [blame] | 302 | std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain( |
Steve Anton | 2d8609c | 2018-01-24 00:38:46 | [diff] [blame] | 303 | const std::string& transport_name) override; |
| 304 | bool IceRestartPending(const std::string& content_name) const override; |
| 305 | bool NeedsIceRestart(const std::string& content_name) const override; |
| 306 | bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override; |
Mirko Bonadei | e0bc8d2 | 2022-02-08 07:41:25 | [diff] [blame] | 307 | |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 308 | // Functions needed by DataChannelController |
Harald Alvestrand | 5b84f38 | 2022-02-08 10:49:09 | [diff] [blame] | 309 | void NoteDataAddedEvent() override { NoteUsageEvent(UsageEvent::DATA_ADDED); } |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 310 | // Returns the observer. Will crash on CHECK if the observer is removed. |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 311 | PeerConnectionObserver* Observer() const override; |
| 312 | bool IsClosed() const override { |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 313 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Tomas Gunnarsson | 2efb8a5 | 2021-04-01 14:26:57 | [diff] [blame] | 314 | return !sdp_handler_ || |
| 315 | sdp_handler_->signaling_state() == PeerConnectionInterface::kClosed; |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 316 | } |
| 317 | // Get current SSL role used by SCTP's underlying transport. |
Tommi | 335d084 | 2023-03-25 09:56:18 | [diff] [blame] | 318 | absl::optional<rtc::SSLRole> GetSctpSslRole_n() override; |
Tommi | d2afbaf | 2023-03-02 09:51:16 | [diff] [blame] | 319 | |
| 320 | void OnSctpDataChannelStateChanged( |
Tommi | 5654898 | 2023-03-27 16:07:34 | [diff] [blame] | 321 | int channel_id, |
Tommi | d2afbaf | 2023-03-02 09:51:16 | [diff] [blame] | 322 | DataChannelInterface::DataState state) override; |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 323 | |
Henrik Boström | e574a31 | 2020-08-25 08:20:11 | [diff] [blame] | 324 | bool ShouldFireNegotiationNeededEvent(uint32_t event_id) override; |
| 325 | |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 326 | // Functions needed by SdpOfferAnswerHandler |
Henrik Boström | f785989 | 2022-07-04 12:36:37 | [diff] [blame] | 327 | LegacyStatsCollector* legacy_stats() override { |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 328 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Henrik Boström | f785989 | 2022-07-04 12:36:37 | [diff] [blame] | 329 | return legacy_stats_.get(); |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 330 | } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 331 | DataChannelController* data_channel_controller() override { |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 332 | RTC_DCHECK_RUN_ON(signaling_thread()); |
| 333 | return &data_channel_controller_; |
| 334 | } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 335 | bool dtls_enabled() const override { |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 336 | RTC_DCHECK_RUN_ON(signaling_thread()); |
| 337 | return dtls_enabled_; |
| 338 | } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 339 | const PeerConnectionInterface::RTCConfiguration* configuration() |
| 340 | const override { |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 341 | RTC_DCHECK_RUN_ON(signaling_thread()); |
| 342 | return &configuration_; |
| 343 | } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 344 | PeerConnectionMessageHandler* message_handler() override { |
Harald Alvestrand | 1090e44 | 2020-10-05 07:01:09 | [diff] [blame] | 345 | RTC_DCHECK_RUN_ON(signaling_thread()); |
| 346 | return &message_handler_; |
| 347 | } |
Harald Alvestrand | cdcfab0 | 2020-09-28 13:02:07 | [diff] [blame] | 348 | |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 349 | RtpTransmissionManager* rtp_manager() override { return rtp_manager_.get(); } |
| 350 | const RtpTransmissionManager* rtp_manager() const override { |
Harald Alvestrand | e15fb15 | 2020-10-19 13:28:05 | [diff] [blame] | 351 | return rtp_manager_.get(); |
| 352 | } |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 353 | |
Harald Alvestrand | bc32c56 | 2022-02-09 12:08:47 | [diff] [blame] | 354 | JsepTransportController* transport_controller_s() override { |
| 355 | RTC_DCHECK_RUN_ON(signaling_thread()); |
| 356 | return transport_controller_copy_; |
| 357 | } |
| 358 | JsepTransportController* transport_controller_n() override { |
| 359 | RTC_DCHECK_RUN_ON(network_thread()); |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 360 | return transport_controller_.get(); |
| 361 | } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 362 | cricket::PortAllocator* port_allocator() override { |
| 363 | return port_allocator_.get(); |
| 364 | } |
| 365 | Call* call_ptr() override { return call_ptr_; } |
Harald Alvestrand | 763f5a9 | 2020-10-22 10:39:40 | [diff] [blame] | 366 | |
| 367 | ConnectionContext* context() { return context_.get(); } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 368 | const PeerConnectionFactoryInterface::Options* options() const override { |
Harald Alvestrand | 4da4a87 | 2020-11-04 10:34:21 | [diff] [blame] | 369 | return &options_; |
| 370 | } |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 371 | void SetIceConnectionState(IceConnectionState new_state) override; |
| 372 | void NoteUsageEvent(UsageEvent event) override; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 373 | |
Tomas Gunnarsson | 8cb9706 | 2021-02-08 17:57:04 | [diff] [blame] | 374 | // Asynchronously adds a remote candidate on the network thread. |
| 375 | void AddRemoteCandidate(const std::string& mid, |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 376 | const cricket::Candidate& candidate) override; |
Tomas Gunnarsson | 8cb9706 | 2021-02-08 17:57:04 | [diff] [blame] | 377 | |
Philipp Hancke | 54b925c | 2021-01-28 08:56:39 | [diff] [blame] | 378 | // Report the UMA metric BundleUsage for the given remote description. |
| 379 | void ReportSdpBundleUsage( |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 380 | const SessionDescriptionInterface& remote_description) override; |
Philipp Hancke | 54b925c | 2021-01-28 08:56:39 | [diff] [blame] | 381 | |
Philipp Hancke | 9799fe0 | 2022-07-06 07:26:41 | [diff] [blame] | 382 | // Report several UMA metrics on establishing the connection. |
| 383 | void ReportFirstConnectUsageMetrics() RTC_RUN_ON(signaling_thread()); |
| 384 | |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 385 | // Returns true if the PeerConnection is configured to use Unified Plan |
| 386 | // semantics for creating offers/answers and setting local/remote |
| 387 | // descriptions. If this is true the RtpTransceiver API will also be available |
| 388 | // to the user. If this is false, Plan B semantics are assumed. |
| 389 | // TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once |
| 390 | // sufficient time has passed. |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 391 | bool IsUnifiedPlan() const override { |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 392 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 393 | return is_unified_plan_; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 394 | } |
Henrik Boström | f8187e0 | 2021-04-26 19:04:26 | [diff] [blame] | 395 | bool ValidateBundleSettings( |
| 396 | const cricket::SessionDescription* desc, |
| 397 | const std::map<std::string, const cricket::ContentGroup*>& |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 398 | bundle_groups_by_mid) override; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 399 | |
Tommi | 840cf78 | 2023-10-21 14:47:56 | [diff] [blame] | 400 | bool CreateDataChannelTransport(absl::string_view mid) override; |
| 401 | void DestroyDataChannelTransport(RTCError error) override; |
Tomas Gunnarsson | 92eebef | 2021-02-10 12:05:44 | [diff] [blame] | 402 | |
| 403 | // Asynchronously calls SctpTransport::Start() on the network thread for |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 404 | // `sctp_mid()` if set. Called as part of setting the local description. |
Tomas Gunnarsson | 92eebef | 2021-02-10 12:05:44 | [diff] [blame] | 405 | void StartSctpTransport(int local_port, |
| 406 | int remote_port, |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 407 | int max_message_size) override; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 408 | |
| 409 | // Returns the CryptoOptions for this PeerConnection. This will always |
| 410 | // return the RTCConfiguration.crypto_options if set and will only default |
| 411 | // back to the PeerConnectionFactory settings if nothing was set. |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 412 | CryptoOptions GetCryptoOptions() override; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 413 | |
| 414 | // Internal implementation for AddTransceiver family of methods. If |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 415 | // `fire_callback` is set, fires OnRenegotiationNeeded callback if successful. |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 416 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 417 | cricket::MediaType media_type, |
| 418 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 419 | const RtpTransceiverInit& init, |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 420 | bool fire_callback = true) override; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 421 | |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 422 | // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by |
| 423 | // this session. |
Harald Alvestrand | 5b66130 | 2022-01-28 13:08:34 | [diff] [blame] | 424 | bool SrtpRequired() const override; |
Harald Alvestrand | 653429c | 2020-10-19 16:05:20 | [diff] [blame] | 425 | |
Tommi | 840cf78 | 2023-10-21 14:47:56 | [diff] [blame] | 426 | absl::optional<std::string> SetupDataChannelTransport_n(absl::string_view mid) |
| 427 | RTC_RUN_ON(network_thread()); |
| 428 | void TeardownDataChannelTransport_n(RTCError error) |
Tommi | b00d63c | 2023-04-12 17:49:53 | [diff] [blame] | 429 | RTC_RUN_ON(network_thread()); |
Harald Alvestrand | e15fb15 | 2020-10-19 13:28:05 | [diff] [blame] | 430 | |
Danil Chapovalov | 3bdb49b | 2023-11-30 07:59:39 | [diff] [blame] | 431 | const FieldTrialsView& trials() const override { return env_.field_trials(); } |
Harald Alvestrand | 35ba0c5 | 2022-05-05 07:37:41 | [diff] [blame] | 432 | |
| 433 | bool ConfiguredForMedia() const; |
| 434 | |
Harald Alvestrand | 05e4d08 | 2019-12-03 13:04:21 | [diff] [blame] | 435 | // Functions made public for testing. |
Harald Alvestrand | 1979384 | 2018-06-25 10:03:50 | [diff] [blame] | 436 | void ReturnHistogramVeryQuicklyForTesting() { |
Karl Wiberg | f73f7d6 | 2019-04-08 13:36:53 | [diff] [blame] | 437 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Harald Alvestrand | 1979384 | 2018-06-25 10:03:50 | [diff] [blame] | 438 | return_histogram_very_quickly_ = true; |
| 439 | } |
Harald Alvestrand | 7a1c7f7 | 2018-08-01 08:50:16 | [diff] [blame] | 440 | void RequestUsagePatternReportForTesting(); |
Harald Alvestrand | 1979384 | 2018-06-25 10:03:50 | [diff] [blame] | 441 | |
Tony Herre | 418bcf2 | 2024-06-17 15:28:40 | [diff] [blame] | 442 | NetworkControllerInterface* GetNetworkController() override { |
| 443 | if (!worker_thread()->IsCurrent()) { |
| 444 | return worker_thread()->BlockingCall( |
| 445 | [this]() { return GetNetworkController(); }); |
| 446 | } |
| 447 | RTC_DCHECK_RUN_ON(worker_thread()); |
| 448 | RTC_DCHECK(call_); |
| 449 | return call_->GetTransportControllerSend()->GetNetworkController(); |
| 450 | } |
| 451 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 452 | protected: |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 453 | // Available for rtc::scoped_refptr creation |
Danil Chapovalov | 3bdb49b | 2023-11-30 07:59:39 | [diff] [blame] | 454 | PeerConnection(const Environment& env, |
| 455 | rtc::scoped_refptr<ConnectionContext> context, |
Harald Alvestrand | 4da4a87 | 2020-11-04 10:34:21 | [diff] [blame] | 456 | const PeerConnectionFactoryInterface::Options& options, |
| 457 | bool is_unified_plan, |
Harald Alvestrand | 4da4a87 | 2020-11-04 10:34:21 | [diff] [blame] | 458 | std::unique_ptr<Call> call, |
Tommi | c3257d0 | 2021-02-10 17:40:08 | [diff] [blame] | 459 | PeerConnectionDependencies& dependencies, |
| 460 | bool dtls_enabled); |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 461 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 462 | ~PeerConnection() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 463 | |
| 464 | private: |
Harald Alvestrand | a3dd772 | 2020-11-27 08:05:42 | [diff] [blame] | 465 | RTCError Initialize( |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 466 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 467 | PeerConnectionDependencies dependencies); |
Harald Alvestrand | bc32c56 | 2022-02-09 12:08:47 | [diff] [blame] | 468 | JsepTransportController* InitializeTransportController_n( |
Tommi | c3257d0 | 2021-02-10 17:40:08 | [diff] [blame] | 469 | const RTCConfiguration& configuration, |
| 470 | const PeerConnectionDependencies& dependencies) |
| 471 | RTC_RUN_ON(network_thread()); |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 472 | |
Steve Anton | f9381f0 | 2017-12-14 18:23:57 | [diff] [blame] | 473 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | a58e169 | 2019-03-26 12:33:43 | [diff] [blame] | 474 | FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender) |
| 475 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | f9381f0 | 2017-12-14 18:23:57 | [diff] [blame] | 476 | |
Jonas Olsson | 635474e | 2018-10-18 13:58:17 | [diff] [blame] | 477 | void SetStandardizedIceConnectionState( |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 478 | PeerConnectionInterface::IceConnectionState new_state) |
| 479 | RTC_RUN_ON(signaling_thread()); |
Jonas Olsson | 635474e | 2018-10-18 13:58:17 | [diff] [blame] | 480 | void SetConnectionState( |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 481 | PeerConnectionInterface::PeerConnectionState new_state) |
| 482 | RTC_RUN_ON(signaling_thread()); |
Jonas Olsson | 635474e | 2018-10-18 13:58:17 | [diff] [blame] | 483 | |
Eldar Rello | da13ea2 | 2019-06-01 09:23:43 | [diff] [blame] | 484 | // Called any time the IceGatheringState changes. |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 485 | void OnIceGatheringChange(IceGatheringState new_state) |
| 486 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 487 | // New ICE candidate has been gathered. |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 488 | void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate) |
| 489 | RTC_RUN_ON(signaling_thread()); |
Eldar Rello | da13ea2 | 2019-06-01 09:23:43 | [diff] [blame] | 490 | // Gathering of an ICE candidate failed. |
Eldar Rello | 0095d37 | 2019-12-02 20:22:07 | [diff] [blame] | 491 | void OnIceCandidateError(const std::string& address, |
| 492 | int port, |
Eldar Rello | da13ea2 | 2019-06-01 09:23:43 | [diff] [blame] | 493 | const std::string& url, |
| 494 | int error_code, |
| 495 | const std::string& error_text) |
| 496 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 497 | // Some local ICE candidates have been removed. |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 498 | void OnIceCandidatesRemoved(const std::vector<cricket::Candidate>& candidates) |
| 499 | RTC_RUN_ON(signaling_thread()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 500 | |
Alex Drake | 00c7ecf | 2019-08-06 17:54:47 | [diff] [blame] | 501 | void OnSelectedCandidatePairChanged( |
| 502 | const cricket::CandidatePairChangeEvent& event) |
| 503 | RTC_RUN_ON(signaling_thread()); |
| 504 | |
Steve Anton | 52d8677 | 2018-02-20 23:48:12 | [diff] [blame] | 505 | void OnNegotiationNeeded(); |
| 506 | |
Taylor Brandstetter | a1c3035 | 2016-05-13 15:15:11 | [diff] [blame] | 507 | // Called when first configuring the port allocator. |
Karl Wiberg | fb3be39 | 2019-03-22 13:13:22 | [diff] [blame] | 508 | struct InitializePortAllocatorResult { |
| 509 | bool enable_ipv6; |
| 510 | }; |
| 511 | InitializePortAllocatorResult InitializePortAllocator_n( |
Harald Alvestrand | b2a7478 | 2018-06-28 11:54:07 | [diff] [blame] | 512 | const cricket::ServerAddresses& stun_servers, |
| 513 | const std::vector<cricket::RelayServerConfig>& turn_servers, |
| 514 | const RTCConfiguration& configuration); |
deadbeef | 293e926 | 2017-01-11 20:28:30 | [diff] [blame] | 515 | // Called when SetConfiguration is called to apply the supported subset |
| 516 | // of the configuration on the network thread. |
| 517 | bool ReconfigurePortAllocator_n( |
| 518 | const cricket::ServerAddresses& stun_servers, |
| 519 | const std::vector<cricket::RelayServerConfig>& turn_servers, |
| 520 | IceTransportsType type, |
| 521 | int candidate_pool_size, |
Honghai Zhang | f8998cf | 2019-10-14 18:27:50 | [diff] [blame] | 522 | PortPrunePolicy turn_port_prune_policy, |
Harald Alvestrand | a654437 | 2023-11-13 09:33:56 | [diff] [blame] | 523 | TurnCustomizer* turn_customizer, |
Karl Wiberg | 739506e | 2019-04-03 09:37:28 | [diff] [blame] | 524 | absl::optional<int> stun_candidate_keepalive_interval, |
| 525 | bool have_local_description); |
Taylor Brandstetter | a1c3035 | 2016-05-13 15:15:11 | [diff] [blame] | 526 | |
Elad Alon | 99c3fe5 | 2017-10-13 14:29:40 | [diff] [blame] | 527 | // Starts output of an RTC event log to the given output object. |
ivoc | 14d5dbe | 2016-07-04 14:06:55 | [diff] [blame] | 528 | // This function should only be called from the worker thread. |
Bjorn Terelius | de93943 | 2017-11-20 16:38:14 | [diff] [blame] | 529 | bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output, |
| 530 | int64_t output_period_ms); |
Elad Alon | 99c3fe5 | 2017-10-13 14:29:40 | [diff] [blame] | 531 | |
Elad Alon | acb2417 | 2017-10-06 12:32:13 | [diff] [blame] | 532 | // Stops recording an RTC event log. |
ivoc | 14d5dbe | 2016-07-04 14:06:55 | [diff] [blame] | 533 | // This function should only be called from the worker thread. |
| 534 | void StopRtcEventLog_w(); |
| 535 | |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 536 | // Returns true and the TransportInfo of the given `content_name` |
| 537 | // from `description`. Returns false if it's not available. |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 538 | static bool GetTransportDescription( |
| 539 | const cricket::SessionDescription* description, |
| 540 | const std::string& content_name, |
| 541 | cricket::TransportDescription* info); |
| 542 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 543 | // Returns the media index for a local ice candidate given the content name. |
| 544 | // Returns false if the local session description does not have a media |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 545 | // content called `content_name`. |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 546 | bool GetLocalCandidateMediaIndex(const std::string& content_name, |
Karl Wiberg | 739506e | 2019-04-03 09:37:28 | [diff] [blame] | 547 | int* sdp_mline_index) |
| 548 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 549 | |
Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 550 | // JsepTransportController signal handlers. |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 551 | void OnTransportControllerConnectionState(cricket::IceConnectionState state) |
| 552 | RTC_RUN_ON(signaling_thread()); |
| 553 | void OnTransportControllerGatheringState(cricket::IceGatheringState state) |
| 554 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 555 | void OnTransportControllerCandidatesGathered( |
| 556 | const std::string& transport_name, |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 557 | const std::vector<cricket::Candidate>& candidates) |
| 558 | RTC_RUN_ON(signaling_thread()); |
Eldar Rello | da13ea2 | 2019-06-01 09:23:43 | [diff] [blame] | 559 | void OnTransportControllerCandidateError( |
| 560 | const cricket::IceCandidateErrorEvent& event) |
| 561 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 562 | void OnTransportControllerCandidatesRemoved( |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 563 | const std::vector<cricket::Candidate>& candidates) |
| 564 | RTC_RUN_ON(signaling_thread()); |
Alex Drake | 00c7ecf | 2019-08-06 17:54:47 | [diff] [blame] | 565 | void OnTransportControllerCandidateChanged( |
| 566 | const cricket::CandidatePairChangeEvent& event) |
| 567 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 568 | void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error); |
| 569 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 570 | // Invoked when TransportController connection completion is signaled. |
| 571 | // Reports stats for all transports in use. |
Tommi | dba22d3 | 2023-06-01 14:08:52 | [diff] [blame] | 572 | void ReportTransportStats(std::vector<RtpTransceiverProxyRefPtr> transceivers) |
| 573 | RTC_RUN_ON(network_thread()); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 574 | |
| 575 | // Gather the usage of IPv4/IPv6 as best connection. |
Tommi | c3257d0 | 2021-02-10 17:40:08 | [diff] [blame] | 576 | static void ReportBestConnectionState(const cricket::TransportStats& stats); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 577 | |
Tommi | c3257d0 | 2021-02-10 17:40:08 | [diff] [blame] | 578 | static void ReportNegotiatedCiphers( |
| 579 | bool dtls_enabled, |
| 580 | const cricket::TransportStats& stats, |
| 581 | const std::set<cricket::MediaType>& media_types); |
Qingsi Wang | 1ba5dec | 2019-08-19 18:57:17 | [diff] [blame] | 582 | void ReportIceCandidateCollected(const cricket::Candidate& candidate) |
| 583 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 584 | |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 585 | void ReportUsagePattern() const RTC_RUN_ON(signaling_thread()); |
Harald Alvestrand | 8ebba74 | 2018-05-31 12:00:34 | [diff] [blame] | 586 | |
Tomas Gunnarsson | 8cb9706 | 2021-02-08 17:57:04 | [diff] [blame] | 587 | void ReportRemoteIceCandidateAdded(const cricket::Candidate& candidate); |
| 588 | |
Zhi Huang | 365381f | 2018-04-13 23:44:34 | [diff] [blame] | 589 | // JsepTransportController::Observer override. |
Taylor Brandstetter | cbaa254 | 2018-04-16 23:42:14 | [diff] [blame] | 590 | // |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 591 | // Called by `transport_controller_` when processing transport information |
Taylor Brandstetter | cbaa254 | 2018-04-16 23:42:14 | [diff] [blame] | 592 | // from a session description, and the mapping from m= sections to transports |
| 593 | // changed (as a result of BUNDLE negotiation, or m= sections being |
| 594 | // rejected). |
Bjorn A Mellem | b689af4 | 2019-08-21 17:44:59 | [diff] [blame] | 595 | bool OnTransportChanged( |
| 596 | const std::string& mid, |
| 597 | RtpTransportInternal* rtp_transport, |
| 598 | rtc::scoped_refptr<DtlsTransport> dtls_transport, |
Bjorn A Mellem | bc3eebc | 2019-09-23 21:53:54 | [diff] [blame] | 599 | DataChannelTransportInterface* data_channel_transport) override; |
Zhi Huang | e830e68 | 2018-03-30 17:48:35 | [diff] [blame] | 600 | |
Henrik Boström | 46053e4 | 2023-01-20 12:18:53 | [diff] [blame] | 601 | void SetSctpTransportName(std::string sctp_transport_name); |
| 602 | |
Tomas Gunnarsson | 1e40a0c | 2020-09-28 08:39:31 | [diff] [blame] | 603 | std::function<void(const rtc::CopyOnWriteBuffer& packet, |
| 604 | int64_t packet_time_us)> |
| 605 | InitializeRtcpCallback(); |
| 606 | |
Per K | e1e94ad | 2023-03-30 14:53:59 | [diff] [blame] | 607 | std::function<void(const RtpPacketReceived& parsed_packet)> |
| 608 | InitializeUnDemuxablePacketHandler(); |
| 609 | |
Danil Chapovalov | 3bdb49b | 2023-11-30 07:59:39 | [diff] [blame] | 610 | const Environment env_; |
Harald Alvestrand | a39689c | 2020-10-15 08:34:31 | [diff] [blame] | 611 | const rtc::scoped_refptr<ConnectionContext> context_; |
Harald Alvestrand | 4da4a87 | 2020-11-04 10:34:21 | [diff] [blame] | 612 | const PeerConnectionFactoryInterface::Options options_; |
Karl Wiberg | 744310f | 2019-02-14 09:18:56 | [diff] [blame] | 613 | PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) = |
| 614 | nullptr; |
terelius | 3386025 | 2017-05-13 06:37:18 | [diff] [blame] | 615 | |
Harald Alvestrand | 6216693 | 2020-10-26 08:30:41 | [diff] [blame] | 616 | const bool is_unified_plan_; |
| 617 | |
Karl Wiberg | 8d2e228 | 2019-02-17 12:00:07 | [diff] [blame] | 618 | IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) = |
| 619 | kIceConnectionNew; |
| 620 | PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_ |
| 621 | RTC_GUARDED_BY(signaling_thread()) = kIceConnectionNew; |
| 622 | PeerConnectionInterface::PeerConnectionState connection_state_ |
| 623 | RTC_GUARDED_BY(signaling_thread()) = PeerConnectionState::kNew; |
Jonas Olsson | 635474e | 2018-10-18 13:58:17 | [diff] [blame] | 624 | |
Karl Wiberg | 8d2e228 | 2019-02-17 12:00:07 | [diff] [blame] | 625 | IceGatheringState ice_gathering_state_ RTC_GUARDED_BY(signaling_thread()) = |
| 626 | kIceGatheringNew; |
Karl Wiberg | 5966c50 | 2019-02-21 22:55:09 | [diff] [blame] | 627 | PeerConnectionInterface::RTCConfiguration configuration_ |
| 628 | RTC_GUARDED_BY(signaling_thread()); |
| 629 | |
Harald Alvestrand | 0ccfbd2 | 2021-04-08 07:25:04 | [diff] [blame] | 630 | const std::unique_ptr<AsyncDnsResolverFactoryInterface> |
| 631 | async_dns_resolver_factory_; |
Karl Wiberg | fb3be39 | 2019-03-22 13:13:22 | [diff] [blame] | 632 | std::unique_ptr<cricket::PortAllocator> |
| 633 | port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 634 | // signaling and network thread. |
Harald Alvestrand | a654437 | 2023-11-13 09:33:56 | [diff] [blame] | 635 | const std::unique_ptr<IceTransportFactory> |
Qingsi Wang | 25ec888 | 2019-11-15 20:33:05 | [diff] [blame] | 636 | ice_transport_factory_; // TODO(bugs.webrtc.org/9987): Accessed on the |
| 637 | // signaling thread but the underlying raw |
| 638 | // pointer is given to |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 639 | // `jsep_transport_controller_` and used on the |
Qingsi Wang | 25ec888 | 2019-11-15 20:33:05 | [diff] [blame] | 640 | // network thread. |
Harald Alvestrand | f598e49 | 2020-11-04 05:54:10 | [diff] [blame] | 641 | const std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier_ |
| 642 | RTC_GUARDED_BY(network_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 643 | |
Karl Wiberg | ac02589 | 2019-03-26 12:08:37 | [diff] [blame] | 644 | // The unique_ptr belongs to the worker thread, but the Call object manages |
| 645 | // its own thread safety. |
Karl Wiberg | 6cab5c8 | 2019-03-26 08:57:01 | [diff] [blame] | 646 | std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread()); |
Tomas Gunnarsson | 92eebef | 2021-02-10 12:05:44 | [diff] [blame] | 647 | ScopedTaskSafety signaling_thread_safety_; |
| 648 | rtc::scoped_refptr<PendingTaskSafetyFlag> network_thread_safety_; |
Tommi | c3257d0 | 2021-02-10 17:40:08 | [diff] [blame] | 649 | rtc::scoped_refptr<PendingTaskSafetyFlag> worker_thread_safety_; |
Sebastian Jansson | 1b83a9e | 2019-09-18 16:22:12 | [diff] [blame] | 650 | |
Karl Wiberg | 6cab5c8 | 2019-03-26 08:57:01 | [diff] [blame] | 651 | // Points to the same thing as `call_`. Since it's const, we may read the |
Karl Wiberg | ac02589 | 2019-03-26 12:08:37 | [diff] [blame] | 652 | // pointer from any thread. |
Tomas Gunnarsson | 1e40a0c | 2020-09-28 08:39:31 | [diff] [blame] | 653 | // TODO(bugs.webrtc.org/11992): Remove this workaround (and potential dangling |
| 654 | // pointer). |
Karl Wiberg | ac02589 | 2019-03-26 12:08:37 | [diff] [blame] | 655 | Call* const call_ptr_; |
Karl Wiberg | 6cab5c8 | 2019-03-26 08:57:01 | [diff] [blame] | 656 | |
Henrik Boström | f785989 | 2022-07-04 12:36:37 | [diff] [blame] | 657 | std::unique_ptr<LegacyStatsCollector> legacy_stats_ |
Karl Wiberg | 6cab5c8 | 2019-03-26 08:57:01 | [diff] [blame] | 658 | RTC_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_ |
| 659 | rtc::scoped_refptr<RTCStatsCollector> stats_collector_ |
| 660 | RTC_GUARDED_BY(signaling_thread()); |
Karl Wiberg | 2cc368f | 2019-04-02 09:31:56 | [diff] [blame] | 661 | |
Tomas Gunnarsson | 97a387d | 2021-03-29 19:04:29 | [diff] [blame] | 662 | const std::string session_id_; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 663 | |
Harald Alvestrand | bc32c56 | 2022-02-09 12:08:47 | [diff] [blame] | 664 | // The transport controller is set and used on the network thread. |
| 665 | // Some functions pass the value of the transport_controller_ pointer |
| 666 | // around as arguments while running on the signaling thread; these |
| 667 | // use the transport_controller_copy. |
| 668 | std::unique_ptr<JsepTransportController> transport_controller_ |
| 669 | RTC_GUARDED_BY(network_thread()); |
| 670 | JsepTransportController* transport_controller_copy_ |
| 671 | RTC_GUARDED_BY(signaling_thread()) = nullptr; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 672 | |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 673 | // `sctp_mid_` is the content name (MID) in SDP. |
Bjorn A Mellem | b689af4 | 2019-08-21 17:44:59 | [diff] [blame] | 674 | // Note: this is used as the data channel MID by both SCTP and data channel |
| 675 | // transports. It is set when either transport is initialized and unset when |
| 676 | // both transports are deleted. |
Harald Alvestrand | 7a829a8 | 2020-02-12 06:38:21 | [diff] [blame] | 677 | // There is one copy on the signaling thread and another copy on the |
| 678 | // networking thread. Changes are always initiated from the signaling |
| 679 | // thread, but applied first on the networking thread via an invoke(). |
| 680 | absl::optional<std::string> sctp_mid_s_ RTC_GUARDED_BY(signaling_thread()); |
| 681 | absl::optional<std::string> sctp_mid_n_ RTC_GUARDED_BY(network_thread()); |
Tomas Gunnarsson | 92eebef | 2021-02-10 12:05:44 | [diff] [blame] | 682 | std::string sctp_transport_name_s_ RTC_GUARDED_BY(signaling_thread()); |
Karl Wiberg | 2cc368f | 2019-04-02 09:31:56 | [diff] [blame] | 683 | |
Harald Alvestrand | 9cd199d | 2020-10-27 07:10:43 | [diff] [blame] | 684 | // The machinery for handling offers and answers. Const after initialization. |
| 685 | std::unique_ptr<SdpOfferAnswerHandler> sdp_handler_ |
Harald Alvestrand | 00c62ed | 2021-10-20 08:52:12 | [diff] [blame] | 686 | RTC_GUARDED_BY(signaling_thread()) RTC_PT_GUARDED_BY(signaling_thread()); |
Bjorn Mellem | 175aa2e | 2018-11-08 19:23:22 | [diff] [blame] | 687 | |
Tommi | c3257d0 | 2021-02-10 17:40:08 | [diff] [blame] | 688 | const bool dtls_enabled_; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 689 | |
Harald Alvestrand | 44d0dff | 2020-10-09 05:43:53 | [diff] [blame] | 690 | UsagePattern usage_pattern_ RTC_GUARDED_BY(signaling_thread()); |
Karl Wiberg | f73f7d6 | 2019-04-08 13:36:53 | [diff] [blame] | 691 | bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) = |
| 692 | false; |
Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 693 | |
Harald Alvestrand | 00c62ed | 2021-10-20 08:52:12 | [diff] [blame] | 694 | // The DataChannelController is accessed from both the signaling thread |
| 695 | // and networking thread. It is a thread-aware object. |
Harald Alvestrand | 00cf34c | 2019-12-02 08:56:02 | [diff] [blame] | 696 | DataChannelController data_channel_controller_; |
Harald Alvestrand | 1090e44 | 2020-10-05 07:01:09 | [diff] [blame] | 697 | |
| 698 | // Machinery for handling messages posted to oneself |
Harald Alvestrand | 00c62ed | 2021-10-20 08:52:12 | [diff] [blame] | 699 | PeerConnectionMessageHandler message_handler_ |
| 700 | RTC_GUARDED_BY(signaling_thread()); |
Harald Alvestrand | e15fb15 | 2020-10-19 13:28:05 | [diff] [blame] | 701 | |
| 702 | // Administration of senders, receivers and transceivers |
| 703 | // Accessed on both signaling and network thread. Const after Initialize(). |
| 704 | std::unique_ptr<RtpTransmissionManager> rtp_manager_; |
Lahiru Ginnaliya Gamathige | 70f9e24 | 2021-01-28 07:32:46 | [diff] [blame] | 705 | |
Philipp Hancke | cd0373f | 2021-02-24 10:04:30 | [diff] [blame] | 706 | // Did the connectionState ever change to `connected`? |
| 707 | // Used to gather metrics only the first such state change. |
| 708 | bool was_ever_connected_ RTC_GUARDED_BY(signaling_thread()) = false; |
Harald Alvestrand | 00c62ed | 2021-10-20 08:52:12 | [diff] [blame] | 709 | |
| 710 | // This variable needs to be the last one in the class. |
| 711 | rtc::WeakPtrFactory<PeerConnection> weak_factory_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 712 | }; |
| 713 | |
| 714 | } // namespace webrtc |
| 715 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 716 | #endif // PC_PEER_CONNECTION_H_ |