Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: talk/app/webrtc/peerconnection_unittest.cc

Issue 1460323002: Revert of Adding the ability to create an RtpSender without a track. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/peerconnection.cc ('k') | talk/app/webrtc/peerconnectioninterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 using webrtc::StreamCollectionInterface; 91 using webrtc::StreamCollectionInterface;
92 92
93 static const int kMaxWaitMs = 10000; 93 static const int kMaxWaitMs = 10000;
94 // Disable for TSan v2, see 94 // Disable for TSan v2, see
95 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. 95 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details.
96 // This declaration is also #ifdef'd as it causes uninitialized-variable 96 // This declaration is also #ifdef'd as it causes uninitialized-variable
97 // warnings. 97 // warnings.
98 #if !defined(THREAD_SANITIZER) 98 #if !defined(THREAD_SANITIZER)
99 static const int kMaxWaitForStatsMs = 3000; 99 static const int kMaxWaitForStatsMs = 3000;
100 #endif 100 #endif
101 static const int kMaxWaitForActivationMs = 5000;
102 static const int kMaxWaitForFramesMs = 10000; 101 static const int kMaxWaitForFramesMs = 10000;
103 static const int kEndAudioFrameCount = 3; 102 static const int kEndAudioFrameCount = 3;
104 static const int kEndVideoFrameCount = 3; 103 static const int kEndVideoFrameCount = 3;
105 104
106 static const char kStreamLabelBase[] = "stream_label"; 105 static const char kStreamLabelBase[] = "stream_label";
107 static const char kVideoTrackLabelBase[] = "video_track"; 106 static const char kVideoTrackLabelBase[] = "video_track";
108 static const char kAudioTrackLabelBase[] = "audio_track"; 107 static const char kAudioTrackLabelBase[] = "audio_track";
109 static const char kDataChannelLabel[] = "data_channel"; 108 static const char kDataChannelLabel[] = "data_channel";
110 109
111 // Disable for TSan v2, see 110 // Disable for TSan v2, see
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 281 }
283 282
284 void AddMediaStream(bool audio, bool video) { 283 void AddMediaStream(bool audio, bool video) {
285 std::string stream_label = 284 std::string stream_label =
286 kStreamLabelBase + 285 kStreamLabelBase +
287 rtc::ToString<int>(static_cast<int>(pc()->local_streams()->count())); 286 rtc::ToString<int>(static_cast<int>(pc()->local_streams()->count()));
288 rtc::scoped_refptr<MediaStreamInterface> stream = 287 rtc::scoped_refptr<MediaStreamInterface> stream =
289 peer_connection_factory_->CreateLocalMediaStream(stream_label); 288 peer_connection_factory_->CreateLocalMediaStream(stream_label);
290 289
291 if (audio && can_receive_audio()) { 290 if (audio && can_receive_audio()) {
292 stream->AddTrack(CreateLocalAudioTrack(stream_label)); 291 FakeConstraints constraints;
292 // Disable highpass filter so that we can get all the test audio frames.
293 constraints.AddMandatory(
294 MediaConstraintsInterface::kHighpassFilter, false);
295 rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
296 peer_connection_factory_->CreateAudioSource(&constraints);
297 // TODO(perkj): Test audio source when it is implemented. Currently audio
298 // always use the default input.
299 std::string label = stream_label + kAudioTrackLabelBase;
300 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
301 peer_connection_factory_->CreateAudioTrack(label, source));
302 stream->AddTrack(audio_track);
293 } 303 }
294 if (video && can_receive_video()) { 304 if (video && can_receive_video()) {
295 stream->AddTrack(CreateLocalVideoTrack(stream_label)); 305 stream->AddTrack(CreateLocalVideoTrack(stream_label));
296 } 306 }
297 307
298 EXPECT_TRUE(pc()->AddStream(stream)); 308 EXPECT_TRUE(pc()->AddStream(stream));
299 } 309 }
300 310
301 size_t NumberOfLocalMediaStreams() { return pc()->local_streams()->count(); } 311 size_t NumberOfLocalMediaStreams() { return pc()->local_streams()->count(); }
302 312
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 data_channel_ = data_channel; 394 data_channel_ = data_channel;
385 data_observer_.reset(new MockDataChannelObserver(data_channel)); 395 data_observer_.reset(new MockDataChannelObserver(data_channel));
386 } 396 }
387 397
388 void CreateDataChannel() { 398 void CreateDataChannel() {
389 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr); 399 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr);
390 ASSERT_TRUE(data_channel_.get() != nullptr); 400 ASSERT_TRUE(data_channel_.get() != nullptr);
391 data_observer_.reset(new MockDataChannelObserver(data_channel_)); 401 data_observer_.reset(new MockDataChannelObserver(data_channel_));
392 } 402 }
393 403
394 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack(
395 const std::string& stream_label) {
396 FakeConstraints constraints;
397 // Disable highpass filter so that we can get all the test audio frames.
398 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false);
399 rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
400 peer_connection_factory_->CreateAudioSource(&constraints);
401 // TODO(perkj): Test audio source when it is implemented. Currently audio
402 // always use the default input.
403 std::string label = stream_label + kAudioTrackLabelBase;
404 return peer_connection_factory_->CreateAudioTrack(label, source);
405 }
406
407 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack(
408 const std::string& stream_label) {
409 // Set max frame rate to 10fps to reduce the risk of the tests to be flaky.
410 FakeConstraints source_constraints = video_constraints_;
411 source_constraints.SetMandatoryMaxFrameRate(10);
412
413 cricket::FakeVideoCapturer* fake_capturer =
414 new webrtc::FakePeriodicVideoCapturer();
415 video_capturers_.push_back(fake_capturer);
416 rtc::scoped_refptr<webrtc::VideoSourceInterface> source =
417 peer_connection_factory_->CreateVideoSource(fake_capturer,
418 &source_constraints);
419 std::string label = stream_label + kVideoTrackLabelBase;
420 return peer_connection_factory_->CreateVideoTrack(label, source);
421 }
422
423 DataChannelInterface* data_channel() { return data_channel_; } 404 DataChannelInterface* data_channel() { return data_channel_; }
424 const MockDataChannelObserver* data_observer() const { 405 const MockDataChannelObserver* data_observer() const {
425 return data_observer_.get(); 406 return data_observer_.get();
426 } 407 }
427 408
428 webrtc::PeerConnectionInterface* pc() { return peer_connection_.get(); } 409 webrtc::PeerConnectionInterface* pc() { return peer_connection_.get(); }
429 410
430 void StopVideoCapturers() { 411 void StopVideoCapturers() {
431 for (std::vector<cricket::VideoCapturer*>::iterator it = 412 for (std::vector<cricket::VideoCapturer*>::iterator it =
432 video_capturers_.begin(); 413 video_capturers_.begin();
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 return false; 708 return false;
728 } 709 }
729 if (options) { 710 if (options) {
730 peer_connection_factory_->SetOptions(*options); 711 peer_connection_factory_->SetOptions(*options);
731 } 712 }
732 peer_connection_ = CreatePeerConnection(allocator_factory_.get(), 713 peer_connection_ = CreatePeerConnection(allocator_factory_.get(),
733 constraints); 714 constraints);
734 return peer_connection_.get() != nullptr; 715 return peer_connection_.get() != nullptr;
735 } 716 }
736 717
718 rtc::scoped_refptr<webrtc::VideoTrackInterface>
719 CreateLocalVideoTrack(const std::string stream_label) {
720 // Set max frame rate to 10fps to reduce the risk of the tests to be flaky.
721 FakeConstraints source_constraints = video_constraints_;
722 source_constraints.SetMandatoryMaxFrameRate(10);
723
724 cricket::FakeVideoCapturer* fake_capturer =
725 new webrtc::FakePeriodicVideoCapturer();
726 video_capturers_.push_back(fake_capturer);
727 rtc::scoped_refptr<webrtc::VideoSourceInterface> source =
728 peer_connection_factory_->CreateVideoSource(
729 fake_capturer, &source_constraints);
730 std::string label = stream_label + kVideoTrackLabelBase;
731 return peer_connection_factory_->CreateVideoTrack(label, source);
732 }
733
737 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( 734 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
738 webrtc::PortAllocatorFactoryInterface* factory, 735 webrtc::PortAllocatorFactoryInterface* factory,
739 const MediaConstraintsInterface* constraints) { 736 const MediaConstraintsInterface* constraints) {
740 // CreatePeerConnection with IceServers. 737 // CreatePeerConnection with IceServers.
741 webrtc::PeerConnectionInterface::IceServers ice_servers; 738 webrtc::PeerConnectionInterface::IceServers ice_servers;
742 webrtc::PeerConnectionInterface::IceServer ice_server; 739 webrtc::PeerConnectionInterface::IceServer ice_server;
743 ice_server.uri = "stun:stun.l.google.com:19302"; 740 ice_server.uri = "stun:stun.l.google.com:19302";
744 ice_servers.push_back(ice_server); 741 ice_servers.push_back(ice_server);
745 742
746 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( 743 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 1004 }
1008 1005
1009 // This test sets up a call between two parties. Both parties send static 1006 // This test sets up a call between two parties. Both parties send static
1010 // frames to each other. Once the test is finished the number of sent frames 1007 // frames to each other. Once the test is finished the number of sent frames
1011 // is compared to the number of received frames. 1008 // is compared to the number of received frames.
1012 void LocalP2PTest() { 1009 void LocalP2PTest() {
1013 if (initiating_client_->NumberOfLocalMediaStreams() == 0) { 1010 if (initiating_client_->NumberOfLocalMediaStreams() == 0) {
1014 initiating_client_->AddMediaStream(true, true); 1011 initiating_client_->AddMediaStream(true, true);
1015 } 1012 }
1016 initiating_client_->Negotiate(); 1013 initiating_client_->Negotiate();
1014 const int kMaxWaitForActivationMs = 5000;
1017 // Assert true is used here since next tests are guaranteed to fail and 1015 // Assert true is used here since next tests are guaranteed to fail and
1018 // would eat up 5 seconds. 1016 // would eat up 5 seconds.
1019 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); 1017 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs);
1020 VerifySessionDescriptions(); 1018 VerifySessionDescriptions();
1021 1019
1022 int audio_frame_count = kEndAudioFrameCount; 1020 int audio_frame_count = kEndAudioFrameCount;
1023 // TODO(ronghuawu): Add test to cover the case of sendonly and recvonly. 1021 // TODO(ronghuawu): Add test to cover the case of sendonly and recvonly.
1024 if (!initiating_client_->can_receive_audio() || 1022 if (!initiating_client_->can_receive_audio() ||
1025 !receiving_client_->can_receive_audio()) { 1023 !receiving_client_->can_receive_audio()) {
1026 audio_frame_count = -1; 1024 audio_frame_count = -1;
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 // VideoDecoderFactory. 1646 // VideoDecoderFactory.
1649 // TODO(holmer): Disabled due to sometimes crashing on buildbots. 1647 // TODO(holmer): Disabled due to sometimes crashing on buildbots.
1650 // See issue webrtc/2378. 1648 // See issue webrtc/2378.
1651 TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, 1649 TEST_F(MAYBE_JsepPeerConnectionP2PTestClient,
1652 DISABLED_LocalP2PTestWithVideoDecoderFactory) { 1650 DISABLED_LocalP2PTestWithVideoDecoderFactory) {
1653 ASSERT_TRUE(CreateTestClients()); 1651 ASSERT_TRUE(CreateTestClients());
1654 EnableVideoDecoderFactory(); 1652 EnableVideoDecoderFactory();
1655 LocalP2PTest(); 1653 LocalP2PTest();
1656 } 1654 }
1657 1655
1658 // This tests that if we negotiate after calling CreateSender but before we
1659 // have a track, then set a track later, frames from the newly-set track are
1660 // received end-to-end.
1661 TEST_F(MAYBE_JsepPeerConnectionP2PTestClient, EarlyWarmupTest) {
1662 ASSERT_TRUE(CreateTestClients());
1663 auto audio_sender = initializing_client()->pc()->CreateSender("audio");
1664 auto video_sender = initializing_client()->pc()->CreateSender("video");
1665 initializing_client()->Negotiate();
1666 // Wait for ICE connection to complete, without any tracks.
1667 // Note that the receiving client WILL (in HandleIncomingOffer) create
1668 // tracks, so it's only the initiator here that's doing early warmup.
1669 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs);
1670 VerifySessionDescriptions();
1671 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
1672 initializing_client()->ice_connection_state(),
1673 kMaxWaitForFramesMs);
1674 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
1675 receiving_client()->ice_connection_state(),
1676 kMaxWaitForFramesMs);
1677 // Now set the tracks, and expect frames to immediately start flowing.
1678 EXPECT_TRUE(
1679 audio_sender->SetTrack(initializing_client()->CreateLocalAudioTrack("")));
1680 EXPECT_TRUE(
1681 video_sender->SetTrack(initializing_client()->CreateLocalVideoTrack("")));
1682 EXPECT_TRUE_WAIT(FramesNotPending(kEndAudioFrameCount, kEndVideoFrameCount),
1683 kMaxWaitForFramesMs);
1684 }
1685
1686 class IceServerParsingTest : public testing::Test { 1656 class IceServerParsingTest : public testing::Test {
1687 public: 1657 public:
1688 // Convenience for parsing a single URL. 1658 // Convenience for parsing a single URL.
1689 bool ParseUrl(const std::string& url) { 1659 bool ParseUrl(const std::string& url) {
1690 return ParseUrl(url, std::string(), std::string()); 1660 return ParseUrl(url, std::string(), std::string());
1691 } 1661 }
1692 1662
1693 bool ParseUrl(const std::string& url, 1663 bool ParseUrl(const std::string& url,
1694 const std::string& username, 1664 const std::string& username,
1695 const std::string& password) { 1665 const std::string& password) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 server.urls.push_back("stun:hostname"); 1823 server.urls.push_back("stun:hostname");
1854 server.urls.push_back("turn:hostname"); 1824 server.urls.push_back("turn:hostname");
1855 servers.push_back(server); 1825 servers.push_back(server);
1856 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, 1826 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_,
1857 &turn_configurations_)); 1827 &turn_configurations_));
1858 EXPECT_EQ(1U, stun_configurations_.size()); 1828 EXPECT_EQ(1U, stun_configurations_.size());
1859 EXPECT_EQ(1U, turn_configurations_.size()); 1829 EXPECT_EQ(1U, turn_configurations_.size());
1860 } 1830 }
1861 1831
1862 #endif // if !defined(THREAD_SANITIZER) 1832 #endif // if !defined(THREAD_SANITIZER)
OLDNEW
« no previous file with comments | « talk/app/webrtc/peerconnection.cc ('k') | talk/app/webrtc/peerconnectioninterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698