Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #include "pc/peer_connection_wrapper.h" |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 12 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 13 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 14 | |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 15 | #include <memory> |
| 16 | #include <string> |
| 17 | #include <utility> |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 18 | #include <vector> |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 19 | |
Artem Titov | 741daaf | 2019-03-21 14:37:36 +0100 | [diff] [blame] | 20 | #include "api/function_view.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 21 | #include "api/set_remote_description_observer_interface.h" |
| 22 | #include "pc/sdp_utils.h" |
| 23 | #include "pc/test/fake_video_track_source.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 24 | #include "rtc_base/checks.h" |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 25 | #include "rtc_base/gunit.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 26 | #include "rtc_base/logging.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 27 | #include "rtc_base/ref_counted_object.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 28 | #include "test/gtest.h" |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 29 | |
| 30 | namespace webrtc { |
| 31 | |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 32 | using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; |
| 33 | |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 34 | namespace { |
Steve Anton | 6f25b09 | 2017-10-23 09:39:20 -0700 | [diff] [blame] | 35 | const uint32_t kDefaultTimeout = 10000U; |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | PeerConnectionWrapper::PeerConnectionWrapper( |
| 39 | rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory, |
| 40 | rtc::scoped_refptr<PeerConnectionInterface> pc, |
| 41 | std::unique_ptr<MockPeerConnectionObserver> observer) |
Mirko Bonadei | 2a82310 | 2017-11-13 11:50:33 +0100 | [diff] [blame] | 42 | : pc_factory_(std::move(pc_factory)), |
| 43 | observer_(std::move(observer)), |
| 44 | pc_(std::move(pc)) { |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 45 | RTC_DCHECK(pc_factory_); |
| 46 | RTC_DCHECK(pc_); |
| 47 | RTC_DCHECK(observer_); |
| 48 | observer_->SetPeerConnectionInterface(pc_.get()); |
| 49 | } |
| 50 | |
Tomas Gunnarsson | 2efb8a5 | 2021-04-01 16:26:57 +0200 | [diff] [blame] | 51 | PeerConnectionWrapper::~PeerConnectionWrapper() { |
| 52 | if (pc_) |
| 53 | pc_->Close(); |
| 54 | } |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 55 | |
| 56 | PeerConnectionFactoryInterface* PeerConnectionWrapper::pc_factory() { |
| 57 | return pc_factory_.get(); |
| 58 | } |
| 59 | |
| 60 | PeerConnectionInterface* PeerConnectionWrapper::pc() { |
| 61 | return pc_.get(); |
| 62 | } |
| 63 | |
| 64 | MockPeerConnectionObserver* PeerConnectionWrapper::observer() { |
| 65 | return observer_.get(); |
| 66 | } |
| 67 | |
| 68 | std::unique_ptr<SessionDescriptionInterface> |
| 69 | PeerConnectionWrapper::CreateOffer() { |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 70 | return CreateOffer(RTCOfferAnswerOptions()); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | std::unique_ptr<SessionDescriptionInterface> PeerConnectionWrapper::CreateOffer( |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 74 | const PeerConnectionInterface::RTCOfferAnswerOptions& options, |
| 75 | std::string* error_out) { |
| 76 | return CreateSdp( |
| 77 | [this, options](CreateSessionDescriptionObserver* observer) { |
| 78 | pc()->CreateOffer(observer, options); |
| 79 | }, |
| 80 | error_out); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | std::unique_ptr<SessionDescriptionInterface> |
| 84 | PeerConnectionWrapper::CreateOfferAndSetAsLocal() { |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 85 | return CreateOfferAndSetAsLocal(RTCOfferAnswerOptions()); |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | std::unique_ptr<SessionDescriptionInterface> |
| 89 | PeerConnectionWrapper::CreateOfferAndSetAsLocal( |
| 90 | const PeerConnectionInterface::RTCOfferAnswerOptions& options) { |
| 91 | auto offer = CreateOffer(options); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 92 | if (!offer) { |
| 93 | return nullptr; |
| 94 | } |
| 95 | EXPECT_TRUE(SetLocalDescription(CloneSessionDescription(offer.get()))); |
| 96 | return offer; |
| 97 | } |
| 98 | |
| 99 | std::unique_ptr<SessionDescriptionInterface> |
| 100 | PeerConnectionWrapper::CreateAnswer() { |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 101 | return CreateAnswer(RTCOfferAnswerOptions()); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | std::unique_ptr<SessionDescriptionInterface> |
| 105 | PeerConnectionWrapper::CreateAnswer( |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 106 | const PeerConnectionInterface::RTCOfferAnswerOptions& options, |
| 107 | std::string* error_out) { |
| 108 | return CreateSdp( |
| 109 | [this, options](CreateSessionDescriptionObserver* observer) { |
| 110 | pc()->CreateAnswer(observer, options); |
| 111 | }, |
| 112 | error_out); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | std::unique_ptr<SessionDescriptionInterface> |
| 116 | PeerConnectionWrapper::CreateAnswerAndSetAsLocal() { |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 117 | return CreateAnswerAndSetAsLocal(RTCOfferAnswerOptions()); |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | std::unique_ptr<SessionDescriptionInterface> |
| 121 | PeerConnectionWrapper::CreateAnswerAndSetAsLocal( |
| 122 | const PeerConnectionInterface::RTCOfferAnswerOptions& options) { |
| 123 | auto answer = CreateAnswer(options); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 124 | if (!answer) { |
| 125 | return nullptr; |
| 126 | } |
| 127 | EXPECT_TRUE(SetLocalDescription(CloneSessionDescription(answer.get()))); |
| 128 | return answer; |
| 129 | } |
| 130 | |
Eldar Rello | 5ab79e6 | 2019-10-09 18:29:44 +0300 | [diff] [blame] | 131 | std::unique_ptr<SessionDescriptionInterface> |
| 132 | PeerConnectionWrapper::CreateRollback() { |
| 133 | return CreateSessionDescription(SdpType::kRollback, ""); |
| 134 | } |
| 135 | |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 136 | std::unique_ptr<SessionDescriptionInterface> PeerConnectionWrapper::CreateSdp( |
Mirko Bonadei | 2a82310 | 2017-11-13 11:50:33 +0100 | [diff] [blame] | 137 | rtc::FunctionView<void(CreateSessionDescriptionObserver*)> fn, |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 138 | std::string* error_out) { |
Tommi | 87f7090 | 2021-04-27 14:43:08 +0200 | [diff] [blame] | 139 | auto observer = rtc::make_ref_counted<MockCreateSessionDescriptionObserver>(); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 140 | fn(observer); |
Steve Anton | 6f25b09 | 2017-10-23 09:39:20 -0700 | [diff] [blame] | 141 | EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout); |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 142 | if (error_out && !observer->result()) { |
| 143 | *error_out = observer->error(); |
| 144 | } |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 145 | return observer->MoveDescription(); |
| 146 | } |
| 147 | |
| 148 | bool PeerConnectionWrapper::SetLocalDescription( |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 149 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 150 | std::string* error_out) { |
| 151 | return SetSdp( |
| 152 | [this, &desc](SetSessionDescriptionObserver* observer) { |
| 153 | pc()->SetLocalDescription(observer, desc.release()); |
| 154 | }, |
| 155 | error_out); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | bool PeerConnectionWrapper::SetRemoteDescription( |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 159 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 160 | std::string* error_out) { |
| 161 | return SetSdp( |
| 162 | [this, &desc](SetSessionDescriptionObserver* observer) { |
| 163 | pc()->SetRemoteDescription(observer, desc.release()); |
| 164 | }, |
| 165 | error_out); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Henrik Boström | 3163867 | 2017-11-23 17:48:32 +0100 | [diff] [blame] | 168 | bool PeerConnectionWrapper::SetRemoteDescription( |
| 169 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 170 | RTCError* error_out) { |
Henrik Boström | 831ae4e | 2020-07-29 12:04:00 +0200 | [diff] [blame] | 171 | rtc::scoped_refptr<FakeSetRemoteDescriptionObserver> observer = |
| 172 | new FakeSetRemoteDescriptionObserver(); |
Henrik Boström | 3163867 | 2017-11-23 17:48:32 +0100 | [diff] [blame] | 173 | pc()->SetRemoteDescription(std::move(desc), observer); |
| 174 | EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout); |
| 175 | bool ok = observer->error().ok(); |
| 176 | if (error_out) |
| 177 | *error_out = std::move(observer->error()); |
| 178 | return ok; |
| 179 | } |
| 180 | |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 181 | bool PeerConnectionWrapper::SetSdp( |
Mirko Bonadei | 2a82310 | 2017-11-13 11:50:33 +0100 | [diff] [blame] | 182 | rtc::FunctionView<void(SetSessionDescriptionObserver*)> fn, |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 183 | std::string* error_out) { |
Tommi | 87f7090 | 2021-04-27 14:43:08 +0200 | [diff] [blame] | 184 | auto observer = rtc::make_ref_counted<MockSetSessionDescriptionObserver>(); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 185 | fn(observer); |
Steve Anton | 6f25b09 | 2017-10-23 09:39:20 -0700 | [diff] [blame] | 186 | EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout); |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 187 | if (error_out && !observer->result()) { |
| 188 | *error_out = observer->error(); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 189 | } |
| 190 | return observer->result(); |
| 191 | } |
| 192 | |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 193 | bool PeerConnectionWrapper::ExchangeOfferAnswerWith( |
| 194 | PeerConnectionWrapper* answerer) { |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 195 | return ExchangeOfferAnswerWith(answerer, RTCOfferAnswerOptions(), |
| 196 | RTCOfferAnswerOptions()); |
| 197 | } |
| 198 | |
| 199 | bool PeerConnectionWrapper::ExchangeOfferAnswerWith( |
| 200 | PeerConnectionWrapper* answerer, |
| 201 | const PeerConnectionInterface::RTCOfferAnswerOptions& offer_options, |
| 202 | const PeerConnectionInterface::RTCOfferAnswerOptions& answer_options) { |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 203 | RTC_DCHECK(answerer); |
| 204 | if (answerer == this) { |
| 205 | RTC_LOG(LS_ERROR) << "Cannot exchange offer/answer with ourself!"; |
| 206 | return false; |
| 207 | } |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 208 | auto offer = CreateOffer(offer_options); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 209 | EXPECT_TRUE(offer); |
| 210 | if (!offer) { |
| 211 | return false; |
| 212 | } |
| 213 | bool set_local_offer = |
| 214 | SetLocalDescription(CloneSessionDescription(offer.get())); |
| 215 | EXPECT_TRUE(set_local_offer); |
| 216 | if (!set_local_offer) { |
| 217 | return false; |
| 218 | } |
| 219 | bool set_remote_offer = answerer->SetRemoteDescription(std::move(offer)); |
| 220 | EXPECT_TRUE(set_remote_offer); |
| 221 | if (!set_remote_offer) { |
| 222 | return false; |
| 223 | } |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 224 | auto answer = answerer->CreateAnswer(answer_options); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 225 | EXPECT_TRUE(answer); |
| 226 | if (!answer) { |
| 227 | return false; |
| 228 | } |
| 229 | bool set_local_answer = |
| 230 | answerer->SetLocalDescription(CloneSessionDescription(answer.get())); |
| 231 | EXPECT_TRUE(set_local_answer); |
| 232 | if (!set_local_answer) { |
| 233 | return false; |
| 234 | } |
| 235 | bool set_remote_answer = SetRemoteDescription(std::move(answer)); |
| 236 | EXPECT_TRUE(set_remote_answer); |
| 237 | return set_remote_answer; |
| 238 | } |
| 239 | |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 240 | rtc::scoped_refptr<RtpTransceiverInterface> |
| 241 | PeerConnectionWrapper::AddTransceiver(cricket::MediaType media_type) { |
| 242 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result = |
| 243 | pc()->AddTransceiver(media_type); |
| 244 | EXPECT_EQ(RTCErrorType::NONE, result.error().type()); |
| 245 | return result.MoveValue(); |
| 246 | } |
| 247 | |
| 248 | rtc::scoped_refptr<RtpTransceiverInterface> |
| 249 | PeerConnectionWrapper::AddTransceiver(cricket::MediaType media_type, |
| 250 | const RtpTransceiverInit& init) { |
| 251 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result = |
| 252 | pc()->AddTransceiver(media_type, init); |
| 253 | EXPECT_EQ(RTCErrorType::NONE, result.error().type()); |
| 254 | return result.MoveValue(); |
| 255 | } |
| 256 | |
| 257 | rtc::scoped_refptr<RtpTransceiverInterface> |
| 258 | PeerConnectionWrapper::AddTransceiver( |
| 259 | rtc::scoped_refptr<MediaStreamTrackInterface> track) { |
| 260 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result = |
| 261 | pc()->AddTransceiver(track); |
| 262 | EXPECT_EQ(RTCErrorType::NONE, result.error().type()); |
| 263 | return result.MoveValue(); |
| 264 | } |
| 265 | |
| 266 | rtc::scoped_refptr<RtpTransceiverInterface> |
| 267 | PeerConnectionWrapper::AddTransceiver( |
| 268 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 269 | const RtpTransceiverInit& init) { |
| 270 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result = |
| 271 | pc()->AddTransceiver(track, init); |
| 272 | EXPECT_EQ(RTCErrorType::NONE, result.error().type()); |
| 273 | return result.MoveValue(); |
| 274 | } |
| 275 | |
| 276 | rtc::scoped_refptr<AudioTrackInterface> PeerConnectionWrapper::CreateAudioTrack( |
| 277 | const std::string& label) { |
| 278 | return pc_factory()->CreateAudioTrack(label, nullptr); |
| 279 | } |
| 280 | |
| 281 | rtc::scoped_refptr<VideoTrackInterface> PeerConnectionWrapper::CreateVideoTrack( |
| 282 | const std::string& label) { |
Niels Möller | e8ae5df | 2018-05-29 09:13:57 +0200 | [diff] [blame] | 283 | return pc_factory()->CreateVideoTrack(label, FakeVideoTrackSource::Create()); |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 284 | } |
| 285 | |
Steve Anton | 2d6c76a | 2018-01-05 17:10:52 -0800 | [diff] [blame] | 286 | rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddTrack( |
| 287 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 288 | const std::vector<std::string>& stream_ids) { |
Steve Anton | 2d6c76a | 2018-01-05 17:10:52 -0800 | [diff] [blame] | 289 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> result = |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 290 | pc()->AddTrack(track, stream_ids); |
Steve Anton | 2d6c76a | 2018-01-05 17:10:52 -0800 | [diff] [blame] | 291 | EXPECT_EQ(RTCErrorType::NONE, result.error().type()); |
| 292 | return result.MoveValue(); |
| 293 | } |
| 294 | |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 295 | rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddAudioTrack( |
| 296 | const std::string& track_label, |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 297 | const std::vector<std::string>& stream_ids) { |
| 298 | return AddTrack(CreateAudioTrack(track_label), stream_ids); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 301 | rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddVideoTrack( |
| 302 | const std::string& track_label, |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 303 | const std::vector<std::string>& stream_ids) { |
| 304 | return AddTrack(CreateVideoTrack(track_label), stream_ids); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 307 | rtc::scoped_refptr<DataChannelInterface> |
| 308 | PeerConnectionWrapper::CreateDataChannel(const std::string& label) { |
Harald Alvestrand | a9af50f | 2021-05-21 13:33:51 +0000 | [diff] [blame^] | 309 | auto result = pc()->CreateDataChannelOrError(label, nullptr); |
| 310 | if (!result.ok()) { |
| 311 | RTC_LOG(LS_ERROR) << "CreateDataChannel failed: " |
| 312 | << ToString(result.error().type()) << " " |
| 313 | << result.error().message(); |
| 314 | return nullptr; |
| 315 | } |
| 316 | return result.MoveValue(); |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 317 | } |
| 318 | |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 319 | PeerConnectionInterface::SignalingState |
| 320 | PeerConnectionWrapper::signaling_state() { |
| 321 | return pc()->signaling_state(); |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 322 | } |
| 323 | |
Steve Anton | f1c6db1 | 2017-10-13 11:13:35 -0700 | [diff] [blame] | 324 | bool PeerConnectionWrapper::IsIceGatheringDone() { |
Steve Anton | 6f25b09 | 2017-10-23 09:39:20 -0700 | [diff] [blame] | 325 | return observer()->ice_gathering_complete_; |
| 326 | } |
| 327 | |
| 328 | bool PeerConnectionWrapper::IsIceConnected() { |
| 329 | return observer()->ice_connected_; |
| 330 | } |
| 331 | |
| 332 | rtc::scoped_refptr<const webrtc::RTCStatsReport> |
| 333 | PeerConnectionWrapper::GetStats() { |
Tommi | 87f7090 | 2021-04-27 14:43:08 +0200 | [diff] [blame] | 334 | auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>(); |
Steve Anton | 6f25b09 | 2017-10-23 09:39:20 -0700 | [diff] [blame] | 335 | pc()->GetStats(callback); |
| 336 | EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout); |
| 337 | return callback->report(); |
Steve Anton | f1c6db1 | 2017-10-13 11:13:35 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Steve Anton | 94286cb | 2017-09-26 16:20:19 -0700 | [diff] [blame] | 340 | } // namespace webrtc |