| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include <vector> | 28 #include <vector> |
| 29 | 29 |
| 30 #include "talk/app/webrtc/audiotrack.h" | 30 #include "talk/app/webrtc/audiotrack.h" |
| 31 #include "talk/app/webrtc/fakemediacontroller.h" |
| 31 #include "talk/app/webrtc/fakemetricsobserver.h" | 32 #include "talk/app/webrtc/fakemetricsobserver.h" |
| 32 #include "talk/app/webrtc/jsepicecandidate.h" | 33 #include "talk/app/webrtc/jsepicecandidate.h" |
| 33 #include "talk/app/webrtc/jsepsessiondescription.h" | 34 #include "talk/app/webrtc/jsepsessiondescription.h" |
| 34 #include "talk/app/webrtc/mediastreamsignaling.h" | 35 #include "talk/app/webrtc/mediastreamsignaling.h" |
| 35 #include "talk/app/webrtc/streamcollection.h" | 36 #include "talk/app/webrtc/streamcollection.h" |
| 36 #include "talk/app/webrtc/test/fakeconstraints.h" | 37 #include "talk/app/webrtc/test/fakeconstraints.h" |
| 37 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" | 38 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" |
| 38 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" | 39 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
| 39 #include "talk/app/webrtc/videotrack.h" | 40 #include "talk/app/webrtc/videotrack.h" |
| 40 #include "talk/app/webrtc/webrtcsession.h" | 41 #include "talk/app/webrtc/webrtcsession.h" |
| 41 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" | 42 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
| 42 #include "talk/media/base/fakemediaengine.h" | 43 #include "talk/media/base/fakemediaengine.h" |
| 43 #include "talk/media/base/fakevideorenderer.h" | 44 #include "talk/media/base/fakevideorenderer.h" |
| 44 #include "talk/media/base/mediachannel.h" | 45 #include "talk/media/base/mediachannel.h" |
| 46 #include "talk/media/webrtc/fakewebrtccall.h" |
| 45 #include "webrtc/p2p/base/stunserver.h" | 47 #include "webrtc/p2p/base/stunserver.h" |
| 46 #include "webrtc/p2p/base/teststunserver.h" | 48 #include "webrtc/p2p/base/teststunserver.h" |
| 47 #include "webrtc/p2p/base/testturnserver.h" | 49 #include "webrtc/p2p/base/testturnserver.h" |
| 48 #include "webrtc/p2p/base/transportchannel.h" | 50 #include "webrtc/p2p/base/transportchannel.h" |
| 49 #include "webrtc/p2p/client/basicportallocator.h" | 51 #include "webrtc/p2p/client/basicportallocator.h" |
| 50 #include "talk/session/media/channelmanager.h" | 52 #include "talk/session/media/channelmanager.h" |
| 51 #include "talk/session/media/mediasession.h" | 53 #include "talk/session/media/mediasession.h" |
| 52 #include "webrtc/base/fakenetwork.h" | 54 #include "webrtc/base/fakenetwork.h" |
| 53 #include "webrtc/base/firewallsocketserver.h" | 55 #include "webrtc/base/firewallsocketserver.h" |
| 54 #include "webrtc/base/gunit.h" | 56 #include "webrtc/base/gunit.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 228 |
| 227 bool oncandidatesready_; | 229 bool oncandidatesready_; |
| 228 std::vector<cricket::Candidate> mline_0_candidates_; | 230 std::vector<cricket::Candidate> mline_0_candidates_; |
| 229 std::vector<cricket::Candidate> mline_1_candidates_; | 231 std::vector<cricket::Candidate> mline_1_candidates_; |
| 230 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 232 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
| 231 PeerConnectionInterface::IceGatheringState ice_gathering_state_; | 233 PeerConnectionInterface::IceGatheringState ice_gathering_state_; |
| 232 }; | 234 }; |
| 233 | 235 |
| 234 class WebRtcSessionForTest : public webrtc::WebRtcSession { | 236 class WebRtcSessionForTest : public webrtc::WebRtcSession { |
| 235 public: | 237 public: |
| 236 WebRtcSessionForTest(cricket::ChannelManager* cmgr, | 238 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, |
| 237 rtc::Thread* signaling_thread, | 239 rtc::Thread* signaling_thread, |
| 238 rtc::Thread* worker_thread, | 240 rtc::Thread* worker_thread, |
| 239 cricket::PortAllocator* port_allocator, | 241 cricket::PortAllocator* port_allocator, |
| 240 webrtc::IceObserver* ice_observer, | 242 webrtc::IceObserver* ice_observer, |
| 241 webrtc::MediaStreamSignaling* mediastream_signaling) | 243 webrtc::MediaStreamSignaling* mediastream_signaling) |
| 242 : WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator, | 244 : WebRtcSession(media_controller, |
| 243 mediastream_signaling) { | 245 signaling_thread, |
| 246 worker_thread, |
| 247 port_allocator, |
| 248 mediastream_signaling) { |
| 244 RegisterIceObserver(ice_observer); | 249 RegisterIceObserver(ice_observer); |
| 245 } | 250 } |
| 246 virtual ~WebRtcSessionForTest() {} | 251 virtual ~WebRtcSessionForTest() {} |
| 247 | 252 |
| 248 // Note that these methods are only safe to use if the signaling thread | 253 // Note that these methods are only safe to use if the signaling thread |
| 249 // is the same as the worker thread | 254 // is the same as the worker thread |
| 250 cricket::TransportChannel* voice_rtp_transport_channel() { | 255 cricket::TransportChannel* voice_rtp_transport_channel() { |
| 251 return rtp_transport_channel(voice_channel()); | 256 return rtp_transport_channel(voice_channel()); |
| 252 } | 257 } |
| 253 | 258 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 int channel_id_; | 357 int channel_id_; |
| 353 cricket::AudioRenderer::Sink* sink_; | 358 cricket::AudioRenderer::Sink* sink_; |
| 354 }; | 359 }; |
| 355 | 360 |
| 356 class WebRtcSessionTest | 361 class WebRtcSessionTest |
| 357 : public testing::TestWithParam<RTCCertificateGenerationMethod> { | 362 : public testing::TestWithParam<RTCCertificateGenerationMethod> { |
| 358 protected: | 363 protected: |
| 359 // TODO Investigate why ChannelManager crashes, if it's created | 364 // TODO Investigate why ChannelManager crashes, if it's created |
| 360 // after stun_server. | 365 // after stun_server. |
| 361 WebRtcSessionTest() | 366 WebRtcSessionTest() |
| 362 : media_engine_(new cricket::FakeMediaEngine()), | 367 : media_engine_(new cricket::FakeMediaEngine()), |
| 363 data_engine_(new cricket::FakeDataEngine()), | 368 data_engine_(new cricket::FakeDataEngine()), |
| 364 channel_manager_(new cricket::ChannelManager( | 369 channel_manager_( |
| 365 media_engine_, data_engine_, new cricket::CaptureManager(), | 370 new cricket::ChannelManager(media_engine_, |
| 366 rtc::Thread::Current())), | 371 data_engine_, |
| 367 tdesc_factory_(new cricket::TransportDescriptionFactory()), | 372 new cricket::CaptureManager(), |
| 368 desc_factory_(new cricket::MediaSessionDescriptionFactory( | 373 rtc::Thread::Current())), |
| 369 channel_manager_.get(), tdesc_factory_.get())), | 374 fake_call_(webrtc::Call::Config()), |
| 370 pss_(new rtc::PhysicalSocketServer), | 375 media_controller_( |
| 371 vss_(new rtc::VirtualSocketServer(pss_.get())), | 376 webrtc::MediaControllerInterface::Create(rtc::Thread::Current(), |
| 372 fss_(new rtc::FirewallSocketServer(vss_.get())), | 377 channel_manager_.get())), |
| 373 ss_scope_(fss_.get()), | 378 tdesc_factory_(new cricket::TransportDescriptionFactory()), |
| 374 stun_socket_addr_(rtc::SocketAddress(kStunAddrHost, | 379 desc_factory_( |
| 375 cricket::STUN_SERVER_PORT)), | 380 new cricket::MediaSessionDescriptionFactory(channel_manager_.get(), |
| 376 stun_server_(cricket::TestStunServer::Create(Thread::Current(), | 381 tdesc_factory_.get())), |
| 377 stun_socket_addr_)), | 382 pss_(new rtc::PhysicalSocketServer), |
| 378 turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), | 383 vss_(new rtc::VirtualSocketServer(pss_.get())), |
| 379 mediastream_signaling_(channel_manager_.get()), | 384 fss_(new rtc::FirewallSocketServer(vss_.get())), |
| 380 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { | 385 ss_scope_(fss_.get()), |
| 386 stun_socket_addr_( |
| 387 rtc::SocketAddress(kStunAddrHost, cricket::STUN_SERVER_PORT)), |
| 388 stun_server_(cricket::TestStunServer::Create(Thread::Current(), |
| 389 stun_socket_addr_)), |
| 390 turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), |
| 391 mediastream_signaling_(channel_manager_.get()), |
| 392 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { |
| 381 cricket::ServerAddresses stun_servers; | 393 cricket::ServerAddresses stun_servers; |
| 382 stun_servers.insert(stun_socket_addr_); | 394 stun_servers.insert(stun_socket_addr_); |
| 383 allocator_.reset(new cricket::BasicPortAllocator( | 395 allocator_.reset(new cricket::BasicPortAllocator( |
| 384 &network_manager_, | 396 &network_manager_, |
| 385 stun_servers, | 397 stun_servers, |
| 386 SocketAddress(), SocketAddress(), SocketAddress())); | 398 SocketAddress(), SocketAddress(), SocketAddress())); |
| 387 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 399 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 388 cricket::PORTALLOCATOR_DISABLE_RELAY); | 400 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 389 EXPECT_TRUE(channel_manager_->Init()); | 401 EXPECT_TRUE(channel_manager_->Init()); |
| 390 desc_factory_->set_add_legacy_streams(false); | 402 desc_factory_->set_add_legacy_streams(false); |
| 391 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 403 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 392 } | 404 } |
| 393 | 405 |
| 394 void AddInterface(const SocketAddress& addr) { | 406 void AddInterface(const SocketAddress& addr) { |
| 395 network_manager_.AddInterface(addr); | 407 network_manager_.AddInterface(addr); |
| 396 } | 408 } |
| 397 | 409 |
| 398 // If |dtls_identity_store| != null or |rtc_configuration| contains | 410 // If |dtls_identity_store| != null or |rtc_configuration| contains |
| 399 // |certificates| then DTLS will be enabled unless explicitly disabled by | 411 // |certificates| then DTLS will be enabled unless explicitly disabled by |
| 400 // |rtc_configuration| options. When DTLS is enabled a certificate will be | 412 // |rtc_configuration| options. When DTLS is enabled a certificate will be |
| 401 // used if provided, otherwise one will be generated using the | 413 // used if provided, otherwise one will be generated using the |
| 402 // |dtls_identity_store|. | 414 // |dtls_identity_store|. |
| 403 void Init( | 415 void Init( |
| 404 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 416 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
| 405 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 417 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
| 406 ASSERT_TRUE(session_.get() == NULL); | 418 ASSERT_TRUE(session_.get() == NULL); |
| 407 session_.reset(new WebRtcSessionForTest( | 419 session_.reset(new WebRtcSessionForTest( |
| 408 channel_manager_.get(), rtc::Thread::Current(), | 420 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), |
| 409 rtc::Thread::Current(), allocator_.get(), | 421 allocator_.get(), &observer_, &mediastream_signaling_)); |
| 410 &observer_, | |
| 411 &mediastream_signaling_)); | |
| 412 | 422 |
| 413 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 423 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 414 observer_.ice_connection_state_); | 424 observer_.ice_connection_state_); |
| 415 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 425 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 416 observer_.ice_gathering_state_); | 426 observer_.ice_gathering_state_); |
| 417 | 427 |
| 418 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), | 428 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), |
| 419 dtls_identity_store.Pass(), | 429 dtls_identity_store.Pass(), |
| 420 rtc_configuration)); | 430 rtc_configuration)); |
| 421 session_->set_metrics_observer(metrics_observer_); | 431 session_->set_metrics_observer(metrics_observer_); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 // This code is placed in a method so that it can be invoked | 1131 // This code is placed in a method so that it can be invoked |
| 1122 // by multiple tests with different allocators (e.g. with and without BUNDLE). | 1132 // by multiple tests with different allocators (e.g. with and without BUNDLE). |
| 1123 // While running the call, this method also checks if the session goes through | 1133 // While running the call, this method also checks if the session goes through |
| 1124 // the correct sequence of ICE states when a connection is established, | 1134 // the correct sequence of ICE states when a connection is established, |
| 1125 // broken, and re-established. | 1135 // broken, and re-established. |
| 1126 // The Connection state should go: | 1136 // The Connection state should go: |
| 1127 // New -> Checking -> (Connected) -> Completed -> Disconnected -> Completed | 1137 // New -> Checking -> (Connected) -> Completed -> Disconnected -> Completed |
| 1128 // -> Failed. | 1138 // -> Failed. |
| 1129 // The Gathering state should go: New -> Gathering -> Completed. | 1139 // The Gathering state should go: New -> Gathering -> Completed. |
| 1130 | 1140 |
| 1131 void TestLoopbackCall(const LoopbackNetworkConfiguration& config) { | 1141 void SetupLoopbackCall() { |
| 1132 LoopbackNetworkManager loopback_network_manager(this, config); | |
| 1133 Init(); | 1142 Init(); |
| 1134 mediastream_signaling_.SendAudioVideoStream1(); | 1143 mediastream_signaling_.SendAudioVideoStream1(); |
| 1135 SessionDescriptionInterface* offer = CreateOffer(); | 1144 SessionDescriptionInterface* offer = CreateOffer(); |
| 1136 | 1145 |
| 1137 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 1146 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 1138 observer_.ice_gathering_state_); | 1147 observer_.ice_gathering_state_); |
| 1139 SetLocalDescriptionWithoutError(offer); | 1148 SetLocalDescriptionWithoutError(offer); |
| 1140 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 1149 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 1141 observer_.ice_connection_state_); | 1150 observer_.ice_connection_state_); |
| 1142 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering, | 1151 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering, |
| 1143 observer_.ice_gathering_state_, | 1152 observer_.ice_gathering_state_, kIceCandidatesTimeout); |
| 1144 kIceCandidatesTimeout); | |
| 1145 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 1153 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1146 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, | 1154 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, |
| 1147 observer_.ice_gathering_state_, | 1155 observer_.ice_gathering_state_, kIceCandidatesTimeout); |
| 1148 kIceCandidatesTimeout); | |
| 1149 | 1156 |
| 1150 std::string sdp; | 1157 std::string sdp; |
| 1151 offer->ToString(&sdp); | 1158 offer->ToString(&sdp); |
| 1152 SessionDescriptionInterface* desc = | 1159 SessionDescriptionInterface* desc = webrtc::CreateSessionDescription( |
| 1153 webrtc::CreateSessionDescription( | 1160 JsepSessionDescription::kAnswer, sdp, nullptr); |
| 1154 JsepSessionDescription::kAnswer, sdp, nullptr); | |
| 1155 ASSERT_TRUE(desc != NULL); | 1161 ASSERT_TRUE(desc != NULL); |
| 1156 SetRemoteDescriptionWithoutError(desc); | 1162 SetRemoteDescriptionWithoutError(desc); |
| 1157 | 1163 |
| 1158 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking, | 1164 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking, |
| 1159 observer_.ice_connection_state_, | 1165 observer_.ice_connection_state_, kIceCandidatesTimeout); |
| 1160 kIceCandidatesTimeout); | |
| 1161 | 1166 |
| 1162 // The ice connection state is "Connected" too briefly to catch in a test. | 1167 // The ice connection state is "Connected" too briefly to catch in a test. |
| 1163 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, | 1168 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
| 1164 observer_.ice_connection_state_, | 1169 observer_.ice_connection_state_, kIceCandidatesTimeout); |
| 1165 kIceCandidatesTimeout); | 1170 } |
| 1166 | 1171 |
| 1172 void TestLoopbackCall(const LoopbackNetworkConfiguration& config) { |
| 1173 LoopbackNetworkManager loopback_network_manager(this, config); |
| 1174 SetupLoopbackCall(); |
| 1167 config.VerifyBestConnectionAfterIceConverge(metrics_observer_); | 1175 config.VerifyBestConnectionAfterIceConverge(metrics_observer_); |
| 1168 // Adding firewall rule to block ping requests, which should cause | 1176 // Adding firewall rule to block ping requests, which should cause |
| 1169 // transport channel failure. | 1177 // transport channel failure. |
| 1170 | 1178 |
| 1171 loopback_network_manager.ApplyFirewallRules(fss_.get()); | 1179 loopback_network_manager.ApplyFirewallRules(fss_.get()); |
| 1172 | 1180 |
| 1173 LOG(LS_INFO) << "Firewall Rules applied"; | 1181 LOG(LS_INFO) << "Firewall Rules applied"; |
| 1174 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, | 1182 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
| 1175 observer_.ice_connection_state_, | 1183 observer_.ice_connection_state_, |
| 1176 kIceCandidatesTimeout); | 1184 kIceCandidatesTimeout); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1195 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, | 1203 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
| 1196 observer_.ice_connection_state_, | 1204 observer_.ice_connection_state_, |
| 1197 kIceCandidatesTimeout + port_timeout); | 1205 kIceCandidatesTimeout + port_timeout); |
| 1198 } | 1206 } |
| 1199 | 1207 |
| 1200 void TestLoopbackCall() { | 1208 void TestLoopbackCall() { |
| 1201 LoopbackNetworkConfiguration config; | 1209 LoopbackNetworkConfiguration config; |
| 1202 TestLoopbackCall(config); | 1210 TestLoopbackCall(config); |
| 1203 } | 1211 } |
| 1204 | 1212 |
| 1213 void TestPacketOptions() { |
| 1214 media_controller_.reset( |
| 1215 new cricket::FakeMediaController(channel_manager_.get(), &fake_call_)); |
| 1216 LoopbackNetworkConfiguration config; |
| 1217 LoopbackNetworkManager loopback_network_manager(this, config); |
| 1218 |
| 1219 SetupLoopbackCall(); |
| 1220 |
| 1221 uint8_t test_packet[15] = {0}; |
| 1222 rtc::PacketOptions options; |
| 1223 options.packet_id = 10; |
| 1224 media_engine_->GetVideoChannel(0) |
| 1225 ->SendRtp(test_packet, sizeof(test_packet), options); |
| 1226 |
| 1227 const int kPacketTimeout = 2000; |
| 1228 EXPECT_EQ_WAIT(fake_call_.last_sent_packet().packet_id, 10, kPacketTimeout); |
| 1229 EXPECT_GT(fake_call_.last_sent_packet().send_time_ms, -1); |
| 1230 } |
| 1231 |
| 1205 // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. | 1232 // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. |
| 1206 void AddCNCodecs() { | 1233 void AddCNCodecs() { |
| 1207 const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); | 1234 const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); |
| 1208 const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); | 1235 const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); |
| 1209 | 1236 |
| 1210 // Add kCNCodec for dtmf test. | 1237 // Add kCNCodec for dtmf test. |
| 1211 std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; | 1238 std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; |
| 1212 codecs.push_back(kCNCodec1); | 1239 codecs.push_back(kCNCodec1); |
| 1213 codecs.push_back(kCNCodec2); | 1240 codecs.push_back(kCNCodec2); |
| 1214 media_engine_->SetAudioCodecs(codecs); | 1241 media_engine_->SetAudioCodecs(codecs); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 relay_server.ports.push_back(cricket::ProtocolAddress( | 1322 relay_server.ports.push_back(cricket::ProtocolAddress( |
| 1296 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); | 1323 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); |
| 1297 allocator_->AddRelay(relay_server); | 1324 allocator_->AddRelay(relay_server); |
| 1298 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 1325 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 1299 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); | 1326 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); |
| 1300 } | 1327 } |
| 1301 | 1328 |
| 1302 cricket::FakeMediaEngine* media_engine_; | 1329 cricket::FakeMediaEngine* media_engine_; |
| 1303 cricket::FakeDataEngine* data_engine_; | 1330 cricket::FakeDataEngine* data_engine_; |
| 1304 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; | 1331 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; |
| 1332 cricket::FakeCall fake_call_; |
| 1333 rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_; |
| 1305 rtc::scoped_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; | 1334 rtc::scoped_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; |
| 1306 rtc::scoped_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; | 1335 rtc::scoped_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; |
| 1307 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 1336 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; |
| 1308 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; | 1337 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; |
| 1309 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; | 1338 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; |
| 1310 rtc::SocketServerScope ss_scope_; | 1339 rtc::SocketServerScope ss_scope_; |
| 1311 rtc::SocketAddress stun_socket_addr_; | 1340 rtc::SocketAddress stun_socket_addr_; |
| 1312 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; | 1341 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; |
| 1313 cricket::TestTurnServer turn_server_; | 1342 cricket::TestTurnServer turn_server_; |
| 1314 rtc::FakeNetworkManager network_manager_; | 1343 rtc::FakeNetworkManager network_manager_; |
| (...skipping 2710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4025 | 4054 |
| 4026 for (auto& o : observers) { | 4055 for (auto& o : observers) { |
| 4027 // We expect to have received a notification now even if the session was | 4056 // We expect to have received a notification now even if the session was |
| 4028 // terminated. The offer creation may or may not have succeeded, but we | 4057 // terminated. The offer creation may or may not have succeeded, but we |
| 4029 // must have received a notification which, so the only invalid state | 4058 // must have received a notification which, so the only invalid state |
| 4030 // is kInit. | 4059 // is kInit. |
| 4031 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4060 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 4032 } | 4061 } |
| 4033 } | 4062 } |
| 4034 | 4063 |
| 4064 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { |
| 4065 TestPacketOptions(); |
| 4066 } |
| 4067 |
| 4035 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4068 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4036 // currently fails because upon disconnection and reconnection OnIceComplete is | 4069 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4037 // called more than once without returning to IceGatheringGathering. | 4070 // called more than once without returning to IceGatheringGathering. |
| 4038 | 4071 |
| 4039 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4072 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4040 WebRtcSessionTest, | 4073 WebRtcSessionTest, |
| 4041 testing::Values(ALREADY_GENERATED, | 4074 testing::Values(ALREADY_GENERATED, |
| 4042 DTLS_IDENTITY_STORE)); | 4075 DTLS_IDENTITY_STORE)); |
| OLD | NEW |