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