OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 using webrtc::MediaStreamInterface; | 314 using webrtc::MediaStreamInterface; |
315 using webrtc::MediaStreamTrackInterface; | 315 using webrtc::MediaStreamTrackInterface; |
316 using webrtc::MockCreateSessionDescriptionObserver; | 316 using webrtc::MockCreateSessionDescriptionObserver; |
317 using webrtc::MockDataChannelObserver; | 317 using webrtc::MockDataChannelObserver; |
318 using webrtc::MockSetSessionDescriptionObserver; | 318 using webrtc::MockSetSessionDescriptionObserver; |
319 using webrtc::MockStatsObserver; | 319 using webrtc::MockStatsObserver; |
320 using webrtc::NotifierInterface; | 320 using webrtc::NotifierInterface; |
321 using webrtc::ObserverInterface; | 321 using webrtc::ObserverInterface; |
322 using webrtc::PeerConnectionInterface; | 322 using webrtc::PeerConnectionInterface; |
323 using webrtc::PeerConnectionObserver; | 323 using webrtc::PeerConnectionObserver; |
| 324 using webrtc::RTCError; |
| 325 using webrtc::RTCErrorType; |
324 using webrtc::RtpReceiverInterface; | 326 using webrtc::RtpReceiverInterface; |
325 using webrtc::RtpSenderInterface; | 327 using webrtc::RtpSenderInterface; |
326 using webrtc::SdpParseError; | 328 using webrtc::SdpParseError; |
327 using webrtc::SessionDescriptionInterface; | 329 using webrtc::SessionDescriptionInterface; |
328 using webrtc::StreamCollection; | 330 using webrtc::StreamCollection; |
329 using webrtc::StreamCollectionInterface; | 331 using webrtc::StreamCollectionInterface; |
330 using webrtc::VideoTrackSourceInterface; | 332 using webrtc::VideoTrackSourceInterface; |
331 using webrtc::VideoTrack; | 333 using webrtc::VideoTrack; |
332 using webrtc::VideoTrackInterface; | 334 using webrtc::VideoTrackInterface; |
333 | 335 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 ASSERT_TRUE(pc_factory_); | 689 ASSERT_TRUE(pc_factory_); |
688 pc_factory_for_test_ = | 690 pc_factory_for_test_ = |
689 new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); | 691 new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); |
690 pc_factory_for_test_->Initialize(); | 692 pc_factory_for_test_->Initialize(); |
691 } | 693 } |
692 | 694 |
693 void CreatePeerConnection() { | 695 void CreatePeerConnection() { |
694 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr); | 696 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr); |
695 } | 697 } |
696 | 698 |
| 699 // DTLS does not work in a loopback call, so is disabled for most of the |
| 700 // tests in this file. |
| 701 void CreatePeerConnectionWithoutDtls() { |
| 702 FakeConstraints no_dtls_constraints; |
| 703 no_dtls_constraints.AddMandatory( |
| 704 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); |
| 705 |
| 706 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), |
| 707 &no_dtls_constraints); |
| 708 } |
| 709 |
697 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { | 710 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { |
698 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), | 711 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), |
699 constraints); | 712 constraints); |
700 } | 713 } |
701 | 714 |
702 void CreatePeerConnectionWithIceTransportsType( | 715 void CreatePeerConnectionWithIceTransportsType( |
703 PeerConnectionInterface::IceTransportsType type) { | 716 PeerConnectionInterface::IceTransportsType type) { |
704 PeerConnectionInterface::RTCConfiguration config; | 717 PeerConnectionInterface::RTCConfiguration config; |
705 config.type = type; | 718 config.type = type; |
706 return CreatePeerConnection(config, nullptr); | 719 return CreatePeerConnection(config, nullptr); |
707 } | 720 } |
708 | 721 |
709 void CreatePeerConnectionWithIceServer(const std::string& uri, | 722 void CreatePeerConnectionWithIceServer(const std::string& uri, |
710 const std::string& password) { | 723 const std::string& password) { |
711 PeerConnectionInterface::RTCConfiguration config; | 724 PeerConnectionInterface::RTCConfiguration config; |
712 PeerConnectionInterface::IceServer server; | 725 PeerConnectionInterface::IceServer server; |
713 server.uri = uri; | 726 server.uri = uri; |
714 server.password = password; | 727 server.password = password; |
715 config.servers.push_back(server); | 728 config.servers.push_back(server); |
716 CreatePeerConnection(config, nullptr); | 729 CreatePeerConnection(config, nullptr); |
717 } | 730 } |
718 | 731 |
719 void CreatePeerConnection(PeerConnectionInterface::RTCConfiguration config, | 732 void CreatePeerConnection(PeerConnectionInterface::RTCConfiguration config, |
720 webrtc::MediaConstraintsInterface* constraints) { | 733 webrtc::MediaConstraintsInterface* constraints) { |
721 std::unique_ptr<cricket::FakePortAllocator> port_allocator( | 734 std::unique_ptr<cricket::FakePortAllocator> port_allocator( |
722 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); | 735 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); |
723 port_allocator_ = port_allocator.get(); | 736 port_allocator_ = port_allocator.get(); |
724 | 737 |
725 // DTLS does not work in a loopback call, so is disabled for most of the | |
726 // tests in this file. We only create a FakeIdentityService if the test | |
727 // explicitly sets the constraint. | |
728 FakeConstraints default_constraints; | |
729 if (!constraints) { | |
730 constraints = &default_constraints; | |
731 | |
732 default_constraints.AddMandatory( | |
733 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); | |
734 } | |
735 | |
736 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator; | 738 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator; |
737 bool dtls; | 739 bool dtls; |
738 if (FindConstraint(constraints, | 740 if (FindConstraint(constraints, |
739 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 741 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
740 &dtls, | 742 &dtls, |
741 nullptr) && dtls) { | 743 nullptr) && dtls) { |
742 cert_generator.reset(new FakeRTCCertificateGenerator()); | 744 cert_generator.reset(new FakeRTCCertificateGenerator()); |
743 } | 745 } |
744 pc_ = pc_factory_->CreatePeerConnection( | 746 pc_ = pc_factory_->CreatePeerConnection( |
745 config, constraints, std::move(port_allocator), | 747 config, constraints, std::move(port_allocator), |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 rtc::scoped_refptr<MockStatsObserver> observer( | 893 rtc::scoped_refptr<MockStatsObserver> observer( |
892 new rtc::RefCountedObject<MockStatsObserver>()); | 894 new rtc::RefCountedObject<MockStatsObserver>()); |
893 if (!pc_->GetStats( | 895 if (!pc_->GetStats( |
894 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)) | 896 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)) |
895 return false; | 897 return false; |
896 EXPECT_TRUE_WAIT(observer->called(), kTimeout); | 898 EXPECT_TRUE_WAIT(observer->called(), kTimeout); |
897 return observer->called(); | 899 return observer->called(); |
898 } | 900 } |
899 | 901 |
900 void InitiateCall() { | 902 void InitiateCall() { |
901 CreatePeerConnection(); | 903 CreatePeerConnectionWithoutDtls(); |
902 // Create a local stream with audio&video tracks. | 904 // Create a local stream with audio&video tracks. |
903 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 905 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
904 CreateOfferReceiveAnswer(); | 906 CreateOfferReceiveAnswer(); |
905 } | 907 } |
906 | 908 |
907 // Verify that RTP Header extensions has been negotiated for audio and video. | 909 // Verify that RTP Header extensions has been negotiated for audio and video. |
908 void VerifyRemoteRtpHeaderExtensions() { | 910 void VerifyRemoteRtpHeaderExtensions() { |
909 const cricket::MediaContentDescription* desc = | 911 const cricket::MediaContentDescription* desc = |
910 cricket::GetFirstAudioContentDescription( | 912 cricket::GetFirstAudioContentDescription( |
911 pc_->remote_description()->description()); | 913 pc_->remote_description()->description()); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1100 |
1099 void AddVideoTrack(const std::string& track_id, | 1101 void AddVideoTrack(const std::string& track_id, |
1100 MediaStreamInterface* stream) { | 1102 MediaStreamInterface* stream) { |
1101 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( | 1103 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( |
1102 webrtc::VideoTrack::Create(track_id, | 1104 webrtc::VideoTrack::Create(track_id, |
1103 webrtc::FakeVideoTrackSource::Create())); | 1105 webrtc::FakeVideoTrackSource::Create())); |
1104 ASSERT_TRUE(stream->AddTrack(video_track)); | 1106 ASSERT_TRUE(stream->AddTrack(video_track)); |
1105 } | 1107 } |
1106 | 1108 |
1107 std::unique_ptr<SessionDescriptionInterface> CreateOfferWithOneAudioStream() { | 1109 std::unique_ptr<SessionDescriptionInterface> CreateOfferWithOneAudioStream() { |
1108 CreatePeerConnection(); | 1110 CreatePeerConnectionWithoutDtls(); |
1109 AddVoiceStream(kStreamLabel1); | 1111 AddVoiceStream(kStreamLabel1); |
1110 std::unique_ptr<SessionDescriptionInterface> offer; | 1112 std::unique_ptr<SessionDescriptionInterface> offer; |
1111 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 1113 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
1112 return offer; | 1114 return offer; |
1113 } | 1115 } |
1114 | 1116 |
1115 std::unique_ptr<SessionDescriptionInterface> | 1117 std::unique_ptr<SessionDescriptionInterface> |
1116 CreateAnswerWithOneAudioStream() { | 1118 CreateAnswerWithOneAudioStream() { |
1117 std::unique_ptr<SessionDescriptionInterface> offer = | 1119 std::unique_ptr<SessionDescriptionInterface> offer = |
1118 CreateOfferWithOneAudioStream(); | 1120 CreateOfferWithOneAudioStream(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 PeerConnectionInterface::RTCConfiguration config; | 1276 PeerConnectionInterface::RTCConfiguration config; |
1275 config.type = PeerConnectionInterface::kRelay; | 1277 config.type = PeerConnectionInterface::kRelay; |
1276 EXPECT_TRUE(pc_->SetConfiguration(config)); | 1278 EXPECT_TRUE(pc_->SetConfiguration(config)); |
1277 | 1279 |
1278 PeerConnectionInterface::RTCConfiguration returned_config = | 1280 PeerConnectionInterface::RTCConfiguration returned_config = |
1279 pc_->GetConfiguration(); | 1281 pc_->GetConfiguration(); |
1280 EXPECT_EQ(PeerConnectionInterface::kRelay, returned_config.type); | 1282 EXPECT_EQ(PeerConnectionInterface::kRelay, returned_config.type); |
1281 } | 1283 } |
1282 | 1284 |
1283 TEST_F(PeerConnectionInterfaceTest, AddStreams) { | 1285 TEST_F(PeerConnectionInterfaceTest, AddStreams) { |
1284 CreatePeerConnection(); | 1286 CreatePeerConnectionWithoutDtls(); |
1285 AddVideoStream(kStreamLabel1); | 1287 AddVideoStream(kStreamLabel1); |
1286 AddVoiceStream(kStreamLabel2); | 1288 AddVoiceStream(kStreamLabel2); |
1287 ASSERT_EQ(2u, pc_->local_streams()->count()); | 1289 ASSERT_EQ(2u, pc_->local_streams()->count()); |
1288 | 1290 |
1289 // Test we can add multiple local streams to one peerconnection. | 1291 // Test we can add multiple local streams to one peerconnection. |
1290 rtc::scoped_refptr<MediaStreamInterface> stream( | 1292 rtc::scoped_refptr<MediaStreamInterface> stream( |
1291 pc_factory_->CreateLocalMediaStream(kStreamLabel3)); | 1293 pc_factory_->CreateLocalMediaStream(kStreamLabel3)); |
1292 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 1294 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
1293 pc_factory_->CreateAudioTrack(kStreamLabel3, | 1295 pc_factory_->CreateAudioTrack(kStreamLabel3, |
1294 static_cast<AudioSourceInterface*>(NULL))); | 1296 static_cast<AudioSourceInterface*>(NULL))); |
1295 stream->AddTrack(audio_track.get()); | 1297 stream->AddTrack(audio_track.get()); |
1296 EXPECT_TRUE(pc_->AddStream(stream)); | 1298 EXPECT_TRUE(pc_->AddStream(stream)); |
1297 EXPECT_EQ(3u, pc_->local_streams()->count()); | 1299 EXPECT_EQ(3u, pc_->local_streams()->count()); |
1298 | 1300 |
1299 // Remove the third stream. | 1301 // Remove the third stream. |
1300 pc_->RemoveStream(pc_->local_streams()->at(2)); | 1302 pc_->RemoveStream(pc_->local_streams()->at(2)); |
1301 EXPECT_EQ(2u, pc_->local_streams()->count()); | 1303 EXPECT_EQ(2u, pc_->local_streams()->count()); |
1302 | 1304 |
1303 // Remove the second stream. | 1305 // Remove the second stream. |
1304 pc_->RemoveStream(pc_->local_streams()->at(1)); | 1306 pc_->RemoveStream(pc_->local_streams()->at(1)); |
1305 EXPECT_EQ(1u, pc_->local_streams()->count()); | 1307 EXPECT_EQ(1u, pc_->local_streams()->count()); |
1306 | 1308 |
1307 // Remove the first stream. | 1309 // Remove the first stream. |
1308 pc_->RemoveStream(pc_->local_streams()->at(0)); | 1310 pc_->RemoveStream(pc_->local_streams()->at(0)); |
1309 EXPECT_EQ(0u, pc_->local_streams()->count()); | 1311 EXPECT_EQ(0u, pc_->local_streams()->count()); |
1310 } | 1312 } |
1311 | 1313 |
1312 // Test that the created offer includes streams we added. | 1314 // Test that the created offer includes streams we added. |
1313 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { | 1315 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { |
1314 CreatePeerConnection(); | 1316 CreatePeerConnectionWithoutDtls(); |
1315 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); | 1317 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); |
1316 std::unique_ptr<SessionDescriptionInterface> offer; | 1318 std::unique_ptr<SessionDescriptionInterface> offer; |
1317 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 1319 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
1318 | 1320 |
1319 const cricket::ContentInfo* audio_content = | 1321 const cricket::ContentInfo* audio_content = |
1320 cricket::GetFirstAudioContent(offer->description()); | 1322 cricket::GetFirstAudioContent(offer->description()); |
1321 const cricket::AudioContentDescription* audio_desc = | 1323 const cricket::AudioContentDescription* audio_desc = |
1322 static_cast<const cricket::AudioContentDescription*>( | 1324 static_cast<const cricket::AudioContentDescription*>( |
1323 audio_content->description); | 1325 audio_content->description); |
1324 EXPECT_TRUE( | 1326 EXPECT_TRUE( |
(...skipping 23 matching lines...) Expand all Loading... |
1348 video_content = cricket::GetFirstVideoContent(offer->description()); | 1350 video_content = cricket::GetFirstVideoContent(offer->description()); |
1349 video_desc = static_cast<const cricket::VideoContentDescription*>( | 1351 video_desc = static_cast<const cricket::VideoContentDescription*>( |
1350 video_content->description); | 1352 video_content->description); |
1351 EXPECT_TRUE( | 1353 EXPECT_TRUE( |
1352 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); | 1354 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); |
1353 EXPECT_TRUE( | 1355 EXPECT_TRUE( |
1354 ContainsTrack(video_desc->streams(), kStreamLabel2, "video_track2")); | 1356 ContainsTrack(video_desc->streams(), kStreamLabel2, "video_track2")); |
1355 } | 1357 } |
1356 | 1358 |
1357 TEST_F(PeerConnectionInterfaceTest, RemoveStream) { | 1359 TEST_F(PeerConnectionInterfaceTest, RemoveStream) { |
1358 CreatePeerConnection(); | 1360 CreatePeerConnectionWithoutDtls(); |
1359 AddVideoStream(kStreamLabel1); | 1361 AddVideoStream(kStreamLabel1); |
1360 ASSERT_EQ(1u, pc_->local_streams()->count()); | 1362 ASSERT_EQ(1u, pc_->local_streams()->count()); |
1361 pc_->RemoveStream(pc_->local_streams()->at(0)); | 1363 pc_->RemoveStream(pc_->local_streams()->at(0)); |
1362 EXPECT_EQ(0u, pc_->local_streams()->count()); | 1364 EXPECT_EQ(0u, pc_->local_streams()->count()); |
1363 } | 1365 } |
1364 | 1366 |
1365 // Test for AddTrack and RemoveTrack methods. | 1367 // Test for AddTrack and RemoveTrack methods. |
1366 // Tests that the created offer includes tracks we added, | 1368 // Tests that the created offer includes tracks we added, |
1367 // and that the RtpSenders are created correctly. | 1369 // and that the RtpSenders are created correctly. |
1368 // Also tests that RemoveTrack removes the tracks from subsequent offers. | 1370 // Also tests that RemoveTrack removes the tracks from subsequent offers. |
1369 TEST_F(PeerConnectionInterfaceTest, AddTrackRemoveTrack) { | 1371 TEST_F(PeerConnectionInterfaceTest, AddTrackRemoveTrack) { |
1370 CreatePeerConnection(); | 1372 CreatePeerConnectionWithoutDtls(); |
1371 // Create a dummy stream, so tracks share a stream label. | 1373 // Create a dummy stream, so tracks share a stream label. |
1372 rtc::scoped_refptr<MediaStreamInterface> stream( | 1374 rtc::scoped_refptr<MediaStreamInterface> stream( |
1373 pc_factory_->CreateLocalMediaStream(kStreamLabel1)); | 1375 pc_factory_->CreateLocalMediaStream(kStreamLabel1)); |
1374 std::vector<MediaStreamInterface*> stream_list; | 1376 std::vector<MediaStreamInterface*> stream_list; |
1375 stream_list.push_back(stream.get()); | 1377 stream_list.push_back(stream.get()); |
1376 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 1378 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
1377 pc_factory_->CreateAudioTrack("audio_track", nullptr)); | 1379 pc_factory_->CreateAudioTrack("audio_track", nullptr)); |
1378 rtc::scoped_refptr<VideoTrackInterface> video_track( | 1380 rtc::scoped_refptr<VideoTrackInterface> video_track( |
1379 pc_factory_->CreateVideoTrack( | 1381 pc_factory_->CreateVideoTrack( |
1380 "video_track", | 1382 "video_track", |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1437 |
1436 // Calling RemoveTrack on a sender no longer attached to a PeerConnection | 1438 // Calling RemoveTrack on a sender no longer attached to a PeerConnection |
1437 // should return false. | 1439 // should return false. |
1438 EXPECT_FALSE(pc_->RemoveTrack(audio_sender)); | 1440 EXPECT_FALSE(pc_->RemoveTrack(audio_sender)); |
1439 EXPECT_FALSE(pc_->RemoveTrack(video_sender)); | 1441 EXPECT_FALSE(pc_->RemoveTrack(video_sender)); |
1440 } | 1442 } |
1441 | 1443 |
1442 // Test creating senders without a stream specified, | 1444 // Test creating senders without a stream specified, |
1443 // expecting a random stream ID to be generated. | 1445 // expecting a random stream ID to be generated. |
1444 TEST_F(PeerConnectionInterfaceTest, AddTrackWithoutStream) { | 1446 TEST_F(PeerConnectionInterfaceTest, AddTrackWithoutStream) { |
1445 CreatePeerConnection(); | 1447 CreatePeerConnectionWithoutDtls(); |
1446 // Create a dummy stream, so tracks share a stream label. | 1448 // Create a dummy stream, so tracks share a stream label. |
1447 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 1449 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
1448 pc_factory_->CreateAudioTrack("audio_track", nullptr)); | 1450 pc_factory_->CreateAudioTrack("audio_track", nullptr)); |
1449 rtc::scoped_refptr<VideoTrackInterface> video_track( | 1451 rtc::scoped_refptr<VideoTrackInterface> video_track( |
1450 pc_factory_->CreateVideoTrack( | 1452 pc_factory_->CreateVideoTrack( |
1451 "video_track", | 1453 "video_track", |
1452 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 1454 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); |
1453 auto audio_sender = | 1455 auto audio_sender = |
1454 pc_->AddTrack(audio_track, std::vector<MediaStreamInterface*>()); | 1456 pc_->AddTrack(audio_track, std::vector<MediaStreamInterface*>()); |
1455 auto video_sender = | 1457 auto video_sender = |
1456 pc_->AddTrack(video_track, std::vector<MediaStreamInterface*>()); | 1458 pc_->AddTrack(video_track, std::vector<MediaStreamInterface*>()); |
1457 EXPECT_EQ("audio_track", audio_sender->id()); | 1459 EXPECT_EQ("audio_track", audio_sender->id()); |
1458 EXPECT_EQ(audio_track, audio_sender->track()); | 1460 EXPECT_EQ(audio_track, audio_sender->track()); |
1459 EXPECT_EQ("video_track", video_sender->id()); | 1461 EXPECT_EQ("video_track", video_sender->id()); |
1460 EXPECT_EQ(video_track, video_sender->track()); | 1462 EXPECT_EQ(video_track, video_sender->track()); |
1461 // If the ID is truly a random GUID, it should be infinitely unlikely they | 1463 // If the ID is truly a random GUID, it should be infinitely unlikely they |
1462 // will be the same. | 1464 // will be the same. |
1463 EXPECT_NE(video_sender->stream_ids(), audio_sender->stream_ids()); | 1465 EXPECT_NE(video_sender->stream_ids(), audio_sender->stream_ids()); |
1464 } | 1466 } |
1465 | 1467 |
1466 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceiveAnswer) { | 1468 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceiveAnswer) { |
1467 InitiateCall(); | 1469 InitiateCall(); |
1468 WaitAndVerifyOnAddStream(kStreamLabel1); | 1470 WaitAndVerifyOnAddStream(kStreamLabel1); |
1469 VerifyRemoteRtpHeaderExtensions(); | 1471 VerifyRemoteRtpHeaderExtensions(); |
1470 } | 1472 } |
1471 | 1473 |
1472 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceivePrAnswerAndAnswer) { | 1474 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceivePrAnswerAndAnswer) { |
1473 CreatePeerConnection(); | 1475 CreatePeerConnectionWithoutDtls(); |
1474 AddVideoStream(kStreamLabel1); | 1476 AddVideoStream(kStreamLabel1); |
1475 CreateOfferAsLocalDescription(); | 1477 CreateOfferAsLocalDescription(); |
1476 std::string offer; | 1478 std::string offer; |
1477 EXPECT_TRUE(pc_->local_description()->ToString(&offer)); | 1479 EXPECT_TRUE(pc_->local_description()->ToString(&offer)); |
1478 CreatePrAnswerAndAnswerAsRemoteDescription(offer); | 1480 CreatePrAnswerAndAnswerAsRemoteDescription(offer); |
1479 WaitAndVerifyOnAddStream(kStreamLabel1); | 1481 WaitAndVerifyOnAddStream(kStreamLabel1); |
1480 } | 1482 } |
1481 | 1483 |
1482 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreateAnswer) { | 1484 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreateAnswer) { |
1483 CreatePeerConnection(); | 1485 CreatePeerConnectionWithoutDtls(); |
1484 AddVideoStream(kStreamLabel1); | 1486 AddVideoStream(kStreamLabel1); |
1485 | 1487 |
1486 CreateOfferAsRemoteDescription(); | 1488 CreateOfferAsRemoteDescription(); |
1487 CreateAnswerAsLocalDescription(); | 1489 CreateAnswerAsLocalDescription(); |
1488 | 1490 |
1489 WaitAndVerifyOnAddStream(kStreamLabel1); | 1491 WaitAndVerifyOnAddStream(kStreamLabel1); |
1490 } | 1492 } |
1491 | 1493 |
1492 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreatePrAnswerAndAnswer) { | 1494 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreatePrAnswerAndAnswer) { |
1493 CreatePeerConnection(); | 1495 CreatePeerConnectionWithoutDtls(); |
1494 AddVideoStream(kStreamLabel1); | 1496 AddVideoStream(kStreamLabel1); |
1495 | 1497 |
1496 CreateOfferAsRemoteDescription(); | 1498 CreateOfferAsRemoteDescription(); |
1497 CreatePrAnswerAsLocalDescription(); | 1499 CreatePrAnswerAsLocalDescription(); |
1498 CreateAnswerAsLocalDescription(); | 1500 CreateAnswerAsLocalDescription(); |
1499 | 1501 |
1500 WaitAndVerifyOnAddStream(kStreamLabel1); | 1502 WaitAndVerifyOnAddStream(kStreamLabel1); |
1501 } | 1503 } |
1502 | 1504 |
1503 TEST_F(PeerConnectionInterfaceTest, Renegotiate) { | 1505 TEST_F(PeerConnectionInterfaceTest, Renegotiate) { |
1504 InitiateCall(); | 1506 InitiateCall(); |
1505 ASSERT_EQ(1u, pc_->remote_streams()->count()); | 1507 ASSERT_EQ(1u, pc_->remote_streams()->count()); |
1506 pc_->RemoveStream(pc_->local_streams()->at(0)); | 1508 pc_->RemoveStream(pc_->local_streams()->at(0)); |
1507 CreateOfferReceiveAnswer(); | 1509 CreateOfferReceiveAnswer(); |
1508 EXPECT_EQ(0u, pc_->remote_streams()->count()); | 1510 EXPECT_EQ(0u, pc_->remote_streams()->count()); |
1509 AddVideoStream(kStreamLabel1); | 1511 AddVideoStream(kStreamLabel1); |
1510 CreateOfferReceiveAnswer(); | 1512 CreateOfferReceiveAnswer(); |
1511 } | 1513 } |
1512 | 1514 |
1513 // Tests that after negotiating an audio only call, the respondent can perform a | 1515 // Tests that after negotiating an audio only call, the respondent can perform a |
1514 // renegotiation that removes the audio stream. | 1516 // renegotiation that removes the audio stream. |
1515 TEST_F(PeerConnectionInterfaceTest, RenegotiateAudioOnly) { | 1517 TEST_F(PeerConnectionInterfaceTest, RenegotiateAudioOnly) { |
1516 CreatePeerConnection(); | 1518 CreatePeerConnectionWithoutDtls(); |
1517 AddVoiceStream(kStreamLabel1); | 1519 AddVoiceStream(kStreamLabel1); |
1518 CreateOfferAsRemoteDescription(); | 1520 CreateOfferAsRemoteDescription(); |
1519 CreateAnswerAsLocalDescription(); | 1521 CreateAnswerAsLocalDescription(); |
1520 | 1522 |
1521 ASSERT_EQ(1u, pc_->remote_streams()->count()); | 1523 ASSERT_EQ(1u, pc_->remote_streams()->count()); |
1522 pc_->RemoveStream(pc_->local_streams()->at(0)); | 1524 pc_->RemoveStream(pc_->local_streams()->at(0)); |
1523 CreateOfferReceiveAnswer(); | 1525 CreateOfferReceiveAnswer(); |
1524 EXPECT_EQ(0u, pc_->remote_streams()->count()); | 1526 EXPECT_EQ(0u, pc_->remote_streams()->count()); |
1525 } | 1527 } |
1526 | 1528 |
1527 // Test that candidates are generated and that we can parse our own candidates. | 1529 // Test that candidates are generated and that we can parse our own candidates. |
1528 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { | 1530 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { |
1529 CreatePeerConnection(); | 1531 CreatePeerConnectionWithoutDtls(); |
1530 | 1532 |
1531 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); | 1533 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
1532 // SetRemoteDescription takes ownership of offer. | 1534 // SetRemoteDescription takes ownership of offer. |
1533 std::unique_ptr<SessionDescriptionInterface> offer; | 1535 std::unique_ptr<SessionDescriptionInterface> offer; |
1534 AddVideoStream(kStreamLabel1); | 1536 AddVideoStream(kStreamLabel1); |
1535 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 1537 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
1536 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); | 1538 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); |
1537 | 1539 |
1538 // SetLocalDescription takes ownership of answer. | 1540 // SetLocalDescription takes ownership of answer. |
1539 std::unique_ptr<SessionDescriptionInterface> answer; | 1541 std::unique_ptr<SessionDescriptionInterface> answer; |
1540 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | 1542 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
1541 EXPECT_TRUE(DoSetLocalDescription(answer.release())); | 1543 EXPECT_TRUE(DoSetLocalDescription(answer.release())); |
1542 | 1544 |
1543 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); | 1545 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); |
1544 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); | 1546 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); |
1545 | 1547 |
1546 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); | 1548 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
1547 } | 1549 } |
1548 | 1550 |
1549 // Test that CreateOffer and CreateAnswer will fail if the track labels are | 1551 // Test that CreateOffer and CreateAnswer will fail if the track labels are |
1550 // not unique. | 1552 // not unique. |
1551 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { | 1553 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { |
1552 CreatePeerConnection(); | 1554 CreatePeerConnectionWithoutDtls(); |
1553 // Create a regular offer for the CreateAnswer test later. | 1555 // Create a regular offer for the CreateAnswer test later. |
1554 std::unique_ptr<SessionDescriptionInterface> offer; | 1556 std::unique_ptr<SessionDescriptionInterface> offer; |
1555 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 1557 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
1556 EXPECT_TRUE(offer); | 1558 EXPECT_TRUE(offer); |
1557 offer.reset(); | 1559 offer.reset(); |
1558 | 1560 |
1559 // Create a local stream with audio&video tracks having same label. | 1561 // Create a local stream with audio&video tracks having same label. |
1560 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); | 1562 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); |
1561 | 1563 |
1562 // Test CreateOffer | 1564 // Test CreateOffer |
1563 EXPECT_FALSE(DoCreateOffer(&offer, nullptr)); | 1565 EXPECT_FALSE(DoCreateOffer(&offer, nullptr)); |
1564 | 1566 |
1565 // Test CreateAnswer | 1567 // Test CreateAnswer |
1566 std::unique_ptr<SessionDescriptionInterface> answer; | 1568 std::unique_ptr<SessionDescriptionInterface> answer; |
1567 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); | 1569 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); |
1568 } | 1570 } |
1569 | 1571 |
1570 // Test that we will get different SSRCs for each tracks in the offer and answer | 1572 // Test that we will get different SSRCs for each tracks in the offer and answer |
1571 // we created. | 1573 // we created. |
1572 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { | 1574 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { |
1573 CreatePeerConnection(); | 1575 CreatePeerConnectionWithoutDtls(); |
1574 // Create a local stream with audio&video tracks having different labels. | 1576 // Create a local stream with audio&video tracks having different labels. |
1575 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 1577 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
1576 | 1578 |
1577 // Test CreateOffer | 1579 // Test CreateOffer |
1578 std::unique_ptr<SessionDescriptionInterface> offer; | 1580 std::unique_ptr<SessionDescriptionInterface> offer; |
1579 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 1581 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
1580 int audio_ssrc = 0; | 1582 int audio_ssrc = 0; |
1581 int video_ssrc = 0; | 1583 int video_ssrc = 0; |
1582 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), | 1584 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), |
1583 &audio_ssrc)); | 1585 &audio_ssrc)); |
(...skipping 11 matching lines...) Expand all Loading... |
1595 &audio_ssrc)); | 1597 &audio_ssrc)); |
1596 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), | 1598 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), |
1597 &video_ssrc)); | 1599 &video_ssrc)); |
1598 EXPECT_NE(audio_ssrc, video_ssrc); | 1600 EXPECT_NE(audio_ssrc, video_ssrc); |
1599 } | 1601 } |
1600 | 1602 |
1601 // Test that it's possible to call AddTrack on a MediaStream after adding | 1603 // Test that it's possible to call AddTrack on a MediaStream after adding |
1602 // the stream to a PeerConnection. | 1604 // the stream to a PeerConnection. |
1603 // TODO(deadbeef): Remove this test once this behavior is no longer supported. | 1605 // TODO(deadbeef): Remove this test once this behavior is no longer supported. |
1604 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { | 1606 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { |
1605 CreatePeerConnection(); | 1607 CreatePeerConnectionWithoutDtls(); |
1606 // Create audio stream and add to PeerConnection. | 1608 // Create audio stream and add to PeerConnection. |
1607 AddVoiceStream(kStreamLabel1); | 1609 AddVoiceStream(kStreamLabel1); |
1608 MediaStreamInterface* stream = pc_->local_streams()->at(0); | 1610 MediaStreamInterface* stream = pc_->local_streams()->at(0); |
1609 | 1611 |
1610 // Add video track to the audio-only stream. | 1612 // Add video track to the audio-only stream. |
1611 rtc::scoped_refptr<VideoTrackInterface> video_track( | 1613 rtc::scoped_refptr<VideoTrackInterface> video_track( |
1612 pc_factory_->CreateVideoTrack( | 1614 pc_factory_->CreateVideoTrack( |
1613 "video_label", | 1615 "video_label", |
1614 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 1616 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); |
1615 stream->AddTrack(video_track.get()); | 1617 stream->AddTrack(video_track.get()); |
1616 | 1618 |
1617 std::unique_ptr<SessionDescriptionInterface> offer; | 1619 std::unique_ptr<SessionDescriptionInterface> offer; |
1618 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 1620 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
1619 | 1621 |
1620 const cricket::MediaContentDescription* video_desc = | 1622 const cricket::MediaContentDescription* video_desc = |
1621 cricket::GetFirstVideoContentDescription(offer->description()); | 1623 cricket::GetFirstVideoContentDescription(offer->description()); |
1622 EXPECT_TRUE(video_desc != nullptr); | 1624 EXPECT_TRUE(video_desc != nullptr); |
1623 } | 1625 } |
1624 | 1626 |
1625 // Test that it's possible to call RemoveTrack on a MediaStream after adding | 1627 // Test that it's possible to call RemoveTrack on a MediaStream after adding |
1626 // the stream to a PeerConnection. | 1628 // the stream to a PeerConnection. |
1627 // TODO(deadbeef): Remove this test once this behavior is no longer supported. | 1629 // TODO(deadbeef): Remove this test once this behavior is no longer supported. |
1628 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) { | 1630 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) { |
1629 CreatePeerConnection(); | 1631 CreatePeerConnectionWithoutDtls(); |
1630 // Create audio/video stream and add to PeerConnection. | 1632 // Create audio/video stream and add to PeerConnection. |
1631 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 1633 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
1632 MediaStreamInterface* stream = pc_->local_streams()->at(0); | 1634 MediaStreamInterface* stream = pc_->local_streams()->at(0); |
1633 | 1635 |
1634 // Remove the video track. | 1636 // Remove the video track. |
1635 stream->RemoveTrack(stream->GetVideoTracks()[0]); | 1637 stream->RemoveTrack(stream->GetVideoTracks()[0]); |
1636 | 1638 |
1637 std::unique_ptr<SessionDescriptionInterface> offer; | 1639 std::unique_ptr<SessionDescriptionInterface> offer; |
1638 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 1640 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
1639 | 1641 |
1640 const cricket::MediaContentDescription* video_desc = | 1642 const cricket::MediaContentDescription* video_desc = |
1641 cricket::GetFirstVideoContentDescription(offer->description()); | 1643 cricket::GetFirstVideoContentDescription(offer->description()); |
1642 EXPECT_TRUE(video_desc == nullptr); | 1644 EXPECT_TRUE(video_desc == nullptr); |
1643 } | 1645 } |
1644 | 1646 |
1645 // Test creating a sender with a stream ID, and ensure the ID is populated | 1647 // Test creating a sender with a stream ID, and ensure the ID is populated |
1646 // in the offer. | 1648 // in the offer. |
1647 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) { | 1649 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) { |
1648 CreatePeerConnection(); | 1650 CreatePeerConnectionWithoutDtls(); |
1649 pc_->CreateSender("video", kStreamLabel1); | 1651 pc_->CreateSender("video", kStreamLabel1); |
1650 | 1652 |
1651 std::unique_ptr<SessionDescriptionInterface> offer; | 1653 std::unique_ptr<SessionDescriptionInterface> offer; |
1652 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 1654 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
1653 | 1655 |
1654 const cricket::MediaContentDescription* video_desc = | 1656 const cricket::MediaContentDescription* video_desc = |
1655 cricket::GetFirstVideoContentDescription(offer->description()); | 1657 cricket::GetFirstVideoContentDescription(offer->description()); |
1656 ASSERT_TRUE(video_desc != nullptr); | 1658 ASSERT_TRUE(video_desc != nullptr); |
1657 ASSERT_EQ(1u, video_desc->streams().size()); | 1659 ASSERT_EQ(1u, video_desc->streams().size()); |
1658 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label); | 1660 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 cricket::GetFirstDataContent(pc_->local_description()->description()); | 2070 cricket::GetFirstDataContent(pc_->local_description()->description()); |
2069 ASSERT_TRUE(content != NULL); | 2071 ASSERT_TRUE(content != NULL); |
2070 EXPECT_TRUE(content->rejected); | 2072 EXPECT_TRUE(content->rejected); |
2071 #endif | 2073 #endif |
2072 } | 2074 } |
2073 | 2075 |
2074 // Test that we can create an audio only offer and receive an answer with a | 2076 // Test that we can create an audio only offer and receive an answer with a |
2075 // limited set of audio codecs and receive an updated offer with more audio | 2077 // limited set of audio codecs and receive an updated offer with more audio |
2076 // codecs, where the added codecs are not supported. | 2078 // codecs, where the added codecs are not supported. |
2077 TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) { | 2079 TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) { |
2078 CreatePeerConnection(); | 2080 CreatePeerConnectionWithoutDtls(); |
2079 AddVoiceStream("audio_label"); | 2081 AddVoiceStream("audio_label"); |
2080 CreateOfferAsLocalDescription(); | 2082 CreateOfferAsLocalDescription(); |
2081 | 2083 |
2082 SessionDescriptionInterface* answer = | 2084 SessionDescriptionInterface* answer = |
2083 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, | 2085 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, |
2084 webrtc::kAudioSdp, nullptr); | 2086 webrtc::kAudioSdp, nullptr); |
2085 EXPECT_TRUE(DoSetSessionDescription(answer, false)); | 2087 EXPECT_TRUE(DoSetSessionDescription(answer, false)); |
2086 | 2088 |
2087 SessionDescriptionInterface* updated_offer = | 2089 SessionDescriptionInterface* updated_offer = |
2088 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 2090 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2176 } | 2178 } |
2177 | 2179 |
2178 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesCandidateFilter) { | 2180 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesCandidateFilter) { |
2179 CreatePeerConnection(); | 2181 CreatePeerConnection(); |
2180 PeerConnectionInterface::RTCConfiguration config; | 2182 PeerConnectionInterface::RTCConfiguration config; |
2181 config.type = PeerConnectionInterface::kRelay; | 2183 config.type = PeerConnectionInterface::kRelay; |
2182 EXPECT_TRUE(pc_->SetConfiguration(config)); | 2184 EXPECT_TRUE(pc_->SetConfiguration(config)); |
2183 EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter()); | 2185 EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter()); |
2184 } | 2186 } |
2185 | 2187 |
| 2188 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesPruneTurnPortsFlag) { |
| 2189 PeerConnectionInterface::RTCConfiguration config; |
| 2190 config.prune_turn_ports = false; |
| 2191 CreatePeerConnection(config, nullptr); |
| 2192 EXPECT_FALSE(port_allocator_->prune_turn_ports()); |
| 2193 |
| 2194 config.prune_turn_ports = true; |
| 2195 EXPECT_TRUE(pc_->SetConfiguration(config)); |
| 2196 EXPECT_TRUE(port_allocator_->prune_turn_ports()); |
| 2197 } |
| 2198 |
2186 // Test that when SetConfiguration changes both the pool size and other | 2199 // Test that when SetConfiguration changes both the pool size and other |
2187 // attributes, the pooled session is created with the updated attributes. | 2200 // attributes, the pooled session is created with the updated attributes. |
2188 TEST_F(PeerConnectionInterfaceTest, | 2201 TEST_F(PeerConnectionInterfaceTest, |
2189 SetConfigurationCreatesPooledSessionCorrectly) { | 2202 SetConfigurationCreatesPooledSessionCorrectly) { |
2190 CreatePeerConnection(); | 2203 CreatePeerConnection(); |
2191 PeerConnectionInterface::RTCConfiguration config; | 2204 PeerConnectionInterface::RTCConfiguration config; |
2192 config.ice_candidate_pool_size = 1; | 2205 config.ice_candidate_pool_size = 1; |
2193 PeerConnectionInterface::IceServer server; | 2206 PeerConnectionInterface::IceServer server; |
2194 server.uri = kStunAddressOnly; | 2207 server.uri = kStunAddressOnly; |
2195 config.servers.push_back(server); | 2208 config.servers.push_back(server); |
2196 config.type = PeerConnectionInterface::kRelay; | 2209 config.type = PeerConnectionInterface::kRelay; |
2197 EXPECT_TRUE(pc_->SetConfiguration(config)); | 2210 EXPECT_TRUE(pc_->SetConfiguration(config)); |
2198 | 2211 |
2199 const cricket::FakePortAllocatorSession* session = | 2212 const cricket::FakePortAllocatorSession* session = |
2200 static_cast<const cricket::FakePortAllocatorSession*>( | 2213 static_cast<const cricket::FakePortAllocatorSession*>( |
2201 port_allocator_->GetPooledSession()); | 2214 port_allocator_->GetPooledSession()); |
2202 ASSERT_NE(nullptr, session); | 2215 ASSERT_NE(nullptr, session); |
2203 EXPECT_EQ(1UL, session->stun_servers().size()); | 2216 EXPECT_EQ(1UL, session->stun_servers().size()); |
2204 } | 2217 } |
2205 | 2218 |
2206 // Test that after SetLocalDescription, changing the pool size is not allowed. | 2219 // Test that after SetLocalDescription, changing the pool size is not allowed, |
| 2220 // and an invalid modification error is returned. |
2207 TEST_F(PeerConnectionInterfaceTest, | 2221 TEST_F(PeerConnectionInterfaceTest, |
2208 CantChangePoolSizeAfterSetLocalDescription) { | 2222 CantChangePoolSizeAfterSetLocalDescription) { |
2209 CreatePeerConnection(); | 2223 CreatePeerConnection(); |
2210 // Start by setting a size of 1. | 2224 // Start by setting a size of 1. |
2211 PeerConnectionInterface::RTCConfiguration config; | 2225 PeerConnectionInterface::RTCConfiguration config; |
2212 config.ice_candidate_pool_size = 1; | 2226 config.ice_candidate_pool_size = 1; |
2213 EXPECT_TRUE(pc_->SetConfiguration(config)); | 2227 EXPECT_TRUE(pc_->SetConfiguration(config)); |
2214 | 2228 |
2215 // Set remote offer; can still change pool size at this point. | 2229 // Set remote offer; can still change pool size at this point. |
2216 CreateOfferAsRemoteDescription(); | 2230 CreateOfferAsRemoteDescription(); |
2217 config.ice_candidate_pool_size = 2; | 2231 config.ice_candidate_pool_size = 2; |
2218 EXPECT_TRUE(pc_->SetConfiguration(config)); | 2232 EXPECT_TRUE(pc_->SetConfiguration(config)); |
2219 | 2233 |
2220 // Set local answer; now it's too late. | 2234 // Set local answer; now it's too late. |
2221 CreateAnswerAsLocalDescription(); | 2235 CreateAnswerAsLocalDescription(); |
2222 config.ice_candidate_pool_size = 3; | 2236 config.ice_candidate_pool_size = 3; |
2223 EXPECT_FALSE(pc_->SetConfiguration(config)); | 2237 RTCError error; |
| 2238 EXPECT_FALSE(pc_->SetConfiguration(config, &error)); |
| 2239 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); |
| 2240 } |
| 2241 |
| 2242 // Test that SetConfiguration returns an invalid modification error if |
| 2243 // modifying a field in the configuration that isn't allowed to be modified. |
| 2244 TEST_F(PeerConnectionInterfaceTest, |
| 2245 SetConfigurationReturnsInvalidModificationError) { |
| 2246 PeerConnectionInterface::RTCConfiguration config; |
| 2247 config.bundle_policy = PeerConnectionInterface::kBundlePolicyBalanced; |
| 2248 config.rtcp_mux_policy = PeerConnectionInterface::kRtcpMuxPolicyNegotiate; |
| 2249 config.continual_gathering_policy = PeerConnectionInterface::GATHER_ONCE; |
| 2250 CreatePeerConnection(config, nullptr); |
| 2251 |
| 2252 PeerConnectionInterface::RTCConfiguration modified_config = config; |
| 2253 modified_config.bundle_policy = |
| 2254 PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 2255 RTCError error; |
| 2256 EXPECT_FALSE(pc_->SetConfiguration(modified_config, &error)); |
| 2257 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); |
| 2258 |
| 2259 modified_config = config; |
| 2260 modified_config.rtcp_mux_policy = |
| 2261 PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 2262 error.set_type(RTCErrorType::NONE); |
| 2263 EXPECT_FALSE(pc_->SetConfiguration(modified_config, &error)); |
| 2264 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); |
| 2265 |
| 2266 modified_config = config; |
| 2267 modified_config.continual_gathering_policy = |
| 2268 PeerConnectionInterface::GATHER_CONTINUALLY; |
| 2269 error.set_type(RTCErrorType::NONE); |
| 2270 EXPECT_FALSE(pc_->SetConfiguration(modified_config, &error)); |
| 2271 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); |
| 2272 } |
| 2273 |
| 2274 // Test that SetConfiguration returns a range error if the candidate pool size |
| 2275 // is negative or larger than allowed by the spec. |
| 2276 TEST_F(PeerConnectionInterfaceTest, |
| 2277 SetConfigurationReturnsRangeErrorForBadCandidatePoolSize) { |
| 2278 PeerConnectionInterface::RTCConfiguration config; |
| 2279 CreatePeerConnection(config, nullptr); |
| 2280 |
| 2281 config.ice_candidate_pool_size = -1; |
| 2282 RTCError error; |
| 2283 EXPECT_FALSE(pc_->SetConfiguration(config, &error)); |
| 2284 EXPECT_EQ(RTCErrorType::INVALID_RANGE, error.type()); |
| 2285 |
| 2286 config.ice_candidate_pool_size = INT_MAX; |
| 2287 error.set_type(RTCErrorType::NONE); |
| 2288 EXPECT_FALSE(pc_->SetConfiguration(config, &error)); |
| 2289 EXPECT_EQ(RTCErrorType::INVALID_RANGE, error.type()); |
| 2290 } |
| 2291 |
| 2292 // Test that SetConfiguration returns a syntax error if parsing an ICE server |
| 2293 // URL failed. |
| 2294 TEST_F(PeerConnectionInterfaceTest, |
| 2295 SetConfigurationReturnsSyntaxErrorFromBadIceUrls) { |
| 2296 PeerConnectionInterface::RTCConfiguration config; |
| 2297 CreatePeerConnection(config, nullptr); |
| 2298 |
| 2299 PeerConnectionInterface::IceServer bad_server; |
| 2300 bad_server.uri = "stunn:www.example.com"; |
| 2301 config.servers.push_back(bad_server); |
| 2302 RTCError error; |
| 2303 EXPECT_FALSE(pc_->SetConfiguration(config, &error)); |
| 2304 EXPECT_EQ(RTCErrorType::SYNTAX_ERROR, error.type()); |
| 2305 } |
| 2306 |
| 2307 // Test that SetConfiguration returns an invalid parameter error if a TURN |
| 2308 // IceServer is missing a username or password. |
| 2309 TEST_F(PeerConnectionInterfaceTest, |
| 2310 SetConfigurationReturnsInvalidParameterIfCredentialsMissing) { |
| 2311 PeerConnectionInterface::RTCConfiguration config; |
| 2312 CreatePeerConnection(config, nullptr); |
| 2313 |
| 2314 PeerConnectionInterface::IceServer bad_server; |
| 2315 bad_server.uri = "turn:www.example.com"; |
| 2316 // Missing password. |
| 2317 bad_server.username = "foo"; |
| 2318 config.servers.push_back(bad_server); |
| 2319 RTCError error; |
| 2320 EXPECT_FALSE(pc_->SetConfiguration(config, &error)); |
| 2321 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, error.type()); |
2224 } | 2322 } |
2225 | 2323 |
2226 // Test that PeerConnection::Close changes the states to closed and all remote | 2324 // Test that PeerConnection::Close changes the states to closed and all remote |
2227 // tracks change state to ended. | 2325 // tracks change state to ended. |
2228 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { | 2326 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { |
2229 // Initialize a PeerConnection and negotiate local and remote session | 2327 // Initialize a PeerConnection and negotiate local and remote session |
2230 // description. | 2328 // description. |
2231 InitiateCall(); | 2329 InitiateCall(); |
2232 ASSERT_EQ(1u, pc_->local_streams()->count()); | 2330 ASSERT_EQ(1u, pc_->local_streams()->count()); |
2233 ASSERT_EQ(1u, pc_->remote_streams()->count()); | 2331 ASSERT_EQ(1u, pc_->remote_streams()->count()); |
(...skipping 14 matching lines...) Expand all Loading... |
2248 // Track state may be updated asynchronously. | 2346 // Track state may be updated asynchronously. |
2249 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, | 2347 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, |
2250 remote_stream->GetAudioTracks()[0]->state(), kTimeout); | 2348 remote_stream->GetAudioTracks()[0]->state(), kTimeout); |
2251 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, | 2349 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, |
2252 remote_stream->GetVideoTracks()[0]->state(), kTimeout); | 2350 remote_stream->GetVideoTracks()[0]->state(), kTimeout); |
2253 } | 2351 } |
2254 | 2352 |
2255 // Test that PeerConnection methods fails gracefully after | 2353 // Test that PeerConnection methods fails gracefully after |
2256 // PeerConnection::Close has been called. | 2354 // PeerConnection::Close has been called. |
2257 TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { | 2355 TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { |
2258 CreatePeerConnection(); | 2356 CreatePeerConnectionWithoutDtls(); |
2259 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 2357 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
2260 CreateOfferAsRemoteDescription(); | 2358 CreateOfferAsRemoteDescription(); |
2261 CreateAnswerAsLocalDescription(); | 2359 CreateAnswerAsLocalDescription(); |
2262 | 2360 |
2263 ASSERT_EQ(1u, pc_->local_streams()->count()); | 2361 ASSERT_EQ(1u, pc_->local_streams()->count()); |
2264 rtc::scoped_refptr<MediaStreamInterface> local_stream = | 2362 rtc::scoped_refptr<MediaStreamInterface> local_stream = |
2265 pc_->local_streams()->at(0); | 2363 pc_->local_streams()->at(0); |
2266 | 2364 |
2267 pc_->Close(); | 2365 pc_->Close(); |
2268 | 2366 |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3220 answer_c.SetMandatoryReceiveAudio(false); | 3318 answer_c.SetMandatoryReceiveAudio(false); |
3221 answer_c.SetMandatoryReceiveVideo(false); | 3319 answer_c.SetMandatoryReceiveVideo(false); |
3222 | 3320 |
3223 cricket::MediaSessionOptions updated_answer_options; | 3321 cricket::MediaSessionOptions updated_answer_options; |
3224 EXPECT_TRUE( | 3322 EXPECT_TRUE( |
3225 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 3323 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
3226 EXPECT_TRUE(updated_answer_options.has_audio()); | 3324 EXPECT_TRUE(updated_answer_options.has_audio()); |
3227 EXPECT_TRUE(updated_answer_options.has_video()); | 3325 EXPECT_TRUE(updated_answer_options.has_video()); |
3228 } | 3326 } |
3229 | 3327 |
3230 TEST(RtcErrorTest, OstreamOperator) { | 3328 TEST(RTCErrorTypeTest, OstreamOperator) { |
3231 std::ostringstream oss; | 3329 std::ostringstream oss; |
3232 oss << webrtc::RtcError::NONE << ' ' | 3330 oss << webrtc::RTCErrorType::NONE << ' ' |
3233 << webrtc::RtcError::INVALID_PARAMETER << ' ' | 3331 << webrtc::RTCErrorType::INVALID_PARAMETER << ' ' |
3234 << webrtc::RtcError::INTERNAL_ERROR; | 3332 << webrtc::RTCErrorType::INTERNAL_ERROR; |
3235 EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str()); | 3333 EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str()); |
3236 } | 3334 } |
| 3335 |
| 3336 // Tests a few random fields being different. |
| 3337 TEST(RTCConfigurationTest, ComparisonOperators) { |
| 3338 PeerConnectionInterface::RTCConfiguration a; |
| 3339 PeerConnectionInterface::RTCConfiguration b; |
| 3340 EXPECT_EQ(a, b); |
| 3341 |
| 3342 PeerConnectionInterface::RTCConfiguration c; |
| 3343 c.servers.push_back(PeerConnectionInterface::IceServer()); |
| 3344 EXPECT_NE(a, c); |
| 3345 |
| 3346 PeerConnectionInterface::RTCConfiguration d; |
| 3347 d.type = PeerConnectionInterface::kRelay; |
| 3348 EXPECT_NE(a, d); |
| 3349 |
| 3350 PeerConnectionInterface::RTCConfiguration e; |
| 3351 e.audio_jitter_buffer_max_packets = 5; |
| 3352 EXPECT_NE(a, e); |
| 3353 |
| 3354 PeerConnectionInterface::RTCConfiguration f; |
| 3355 f.ice_connection_receiving_timeout = 1337; |
| 3356 EXPECT_NE(a, f); |
| 3357 |
| 3358 PeerConnectionInterface::RTCConfiguration g; |
| 3359 g.disable_ipv6 = true; |
| 3360 EXPECT_NE(a, g); |
| 3361 |
| 3362 PeerConnectionInterface::RTCConfiguration h( |
| 3363 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
| 3364 EXPECT_NE(a, h); |
| 3365 } |
OLD | NEW |