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 23 matching lines...) Expand all Loading... |
34 #include "webrtc/media/base/mediachannel.h" | 34 #include "webrtc/media/base/mediachannel.h" |
35 #include "webrtc/media/engine/fakewebrtccall.h" | 35 #include "webrtc/media/engine/fakewebrtccall.h" |
36 #include "webrtc/media/sctp/sctptransportinternal.h" | 36 #include "webrtc/media/sctp/sctptransportinternal.h" |
37 #include "webrtc/p2p/base/packettransportinternal.h" | 37 #include "webrtc/p2p/base/packettransportinternal.h" |
38 #include "webrtc/p2p/base/stunserver.h" | 38 #include "webrtc/p2p/base/stunserver.h" |
39 #include "webrtc/p2p/base/teststunserver.h" | 39 #include "webrtc/p2p/base/teststunserver.h" |
40 #include "webrtc/p2p/base/testturnserver.h" | 40 #include "webrtc/p2p/base/testturnserver.h" |
41 #include "webrtc/p2p/client/basicportallocator.h" | 41 #include "webrtc/p2p/client/basicportallocator.h" |
42 #include "webrtc/pc/audiotrack.h" | 42 #include "webrtc/pc/audiotrack.h" |
43 #include "webrtc/pc/channelmanager.h" | 43 #include "webrtc/pc/channelmanager.h" |
44 #include "webrtc/pc/fakemediacontroller.h" | |
45 #include "webrtc/pc/mediasession.h" | 44 #include "webrtc/pc/mediasession.h" |
46 #include "webrtc/pc/peerconnection.h" | 45 #include "webrtc/pc/peerconnection.h" |
47 #include "webrtc/pc/sctputils.h" | 46 #include "webrtc/pc/sctputils.h" |
48 #include "webrtc/pc/test/fakertccertificategenerator.h" | 47 #include "webrtc/pc/test/fakertccertificategenerator.h" |
49 #include "webrtc/pc/videotrack.h" | 48 #include "webrtc/pc/videotrack.h" |
50 #include "webrtc/pc/webrtcsession.h" | 49 #include "webrtc/pc/webrtcsession.h" |
51 #include "webrtc/pc/webrtcsessiondescriptionfactory.h" | 50 #include "webrtc/pc/webrtcsessiondescriptionfactory.h" |
52 | 51 |
53 using cricket::FakeVoiceMediaChannel; | 52 using cricket::FakeVoiceMediaChannel; |
54 using cricket::TransportInfo; | 53 using cricket::TransportInfo; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 return last_fake_sctp_transport_; | 247 return last_fake_sctp_transport_; |
249 } | 248 } |
250 | 249 |
251 private: | 250 private: |
252 FakeSctpTransport* last_fake_sctp_transport_ = nullptr; | 251 FakeSctpTransport* last_fake_sctp_transport_ = nullptr; |
253 }; | 252 }; |
254 | 253 |
255 class WebRtcSessionForTest : public webrtc::WebRtcSession { | 254 class WebRtcSessionForTest : public webrtc::WebRtcSession { |
256 public: | 255 public: |
257 WebRtcSessionForTest( | 256 WebRtcSessionForTest( |
258 webrtc::MediaControllerInterface* media_controller, | 257 webrtc::Call* fake_call, |
| 258 cricket::ChannelManager* channel_manager, |
| 259 const cricket::MediaConfig& media_config, |
| 260 webrtc::RtcEventLog* event_log, |
259 rtc::Thread* network_thread, | 261 rtc::Thread* network_thread, |
260 rtc::Thread* worker_thread, | 262 rtc::Thread* worker_thread, |
261 rtc::Thread* signaling_thread, | 263 rtc::Thread* signaling_thread, |
262 cricket::PortAllocator* port_allocator, | 264 cricket::PortAllocator* port_allocator, |
263 webrtc::IceObserver* ice_observer, | 265 webrtc::IceObserver* ice_observer, |
264 std::unique_ptr<cricket::TransportController> transport_controller, | 266 std::unique_ptr<cricket::TransportController> transport_controller, |
265 std::unique_ptr<FakeSctpTransportFactory> sctp_factory) | 267 std::unique_ptr<FakeSctpTransportFactory> sctp_factory) |
266 : WebRtcSession(media_controller, | 268 : WebRtcSession(fake_call, channel_manager, media_config, event_log, |
267 network_thread, | 269 network_thread, |
268 worker_thread, | 270 worker_thread, |
269 signaling_thread, | 271 signaling_thread, |
270 port_allocator, | 272 port_allocator, |
271 std::move(transport_controller), | 273 std::move(transport_controller), |
272 std::move(sctp_factory)) { | 274 std::move(sctp_factory)) { |
273 RegisterIceObserver(ice_observer); | 275 RegisterIceObserver(ice_observer); |
274 } | 276 } |
275 virtual ~WebRtcSessionForTest() {} | 277 virtual ~WebRtcSessionForTest() {} |
276 | 278 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // TODO Investigate why ChannelManager crashes, if it's created | 370 // TODO Investigate why ChannelManager crashes, if it's created |
369 // after stun_server. | 371 // after stun_server. |
370 WebRtcSessionTest() | 372 WebRtcSessionTest() |
371 : media_engine_(new cricket::FakeMediaEngine()), | 373 : media_engine_(new cricket::FakeMediaEngine()), |
372 data_engine_(new cricket::FakeDataEngine()), | 374 data_engine_(new cricket::FakeDataEngine()), |
373 channel_manager_(new cricket::ChannelManager( | 375 channel_manager_(new cricket::ChannelManager( |
374 std::unique_ptr<cricket::MediaEngineInterface>(media_engine_), | 376 std::unique_ptr<cricket::MediaEngineInterface>(media_engine_), |
375 std::unique_ptr<cricket::DataEngineInterface>(data_engine_), | 377 std::unique_ptr<cricket::DataEngineInterface>(data_engine_), |
376 rtc::Thread::Current())), | 378 rtc::Thread::Current())), |
377 fake_call_(webrtc::Call::Config(&event_log_)), | 379 fake_call_(webrtc::Call::Config(&event_log_)), |
378 media_controller_( | |
379 webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), | |
380 rtc::Thread::Current(), | |
381 channel_manager_.get(), | |
382 &event_log_)), | |
383 tdesc_factory_(new cricket::TransportDescriptionFactory()), | 380 tdesc_factory_(new cricket::TransportDescriptionFactory()), |
384 desc_factory_( | 381 desc_factory_( |
385 new cricket::MediaSessionDescriptionFactory(channel_manager_.get(), | 382 new cricket::MediaSessionDescriptionFactory(channel_manager_.get(), |
386 tdesc_factory_.get())), | 383 tdesc_factory_.get())), |
387 pss_(new rtc::PhysicalSocketServer), | 384 pss_(new rtc::PhysicalSocketServer), |
388 vss_(new rtc::VirtualSocketServer(pss_.get())), | 385 vss_(new rtc::VirtualSocketServer(pss_.get())), |
389 fss_(new rtc::FirewallSocketServer(vss_.get())), | 386 fss_(new rtc::FirewallSocketServer(vss_.get())), |
390 ss_scope_(fss_.get()), | 387 ss_scope_(fss_.get()), |
391 stun_socket_addr_( | 388 stun_socket_addr_( |
392 rtc::SocketAddress(kStunAddrHost, cricket::STUN_SERVER_PORT)), | 389 rtc::SocketAddress(kStunAddrHost, cricket::STUN_SERVER_PORT)), |
(...skipping 24 matching lines...) Expand all Loading... |
417 // If |cert_generator| != null or |rtc_configuration| contains |certificates| | 414 // If |cert_generator| != null or |rtc_configuration| contains |certificates| |
418 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| | 415 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| |
419 // options. When DTLS is enabled a certificate will be used if provided, | 416 // options. When DTLS is enabled a certificate will be used if provided, |
420 // otherwise one will be generated using the |cert_generator|. | 417 // otherwise one will be generated using the |cert_generator|. |
421 void Init( | 418 void Init( |
422 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 419 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
423 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy, | 420 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy, |
424 const rtc::CryptoOptions& crypto_options) { | 421 const rtc::CryptoOptions& crypto_options) { |
425 ASSERT_TRUE(session_.get() == NULL); | 422 ASSERT_TRUE(session_.get() == NULL); |
426 fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); | 423 fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); |
427 session_.reset(new WebRtcSessionForTest( | 424 session_.reset(new WebRtcSessionForTest(&fake_call_, |
428 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), | 425 channel_manager_.get(), cricket::MediaConfig(), &event_log_, |
| 426 rtc::Thread::Current(), rtc::Thread::Current(), |
429 rtc::Thread::Current(), allocator_.get(), &observer_, | 427 rtc::Thread::Current(), allocator_.get(), &observer_, |
430 std::unique_ptr<cricket::TransportController>( | 428 std::unique_ptr<cricket::TransportController>( |
431 new cricket::TransportController( | 429 new cricket::TransportController( |
432 rtc::Thread::Current(), rtc::Thread::Current(), | 430 rtc::Thread::Current(), rtc::Thread::Current(), |
433 allocator_.get(), | 431 allocator_.get(), |
434 /*redetermine_role_on_ice_restart=*/true, crypto_options)), | 432 /*redetermine_role_on_ice_restart=*/true, crypto_options)), |
435 std::unique_ptr<FakeSctpTransportFactory>( | 433 std::unique_ptr<FakeSctpTransportFactory>( |
436 fake_sctp_transport_factory_))); | 434 fake_sctp_transport_factory_))); |
437 session_->SignalDataChannelOpenMessage.connect( | 435 session_->SignalDataChannelOpenMessage.connect( |
438 this, &WebRtcSessionTest::OnDataChannelOpenMessage); | 436 this, &WebRtcSessionTest::OnDataChannelOpenMessage); |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 observer_.ice_connection_state_, | 1371 observer_.ice_connection_state_, |
1374 kIceCandidatesTimeout + port_timeout); | 1372 kIceCandidatesTimeout + port_timeout); |
1375 } | 1373 } |
1376 | 1374 |
1377 void TestLoopbackCall() { | 1375 void TestLoopbackCall() { |
1378 LoopbackNetworkConfiguration config; | 1376 LoopbackNetworkConfiguration config; |
1379 TestLoopbackCall(config); | 1377 TestLoopbackCall(config); |
1380 } | 1378 } |
1381 | 1379 |
1382 void TestPacketOptions() { | 1380 void TestPacketOptions() { |
1383 media_controller_.reset( | |
1384 new cricket::FakeMediaController(channel_manager_.get(), &fake_call_)); | |
1385 LoopbackNetworkConfiguration config; | 1381 LoopbackNetworkConfiguration config; |
1386 LoopbackNetworkManager loopback_network_manager(this, config); | 1382 LoopbackNetworkManager loopback_network_manager(this, config); |
1387 | 1383 |
1388 SetupLoopbackCall(); | 1384 SetupLoopbackCall(); |
1389 | 1385 |
1390 // Wait for channel to be ready for sending. | 1386 // Wait for channel to be ready for sending. |
1391 EXPECT_TRUE_WAIT(media_engine_->GetVideoChannel(0)->sending(), 100); | 1387 EXPECT_TRUE_WAIT(media_engine_->GetVideoChannel(0)->sending(), 100); |
1392 uint8_t test_packet[15] = {0}; | 1388 uint8_t test_packet[15] = {0}; |
1393 rtc::PacketOptions options; | 1389 rtc::PacketOptions options; |
1394 options.packet_id = 10; | 1390 options.packet_id = 10; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 | 1504 |
1509 webrtc::RtcEventLogNullImpl event_log_; | 1505 webrtc::RtcEventLogNullImpl event_log_; |
1510 // |media_engine_| and |data_engine_| are actually owned by | 1506 // |media_engine_| and |data_engine_| are actually owned by |
1511 // |channel_manager_|. | 1507 // |channel_manager_|. |
1512 cricket::FakeMediaEngine* media_engine_; | 1508 cricket::FakeMediaEngine* media_engine_; |
1513 cricket::FakeDataEngine* data_engine_; | 1509 cricket::FakeDataEngine* data_engine_; |
1514 // Actually owned by session_. | 1510 // Actually owned by session_. |
1515 FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr; | 1511 FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr; |
1516 std::unique_ptr<cricket::ChannelManager> channel_manager_; | 1512 std::unique_ptr<cricket::ChannelManager> channel_manager_; |
1517 cricket::FakeCall fake_call_; | 1513 cricket::FakeCall fake_call_; |
1518 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; | |
1519 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; | 1514 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; |
1520 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; | 1515 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; |
1521 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 1516 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
1522 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 1517 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
1523 std::unique_ptr<rtc::FirewallSocketServer> fss_; | 1518 std::unique_ptr<rtc::FirewallSocketServer> fss_; |
1524 rtc::SocketServerScope ss_scope_; | 1519 rtc::SocketServerScope ss_scope_; |
1525 rtc::SocketAddress stun_socket_addr_; | 1520 rtc::SocketAddress stun_socket_addr_; |
1526 std::unique_ptr<cricket::TestStunServer> stun_server_; | 1521 std::unique_ptr<cricket::TestStunServer> stun_server_; |
1527 cricket::TestTurnServer turn_server_; | 1522 cricket::TestTurnServer turn_server_; |
1528 rtc::FakeNetworkManager network_manager_; | 1523 rtc::FakeNetworkManager network_manager_; |
(...skipping 2818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4347 } | 4342 } |
4348 | 4343 |
4349 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4344 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4350 // currently fails because upon disconnection and reconnection OnIceComplete is | 4345 // currently fails because upon disconnection and reconnection OnIceComplete is |
4351 // called more than once without returning to IceGatheringGathering. | 4346 // called more than once without returning to IceGatheringGathering. |
4352 | 4347 |
4353 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4348 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4354 WebRtcSessionTest, | 4349 WebRtcSessionTest, |
4355 testing::Values(ALREADY_GENERATED, | 4350 testing::Values(ALREADY_GENERATED, |
4356 DTLS_IDENTITY_STORE)); | 4351 DTLS_IDENTITY_STORE)); |
OLD | NEW |