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

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

Issue 1581693006: Adding "first packet received" notification to PeerConnectionObserver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing race condition in unit test. Created 4 years, 11 months 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 std::string ice_sdp; 245 std::string ice_sdp;
246 EXPECT_TRUE(candidate->ToString(&ice_sdp)); 246 EXPECT_TRUE(candidate->ToString(&ice_sdp));
247 if (signaling_message_receiver_ == nullptr) { 247 if (signaling_message_receiver_ == nullptr) {
248 // Remote party may be deleted. 248 // Remote party may be deleted.
249 return; 249 return;
250 } 250 }
251 signaling_message_receiver_->ReceiveIceMessage( 251 signaling_message_receiver_->ReceiveIceMessage(
252 candidate->sdp_mid(), candidate->sdp_mline_index(), ice_sdp); 252 candidate->sdp_mid(), candidate->sdp_mline_index(), ice_sdp);
253 } 253 }
254 void OnFirstMediaPacketReceived() override { received_media_packet_ = true; }
254 255
255 // MediaStreamInterface callback 256 // MediaStreamInterface callback
256 void OnChanged() override { 257 void OnChanged() override {
257 // Track added or removed from MediaStream, so update our renderers. 258 // Track added or removed from MediaStream, so update our renderers.
258 rtc::scoped_refptr<StreamCollectionInterface> remote_streams = 259 rtc::scoped_refptr<StreamCollectionInterface> remote_streams =
259 pc()->remote_streams(); 260 pc()->remote_streams();
260 // Remove renderers for tracks that were removed. 261 // Remove renderers for tracks that were removed.
261 for (auto it = fake_video_renderers_.begin(); 262 for (auto it = fake_video_renderers_.begin();
262 it != fake_video_renderers_.end();) { 263 it != fake_video_renderers_.end();) {
263 if (remote_streams->FindVideoTrack(it->first) == nullptr) { 264 if (remote_streams->FindVideoTrack(it->first) == nullptr) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 bool can_receive_video() { 380 bool can_receive_video() {
380 bool value; 381 bool value;
381 if (webrtc::FindConstraint(&session_description_constraints_, 382 if (webrtc::FindConstraint(&session_description_constraints_,
382 MediaConstraintsInterface::kOfferToReceiveVideo, 383 MediaConstraintsInterface::kOfferToReceiveVideo,
383 &value, nullptr)) { 384 &value, nullptr)) {
384 return value; 385 return value;
385 } 386 }
386 return true; 387 return true;
387 } 388 }
388 389
390 bool received_media_packet() const { return received_media_packet_; }
391
389 void OnIceComplete() override { LOG(INFO) << id_ << "OnIceComplete"; } 392 void OnIceComplete() override { LOG(INFO) << id_ << "OnIceComplete"; }
390 393
391 void OnDataChannel(DataChannelInterface* data_channel) override { 394 void OnDataChannel(DataChannelInterface* data_channel) override {
392 LOG(INFO) << id_ << "OnDataChannel"; 395 LOG(INFO) << id_ << "OnDataChannel";
393 data_channel_ = data_channel; 396 data_channel_ = data_channel;
394 data_observer_.reset(new MockDataChannelObserver(data_channel)); 397 data_observer_.reset(new MockDataChannelObserver(data_channel));
395 } 398 }
396 399
397 void CreateDataChannel() { 400 void CreateDataChannel() {
398 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr); 401 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr);
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 920
918 webrtc::FakeConstraints session_description_constraints_; 921 webrtc::FakeConstraints session_description_constraints_;
919 bool remove_msid_ = false; // True if MSID should be removed in received SDP. 922 bool remove_msid_ = false; // True if MSID should be removed in received SDP.
920 bool remove_bundle_ = 923 bool remove_bundle_ =
921 false; // True if bundle should be removed in received SDP. 924 false; // True if bundle should be removed in received SDP.
922 bool remove_sdes_ = 925 bool remove_sdes_ =
923 false; // True if a=crypto should be removed in received SDP. 926 false; // True if a=crypto should be removed in received SDP.
924 927
925 rtc::scoped_refptr<DataChannelInterface> data_channel_; 928 rtc::scoped_refptr<DataChannelInterface> data_channel_;
926 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; 929 rtc::scoped_ptr<MockDataChannelObserver> data_observer_;
930
931 // "true" if the PeerConnection indicated that a packet was received,
932 // through PeerConnectionObserverInterface.
933 bool received_media_packet_ = false;
927 }; 934 };
928 935
929 class P2PTestConductor : public testing::Test { 936 class P2PTestConductor : public testing::Test {
930 public: 937 public:
931 P2PTestConductor() 938 P2PTestConductor()
932 : pss_(new rtc::PhysicalSocketServer), 939 : pss_(new rtc::PhysicalSocketServer),
933 ss_(new rtc::VirtualSocketServer(pss_.get())), 940 ss_(new rtc::VirtualSocketServer(pss_.get())),
934 ss_scope_(ss_.get()) {} 941 ss_scope_(ss_.get()) {}
935 942
936 bool SessionActive() { 943 bool SessionActive() {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1104 }
1098 if (receiving_client_->can_receive_audio() || 1105 if (receiving_client_->can_receive_audio() ||
1099 receiving_client_->can_receive_video()) { 1106 receiving_client_->can_receive_video()) {
1100 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete, 1107 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete,
1101 receiving_client_->ice_gathering_state(), 1108 receiving_client_->ice_gathering_state(),
1102 kMaxWaitForFramesMs); 1109 kMaxWaitForFramesMs);
1103 } 1110 }
1104 1111
1105 EXPECT_TRUE_WAIT(FramesNotPending(audio_frame_count, video_frame_count), 1112 EXPECT_TRUE_WAIT(FramesNotPending(audio_frame_count, video_frame_count),
1106 kMaxWaitForFramesMs); 1113 kMaxWaitForFramesMs);
1114 if (audio_frame_count != -1 || video_frame_count != -1) {
1115 EXPECT_TRUE_WAIT(initiating_client_->received_media_packet(),
1116 kMaxWaitForFramesMs);
1117 EXPECT_TRUE_WAIT(receiving_client_->received_media_packet(),
1118 kMaxWaitForFramesMs);
1119 }
1107 } 1120 }
1108 1121
1109 void SetupAndVerifyDtlsCall() { 1122 void SetupAndVerifyDtlsCall() {
1110 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1123 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1111 FakeConstraints setup_constraints; 1124 FakeConstraints setup_constraints;
1112 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1125 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1113 true); 1126 true);
1114 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); 1127 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
1115 LocalP2PTest(); 1128 LocalP2PTest();
1116 VerifyRenderedSize(640, 480); 1129 VerifyRenderedSize(640, 480);
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 PeerConnectionInterface::IceServer server; 2035 PeerConnectionInterface::IceServer server;
2023 server.urls.push_back("turn:hostname"); 2036 server.urls.push_back("turn:hostname");
2024 server.urls.push_back("turn:hostname2"); 2037 server.urls.push_back("turn:hostname2");
2025 servers.push_back(server); 2038 servers.push_back(server);
2026 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); 2039 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
2027 EXPECT_EQ(2U, turn_servers_.size()); 2040 EXPECT_EQ(2U, turn_servers_.size());
2028 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); 2041 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority);
2029 } 2042 }
2030 2043
2031 #endif // if !defined(THREAD_SANITIZER) 2044 #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