OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 size_t ssrc_pos = 0; | 120 size_t ssrc_pos = 0; |
121 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != | 121 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != |
122 std::string::npos) { | 122 std::string::npos) { |
123 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); | 123 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); |
124 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); | 124 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 class SignalingMessageReceiver { | 128 class SignalingMessageReceiver { |
129 public: | 129 public: |
130 protected: | |
131 SignalingMessageReceiver() {} | |
132 virtual ~SignalingMessageReceiver() {} | |
133 }; | |
134 | |
135 class JsepMessageReceiver : public SignalingMessageReceiver { | |
136 public: | |
137 virtual void ReceiveSdpMessage(const std::string& type, | 130 virtual void ReceiveSdpMessage(const std::string& type, |
138 std::string& msg) = 0; | 131 std::string& msg) = 0; |
139 virtual void ReceiveIceMessage(const std::string& sdp_mid, | 132 virtual void ReceiveIceMessage(const std::string& sdp_mid, |
140 int sdp_mline_index, | 133 int sdp_mline_index, |
141 const std::string& msg) = 0; | 134 const std::string& msg) = 0; |
142 | 135 |
143 protected: | 136 protected: |
144 JsepMessageReceiver() {} | 137 SignalingMessageReceiver() {} |
145 virtual ~JsepMessageReceiver() {} | 138 virtual ~SignalingMessageReceiver() {} |
146 }; | 139 }; |
147 | 140 |
148 template <typename MessageReceiver> | 141 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
149 class PeerConnectionTestClientBase | 142 public SignalingMessageReceiver { |
150 : public webrtc::PeerConnectionObserver, | |
151 public MessageReceiver { | |
152 public: | 143 public: |
153 ~PeerConnectionTestClientBase() { | 144 static PeerConnectionTestClient* CreateClient( |
| 145 const std::string& id, |
| 146 const MediaConstraintsInterface* constraints, |
| 147 const PeerConnectionFactory::Options* options) { |
| 148 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); |
| 149 if (!client->Init(constraints, options)) { |
| 150 delete client; |
| 151 return nullptr; |
| 152 } |
| 153 return client; |
| 154 } |
| 155 |
| 156 ~PeerConnectionTestClient() { |
154 while (!fake_video_renderers_.empty()) { | 157 while (!fake_video_renderers_.empty()) { |
155 RenderMap::iterator it = fake_video_renderers_.begin(); | 158 RenderMap::iterator it = fake_video_renderers_.begin(); |
156 delete it->second; | 159 delete it->second; |
157 fake_video_renderers_.erase(it); | 160 fake_video_renderers_.erase(it); |
158 } | 161 } |
159 } | 162 } |
160 | 163 |
161 virtual void Negotiate() = 0; | 164 void Negotiate() { Negotiate(true, true); } |
162 | 165 |
163 virtual void Negotiate(bool audio, bool video) = 0; | 166 void Negotiate(bool audio, bool video) { |
| 167 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 168 ASSERT_TRUE(DoCreateOffer(offer.use())); |
164 | 169 |
165 virtual void SetVideoConstraints( | 170 if (offer->description()->GetContentByName("audio")) { |
166 const webrtc::FakeConstraints& video_constraint) { | 171 offer->description()->GetContentByName("audio")->rejected = !audio; |
| 172 } |
| 173 if (offer->description()->GetContentByName("video")) { |
| 174 offer->description()->GetContentByName("video")->rejected = !video; |
| 175 } |
| 176 |
| 177 std::string sdp; |
| 178 EXPECT_TRUE(offer->ToString(&sdp)); |
| 179 EXPECT_TRUE(DoSetLocalDescription(offer.release())); |
| 180 signaling_message_receiver_->ReceiveSdpMessage( |
| 181 webrtc::SessionDescriptionInterface::kOffer, sdp); |
| 182 } |
| 183 |
| 184 // SignalingMessageReceiver callback. |
| 185 void ReceiveSdpMessage(const std::string& type, std::string& msg) override { |
| 186 FilterIncomingSdpMessage(&msg); |
| 187 if (type == webrtc::SessionDescriptionInterface::kOffer) { |
| 188 HandleIncomingOffer(msg); |
| 189 } else { |
| 190 HandleIncomingAnswer(msg); |
| 191 } |
| 192 } |
| 193 |
| 194 // SignalingMessageReceiver callback. |
| 195 void ReceiveIceMessage(const std::string& sdp_mid, |
| 196 int sdp_mline_index, |
| 197 const std::string& msg) override { |
| 198 LOG(INFO) << id_ << "ReceiveIceMessage"; |
| 199 rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate( |
| 200 webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, msg, nullptr)); |
| 201 EXPECT_TRUE(pc()->AddIceCandidate(candidate.get())); |
| 202 } |
| 203 |
| 204 // PeerConnectionObserver callbacks. |
| 205 void OnSignalingChange( |
| 206 webrtc::PeerConnectionInterface::SignalingState new_state) override { |
| 207 EXPECT_EQ(pc()->signaling_state(), new_state); |
| 208 } |
| 209 void OnAddStream(webrtc::MediaStreamInterface* media_stream) override { |
| 210 for (size_t i = 0; i < media_stream->GetVideoTracks().size(); ++i) { |
| 211 const std::string id = media_stream->GetVideoTracks()[i]->id(); |
| 212 ASSERT_TRUE(fake_video_renderers_.find(id) == |
| 213 fake_video_renderers_.end()); |
| 214 fake_video_renderers_[id] = |
| 215 new webrtc::FakeVideoTrackRenderer(media_stream->GetVideoTracks()[i]); |
| 216 } |
| 217 } |
| 218 void OnRemoveStream(webrtc::MediaStreamInterface* media_stream) override {} |
| 219 void OnRenegotiationNeeded() override {} |
| 220 void OnIceConnectionChange( |
| 221 webrtc::PeerConnectionInterface::IceConnectionState new_state) override { |
| 222 EXPECT_EQ(pc()->ice_connection_state(), new_state); |
| 223 } |
| 224 void OnIceGatheringChange( |
| 225 webrtc::PeerConnectionInterface::IceGatheringState new_state) override { |
| 226 EXPECT_EQ(pc()->ice_gathering_state(), new_state); |
| 227 } |
| 228 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { |
| 229 LOG(INFO) << id_ << "OnIceCandidate"; |
| 230 |
| 231 std::string ice_sdp; |
| 232 EXPECT_TRUE(candidate->ToString(&ice_sdp)); |
| 233 if (signaling_message_receiver_ == nullptr) { |
| 234 // Remote party may be deleted. |
| 235 return; |
| 236 } |
| 237 signaling_message_receiver_->ReceiveIceMessage( |
| 238 candidate->sdp_mid(), candidate->sdp_mline_index(), ice_sdp); |
| 239 } |
| 240 |
| 241 void SetVideoConstraints(const webrtc::FakeConstraints& video_constraint) { |
167 video_constraints_ = video_constraint; | 242 video_constraints_ = video_constraint; |
168 } | 243 } |
169 | 244 |
170 void AddMediaStream(bool audio, bool video) { | 245 void AddMediaStream(bool audio, bool video) { |
171 std::string stream_label = kStreamLabelBase + | 246 std::string stream_label = |
172 rtc::ToString<int>( | 247 kStreamLabelBase + |
173 static_cast<int>(peer_connection_->local_streams()->count())); | 248 rtc::ToString<int>(static_cast<int>(pc()->local_streams()->count())); |
174 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = | 249 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = |
175 peer_connection_factory_->CreateLocalMediaStream(stream_label); | 250 peer_connection_factory_->CreateLocalMediaStream(stream_label); |
176 | 251 |
177 if (audio && can_receive_audio()) { | 252 if (audio && can_receive_audio()) { |
178 FakeConstraints constraints; | 253 FakeConstraints constraints; |
179 // Disable highpass filter so that we can get all the test audio frames. | 254 // Disable highpass filter so that we can get all the test audio frames. |
180 constraints.AddMandatory( | 255 constraints.AddMandatory( |
181 MediaConstraintsInterface::kHighpassFilter, false); | 256 MediaConstraintsInterface::kHighpassFilter, false); |
182 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = | 257 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = |
183 peer_connection_factory_->CreateAudioSource(&constraints); | 258 peer_connection_factory_->CreateAudioSource(&constraints); |
184 // TODO(perkj): Test audio source when it is implemented. Currently audio | 259 // TODO(perkj): Test audio source when it is implemented. Currently audio |
185 // always use the default input. | 260 // always use the default input. |
186 std::string label = stream_label + kAudioTrackLabelBase; | 261 std::string label = stream_label + kAudioTrackLabelBase; |
187 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( | 262 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( |
188 peer_connection_factory_->CreateAudioTrack(label, source)); | 263 peer_connection_factory_->CreateAudioTrack(label, source)); |
189 stream->AddTrack(audio_track); | 264 stream->AddTrack(audio_track); |
190 } | 265 } |
191 if (video && can_receive_video()) { | 266 if (video && can_receive_video()) { |
192 stream->AddTrack(CreateLocalVideoTrack(stream_label)); | 267 stream->AddTrack(CreateLocalVideoTrack(stream_label)); |
193 } | 268 } |
194 | 269 |
195 EXPECT_TRUE(peer_connection_->AddStream(stream)); | 270 EXPECT_TRUE(pc()->AddStream(stream)); |
196 } | 271 } |
197 | 272 |
198 size_t NumberOfLocalMediaStreams() { | 273 size_t NumberOfLocalMediaStreams() { return pc()->local_streams()->count(); } |
199 return peer_connection_->local_streams()->count(); | |
200 } | |
201 | 274 |
202 bool SessionActive() { | 275 bool SessionActive() { |
203 return peer_connection_->signaling_state() == | 276 return pc()->signaling_state() == webrtc::PeerConnectionInterface::kStable; |
204 webrtc::PeerConnectionInterface::kStable; | |
205 } | 277 } |
206 | 278 |
207 void set_signaling_message_receiver( | 279 void set_signaling_message_receiver( |
208 MessageReceiver* signaling_message_receiver) { | 280 SignalingMessageReceiver* signaling_message_receiver) { |
209 signaling_message_receiver_ = signaling_message_receiver; | 281 signaling_message_receiver_ = signaling_message_receiver; |
210 } | 282 } |
211 | 283 |
212 void EnableVideoDecoderFactory() { | 284 void EnableVideoDecoderFactory() { |
213 video_decoder_factory_enabled_ = true; | 285 video_decoder_factory_enabled_ = true; |
214 fake_video_decoder_factory_->AddSupportedVideoCodecType( | 286 fake_video_decoder_factory_->AddSupportedVideoCodecType( |
215 webrtc::kVideoCodecVP8); | 287 webrtc::kVideoCodecVP8); |
216 } | 288 } |
217 | 289 |
| 290 void IceRestart() { |
| 291 session_description_constraints_.SetMandatoryIceRestart(true); |
| 292 SetExpectIceRestart(true); |
| 293 } |
| 294 |
| 295 void SetExpectIceRestart(bool expect_restart) { |
| 296 expect_ice_restart_ = expect_restart; |
| 297 } |
| 298 |
| 299 bool ExpectIceRestart() const { return expect_ice_restart_; } |
| 300 |
| 301 void SetReceiveAudioVideo(bool audio, bool video) { |
| 302 SetReceiveAudio(audio); |
| 303 SetReceiveVideo(video); |
| 304 ASSERT_EQ(audio, can_receive_audio()); |
| 305 ASSERT_EQ(video, can_receive_video()); |
| 306 } |
| 307 |
| 308 void SetReceiveAudio(bool audio) { |
| 309 if (audio && can_receive_audio()) |
| 310 return; |
| 311 session_description_constraints_.SetMandatoryReceiveAudio(audio); |
| 312 } |
| 313 |
| 314 void SetReceiveVideo(bool video) { |
| 315 if (video && can_receive_video()) |
| 316 return; |
| 317 session_description_constraints_.SetMandatoryReceiveVideo(video); |
| 318 } |
| 319 |
| 320 void RemoveMsidFromReceivedSdp(bool remove) { remove_msid_ = remove; } |
| 321 |
| 322 void RemoveSdesCryptoFromReceivedSdp(bool remove) { remove_sdes_ = remove; } |
| 323 |
| 324 void RemoveBundleFromReceivedSdp(bool remove) { remove_bundle_ = remove; } |
| 325 |
| 326 bool can_receive_audio() { |
| 327 bool value; |
| 328 if (webrtc::FindConstraint(&session_description_constraints_, |
| 329 MediaConstraintsInterface::kOfferToReceiveAudio, |
| 330 &value, nullptr)) { |
| 331 return value; |
| 332 } |
| 333 return true; |
| 334 } |
| 335 |
| 336 bool can_receive_video() { |
| 337 bool value; |
| 338 if (webrtc::FindConstraint(&session_description_constraints_, |
| 339 MediaConstraintsInterface::kOfferToReceiveVideo, |
| 340 &value, nullptr)) { |
| 341 return value; |
| 342 } |
| 343 return true; |
| 344 } |
| 345 |
| 346 void OnIceComplete() override { LOG(INFO) << id_ << "OnIceComplete"; } |
| 347 |
| 348 void OnDataChannel(DataChannelInterface* data_channel) override { |
| 349 LOG(INFO) << id_ << "OnDataChannel"; |
| 350 data_channel_ = data_channel; |
| 351 data_observer_.reset(new MockDataChannelObserver(data_channel)); |
| 352 } |
| 353 |
| 354 void CreateDataChannel() { |
| 355 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr); |
| 356 ASSERT_TRUE(data_channel_.get() != nullptr); |
| 357 data_observer_.reset(new MockDataChannelObserver(data_channel_)); |
| 358 } |
| 359 |
| 360 DataChannelInterface* data_channel() { return data_channel_; } |
| 361 const MockDataChannelObserver* data_observer() const { |
| 362 return data_observer_.get(); |
| 363 } |
| 364 |
| 365 webrtc::PeerConnectionInterface* pc() { return peer_connection_.get(); } |
| 366 |
| 367 void StopVideoCapturers() { |
| 368 for (std::vector<cricket::VideoCapturer*>::iterator it = |
| 369 video_capturers_.begin(); |
| 370 it != video_capturers_.end(); ++it) { |
| 371 (*it)->Stop(); |
| 372 } |
| 373 } |
| 374 |
218 bool AudioFramesReceivedCheck(int number_of_frames) const { | 375 bool AudioFramesReceivedCheck(int number_of_frames) const { |
219 return number_of_frames <= fake_audio_capture_module_->frames_received(); | 376 return number_of_frames <= fake_audio_capture_module_->frames_received(); |
220 } | 377 } |
221 | 378 |
222 bool VideoFramesReceivedCheck(int number_of_frames) { | 379 bool VideoFramesReceivedCheck(int number_of_frames) { |
223 if (video_decoder_factory_enabled_) { | 380 if (video_decoder_factory_enabled_) { |
224 const std::vector<FakeWebRtcVideoDecoder*>& decoders | 381 const std::vector<FakeWebRtcVideoDecoder*>& decoders |
225 = fake_video_decoder_factory_->decoders(); | 382 = fake_video_decoder_factory_->decoders(); |
226 if (decoders.empty()) { | 383 if (decoders.empty()) { |
227 return number_of_frames <= 0; | 384 return number_of_frames <= 0; |
(...skipping 13 matching lines...) Expand all Loading... |
241 | 398 |
242 for (RenderMap::const_iterator it = fake_video_renderers_.begin(); | 399 for (RenderMap::const_iterator it = fake_video_renderers_.begin(); |
243 it != fake_video_renderers_.end(); ++it) { | 400 it != fake_video_renderers_.end(); ++it) { |
244 if (number_of_frames > it->second->num_rendered_frames()) { | 401 if (number_of_frames > it->second->num_rendered_frames()) { |
245 return false; | 402 return false; |
246 } | 403 } |
247 } | 404 } |
248 return true; | 405 return true; |
249 } | 406 } |
250 } | 407 } |
| 408 |
251 // Verify the CreateDtmfSender interface | 409 // Verify the CreateDtmfSender interface |
252 void VerifyDtmf() { | 410 void VerifyDtmf() { |
253 rtc::scoped_ptr<DummyDtmfObserver> observer(new DummyDtmfObserver()); | 411 rtc::scoped_ptr<DummyDtmfObserver> observer(new DummyDtmfObserver()); |
254 rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender; | 412 rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender; |
255 | 413 |
256 // We can't create a DTMF sender with an invalid audio track or a non local | 414 // We can't create a DTMF sender with an invalid audio track or a non local |
257 // track. | 415 // track. |
258 EXPECT_TRUE(peer_connection_->CreateDtmfSender(NULL) == NULL); | 416 EXPECT_TRUE(peer_connection_->CreateDtmfSender(nullptr) == nullptr); |
259 rtc::scoped_refptr<webrtc::AudioTrackInterface> non_localtrack( | 417 rtc::scoped_refptr<webrtc::AudioTrackInterface> non_localtrack( |
260 peer_connection_factory_->CreateAudioTrack("dummy_track", | 418 peer_connection_factory_->CreateAudioTrack("dummy_track", nullptr)); |
261 NULL)); | 419 EXPECT_TRUE(peer_connection_->CreateDtmfSender(non_localtrack) == nullptr); |
262 EXPECT_TRUE(peer_connection_->CreateDtmfSender(non_localtrack) == NULL); | |
263 | 420 |
264 // We should be able to create a DTMF sender from a local track. | 421 // We should be able to create a DTMF sender from a local track. |
265 webrtc::AudioTrackInterface* localtrack = | 422 webrtc::AudioTrackInterface* localtrack = |
266 peer_connection_->local_streams()->at(0)->GetAudioTracks()[0]; | 423 peer_connection_->local_streams()->at(0)->GetAudioTracks()[0]; |
267 dtmf_sender = peer_connection_->CreateDtmfSender(localtrack); | 424 dtmf_sender = peer_connection_->CreateDtmfSender(localtrack); |
268 EXPECT_TRUE(dtmf_sender.get() != NULL); | 425 EXPECT_TRUE(dtmf_sender.get() != nullptr); |
269 dtmf_sender->RegisterObserver(observer.get()); | 426 dtmf_sender->RegisterObserver(observer.get()); |
270 | 427 |
271 // Test the DtmfSender object just created. | 428 // Test the DtmfSender object just created. |
272 EXPECT_TRUE(dtmf_sender->CanInsertDtmf()); | 429 EXPECT_TRUE(dtmf_sender->CanInsertDtmf()); |
273 EXPECT_TRUE(dtmf_sender->InsertDtmf("1a", 100, 50)); | 430 EXPECT_TRUE(dtmf_sender->InsertDtmf("1a", 100, 50)); |
274 | 431 |
275 // We don't need to verify that the DTMF tones are actually sent out because | 432 // We don't need to verify that the DTMF tones are actually sent out because |
276 // that is already covered by the tests of the lower level components. | 433 // that is already covered by the tests of the lower level components. |
277 | 434 |
278 EXPECT_TRUE_WAIT(observer->completed(), kMaxWaitMs); | 435 EXPECT_TRUE_WAIT(observer->completed(), kMaxWaitMs); |
279 std::vector<std::string> tones; | 436 std::vector<std::string> tones; |
280 tones.push_back("1"); | 437 tones.push_back("1"); |
281 tones.push_back("a"); | 438 tones.push_back("a"); |
282 tones.push_back(""); | 439 tones.push_back(""); |
283 observer->Verify(tones); | 440 observer->Verify(tones); |
284 | 441 |
285 dtmf_sender->UnregisterObserver(); | 442 dtmf_sender->UnregisterObserver(); |
286 } | 443 } |
287 | 444 |
288 // Verifies that the SessionDescription have rejected the appropriate media | 445 // Verifies that the SessionDescription have rejected the appropriate media |
289 // content. | 446 // content. |
290 void VerifyRejectedMediaInSessionDescription() { | 447 void VerifyRejectedMediaInSessionDescription() { |
291 ASSERT_TRUE(peer_connection_->remote_description() != NULL); | 448 ASSERT_TRUE(peer_connection_->remote_description() != nullptr); |
292 ASSERT_TRUE(peer_connection_->local_description() != NULL); | 449 ASSERT_TRUE(peer_connection_->local_description() != nullptr); |
293 const cricket::SessionDescription* remote_desc = | 450 const cricket::SessionDescription* remote_desc = |
294 peer_connection_->remote_description()->description(); | 451 peer_connection_->remote_description()->description(); |
295 const cricket::SessionDescription* local_desc = | 452 const cricket::SessionDescription* local_desc = |
296 peer_connection_->local_description()->description(); | 453 peer_connection_->local_description()->description(); |
297 | 454 |
298 const ContentInfo* remote_audio_content = GetFirstAudioContent(remote_desc); | 455 const ContentInfo* remote_audio_content = GetFirstAudioContent(remote_desc); |
299 if (remote_audio_content) { | 456 if (remote_audio_content) { |
300 const ContentInfo* audio_content = | 457 const ContentInfo* audio_content = |
301 GetFirstAudioContent(local_desc); | 458 GetFirstAudioContent(local_desc); |
302 EXPECT_EQ(can_receive_audio(), !audio_content->rejected); | 459 EXPECT_EQ(can_receive_audio(), !audio_content->rejected); |
303 } | 460 } |
304 | 461 |
305 const ContentInfo* remote_video_content = GetFirstVideoContent(remote_desc); | 462 const ContentInfo* remote_video_content = GetFirstVideoContent(remote_desc); |
306 if (remote_video_content) { | 463 if (remote_video_content) { |
307 const ContentInfo* video_content = | 464 const ContentInfo* video_content = |
308 GetFirstVideoContent(local_desc); | 465 GetFirstVideoContent(local_desc); |
309 EXPECT_EQ(can_receive_video(), !video_content->rejected); | 466 EXPECT_EQ(can_receive_video(), !video_content->rejected); |
310 } | 467 } |
311 } | 468 } |
312 | 469 |
313 void SetExpectIceRestart(bool expect_restart) { | |
314 expect_ice_restart_ = expect_restart; | |
315 } | |
316 | |
317 bool ExpectIceRestart() const { return expect_ice_restart_; } | |
318 | |
319 void VerifyLocalIceUfragAndPassword() { | 470 void VerifyLocalIceUfragAndPassword() { |
320 ASSERT_TRUE(peer_connection_->local_description() != NULL); | 471 ASSERT_TRUE(peer_connection_->local_description() != nullptr); |
321 const cricket::SessionDescription* desc = | 472 const cricket::SessionDescription* desc = |
322 peer_connection_->local_description()->description(); | 473 peer_connection_->local_description()->description(); |
323 const cricket::ContentInfos& contents = desc->contents(); | 474 const cricket::ContentInfos& contents = desc->contents(); |
324 | 475 |
325 for (size_t index = 0; index < contents.size(); ++index) { | 476 for (size_t index = 0; index < contents.size(); ++index) { |
326 if (contents[index].rejected) | 477 if (contents[index].rejected) |
327 continue; | 478 continue; |
328 const cricket::TransportDescription* transport_desc = | 479 const cricket::TransportDescription* transport_desc = |
329 desc->GetTransportDescriptionByName(contents[index].name); | 480 desc->GetTransportDescriptionByName(contents[index].name); |
330 | 481 |
(...skipping 22 matching lines...) Expand all Loading... |
353 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); | 504 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); |
354 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 505 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
355 EXPECT_NE(0, observer->timestamp()); | 506 EXPECT_NE(0, observer->timestamp()); |
356 return observer->AudioOutputLevel(); | 507 return observer->AudioOutputLevel(); |
357 } | 508 } |
358 | 509 |
359 int GetAudioInputLevelStats() { | 510 int GetAudioInputLevelStats() { |
360 rtc::scoped_refptr<MockStatsObserver> | 511 rtc::scoped_refptr<MockStatsObserver> |
361 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 512 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
362 EXPECT_TRUE(peer_connection_->GetStats( | 513 EXPECT_TRUE(peer_connection_->GetStats( |
363 observer, NULL, PeerConnectionInterface::kStatsOutputLevelStandard)); | 514 observer, nullptr, PeerConnectionInterface::kStatsOutputLevelStandard)); |
364 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 515 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
365 EXPECT_NE(0, observer->timestamp()); | 516 EXPECT_NE(0, observer->timestamp()); |
366 return observer->AudioInputLevel(); | 517 return observer->AudioInputLevel(); |
367 } | 518 } |
368 | 519 |
369 int GetBytesReceivedStats(webrtc::MediaStreamTrackInterface* track) { | 520 int GetBytesReceivedStats(webrtc::MediaStreamTrackInterface* track) { |
370 rtc::scoped_refptr<MockStatsObserver> | 521 rtc::scoped_refptr<MockStatsObserver> |
371 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 522 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
372 EXPECT_TRUE(peer_connection_->GetStats( | 523 EXPECT_TRUE(peer_connection_->GetStats( |
373 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); | 524 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); |
374 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 525 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
375 EXPECT_NE(0, observer->timestamp()); | 526 EXPECT_NE(0, observer->timestamp()); |
376 return observer->BytesReceived(); | 527 return observer->BytesReceived(); |
377 } | 528 } |
378 | 529 |
379 int GetBytesSentStats(webrtc::MediaStreamTrackInterface* track) { | 530 int GetBytesSentStats(webrtc::MediaStreamTrackInterface* track) { |
380 rtc::scoped_refptr<MockStatsObserver> | 531 rtc::scoped_refptr<MockStatsObserver> |
381 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 532 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
382 EXPECT_TRUE(peer_connection_->GetStats( | 533 EXPECT_TRUE(peer_connection_->GetStats( |
383 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); | 534 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); |
384 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 535 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
385 EXPECT_NE(0, observer->timestamp()); | 536 EXPECT_NE(0, observer->timestamp()); |
386 return observer->BytesSent(); | 537 return observer->BytesSent(); |
387 } | 538 } |
388 | 539 |
389 int GetAvailableReceivedBandwidthStats() { | 540 int GetAvailableReceivedBandwidthStats() { |
390 rtc::scoped_refptr<MockStatsObserver> | 541 rtc::scoped_refptr<MockStatsObserver> |
391 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 542 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
392 EXPECT_TRUE(peer_connection_->GetStats( | 543 EXPECT_TRUE(peer_connection_->GetStats( |
393 observer, NULL, PeerConnectionInterface::kStatsOutputLevelStandard)); | 544 observer, nullptr, PeerConnectionInterface::kStatsOutputLevelStandard)); |
394 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 545 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
395 EXPECT_NE(0, observer->timestamp()); | 546 EXPECT_NE(0, observer->timestamp()); |
396 int bw = observer->AvailableReceiveBandwidth(); | 547 int bw = observer->AvailableReceiveBandwidth(); |
397 return bw; | 548 return bw; |
398 } | 549 } |
399 | 550 |
400 std::string GetDtlsCipherStats() { | 551 std::string GetDtlsCipherStats() { |
401 rtc::scoped_refptr<MockStatsObserver> | 552 rtc::scoped_refptr<MockStatsObserver> |
402 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 553 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
403 EXPECT_TRUE(peer_connection_->GetStats( | 554 EXPECT_TRUE(peer_connection_->GetStats( |
404 observer, NULL, PeerConnectionInterface::kStatsOutputLevelStandard)); | 555 observer, nullptr, PeerConnectionInterface::kStatsOutputLevelStandard)); |
405 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 556 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
406 EXPECT_NE(0, observer->timestamp()); | 557 EXPECT_NE(0, observer->timestamp()); |
407 return observer->DtlsCipher(); | 558 return observer->DtlsCipher(); |
408 } | 559 } |
409 | 560 |
410 std::string GetSrtpCipherStats() { | 561 std::string GetSrtpCipherStats() { |
411 rtc::scoped_refptr<MockStatsObserver> | 562 rtc::scoped_refptr<MockStatsObserver> |
412 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 563 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
413 EXPECT_TRUE(peer_connection_->GetStats( | 564 EXPECT_TRUE(peer_connection_->GetStats( |
414 observer, NULL, PeerConnectionInterface::kStatsOutputLevelStandard)); | 565 observer, nullptr, PeerConnectionInterface::kStatsOutputLevelStandard)); |
415 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 566 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
416 EXPECT_NE(0, observer->timestamp()); | 567 EXPECT_NE(0, observer->timestamp()); |
417 return observer->SrtpCipher(); | 568 return observer->SrtpCipher(); |
418 } | 569 } |
419 | 570 |
420 int rendered_width() { | 571 int rendered_width() { |
421 EXPECT_FALSE(fake_video_renderers_.empty()); | 572 EXPECT_FALSE(fake_video_renderers_.empty()); |
422 return fake_video_renderers_.empty() ? 1 : | 573 return fake_video_renderers_.empty() ? 1 : |
423 fake_video_renderers_.begin()->second->width(); | 574 fake_video_renderers_.begin()->second->width(); |
424 } | 575 } |
425 | 576 |
426 int rendered_height() { | 577 int rendered_height() { |
427 EXPECT_FALSE(fake_video_renderers_.empty()); | 578 EXPECT_FALSE(fake_video_renderers_.empty()); |
428 return fake_video_renderers_.empty() ? 1 : | 579 return fake_video_renderers_.empty() ? 1 : |
429 fake_video_renderers_.begin()->second->height(); | 580 fake_video_renderers_.begin()->second->height(); |
430 } | 581 } |
431 | 582 |
432 size_t number_of_remote_streams() { | 583 size_t number_of_remote_streams() { |
433 if (!pc()) | 584 if (!pc()) |
434 return 0; | 585 return 0; |
435 return pc()->remote_streams()->count(); | 586 return pc()->remote_streams()->count(); |
436 } | 587 } |
437 | 588 |
438 StreamCollectionInterface* remote_streams() { | 589 StreamCollectionInterface* remote_streams() { |
439 if (!pc()) { | 590 if (!pc()) { |
440 ADD_FAILURE(); | 591 ADD_FAILURE(); |
441 return NULL; | 592 return nullptr; |
442 } | 593 } |
443 return pc()->remote_streams(); | 594 return pc()->remote_streams(); |
444 } | 595 } |
445 | 596 |
446 StreamCollectionInterface* local_streams() { | 597 StreamCollectionInterface* local_streams() { |
447 if (!pc()) { | 598 if (!pc()) { |
448 ADD_FAILURE(); | 599 ADD_FAILURE(); |
449 return NULL; | 600 return nullptr; |
450 } | 601 } |
451 return pc()->local_streams(); | 602 return pc()->local_streams(); |
452 } | 603 } |
453 | 604 |
454 webrtc::PeerConnectionInterface::SignalingState signaling_state() { | 605 webrtc::PeerConnectionInterface::SignalingState signaling_state() { |
455 return pc()->signaling_state(); | 606 return pc()->signaling_state(); |
456 } | 607 } |
457 | 608 |
458 webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() { | 609 webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() { |
459 return pc()->ice_connection_state(); | 610 return pc()->ice_connection_state(); |
460 } | 611 } |
461 | 612 |
462 webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() { | 613 webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() { |
463 return pc()->ice_gathering_state(); | 614 return pc()->ice_gathering_state(); |
464 } | 615 } |
465 | 616 |
466 // PeerConnectionObserver callbacks. | 617 private: |
467 virtual void OnMessage(const std::string&) {} | 618 class DummyDtmfObserver : public DtmfSenderObserverInterface { |
468 virtual void OnSignalingMessage(const std::string& /*msg*/) {} | 619 public: |
469 virtual void OnSignalingChange( | 620 DummyDtmfObserver() : completed_(false) {} |
470 webrtc::PeerConnectionInterface::SignalingState new_state) { | 621 |
471 EXPECT_EQ(peer_connection_->signaling_state(), new_state); | 622 // Implements DtmfSenderObserverInterface. |
472 } | 623 void OnToneChange(const std::string& tone) override { |
473 virtual void OnAddStream(webrtc::MediaStreamInterface* media_stream) { | 624 tones_.push_back(tone); |
474 for (size_t i = 0; i < media_stream->GetVideoTracks().size(); ++i) { | 625 if (tone.empty()) { |
475 const std::string id = media_stream->GetVideoTracks()[i]->id(); | 626 completed_ = true; |
476 ASSERT_TRUE(fake_video_renderers_.find(id) == | 627 } |
477 fake_video_renderers_.end()); | |
478 fake_video_renderers_[id] = new webrtc::FakeVideoTrackRenderer( | |
479 media_stream->GetVideoTracks()[i]); | |
480 } | 628 } |
481 } | |
482 virtual void OnRemoveStream(webrtc::MediaStreamInterface* media_stream) {} | |
483 virtual void OnRenegotiationNeeded() {} | |
484 virtual void OnIceConnectionChange( | |
485 webrtc::PeerConnectionInterface::IceConnectionState new_state) { | |
486 EXPECT_EQ(peer_connection_->ice_connection_state(), new_state); | |
487 } | |
488 virtual void OnIceGatheringChange( | |
489 webrtc::PeerConnectionInterface::IceGatheringState new_state) { | |
490 EXPECT_EQ(peer_connection_->ice_gathering_state(), new_state); | |
491 } | |
492 virtual void OnIceCandidate( | |
493 const webrtc::IceCandidateInterface* /*candidate*/) {} | |
494 | 629 |
495 webrtc::PeerConnectionInterface* pc() { | 630 void Verify(const std::vector<std::string>& tones) const { |
496 return peer_connection_.get(); | 631 ASSERT_TRUE(tones_.size() == tones.size()); |
497 } | 632 EXPECT_TRUE(std::equal(tones.begin(), tones.end(), tones_.begin())); |
498 void StopVideoCapturers() { | |
499 for (std::vector<cricket::VideoCapturer*>::iterator it = | |
500 video_capturers_.begin(); it != video_capturers_.end(); ++it) { | |
501 (*it)->Stop(); | |
502 } | 633 } |
503 } | |
504 | 634 |
505 protected: | 635 bool completed() const { return completed_; } |
506 explicit PeerConnectionTestClientBase(const std::string& id) | 636 |
507 : id_(id), | 637 private: |
508 expect_ice_restart_(false), | 638 bool completed_; |
509 fake_video_decoder_factory_(NULL), | 639 std::vector<std::string> tones_; |
510 fake_video_encoder_factory_(NULL), | 640 }; |
511 video_decoder_factory_enabled_(false), | 641 |
512 signaling_message_receiver_(NULL) { | 642 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} |
513 } | 643 |
514 bool Init(const MediaConstraintsInterface* constraints, | 644 bool Init(const MediaConstraintsInterface* constraints, |
515 const PeerConnectionFactory::Options* options) { | 645 const PeerConnectionFactory::Options* options) { |
516 EXPECT_TRUE(!peer_connection_); | 646 EXPECT_TRUE(!peer_connection_); |
517 EXPECT_TRUE(!peer_connection_factory_); | 647 EXPECT_TRUE(!peer_connection_factory_); |
518 allocator_factory_ = webrtc::FakePortAllocatorFactory::Create(); | 648 allocator_factory_ = webrtc::FakePortAllocatorFactory::Create(); |
519 if (!allocator_factory_) { | 649 if (!allocator_factory_) { |
520 return false; | 650 return false; |
521 } | 651 } |
522 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); | 652 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); |
523 | 653 |
524 if (fake_audio_capture_module_ == NULL) { | 654 if (fake_audio_capture_module_ == nullptr) { |
525 return false; | 655 return false; |
526 } | 656 } |
527 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); | 657 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); |
528 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); | 658 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); |
529 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 659 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
530 rtc::Thread::Current(), rtc::Thread::Current(), | 660 rtc::Thread::Current(), rtc::Thread::Current(), |
531 fake_audio_capture_module_, fake_video_encoder_factory_, | 661 fake_audio_capture_module_, fake_video_encoder_factory_, |
532 fake_video_decoder_factory_); | 662 fake_video_decoder_factory_); |
533 if (!peer_connection_factory_) { | 663 if (!peer_connection_factory_) { |
534 return false; | 664 return false; |
535 } | 665 } |
536 if (options) { | 666 if (options) { |
537 peer_connection_factory_->SetOptions(*options); | 667 peer_connection_factory_->SetOptions(*options); |
538 } | 668 } |
539 peer_connection_ = CreatePeerConnection(allocator_factory_.get(), | 669 peer_connection_ = CreatePeerConnection(allocator_factory_.get(), |
540 constraints); | 670 constraints); |
541 return peer_connection_.get() != NULL; | 671 return peer_connection_.get() != nullptr; |
542 } | 672 } |
543 virtual rtc::scoped_refptr<webrtc::PeerConnectionInterface> | |
544 CreatePeerConnection(webrtc::PortAllocatorFactoryInterface* factory, | |
545 const MediaConstraintsInterface* constraints) = 0; | |
546 MessageReceiver* signaling_message_receiver() { | |
547 return signaling_message_receiver_; | |
548 } | |
549 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { | |
550 return peer_connection_factory_.get(); | |
551 } | |
552 | |
553 virtual bool can_receive_audio() = 0; | |
554 virtual bool can_receive_video() = 0; | |
555 const std::string& id() const { return id_; } | |
556 | |
557 private: | |
558 class DummyDtmfObserver : public DtmfSenderObserverInterface { | |
559 public: | |
560 DummyDtmfObserver() : completed_(false) {} | |
561 | |
562 // Implements DtmfSenderObserverInterface. | |
563 void OnToneChange(const std::string& tone) { | |
564 tones_.push_back(tone); | |
565 if (tone.empty()) { | |
566 completed_ = true; | |
567 } | |
568 } | |
569 | |
570 void Verify(const std::vector<std::string>& tones) const { | |
571 ASSERT_TRUE(tones_.size() == tones.size()); | |
572 EXPECT_TRUE(std::equal(tones.begin(), tones.end(), tones_.begin())); | |
573 } | |
574 | |
575 bool completed() const { return completed_; } | |
576 | |
577 private: | |
578 bool completed_; | |
579 std::vector<std::string> tones_; | |
580 }; | |
581 | 673 |
582 rtc::scoped_refptr<webrtc::VideoTrackInterface> | 674 rtc::scoped_refptr<webrtc::VideoTrackInterface> |
583 CreateLocalVideoTrack(const std::string stream_label) { | 675 CreateLocalVideoTrack(const std::string stream_label) { |
584 // Set max frame rate to 10fps to reduce the risk of the tests to be flaky. | 676 // Set max frame rate to 10fps to reduce the risk of the tests to be flaky. |
585 FakeConstraints source_constraints = video_constraints_; | 677 FakeConstraints source_constraints = video_constraints_; |
586 source_constraints.SetMandatoryMaxFrameRate(10); | 678 source_constraints.SetMandatoryMaxFrameRate(10); |
587 | 679 |
588 cricket::FakeVideoCapturer* fake_capturer = | 680 cricket::FakeVideoCapturer* fake_capturer = |
589 new webrtc::FakePeriodicVideoCapturer(); | 681 new webrtc::FakePeriodicVideoCapturer(); |
590 video_capturers_.push_back(fake_capturer); | 682 video_capturers_.push_back(fake_capturer); |
591 rtc::scoped_refptr<webrtc::VideoSourceInterface> source = | 683 rtc::scoped_refptr<webrtc::VideoSourceInterface> source = |
592 peer_connection_factory_->CreateVideoSource( | 684 peer_connection_factory_->CreateVideoSource( |
593 fake_capturer, &source_constraints); | 685 fake_capturer, &source_constraints); |
594 std::string label = stream_label + kVideoTrackLabelBase; | 686 std::string label = stream_label + kVideoTrackLabelBase; |
595 return peer_connection_factory_->CreateVideoTrack(label, source); | 687 return peer_connection_factory_->CreateVideoTrack(label, source); |
596 } | 688 } |
597 | 689 |
598 std::string id_; | 690 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
599 | 691 webrtc::PortAllocatorFactoryInterface* factory, |
600 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | 692 const MediaConstraintsInterface* constraints) { |
601 allocator_factory_; | |
602 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | |
603 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | |
604 peer_connection_factory_; | |
605 | |
606 typedef std::pair<std::string, std::string> IceUfragPwdPair; | |
607 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; | |
608 bool expect_ice_restart_; | |
609 | |
610 // Needed to keep track of number of frames send. | |
611 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; | |
612 // Needed to keep track of number of frames received. | |
613 typedef std::map<std::string, webrtc::FakeVideoTrackRenderer*> RenderMap; | |
614 RenderMap fake_video_renderers_; | |
615 // Needed to keep track of number of frames received when external decoder | |
616 // used. | |
617 FakeWebRtcVideoDecoderFactory* fake_video_decoder_factory_; | |
618 FakeWebRtcVideoEncoderFactory* fake_video_encoder_factory_; | |
619 bool video_decoder_factory_enabled_; | |
620 webrtc::FakeConstraints video_constraints_; | |
621 | |
622 // For remote peer communication. | |
623 MessageReceiver* signaling_message_receiver_; | |
624 | |
625 // Store references to the video capturers we've created, so that we can stop | |
626 // them, if required. | |
627 std::vector<cricket::VideoCapturer*> video_capturers_; | |
628 }; | |
629 | |
630 class JsepTestClient | |
631 : public PeerConnectionTestClientBase<JsepMessageReceiver> { | |
632 public: | |
633 static JsepTestClient* CreateClient( | |
634 const std::string& id, | |
635 const MediaConstraintsInterface* constraints, | |
636 const PeerConnectionFactory::Options* options) { | |
637 JsepTestClient* client(new JsepTestClient(id)); | |
638 if (!client->Init(constraints, options)) { | |
639 delete client; | |
640 return NULL; | |
641 } | |
642 return client; | |
643 } | |
644 ~JsepTestClient() {} | |
645 | |
646 virtual void Negotiate() { | |
647 Negotiate(true, true); | |
648 } | |
649 virtual void Negotiate(bool audio, bool video) { | |
650 rtc::scoped_ptr<SessionDescriptionInterface> offer; | |
651 ASSERT_TRUE(DoCreateOffer(offer.use())); | |
652 | |
653 if (offer->description()->GetContentByName("audio")) { | |
654 offer->description()->GetContentByName("audio")->rejected = !audio; | |
655 } | |
656 if (offer->description()->GetContentByName("video")) { | |
657 offer->description()->GetContentByName("video")->rejected = !video; | |
658 } | |
659 | |
660 std::string sdp; | |
661 EXPECT_TRUE(offer->ToString(&sdp)); | |
662 EXPECT_TRUE(DoSetLocalDescription(offer.release())); | |
663 signaling_message_receiver()->ReceiveSdpMessage( | |
664 webrtc::SessionDescriptionInterface::kOffer, sdp); | |
665 } | |
666 // JsepMessageReceiver callback. | |
667 virtual void ReceiveSdpMessage(const std::string& type, | |
668 std::string& msg) { | |
669 FilterIncomingSdpMessage(&msg); | |
670 if (type == webrtc::SessionDescriptionInterface::kOffer) { | |
671 HandleIncomingOffer(msg); | |
672 } else { | |
673 HandleIncomingAnswer(msg); | |
674 } | |
675 } | |
676 // JsepMessageReceiver callback. | |
677 virtual void ReceiveIceMessage(const std::string& sdp_mid, | |
678 int sdp_mline_index, | |
679 const std::string& msg) { | |
680 LOG(INFO) << id() << "ReceiveIceMessage"; | |
681 rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate( | |
682 webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, msg, NULL)); | |
683 EXPECT_TRUE(pc()->AddIceCandidate(candidate.get())); | |
684 } | |
685 // Implements PeerConnectionObserver functions needed by Jsep. | |
686 virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { | |
687 LOG(INFO) << id() << "OnIceCandidate"; | |
688 | |
689 std::string ice_sdp; | |
690 EXPECT_TRUE(candidate->ToString(&ice_sdp)); | |
691 if (signaling_message_receiver() == NULL) { | |
692 // Remote party may be deleted. | |
693 return; | |
694 } | |
695 signaling_message_receiver()->ReceiveIceMessage(candidate->sdp_mid(), | |
696 candidate->sdp_mline_index(), ice_sdp); | |
697 } | |
698 | |
699 void IceRestart() { | |
700 session_description_constraints_.SetMandatoryIceRestart(true); | |
701 SetExpectIceRestart(true); | |
702 } | |
703 | |
704 void SetReceiveAudioVideo(bool audio, bool video) { | |
705 SetReceiveAudio(audio); | |
706 SetReceiveVideo(video); | |
707 ASSERT_EQ(audio, can_receive_audio()); | |
708 ASSERT_EQ(video, can_receive_video()); | |
709 } | |
710 | |
711 void SetReceiveAudio(bool audio) { | |
712 if (audio && can_receive_audio()) | |
713 return; | |
714 session_description_constraints_.SetMandatoryReceiveAudio(audio); | |
715 } | |
716 | |
717 void SetReceiveVideo(bool video) { | |
718 if (video && can_receive_video()) | |
719 return; | |
720 session_description_constraints_.SetMandatoryReceiveVideo(video); | |
721 } | |
722 | |
723 void RemoveMsidFromReceivedSdp(bool remove) { | |
724 remove_msid_ = remove; | |
725 } | |
726 | |
727 void RemoveSdesCryptoFromReceivedSdp(bool remove) { | |
728 remove_sdes_ = remove; | |
729 } | |
730 | |
731 void RemoveBundleFromReceivedSdp(bool remove) { | |
732 remove_bundle_ = remove; | |
733 } | |
734 | |
735 virtual bool can_receive_audio() { | |
736 bool value; | |
737 if (webrtc::FindConstraint(&session_description_constraints_, | |
738 MediaConstraintsInterface::kOfferToReceiveAudio, &value, NULL)) { | |
739 return value; | |
740 } | |
741 return true; | |
742 } | |
743 | |
744 virtual bool can_receive_video() { | |
745 bool value; | |
746 if (webrtc::FindConstraint(&session_description_constraints_, | |
747 MediaConstraintsInterface::kOfferToReceiveVideo, &value, NULL)) { | |
748 return value; | |
749 } | |
750 return true; | |
751 } | |
752 | |
753 virtual void OnIceComplete() { | |
754 LOG(INFO) << id() << "OnIceComplete"; | |
755 } | |
756 | |
757 virtual void OnDataChannel(DataChannelInterface* data_channel) { | |
758 LOG(INFO) << id() << "OnDataChannel"; | |
759 data_channel_ = data_channel; | |
760 data_observer_.reset(new MockDataChannelObserver(data_channel)); | |
761 } | |
762 | |
763 void CreateDataChannel() { | |
764 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, | |
765 NULL); | |
766 ASSERT_TRUE(data_channel_.get() != NULL); | |
767 data_observer_.reset(new MockDataChannelObserver(data_channel_)); | |
768 } | |
769 | |
770 DataChannelInterface* data_channel() { return data_channel_; } | |
771 const MockDataChannelObserver* data_observer() const { | |
772 return data_observer_.get(); | |
773 } | |
774 | |
775 protected: | |
776 explicit JsepTestClient(const std::string& id) | |
777 : PeerConnectionTestClientBase<JsepMessageReceiver>(id), | |
778 remove_msid_(false), | |
779 remove_bundle_(false), | |
780 remove_sdes_(false) { | |
781 } | |
782 | |
783 rtc::scoped_refptr<webrtc::PeerConnectionInterface> | |
784 CreatePeerConnection( | |
785 webrtc::PortAllocatorFactoryInterface* factory, | |
786 const MediaConstraintsInterface* constraints) override { | |
787 // CreatePeerConnection with IceServers. | 693 // CreatePeerConnection with IceServers. |
788 webrtc::PeerConnectionInterface::IceServers ice_servers; | 694 webrtc::PeerConnectionInterface::IceServers ice_servers; |
789 webrtc::PeerConnectionInterface::IceServer ice_server; | 695 webrtc::PeerConnectionInterface::IceServer ice_server; |
790 ice_server.uri = "stun:stun.l.google.com:19302"; | 696 ice_server.uri = "stun:stun.l.google.com:19302"; |
791 ice_servers.push_back(ice_server); | 697 ice_servers.push_back(ice_server); |
792 | 698 |
793 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( | 699 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( |
794 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 700 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
795 : nullptr); | 701 : nullptr); |
796 return peer_connection_factory()->CreatePeerConnection( | 702 return peer_connection_factory_->CreatePeerConnection( |
797 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); | 703 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); |
798 } | 704 } |
799 | 705 |
800 void HandleIncomingOffer(const std::string& msg) { | 706 void HandleIncomingOffer(const std::string& msg) { |
801 LOG(INFO) << id() << "HandleIncomingOffer "; | 707 LOG(INFO) << id_ << "HandleIncomingOffer "; |
802 if (NumberOfLocalMediaStreams() == 0) { | 708 if (NumberOfLocalMediaStreams() == 0) { |
803 // If we are not sending any streams ourselves it is time to add some. | 709 // If we are not sending any streams ourselves it is time to add some. |
804 AddMediaStream(true, true); | 710 AddMediaStream(true, true); |
805 } | 711 } |
806 rtc::scoped_ptr<SessionDescriptionInterface> desc( | 712 rtc::scoped_ptr<SessionDescriptionInterface> desc( |
807 webrtc::CreateSessionDescription("offer", msg, NULL)); | 713 webrtc::CreateSessionDescription("offer", msg, nullptr)); |
808 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); | 714 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); |
809 rtc::scoped_ptr<SessionDescriptionInterface> answer; | 715 rtc::scoped_ptr<SessionDescriptionInterface> answer; |
810 EXPECT_TRUE(DoCreateAnswer(answer.use())); | 716 EXPECT_TRUE(DoCreateAnswer(answer.use())); |
811 std::string sdp; | 717 std::string sdp; |
812 EXPECT_TRUE(answer->ToString(&sdp)); | 718 EXPECT_TRUE(answer->ToString(&sdp)); |
813 EXPECT_TRUE(DoSetLocalDescription(answer.release())); | 719 EXPECT_TRUE(DoSetLocalDescription(answer.release())); |
814 if (signaling_message_receiver()) { | 720 if (signaling_message_receiver_) { |
815 signaling_message_receiver()->ReceiveSdpMessage( | 721 signaling_message_receiver_->ReceiveSdpMessage( |
816 webrtc::SessionDescriptionInterface::kAnswer, sdp); | 722 webrtc::SessionDescriptionInterface::kAnswer, sdp); |
817 } | 723 } |
818 } | 724 } |
819 | 725 |
820 void HandleIncomingAnswer(const std::string& msg) { | 726 void HandleIncomingAnswer(const std::string& msg) { |
821 LOG(INFO) << id() << "HandleIncomingAnswer"; | 727 LOG(INFO) << id_ << "HandleIncomingAnswer"; |
822 rtc::scoped_ptr<SessionDescriptionInterface> desc( | 728 rtc::scoped_ptr<SessionDescriptionInterface> desc( |
823 webrtc::CreateSessionDescription("answer", msg, NULL)); | 729 webrtc::CreateSessionDescription("answer", msg, nullptr)); |
824 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); | 730 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); |
825 } | 731 } |
826 | 732 |
827 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc, | 733 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc, |
828 bool offer) { | 734 bool offer) { |
829 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> | 735 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> |
830 observer(new rtc::RefCountedObject< | 736 observer(new rtc::RefCountedObject< |
831 MockCreateSessionDescriptionObserver>()); | 737 MockCreateSessionDescriptionObserver>()); |
832 if (offer) { | 738 if (offer) { |
833 pc()->CreateOffer(observer, &session_description_constraints_); | 739 pc()->CreateOffer(observer, &session_description_constraints_); |
(...skipping 13 matching lines...) Expand all Loading... |
847 } | 753 } |
848 | 754 |
849 bool DoCreateAnswer(SessionDescriptionInterface** desc) { | 755 bool DoCreateAnswer(SessionDescriptionInterface** desc) { |
850 return DoCreateOfferAnswer(desc, false); | 756 return DoCreateOfferAnswer(desc, false); |
851 } | 757 } |
852 | 758 |
853 bool DoSetLocalDescription(SessionDescriptionInterface* desc) { | 759 bool DoSetLocalDescription(SessionDescriptionInterface* desc) { |
854 rtc::scoped_refptr<MockSetSessionDescriptionObserver> | 760 rtc::scoped_refptr<MockSetSessionDescriptionObserver> |
855 observer(new rtc::RefCountedObject< | 761 observer(new rtc::RefCountedObject< |
856 MockSetSessionDescriptionObserver>()); | 762 MockSetSessionDescriptionObserver>()); |
857 LOG(INFO) << id() << "SetLocalDescription "; | 763 LOG(INFO) << id_ << "SetLocalDescription "; |
858 pc()->SetLocalDescription(observer, desc); | 764 pc()->SetLocalDescription(observer, desc); |
859 // Ignore the observer result. If we wait for the result with | 765 // Ignore the observer result. If we wait for the result with |
860 // EXPECT_TRUE_WAIT, local ice candidates might be sent to the remote peer | 766 // EXPECT_TRUE_WAIT, local ice candidates might be sent to the remote peer |
861 // before the offer which is an error. | 767 // before the offer which is an error. |
862 // The reason is that EXPECT_TRUE_WAIT uses | 768 // The reason is that EXPECT_TRUE_WAIT uses |
863 // rtc::Thread::Current()->ProcessMessages(1); | 769 // rtc::Thread::Current()->ProcessMessages(1); |
864 // ProcessMessages waits at least 1ms but processes all messages before | 770 // ProcessMessages waits at least 1ms but processes all messages before |
865 // returning. Since this test is synchronous and send messages to the remote | 771 // returning. Since this test is synchronous and send messages to the remote |
866 // peer whenever a callback is invoked, this can lead to messages being | 772 // peer whenever a callback is invoked, this can lead to messages being |
867 // sent to the remote peer in the wrong order. | 773 // sent to the remote peer in the wrong order. |
868 // TODO(perkj): Find a way to check the result without risking that the | 774 // TODO(perkj): Find a way to check the result without risking that the |
869 // order of sent messages are changed. Ex- by posting all messages that are | 775 // order of sent messages are changed. Ex- by posting all messages that are |
870 // sent to the remote peer. | 776 // sent to the remote peer. |
871 return true; | 777 return true; |
872 } | 778 } |
873 | 779 |
874 bool DoSetRemoteDescription(SessionDescriptionInterface* desc) { | 780 bool DoSetRemoteDescription(SessionDescriptionInterface* desc) { |
875 rtc::scoped_refptr<MockSetSessionDescriptionObserver> | 781 rtc::scoped_refptr<MockSetSessionDescriptionObserver> |
876 observer(new rtc::RefCountedObject< | 782 observer(new rtc::RefCountedObject< |
877 MockSetSessionDescriptionObserver>()); | 783 MockSetSessionDescriptionObserver>()); |
878 LOG(INFO) << id() << "SetRemoteDescription "; | 784 LOG(INFO) << id_ << "SetRemoteDescription "; |
879 pc()->SetRemoteDescription(observer, desc); | 785 pc()->SetRemoteDescription(observer, desc); |
880 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 786 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
881 return observer->result(); | 787 return observer->result(); |
882 } | 788 } |
883 | 789 |
884 // This modifies all received SDP messages before they are processed. | 790 // This modifies all received SDP messages before they are processed. |
885 void FilterIncomingSdpMessage(std::string* sdp) { | 791 void FilterIncomingSdpMessage(std::string* sdp) { |
886 if (remove_msid_) { | 792 if (remove_msid_) { |
887 const char kSdpSsrcAttribute[] = "a=ssrc:"; | 793 const char kSdpSsrcAttribute[] = "a=ssrc:"; |
888 RemoveLinesFromSdp(kSdpSsrcAttribute, sdp); | 794 RemoveLinesFromSdp(kSdpSsrcAttribute, sdp); |
889 const char kSdpMsidSupportedAttribute[] = "a=msid-semantic:"; | 795 const char kSdpMsidSupportedAttribute[] = "a=msid-semantic:"; |
890 RemoveLinesFromSdp(kSdpMsidSupportedAttribute, sdp); | 796 RemoveLinesFromSdp(kSdpMsidSupportedAttribute, sdp); |
891 } | 797 } |
892 if (remove_bundle_) { | 798 if (remove_bundle_) { |
893 const char kSdpBundleAttribute[] = "a=group:BUNDLE"; | 799 const char kSdpBundleAttribute[] = "a=group:BUNDLE"; |
894 RemoveLinesFromSdp(kSdpBundleAttribute, sdp); | 800 RemoveLinesFromSdp(kSdpBundleAttribute, sdp); |
895 } | 801 } |
896 if (remove_sdes_) { | 802 if (remove_sdes_) { |
897 const char kSdpSdesCryptoAttribute[] = "a=crypto"; | 803 const char kSdpSdesCryptoAttribute[] = "a=crypto"; |
898 RemoveLinesFromSdp(kSdpSdesCryptoAttribute, sdp); | 804 RemoveLinesFromSdp(kSdpSdesCryptoAttribute, sdp); |
899 } | 805 } |
900 } | 806 } |
901 | 807 |
902 private: | 808 std::string id_; |
| 809 |
| 810 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> allocator_factory_; |
| 811 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
| 812 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
| 813 peer_connection_factory_; |
| 814 |
| 815 typedef std::pair<std::string, std::string> IceUfragPwdPair; |
| 816 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; |
| 817 bool expect_ice_restart_ = false; |
| 818 |
| 819 // Needed to keep track of number of frames send. |
| 820 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; |
| 821 // Needed to keep track of number of frames received. |
| 822 typedef std::map<std::string, webrtc::FakeVideoTrackRenderer*> RenderMap; |
| 823 RenderMap fake_video_renderers_; |
| 824 // Needed to keep track of number of frames received when external decoder |
| 825 // used. |
| 826 FakeWebRtcVideoDecoderFactory* fake_video_decoder_factory_ = nullptr; |
| 827 FakeWebRtcVideoEncoderFactory* fake_video_encoder_factory_ = nullptr; |
| 828 bool video_decoder_factory_enabled_ = false; |
| 829 webrtc::FakeConstraints video_constraints_; |
| 830 |
| 831 // For remote peer communication. |
| 832 SignalingMessageReceiver* signaling_message_receiver_ = nullptr; |
| 833 |
| 834 // Store references to the video capturers we've created, so that we can stop |
| 835 // them, if required. |
| 836 std::vector<cricket::VideoCapturer*> video_capturers_; |
| 837 |
903 webrtc::FakeConstraints session_description_constraints_; | 838 webrtc::FakeConstraints session_description_constraints_; |
904 bool remove_msid_; // True if MSID should be removed in received SDP. | 839 bool remove_msid_ = false; // True if MSID should be removed in received SDP. |
905 bool remove_bundle_; // True if bundle should be removed in received SDP. | 840 bool remove_bundle_ = |
906 bool remove_sdes_; // True if a=crypto should be removed in received SDP. | 841 false; // True if bundle should be removed in received SDP. |
| 842 bool remove_sdes_ = |
| 843 false; // True if a=crypto should be removed in received SDP. |
907 | 844 |
908 rtc::scoped_refptr<DataChannelInterface> data_channel_; | 845 rtc::scoped_refptr<DataChannelInterface> data_channel_; |
909 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; | 846 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; |
910 }; | 847 }; |
911 | 848 |
912 template <typename SignalingClass> | |
913 class P2PTestConductor : public testing::Test { | 849 class P2PTestConductor : public testing::Test { |
914 public: | 850 public: |
915 P2PTestConductor() | 851 P2PTestConductor() |
916 : pss_(new rtc::PhysicalSocketServer), | 852 : pss_(new rtc::PhysicalSocketServer), |
917 ss_(new rtc::VirtualSocketServer(pss_.get())), | 853 ss_(new rtc::VirtualSocketServer(pss_.get())), |
918 ss_scope_(ss_.get()) {} | 854 ss_scope_(ss_.get()) {} |
919 | 855 |
920 bool SessionActive() { | 856 bool SessionActive() { |
921 return initiating_client_->SessionActive() && | 857 return initiating_client_->SessionActive() && |
922 receiving_client_->SessionActive(); | 858 receiving_client_->SessionActive(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 898 |
963 void VerifySessionDescriptions() { | 899 void VerifySessionDescriptions() { |
964 initiating_client_->VerifyRejectedMediaInSessionDescription(); | 900 initiating_client_->VerifyRejectedMediaInSessionDescription(); |
965 receiving_client_->VerifyRejectedMediaInSessionDescription(); | 901 receiving_client_->VerifyRejectedMediaInSessionDescription(); |
966 initiating_client_->VerifyLocalIceUfragAndPassword(); | 902 initiating_client_->VerifyLocalIceUfragAndPassword(); |
967 receiving_client_->VerifyLocalIceUfragAndPassword(); | 903 receiving_client_->VerifyLocalIceUfragAndPassword(); |
968 } | 904 } |
969 | 905 |
970 ~P2PTestConductor() { | 906 ~P2PTestConductor() { |
971 if (initiating_client_) { | 907 if (initiating_client_) { |
972 initiating_client_->set_signaling_message_receiver(NULL); | 908 initiating_client_->set_signaling_message_receiver(nullptr); |
973 } | 909 } |
974 if (receiving_client_) { | 910 if (receiving_client_) { |
975 receiving_client_->set_signaling_message_receiver(NULL); | 911 receiving_client_->set_signaling_message_receiver(nullptr); |
976 } | 912 } |
977 } | 913 } |
978 | 914 |
979 bool CreateTestClients() { | 915 bool CreateTestClients() { return CreateTestClients(nullptr, nullptr); } |
980 return CreateTestClients(NULL, NULL); | |
981 } | |
982 | 916 |
983 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 917 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
984 MediaConstraintsInterface* recv_constraints) { | 918 MediaConstraintsInterface* recv_constraints) { |
985 return CreateTestClients(init_constraints, NULL, recv_constraints, NULL); | 919 return CreateTestClients(init_constraints, nullptr, recv_constraints, |
| 920 nullptr); |
986 } | 921 } |
987 | 922 |
988 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 923 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
989 PeerConnectionFactory::Options* init_options, | 924 PeerConnectionFactory::Options* init_options, |
990 MediaConstraintsInterface* recv_constraints, | 925 MediaConstraintsInterface* recv_constraints, |
991 PeerConnectionFactory::Options* recv_options) { | 926 PeerConnectionFactory::Options* recv_options) { |
992 initiating_client_.reset(SignalingClass::CreateClient("Caller: ", | 927 initiating_client_.reset(PeerConnectionTestClient::CreateClient( |
993 init_constraints, | 928 "Caller: ", init_constraints, init_options)); |
994 init_options)); | 929 receiving_client_.reset(PeerConnectionTestClient::CreateClient( |
995 receiving_client_.reset(SignalingClass::CreateClient("Callee: ", | 930 "Callee: ", recv_constraints, recv_options)); |
996 recv_constraints, | |
997 recv_options)); | |
998 if (!initiating_client_ || !receiving_client_) { | 931 if (!initiating_client_ || !receiving_client_) { |
999 return false; | 932 return false; |
1000 } | 933 } |
1001 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); | 934 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); |
1002 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); | 935 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); |
1003 return true; | 936 return true; |
1004 } | 937 } |
1005 | 938 |
1006 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, | 939 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, |
1007 const webrtc::FakeConstraints& recv_constraints) { | 940 const webrtc::FakeConstraints& recv_constraints) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { | 1014 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { |
1082 // Messages may get lost on the unreliable DataChannel, so we send multiple | 1015 // Messages may get lost on the unreliable DataChannel, so we send multiple |
1083 // times to avoid test flakiness. | 1016 // times to avoid test flakiness. |
1084 static const size_t kSendAttempts = 5; | 1017 static const size_t kSendAttempts = 5; |
1085 | 1018 |
1086 for (size_t i = 0; i < kSendAttempts; ++i) { | 1019 for (size_t i = 0; i < kSendAttempts; ++i) { |
1087 dc->Send(DataBuffer(data)); | 1020 dc->Send(DataBuffer(data)); |
1088 } | 1021 } |
1089 } | 1022 } |
1090 | 1023 |
1091 SignalingClass* initializing_client() { return initiating_client_.get(); } | 1024 PeerConnectionTestClient* initializing_client() { |
1092 SignalingClass* receiving_client() { return receiving_client_.get(); } | 1025 return initiating_client_.get(); |
| 1026 } |
| 1027 PeerConnectionTestClient* receiving_client() { |
| 1028 return receiving_client_.get(); |
| 1029 } |
1093 | 1030 |
1094 private: | 1031 private: |
1095 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 1032 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; |
1096 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; | 1033 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; |
1097 rtc::SocketServerScope ss_scope_; | 1034 rtc::SocketServerScope ss_scope_; |
1098 rtc::scoped_ptr<SignalingClass> initiating_client_; | 1035 rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_; |
1099 rtc::scoped_ptr<SignalingClass> receiving_client_; | 1036 rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_; |
1100 }; | 1037 }; |
1101 typedef P2PTestConductor<JsepTestClient> JsepPeerConnectionP2PTestClient; | |
1102 | 1038 |
1103 // Disable for TSan v2, see | 1039 // Disable for TSan v2, see |
1104 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 1040 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
1105 #if !defined(THREAD_SANITIZER) | 1041 #if !defined(THREAD_SANITIZER) |
1106 | 1042 |
1107 // This test sets up a Jsep call between two parties and test Dtmf. | 1043 // This test sets up a Jsep call between two parties and test Dtmf. |
1108 // TODO(holmer): Disabled due to sometimes crashing on buildbots. | 1044 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1109 // See issue webrtc/2378. | 1045 // See issue webrtc/2378. |
1110 TEST_F(JsepPeerConnectionP2PTestClient, DISABLED_LocalP2PTestDtmf) { | 1046 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestDtmf) { |
1111 ASSERT_TRUE(CreateTestClients()); | 1047 ASSERT_TRUE(CreateTestClients()); |
1112 LocalP2PTest(); | 1048 LocalP2PTest(); |
1113 VerifyDtmf(); | 1049 VerifyDtmf(); |
1114 } | 1050 } |
1115 | 1051 |
1116 // This test sets up a Jsep call between two parties and test that we can get a | 1052 // This test sets up a Jsep call between two parties and test that we can get a |
1117 // video aspect ratio of 16:9. | 1053 // video aspect ratio of 16:9. |
1118 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTest16To9) { | 1054 TEST_F(P2PTestConductor, LocalP2PTest16To9) { |
1119 ASSERT_TRUE(CreateTestClients()); | 1055 ASSERT_TRUE(CreateTestClients()); |
1120 FakeConstraints constraint; | 1056 FakeConstraints constraint; |
1121 double requested_ratio = 640.0/360; | 1057 double requested_ratio = 640.0/360; |
1122 constraint.SetMandatoryMinAspectRatio(requested_ratio); | 1058 constraint.SetMandatoryMinAspectRatio(requested_ratio); |
1123 SetVideoConstraints(constraint, constraint); | 1059 SetVideoConstraints(constraint, constraint); |
1124 LocalP2PTest(); | 1060 LocalP2PTest(); |
1125 | 1061 |
1126 ASSERT_LE(0, initializing_client()->rendered_height()); | 1062 ASSERT_LE(0, initializing_client()->rendered_height()); |
1127 double initiating_video_ratio = | 1063 double initiating_video_ratio = |
1128 static_cast<double>(initializing_client()->rendered_width()) / | 1064 static_cast<double>(initializing_client()->rendered_width()) / |
1129 initializing_client()->rendered_height(); | 1065 initializing_client()->rendered_height(); |
1130 EXPECT_LE(requested_ratio, initiating_video_ratio); | 1066 EXPECT_LE(requested_ratio, initiating_video_ratio); |
1131 | 1067 |
1132 ASSERT_LE(0, receiving_client()->rendered_height()); | 1068 ASSERT_LE(0, receiving_client()->rendered_height()); |
1133 double receiving_video_ratio = | 1069 double receiving_video_ratio = |
1134 static_cast<double>(receiving_client()->rendered_width()) / | 1070 static_cast<double>(receiving_client()->rendered_width()) / |
1135 receiving_client()->rendered_height(); | 1071 receiving_client()->rendered_height(); |
1136 EXPECT_LE(requested_ratio, receiving_video_ratio); | 1072 EXPECT_LE(requested_ratio, receiving_video_ratio); |
1137 } | 1073 } |
1138 | 1074 |
1139 // This test sets up a Jsep call between two parties and test that the | 1075 // This test sets up a Jsep call between two parties and test that the |
1140 // received video has a resolution of 1280*720. | 1076 // received video has a resolution of 1280*720. |
1141 // TODO(mallinath): Enable when | 1077 // TODO(mallinath): Enable when |
1142 // http://code.google.com/p/webrtc/issues/detail?id=981 is fixed. | 1078 // http://code.google.com/p/webrtc/issues/detail?id=981 is fixed. |
1143 TEST_F(JsepPeerConnectionP2PTestClient, DISABLED_LocalP2PTest1280By720) { | 1079 TEST_F(P2PTestConductor, DISABLED_LocalP2PTest1280By720) { |
1144 ASSERT_TRUE(CreateTestClients()); | 1080 ASSERT_TRUE(CreateTestClients()); |
1145 FakeConstraints constraint; | 1081 FakeConstraints constraint; |
1146 constraint.SetMandatoryMinWidth(1280); | 1082 constraint.SetMandatoryMinWidth(1280); |
1147 constraint.SetMandatoryMinHeight(720); | 1083 constraint.SetMandatoryMinHeight(720); |
1148 SetVideoConstraints(constraint, constraint); | 1084 SetVideoConstraints(constraint, constraint); |
1149 LocalP2PTest(); | 1085 LocalP2PTest(); |
1150 VerifyRenderedSize(1280, 720); | 1086 VerifyRenderedSize(1280, 720); |
1151 } | 1087 } |
1152 | 1088 |
1153 // This test sets up a call between two endpoints that are configured to use | 1089 // This test sets up a call between two endpoints that are configured to use |
1154 // DTLS key agreement. As a result, DTLS is negotiated and used for transport. | 1090 // DTLS key agreement. As a result, DTLS is negotiated and used for transport. |
1155 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDtls) { | 1091 TEST_F(P2PTestConductor, LocalP2PTestDtls) { |
1156 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1092 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1157 FakeConstraints setup_constraints; | 1093 FakeConstraints setup_constraints; |
1158 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1094 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1159 true); | 1095 true); |
1160 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1096 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1161 LocalP2PTest(); | 1097 LocalP2PTest(); |
1162 VerifyRenderedSize(640, 480); | 1098 VerifyRenderedSize(640, 480); |
1163 } | 1099 } |
1164 | 1100 |
1165 // This test sets up a audio call initially and then upgrades to audio/video, | 1101 // This test sets up a audio call initially and then upgrades to audio/video, |
1166 // using DTLS. | 1102 // using DTLS. |
1167 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDtlsRenegotiate) { | 1103 TEST_F(P2PTestConductor, LocalP2PTestDtlsRenegotiate) { |
1168 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1104 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1169 FakeConstraints setup_constraints; | 1105 FakeConstraints setup_constraints; |
1170 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1106 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1171 true); | 1107 true); |
1172 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1108 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1173 receiving_client()->SetReceiveAudioVideo(true, false); | 1109 receiving_client()->SetReceiveAudioVideo(true, false); |
1174 LocalP2PTest(); | 1110 LocalP2PTest(); |
1175 receiving_client()->SetReceiveAudioVideo(true, true); | 1111 receiving_client()->SetReceiveAudioVideo(true, true); |
1176 receiving_client()->Negotiate(); | 1112 receiving_client()->Negotiate(); |
1177 } | 1113 } |
1178 | 1114 |
1179 // This test sets up a call between two endpoints that are configured to use | 1115 // This test sets up a call between two endpoints that are configured to use |
1180 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is | 1116 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is |
1181 // negotiated and used for transport. | 1117 // negotiated and used for transport. |
1182 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestOfferDtlsButNotSdes) { | 1118 TEST_F(P2PTestConductor, LocalP2PTestOfferDtlsButNotSdes) { |
1183 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1119 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1184 FakeConstraints setup_constraints; | 1120 FakeConstraints setup_constraints; |
1185 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1121 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1186 true); | 1122 true); |
1187 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1123 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1188 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true); | 1124 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true); |
1189 LocalP2PTest(); | 1125 LocalP2PTest(); |
1190 VerifyRenderedSize(640, 480); | 1126 VerifyRenderedSize(640, 480); |
1191 } | 1127 } |
1192 | 1128 |
1193 // This test sets up a Jsep call between two parties, and the callee only | 1129 // This test sets up a Jsep call between two parties, and the callee only |
1194 // accept to receive video. | 1130 // accept to receive video. |
1195 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestAnswerVideo) { | 1131 TEST_F(P2PTestConductor, LocalP2PTestAnswerVideo) { |
1196 ASSERT_TRUE(CreateTestClients()); | 1132 ASSERT_TRUE(CreateTestClients()); |
1197 receiving_client()->SetReceiveAudioVideo(false, true); | 1133 receiving_client()->SetReceiveAudioVideo(false, true); |
1198 LocalP2PTest(); | 1134 LocalP2PTest(); |
1199 } | 1135 } |
1200 | 1136 |
1201 // This test sets up a Jsep call between two parties, and the callee only | 1137 // This test sets up a Jsep call between two parties, and the callee only |
1202 // accept to receive audio. | 1138 // accept to receive audio. |
1203 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestAnswerAudio) { | 1139 TEST_F(P2PTestConductor, LocalP2PTestAnswerAudio) { |
1204 ASSERT_TRUE(CreateTestClients()); | 1140 ASSERT_TRUE(CreateTestClients()); |
1205 receiving_client()->SetReceiveAudioVideo(true, false); | 1141 receiving_client()->SetReceiveAudioVideo(true, false); |
1206 LocalP2PTest(); | 1142 LocalP2PTest(); |
1207 } | 1143 } |
1208 | 1144 |
1209 // This test sets up a Jsep call between two parties, and the callee reject both | 1145 // This test sets up a Jsep call between two parties, and the callee reject both |
1210 // audio and video. | 1146 // audio and video. |
1211 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestAnswerNone) { | 1147 TEST_F(P2PTestConductor, LocalP2PTestAnswerNone) { |
1212 ASSERT_TRUE(CreateTestClients()); | 1148 ASSERT_TRUE(CreateTestClients()); |
1213 receiving_client()->SetReceiveAudioVideo(false, false); | 1149 receiving_client()->SetReceiveAudioVideo(false, false); |
1214 LocalP2PTest(); | 1150 LocalP2PTest(); |
1215 } | 1151 } |
1216 | 1152 |
1217 // This test sets up an audio and video call between two parties. After the call | 1153 // This test sets up an audio and video call between two parties. After the call |
1218 // runs for a while (10 frames), the caller sends an update offer with video | 1154 // runs for a while (10 frames), the caller sends an update offer with video |
1219 // being rejected. Once the re-negotiation is done, the video flow should stop | 1155 // being rejected. Once the re-negotiation is done, the video flow should stop |
1220 // and the audio flow should continue. | 1156 // and the audio flow should continue. |
1221 // Disabled due to b/14955157. | 1157 // Disabled due to b/14955157. |
1222 TEST_F(JsepPeerConnectionP2PTestClient, | 1158 TEST_F(P2PTestConductor, DISABLED_UpdateOfferWithRejectedContent) { |
1223 DISABLED_UpdateOfferWithRejectedContent) { | |
1224 ASSERT_TRUE(CreateTestClients()); | 1159 ASSERT_TRUE(CreateTestClients()); |
1225 LocalP2PTest(); | 1160 LocalP2PTest(); |
1226 TestUpdateOfferWithRejectedContent(); | 1161 TestUpdateOfferWithRejectedContent(); |
1227 } | 1162 } |
1228 | 1163 |
1229 // This test sets up a Jsep call between two parties. The MSID is removed from | 1164 // This test sets up a Jsep call between two parties. The MSID is removed from |
1230 // the SDP strings from the caller. | 1165 // the SDP strings from the caller. |
1231 // Disabled due to b/14955157. | 1166 // Disabled due to b/14955157. |
1232 TEST_F(JsepPeerConnectionP2PTestClient, DISABLED_LocalP2PTestWithoutMsid) { | 1167 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestWithoutMsid) { |
1233 ASSERT_TRUE(CreateTestClients()); | 1168 ASSERT_TRUE(CreateTestClients()); |
1234 receiving_client()->RemoveMsidFromReceivedSdp(true); | 1169 receiving_client()->RemoveMsidFromReceivedSdp(true); |
1235 // TODO(perkj): Currently there is a bug that cause audio to stop playing if | 1170 // TODO(perkj): Currently there is a bug that cause audio to stop playing if |
1236 // audio and video is muxed when MSID is disabled. Remove | 1171 // audio and video is muxed when MSID is disabled. Remove |
1237 // SetRemoveBundleFromSdp once | 1172 // SetRemoveBundleFromSdp once |
1238 // https://code.google.com/p/webrtc/issues/detail?id=1193 is fixed. | 1173 // https://code.google.com/p/webrtc/issues/detail?id=1193 is fixed. |
1239 receiving_client()->RemoveBundleFromReceivedSdp(true); | 1174 receiving_client()->RemoveBundleFromReceivedSdp(true); |
1240 LocalP2PTest(); | 1175 LocalP2PTest(); |
1241 } | 1176 } |
1242 | 1177 |
1243 // This test sets up a Jsep call between two parties and the initiating peer | 1178 // This test sets up a Jsep call between two parties and the initiating peer |
1244 // sends two steams. | 1179 // sends two steams. |
1245 // TODO(perkj): Disabled due to | 1180 // TODO(perkj): Disabled due to |
1246 // https://code.google.com/p/webrtc/issues/detail?id=1454 | 1181 // https://code.google.com/p/webrtc/issues/detail?id=1454 |
1247 TEST_F(JsepPeerConnectionP2PTestClient, DISABLED_LocalP2PTestTwoStreams) { | 1182 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestTwoStreams) { |
1248 ASSERT_TRUE(CreateTestClients()); | 1183 ASSERT_TRUE(CreateTestClients()); |
1249 // Set optional video constraint to max 320pixels to decrease CPU usage. | 1184 // Set optional video constraint to max 320pixels to decrease CPU usage. |
1250 FakeConstraints constraint; | 1185 FakeConstraints constraint; |
1251 constraint.SetOptionalMaxWidth(320); | 1186 constraint.SetOptionalMaxWidth(320); |
1252 SetVideoConstraints(constraint, constraint); | 1187 SetVideoConstraints(constraint, constraint); |
1253 initializing_client()->AddMediaStream(true, true); | 1188 initializing_client()->AddMediaStream(true, true); |
1254 initializing_client()->AddMediaStream(false, true); | 1189 initializing_client()->AddMediaStream(false, true); |
1255 ASSERT_EQ(2u, initializing_client()->NumberOfLocalMediaStreams()); | 1190 ASSERT_EQ(2u, initializing_client()->NumberOfLocalMediaStreams()); |
1256 LocalP2PTest(); | 1191 LocalP2PTest(); |
1257 EXPECT_EQ(2u, receiving_client()->number_of_remote_streams()); | 1192 EXPECT_EQ(2u, receiving_client()->number_of_remote_streams()); |
1258 } | 1193 } |
1259 | 1194 |
1260 // Test that we can receive the audio output level from a remote audio track. | 1195 // Test that we can receive the audio output level from a remote audio track. |
1261 TEST_F(JsepPeerConnectionP2PTestClient, GetAudioOutputLevelStats) { | 1196 TEST_F(P2PTestConductor, GetAudioOutputLevelStats) { |
1262 ASSERT_TRUE(CreateTestClients()); | 1197 ASSERT_TRUE(CreateTestClients()); |
1263 LocalP2PTest(); | 1198 LocalP2PTest(); |
1264 | 1199 |
1265 StreamCollectionInterface* remote_streams = | 1200 StreamCollectionInterface* remote_streams = |
1266 initializing_client()->remote_streams(); | 1201 initializing_client()->remote_streams(); |
1267 ASSERT_GT(remote_streams->count(), 0u); | 1202 ASSERT_GT(remote_streams->count(), 0u); |
1268 ASSERT_GT(remote_streams->at(0)->GetAudioTracks().size(), 0u); | 1203 ASSERT_GT(remote_streams->at(0)->GetAudioTracks().size(), 0u); |
1269 MediaStreamTrackInterface* remote_audio_track = | 1204 MediaStreamTrackInterface* remote_audio_track = |
1270 remote_streams->at(0)->GetAudioTracks()[0]; | 1205 remote_streams->at(0)->GetAudioTracks()[0]; |
1271 | 1206 |
1272 // Get the audio output level stats. Note that the level is not available | 1207 // Get the audio output level stats. Note that the level is not available |
1273 // until a RTCP packet has been received. | 1208 // until a RTCP packet has been received. |
1274 EXPECT_TRUE_WAIT( | 1209 EXPECT_TRUE_WAIT( |
1275 initializing_client()->GetAudioOutputLevelStats(remote_audio_track) > 0, | 1210 initializing_client()->GetAudioOutputLevelStats(remote_audio_track) > 0, |
1276 kMaxWaitForStatsMs); | 1211 kMaxWaitForStatsMs); |
1277 } | 1212 } |
1278 | 1213 |
1279 // Test that an audio input level is reported. | 1214 // Test that an audio input level is reported. |
1280 TEST_F(JsepPeerConnectionP2PTestClient, GetAudioInputLevelStats) { | 1215 TEST_F(P2PTestConductor, GetAudioInputLevelStats) { |
1281 ASSERT_TRUE(CreateTestClients()); | 1216 ASSERT_TRUE(CreateTestClients()); |
1282 LocalP2PTest(); | 1217 LocalP2PTest(); |
1283 | 1218 |
1284 // Get the audio input level stats. The level should be available very | 1219 // Get the audio input level stats. The level should be available very |
1285 // soon after the test starts. | 1220 // soon after the test starts. |
1286 EXPECT_TRUE_WAIT(initializing_client()->GetAudioInputLevelStats() > 0, | 1221 EXPECT_TRUE_WAIT(initializing_client()->GetAudioInputLevelStats() > 0, |
1287 kMaxWaitForStatsMs); | 1222 kMaxWaitForStatsMs); |
1288 } | 1223 } |
1289 | 1224 |
1290 // Test that we can get incoming byte counts from both audio and video tracks. | 1225 // Test that we can get incoming byte counts from both audio and video tracks. |
1291 TEST_F(JsepPeerConnectionP2PTestClient, GetBytesReceivedStats) { | 1226 TEST_F(P2PTestConductor, GetBytesReceivedStats) { |
1292 ASSERT_TRUE(CreateTestClients()); | 1227 ASSERT_TRUE(CreateTestClients()); |
1293 LocalP2PTest(); | 1228 LocalP2PTest(); |
1294 | 1229 |
1295 StreamCollectionInterface* remote_streams = | 1230 StreamCollectionInterface* remote_streams = |
1296 initializing_client()->remote_streams(); | 1231 initializing_client()->remote_streams(); |
1297 ASSERT_GT(remote_streams->count(), 0u); | 1232 ASSERT_GT(remote_streams->count(), 0u); |
1298 ASSERT_GT(remote_streams->at(0)->GetAudioTracks().size(), 0u); | 1233 ASSERT_GT(remote_streams->at(0)->GetAudioTracks().size(), 0u); |
1299 MediaStreamTrackInterface* remote_audio_track = | 1234 MediaStreamTrackInterface* remote_audio_track = |
1300 remote_streams->at(0)->GetAudioTracks()[0]; | 1235 remote_streams->at(0)->GetAudioTracks()[0]; |
1301 EXPECT_TRUE_WAIT( | 1236 EXPECT_TRUE_WAIT( |
1302 initializing_client()->GetBytesReceivedStats(remote_audio_track) > 0, | 1237 initializing_client()->GetBytesReceivedStats(remote_audio_track) > 0, |
1303 kMaxWaitForStatsMs); | 1238 kMaxWaitForStatsMs); |
1304 | 1239 |
1305 MediaStreamTrackInterface* remote_video_track = | 1240 MediaStreamTrackInterface* remote_video_track = |
1306 remote_streams->at(0)->GetVideoTracks()[0]; | 1241 remote_streams->at(0)->GetVideoTracks()[0]; |
1307 EXPECT_TRUE_WAIT( | 1242 EXPECT_TRUE_WAIT( |
1308 initializing_client()->GetBytesReceivedStats(remote_video_track) > 0, | 1243 initializing_client()->GetBytesReceivedStats(remote_video_track) > 0, |
1309 kMaxWaitForStatsMs); | 1244 kMaxWaitForStatsMs); |
1310 } | 1245 } |
1311 | 1246 |
1312 // Test that we can get outgoing byte counts from both audio and video tracks. | 1247 // Test that we can get outgoing byte counts from both audio and video tracks. |
1313 TEST_F(JsepPeerConnectionP2PTestClient, GetBytesSentStats) { | 1248 TEST_F(P2PTestConductor, GetBytesSentStats) { |
1314 ASSERT_TRUE(CreateTestClients()); | 1249 ASSERT_TRUE(CreateTestClients()); |
1315 LocalP2PTest(); | 1250 LocalP2PTest(); |
1316 | 1251 |
1317 StreamCollectionInterface* local_streams = | 1252 StreamCollectionInterface* local_streams = |
1318 initializing_client()->local_streams(); | 1253 initializing_client()->local_streams(); |
1319 ASSERT_GT(local_streams->count(), 0u); | 1254 ASSERT_GT(local_streams->count(), 0u); |
1320 ASSERT_GT(local_streams->at(0)->GetAudioTracks().size(), 0u); | 1255 ASSERT_GT(local_streams->at(0)->GetAudioTracks().size(), 0u); |
1321 MediaStreamTrackInterface* local_audio_track = | 1256 MediaStreamTrackInterface* local_audio_track = |
1322 local_streams->at(0)->GetAudioTracks()[0]; | 1257 local_streams->at(0)->GetAudioTracks()[0]; |
1323 EXPECT_TRUE_WAIT( | 1258 EXPECT_TRUE_WAIT( |
1324 initializing_client()->GetBytesSentStats(local_audio_track) > 0, | 1259 initializing_client()->GetBytesSentStats(local_audio_track) > 0, |
1325 kMaxWaitForStatsMs); | 1260 kMaxWaitForStatsMs); |
1326 | 1261 |
1327 MediaStreamTrackInterface* local_video_track = | 1262 MediaStreamTrackInterface* local_video_track = |
1328 local_streams->at(0)->GetVideoTracks()[0]; | 1263 local_streams->at(0)->GetVideoTracks()[0]; |
1329 EXPECT_TRUE_WAIT( | 1264 EXPECT_TRUE_WAIT( |
1330 initializing_client()->GetBytesSentStats(local_video_track) > 0, | 1265 initializing_client()->GetBytesSentStats(local_video_track) > 0, |
1331 kMaxWaitForStatsMs); | 1266 kMaxWaitForStatsMs); |
1332 } | 1267 } |
1333 | 1268 |
1334 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. | 1269 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. |
1335 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12None) { | 1270 TEST_F(P2PTestConductor, GetDtls12None) { |
1336 PeerConnectionFactory::Options init_options; | 1271 PeerConnectionFactory::Options init_options; |
1337 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1272 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1338 PeerConnectionFactory::Options recv_options; | 1273 PeerConnectionFactory::Options recv_options; |
1339 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1274 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1340 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1275 ASSERT_TRUE( |
| 1276 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1341 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1277 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1342 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1278 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1343 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1279 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1344 LocalP2PTest(); | 1280 LocalP2PTest(); |
1345 | 1281 |
1346 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1282 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( |
1347 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1283 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1348 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), | 1284 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), |
1349 initializing_client()->GetDtlsCipherStats(), | 1285 initializing_client()->GetDtlsCipherStats(), |
1350 kMaxWaitForStatsMs); | 1286 kMaxWaitForStatsMs); |
1351 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1287 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1352 webrtc::kEnumCounterAudioSslCipher, | 1288 webrtc::kEnumCounterAudioSslCipher, |
1353 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1289 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1354 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1290 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
1355 | 1291 |
1356 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1292 EXPECT_EQ_WAIT(kDefaultSrtpCipher, |
1357 initializing_client()->GetSrtpCipherStats(), | 1293 initializing_client()->GetSrtpCipherStats(), |
1358 kMaxWaitForStatsMs); | 1294 kMaxWaitForStatsMs); |
1359 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1295 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1360 webrtc::kEnumCounterAudioSrtpCipher, | 1296 webrtc::kEnumCounterAudioSrtpCipher, |
1361 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1297 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); |
1362 } | 1298 } |
1363 | 1299 |
1364 // Test that DTLS 1.2 is used if both ends support it. | 1300 // Test that DTLS 1.2 is used if both ends support it. |
1365 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { | 1301 TEST_F(P2PTestConductor, GetDtls12Both) { |
1366 PeerConnectionFactory::Options init_options; | 1302 PeerConnectionFactory::Options init_options; |
1367 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1303 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1368 PeerConnectionFactory::Options recv_options; | 1304 PeerConnectionFactory::Options recv_options; |
1369 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1305 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1370 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1306 ASSERT_TRUE( |
| 1307 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1371 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1308 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1372 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1309 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1373 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1310 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1374 LocalP2PTest(); | 1311 LocalP2PTest(); |
1375 | 1312 |
1376 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1313 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( |
1377 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1314 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1378 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT)), | 1315 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT)), |
1379 initializing_client()->GetDtlsCipherStats(), | 1316 initializing_client()->GetDtlsCipherStats(), |
1380 kMaxWaitForStatsMs); | 1317 kMaxWaitForStatsMs); |
1381 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1318 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1382 webrtc::kEnumCounterAudioSslCipher, | 1319 webrtc::kEnumCounterAudioSslCipher, |
1383 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1320 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1384 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT))); | 1321 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT))); |
1385 | 1322 |
1386 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1323 EXPECT_EQ_WAIT(kDefaultSrtpCipher, |
1387 initializing_client()->GetSrtpCipherStats(), | 1324 initializing_client()->GetSrtpCipherStats(), |
1388 kMaxWaitForStatsMs); | 1325 kMaxWaitForStatsMs); |
1389 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1326 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1390 webrtc::kEnumCounterAudioSrtpCipher, | 1327 webrtc::kEnumCounterAudioSrtpCipher, |
1391 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1328 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); |
1392 } | 1329 } |
1393 | 1330 |
1394 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the | 1331 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the |
1395 // received supports 1.0. | 1332 // received supports 1.0. |
1396 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { | 1333 TEST_F(P2PTestConductor, GetDtls12Init) { |
1397 PeerConnectionFactory::Options init_options; | 1334 PeerConnectionFactory::Options init_options; |
1398 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1335 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1399 PeerConnectionFactory::Options recv_options; | 1336 PeerConnectionFactory::Options recv_options; |
1400 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1337 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1401 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1338 ASSERT_TRUE( |
| 1339 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1402 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1340 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1403 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1341 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1404 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1342 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1405 LocalP2PTest(); | 1343 LocalP2PTest(); |
1406 | 1344 |
1407 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1345 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( |
1408 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1346 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1409 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), | 1347 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), |
1410 initializing_client()->GetDtlsCipherStats(), | 1348 initializing_client()->GetDtlsCipherStats(), |
1411 kMaxWaitForStatsMs); | 1349 kMaxWaitForStatsMs); |
1412 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1350 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1413 webrtc::kEnumCounterAudioSslCipher, | 1351 webrtc::kEnumCounterAudioSslCipher, |
1414 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1352 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1415 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1353 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
1416 | 1354 |
1417 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1355 EXPECT_EQ_WAIT(kDefaultSrtpCipher, |
1418 initializing_client()->GetSrtpCipherStats(), | 1356 initializing_client()->GetSrtpCipherStats(), |
1419 kMaxWaitForStatsMs); | 1357 kMaxWaitForStatsMs); |
1420 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1358 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1421 webrtc::kEnumCounterAudioSrtpCipher, | 1359 webrtc::kEnumCounterAudioSrtpCipher, |
1422 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1360 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); |
1423 } | 1361 } |
1424 | 1362 |
1425 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the | 1363 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the |
1426 // received supports 1.2. | 1364 // received supports 1.2. |
1427 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { | 1365 TEST_F(P2PTestConductor, GetDtls12Recv) { |
1428 PeerConnectionFactory::Options init_options; | 1366 PeerConnectionFactory::Options init_options; |
1429 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1367 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1430 PeerConnectionFactory::Options recv_options; | 1368 PeerConnectionFactory::Options recv_options; |
1431 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1369 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1432 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1370 ASSERT_TRUE( |
| 1371 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1433 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1372 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1434 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1373 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1435 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1374 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1436 LocalP2PTest(); | 1375 LocalP2PTest(); |
1437 | 1376 |
1438 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1377 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( |
1439 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1378 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1440 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), | 1379 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), |
1441 initializing_client()->GetDtlsCipherStats(), | 1380 initializing_client()->GetDtlsCipherStats(), |
1442 kMaxWaitForStatsMs); | 1381 kMaxWaitForStatsMs); |
1443 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1382 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1444 webrtc::kEnumCounterAudioSslCipher, | 1383 webrtc::kEnumCounterAudioSslCipher, |
1445 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1384 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1446 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1385 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
1447 | 1386 |
1448 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1387 EXPECT_EQ_WAIT(kDefaultSrtpCipher, |
1449 initializing_client()->GetSrtpCipherStats(), | 1388 initializing_client()->GetSrtpCipherStats(), |
1450 kMaxWaitForStatsMs); | 1389 kMaxWaitForStatsMs); |
1451 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1390 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1452 webrtc::kEnumCounterAudioSrtpCipher, | 1391 webrtc::kEnumCounterAudioSrtpCipher, |
1453 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1392 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); |
1454 } | 1393 } |
1455 | 1394 |
1456 // This test sets up a call between two parties with audio, video and data. | 1395 // This test sets up a call between two parties with audio, video and data. |
1457 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { | 1396 TEST_F(P2PTestConductor, LocalP2PTestDataChannel) { |
1458 FakeConstraints setup_constraints; | 1397 FakeConstraints setup_constraints; |
1459 setup_constraints.SetAllowRtpDataChannels(); | 1398 setup_constraints.SetAllowRtpDataChannels(); |
1460 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1399 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1461 initializing_client()->CreateDataChannel(); | 1400 initializing_client()->CreateDataChannel(); |
1462 LocalP2PTest(); | 1401 LocalP2PTest(); |
1463 ASSERT_TRUE(initializing_client()->data_channel() != NULL); | 1402 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); |
1464 ASSERT_TRUE(receiving_client()->data_channel() != NULL); | 1403 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); |
1465 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), | 1404 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), |
1466 kMaxWaitMs); | 1405 kMaxWaitMs); |
1467 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), | 1406 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), |
1468 kMaxWaitMs); | 1407 kMaxWaitMs); |
1469 | 1408 |
1470 std::string data = "hello world"; | 1409 std::string data = "hello world"; |
1471 | 1410 |
1472 SendRtpData(initializing_client()->data_channel(), data); | 1411 SendRtpData(initializing_client()->data_channel(), data); |
1473 EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(), | 1412 EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(), |
1474 kMaxWaitMs); | 1413 kMaxWaitMs); |
1475 | 1414 |
1476 SendRtpData(receiving_client()->data_channel(), data); | 1415 SendRtpData(receiving_client()->data_channel(), data); |
1477 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), | 1416 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), |
1478 kMaxWaitMs); | 1417 kMaxWaitMs); |
1479 | 1418 |
1480 receiving_client()->data_channel()->Close(); | 1419 receiving_client()->data_channel()->Close(); |
1481 // Send new offer and answer. | 1420 // Send new offer and answer. |
1482 receiving_client()->Negotiate(); | 1421 receiving_client()->Negotiate(); |
1483 EXPECT_FALSE(initializing_client()->data_observer()->IsOpen()); | 1422 EXPECT_FALSE(initializing_client()->data_observer()->IsOpen()); |
1484 EXPECT_FALSE(receiving_client()->data_observer()->IsOpen()); | 1423 EXPECT_FALSE(receiving_client()->data_observer()->IsOpen()); |
1485 } | 1424 } |
1486 | 1425 |
1487 // This test sets up a call between two parties and creates a data channel. | 1426 // This test sets up a call between two parties and creates a data channel. |
1488 // The test tests that received data is buffered unless an observer has been | 1427 // The test tests that received data is buffered unless an observer has been |
1489 // registered. | 1428 // registered. |
1490 // Rtp data channels can receive data before the underlying | 1429 // Rtp data channels can receive data before the underlying |
1491 // transport has detected that a channel is writable and thus data can be | 1430 // transport has detected that a channel is writable and thus data can be |
1492 // received before the data channel state changes to open. That is hard to test | 1431 // received before the data channel state changes to open. That is hard to test |
1493 // but the same buffering is used in that case. | 1432 // but the same buffering is used in that case. |
1494 TEST_F(JsepPeerConnectionP2PTestClient, RegisterDataChannelObserver) { | 1433 TEST_F(P2PTestConductor, RegisterDataChannelObserver) { |
1495 FakeConstraints setup_constraints; | 1434 FakeConstraints setup_constraints; |
1496 setup_constraints.SetAllowRtpDataChannels(); | 1435 setup_constraints.SetAllowRtpDataChannels(); |
1497 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1436 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1498 initializing_client()->CreateDataChannel(); | 1437 initializing_client()->CreateDataChannel(); |
1499 initializing_client()->Negotiate(); | 1438 initializing_client()->Negotiate(); |
1500 | 1439 |
1501 ASSERT_TRUE(initializing_client()->data_channel() != NULL); | 1440 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); |
1502 ASSERT_TRUE(receiving_client()->data_channel() != NULL); | 1441 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); |
1503 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), | 1442 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), |
1504 kMaxWaitMs); | 1443 kMaxWaitMs); |
1505 EXPECT_EQ_WAIT(DataChannelInterface::kOpen, | 1444 EXPECT_EQ_WAIT(DataChannelInterface::kOpen, |
1506 receiving_client()->data_channel()->state(), kMaxWaitMs); | 1445 receiving_client()->data_channel()->state(), kMaxWaitMs); |
1507 | 1446 |
1508 // Unregister the existing observer. | 1447 // Unregister the existing observer. |
1509 receiving_client()->data_channel()->UnregisterObserver(); | 1448 receiving_client()->data_channel()->UnregisterObserver(); |
1510 | 1449 |
1511 std::string data = "hello world"; | 1450 std::string data = "hello world"; |
1512 SendRtpData(initializing_client()->data_channel(), data); | 1451 SendRtpData(initializing_client()->data_channel(), data); |
1513 | 1452 |
1514 // Wait a while to allow the sent data to arrive before an observer is | 1453 // Wait a while to allow the sent data to arrive before an observer is |
1515 // registered.. | 1454 // registered.. |
1516 rtc::Thread::Current()->ProcessMessages(100); | 1455 rtc::Thread::Current()->ProcessMessages(100); |
1517 | 1456 |
1518 MockDataChannelObserver new_observer(receiving_client()->data_channel()); | 1457 MockDataChannelObserver new_observer(receiving_client()->data_channel()); |
1519 EXPECT_EQ_WAIT(data, new_observer.last_message(), kMaxWaitMs); | 1458 EXPECT_EQ_WAIT(data, new_observer.last_message(), kMaxWaitMs); |
1520 } | 1459 } |
1521 | 1460 |
1522 // This test sets up a call between two parties with audio, video and but only | 1461 // This test sets up a call between two parties with audio, video and but only |
1523 // the initiating client support data. | 1462 // the initiating client support data. |
1524 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestReceiverDoesntSupportData) { | 1463 TEST_F(P2PTestConductor, LocalP2PTestReceiverDoesntSupportData) { |
1525 FakeConstraints setup_constraints_1; | 1464 FakeConstraints setup_constraints_1; |
1526 setup_constraints_1.SetAllowRtpDataChannels(); | 1465 setup_constraints_1.SetAllowRtpDataChannels(); |
1527 // Must disable DTLS to make negotiation succeed. | 1466 // Must disable DTLS to make negotiation succeed. |
1528 setup_constraints_1.SetMandatory( | 1467 setup_constraints_1.SetMandatory( |
1529 MediaConstraintsInterface::kEnableDtlsSrtp, false); | 1468 MediaConstraintsInterface::kEnableDtlsSrtp, false); |
1530 FakeConstraints setup_constraints_2; | 1469 FakeConstraints setup_constraints_2; |
1531 setup_constraints_2.SetMandatory( | 1470 setup_constraints_2.SetMandatory( |
1532 MediaConstraintsInterface::kEnableDtlsSrtp, false); | 1471 MediaConstraintsInterface::kEnableDtlsSrtp, false); |
1533 ASSERT_TRUE(CreateTestClients(&setup_constraints_1, &setup_constraints_2)); | 1472 ASSERT_TRUE(CreateTestClients(&setup_constraints_1, &setup_constraints_2)); |
1534 initializing_client()->CreateDataChannel(); | 1473 initializing_client()->CreateDataChannel(); |
1535 LocalP2PTest(); | 1474 LocalP2PTest(); |
1536 EXPECT_TRUE(initializing_client()->data_channel() != NULL); | 1475 EXPECT_TRUE(initializing_client()->data_channel() != nullptr); |
1537 EXPECT_FALSE(receiving_client()->data_channel()); | 1476 EXPECT_FALSE(receiving_client()->data_channel()); |
1538 EXPECT_FALSE(initializing_client()->data_observer()->IsOpen()); | 1477 EXPECT_FALSE(initializing_client()->data_observer()->IsOpen()); |
1539 } | 1478 } |
1540 | 1479 |
1541 // This test sets up a call between two parties with audio, video. When audio | 1480 // This test sets up a call between two parties with audio, video. When audio |
1542 // and video is setup and flowing and data channel is negotiated. | 1481 // and video is setup and flowing and data channel is negotiated. |
1543 TEST_F(JsepPeerConnectionP2PTestClient, AddDataChannelAfterRenegotiation) { | 1482 TEST_F(P2PTestConductor, AddDataChannelAfterRenegotiation) { |
1544 FakeConstraints setup_constraints; | 1483 FakeConstraints setup_constraints; |
1545 setup_constraints.SetAllowRtpDataChannels(); | 1484 setup_constraints.SetAllowRtpDataChannels(); |
1546 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1485 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1547 LocalP2PTest(); | 1486 LocalP2PTest(); |
1548 initializing_client()->CreateDataChannel(); | 1487 initializing_client()->CreateDataChannel(); |
1549 // Send new offer and answer. | 1488 // Send new offer and answer. |
1550 initializing_client()->Negotiate(); | 1489 initializing_client()->Negotiate(); |
1551 ASSERT_TRUE(initializing_client()->data_channel() != NULL); | 1490 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); |
1552 ASSERT_TRUE(receiving_client()->data_channel() != NULL); | 1491 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); |
1553 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), | 1492 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), |
1554 kMaxWaitMs); | 1493 kMaxWaitMs); |
1555 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), | 1494 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), |
1556 kMaxWaitMs); | 1495 kMaxWaitMs); |
1557 } | 1496 } |
1558 | 1497 |
1559 // This test sets up a Jsep call with SCTP DataChannel and verifies the | 1498 // This test sets up a Jsep call with SCTP DataChannel and verifies the |
1560 // negotiation is completed without error. | 1499 // negotiation is completed without error. |
1561 #ifdef HAVE_SCTP | 1500 #ifdef HAVE_SCTP |
1562 TEST_F(JsepPeerConnectionP2PTestClient, CreateOfferWithSctpDataChannel) { | 1501 TEST_F(P2PTestConductor, CreateOfferWithSctpDataChannel) { |
1563 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1502 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1564 FakeConstraints constraints; | 1503 FakeConstraints constraints; |
1565 constraints.SetMandatory( | 1504 constraints.SetMandatory( |
1566 MediaConstraintsInterface::kEnableDtlsSrtp, true); | 1505 MediaConstraintsInterface::kEnableDtlsSrtp, true); |
1567 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); | 1506 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); |
1568 initializing_client()->CreateDataChannel(); | 1507 initializing_client()->CreateDataChannel(); |
1569 initializing_client()->Negotiate(false, false); | 1508 initializing_client()->Negotiate(false, false); |
1570 } | 1509 } |
1571 #endif | 1510 #endif |
1572 | 1511 |
1573 // This test sets up a call between two parties with audio, and video. | 1512 // This test sets up a call between two parties with audio, and video. |
1574 // During the call, the initializing side restart ice and the test verifies that | 1513 // During the call, the initializing side restart ice and the test verifies that |
1575 // new ice candidates are generated and audio and video still can flow. | 1514 // new ice candidates are generated and audio and video still can flow. |
1576 TEST_F(JsepPeerConnectionP2PTestClient, IceRestart) { | 1515 TEST_F(P2PTestConductor, IceRestart) { |
1577 ASSERT_TRUE(CreateTestClients()); | 1516 ASSERT_TRUE(CreateTestClients()); |
1578 | 1517 |
1579 // Negotiate and wait for ice completion and make sure audio and video plays. | 1518 // Negotiate and wait for ice completion and make sure audio and video plays. |
1580 LocalP2PTest(); | 1519 LocalP2PTest(); |
1581 | 1520 |
1582 // Create a SDP string of the first audio candidate for both clients. | 1521 // Create a SDP string of the first audio candidate for both clients. |
1583 const webrtc::IceCandidateCollection* audio_candidates_initiator = | 1522 const webrtc::IceCandidateCollection* audio_candidates_initiator = |
1584 initializing_client()->pc()->local_description()->candidates(0); | 1523 initializing_client()->pc()->local_description()->candidates(0); |
1585 const webrtc::IceCandidateCollection* audio_candidates_receiver = | 1524 const webrtc::IceCandidateCollection* audio_candidates_receiver = |
1586 receiving_client()->pc()->local_description()->candidates(0); | 1525 receiving_client()->pc()->local_description()->candidates(0); |
(...skipping 30 matching lines...) Expand all Loading... |
1617 // Verify that the first candidates in the local session descriptions has | 1556 // Verify that the first candidates in the local session descriptions has |
1618 // changed. | 1557 // changed. |
1619 EXPECT_NE(initiator_candidate, initiator_candidate_restart); | 1558 EXPECT_NE(initiator_candidate, initiator_candidate_restart); |
1620 EXPECT_NE(receiver_candidate, receiver_candidate_restart); | 1559 EXPECT_NE(receiver_candidate, receiver_candidate_restart); |
1621 } | 1560 } |
1622 | 1561 |
1623 // This test sets up a Jsep call between two parties with external | 1562 // This test sets up a Jsep call between two parties with external |
1624 // VideoDecoderFactory. | 1563 // VideoDecoderFactory. |
1625 // TODO(holmer): Disabled due to sometimes crashing on buildbots. | 1564 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1626 // See issue webrtc/2378. | 1565 // See issue webrtc/2378. |
1627 TEST_F(JsepPeerConnectionP2PTestClient, | 1566 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestWithVideoDecoderFactory) { |
1628 DISABLED_LocalP2PTestWithVideoDecoderFactory) { | |
1629 ASSERT_TRUE(CreateTestClients()); | 1567 ASSERT_TRUE(CreateTestClients()); |
1630 EnableVideoDecoderFactory(); | 1568 EnableVideoDecoderFactory(); |
1631 LocalP2PTest(); | 1569 LocalP2PTest(); |
1632 } | 1570 } |
1633 | 1571 |
1634 class IceServerParsingTest : public testing::Test { | 1572 class IceServerParsingTest : public testing::Test { |
1635 public: | 1573 public: |
1636 // Convenience for parsing a single URL. | 1574 // Convenience for parsing a single URL. |
1637 bool ParseUrl(const std::string& url) { | 1575 bool ParseUrl(const std::string& url) { |
1638 return ParseUrl(url, std::string(), std::string()); | 1576 return ParseUrl(url, std::string(), std::string()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 server.urls.push_back("stun:hostname"); | 1739 server.urls.push_back("stun:hostname"); |
1802 server.urls.push_back("turn:hostname"); | 1740 server.urls.push_back("turn:hostname"); |
1803 servers.push_back(server); | 1741 servers.push_back(server); |
1804 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, | 1742 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, |
1805 &turn_configurations_)); | 1743 &turn_configurations_)); |
1806 EXPECT_EQ(1U, stun_configurations_.size()); | 1744 EXPECT_EQ(1U, stun_configurations_.size()); |
1807 EXPECT_EQ(1U, turn_configurations_.size()); | 1745 EXPECT_EQ(1U, turn_configurations_.size()); |
1808 } | 1746 } |
1809 | 1747 |
1810 #endif // if !defined(THREAD_SANITIZER) | 1748 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |