| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 void RemoveInterface(const SocketAddress& addr) { | 413 void RemoveInterface(const SocketAddress& addr) { |
| 414 network_manager_.RemoveInterface(addr); | 414 network_manager_.RemoveInterface(addr); |
| 415 } | 415 } |
| 416 | 416 |
| 417 // If |cert_generator| != null or |rtc_configuration| contains |certificates| | 417 // If |cert_generator| != null or |rtc_configuration| contains |certificates| |
| 418 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| | 418 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| |
| 419 // options. When DTLS is enabled a certificate will be used if provided, | 419 // options. When DTLS is enabled a certificate will be used if provided, |
| 420 // otherwise one will be generated using the |cert_generator|. | 420 // otherwise one will be generated using the |cert_generator|. |
| 421 void Init( | 421 void Init( |
| 422 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 422 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
| 423 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 423 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy, |
| 424 const rtc::CryptoOptions& crypto_options) { |
| 424 ASSERT_TRUE(session_.get() == NULL); | 425 ASSERT_TRUE(session_.get() == NULL); |
| 425 fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); | 426 fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); |
| 426 session_.reset(new WebRtcSessionForTest( | 427 session_.reset(new WebRtcSessionForTest( |
| 427 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), | 428 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), |
| 428 rtc::Thread::Current(), allocator_.get(), &observer_, | 429 rtc::Thread::Current(), allocator_.get(), &observer_, |
| 429 std::unique_ptr<cricket::TransportController>( | 430 std::unique_ptr<cricket::TransportController>( |
| 430 new cricket::TransportController(rtc::Thread::Current(), | 431 new cricket::TransportController( |
| 431 rtc::Thread::Current(), | 432 rtc::Thread::Current(), rtc::Thread::Current(), |
| 432 allocator_.get())), | 433 allocator_.get(), |
| 434 /*redetermine_role_on_ice_restart=*/true, crypto_options)), |
| 433 std::unique_ptr<FakeSctpTransportFactory>( | 435 std::unique_ptr<FakeSctpTransportFactory>( |
| 434 fake_sctp_transport_factory_))); | 436 fake_sctp_transport_factory_))); |
| 435 session_->SignalDataChannelOpenMessage.connect( | 437 session_->SignalDataChannelOpenMessage.connect( |
| 436 this, &WebRtcSessionTest::OnDataChannelOpenMessage); | 438 this, &WebRtcSessionTest::OnDataChannelOpenMessage); |
| 437 | 439 |
| 438 configuration_.rtcp_mux_policy = rtcp_mux_policy; | 440 configuration_.rtcp_mux_policy = rtcp_mux_policy; |
| 439 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 441 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 440 observer_.ice_connection_state_); | 442 observer_.ice_connection_state_); |
| 441 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 443 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 442 observer_.ice_gathering_state_); | 444 observer_.ice_gathering_state_); |
| 443 | 445 |
| 444 EXPECT_TRUE(session_->Initialize(options_, std::move(cert_generator), | 446 EXPECT_TRUE(session_->Initialize(options_, std::move(cert_generator), |
| 445 configuration_)); | 447 configuration_)); |
| 446 session_->set_metrics_observer(metrics_observer_); | 448 session_->set_metrics_observer(metrics_observer_); |
| 447 } | 449 } |
| 448 | 450 |
| 449 void OnDataChannelOpenMessage(const std::string& label, | 451 void OnDataChannelOpenMessage(const std::string& label, |
| 450 const InternalDataChannelInit& config) { | 452 const InternalDataChannelInit& config) { |
| 451 last_data_channel_label_ = label; | 453 last_data_channel_label_ = label; |
| 452 last_data_channel_config_ = config; | 454 last_data_channel_config_ = config; |
| 453 } | 455 } |
| 454 | 456 |
| 455 void Init() { | 457 void Init() { |
| 456 Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | 458 Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate, |
| 457 } | 459 rtc::CryptoOptions()); |
| 458 | |
| 459 void Init(PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | |
| 460 Init(nullptr, rtcp_mux_policy); | |
| 461 } | 460 } |
| 462 | 461 |
| 463 void InitWithBundlePolicy( | 462 void InitWithBundlePolicy( |
| 464 PeerConnectionInterface::BundlePolicy bundle_policy) { | 463 PeerConnectionInterface::BundlePolicy bundle_policy) { |
| 465 configuration_.bundle_policy = bundle_policy; | 464 configuration_.bundle_policy = bundle_policy; |
| 466 Init(); | 465 Init(); |
| 467 } | 466 } |
| 468 | 467 |
| 469 void InitWithRtcpMuxPolicy( | 468 void InitWithRtcpMuxPolicy( |
| 470 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 469 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
| 471 PeerConnectionInterface::RTCConfiguration configuration; | 470 PeerConnectionInterface::RTCConfiguration configuration; |
| 472 Init(rtcp_mux_policy); | 471 Init(nullptr, rtcp_mux_policy, rtc::CryptoOptions()); |
| 472 } |
| 473 |
| 474 void InitWithCryptoOptions(const rtc::CryptoOptions& crypto_options) { |
| 475 Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate, |
| 476 crypto_options); |
| 473 } | 477 } |
| 474 | 478 |
| 475 // Successfully init with DTLS; with a certificate generated and supplied or | 479 // Successfully init with DTLS; with a certificate generated and supplied or |
| 476 // with a store that generates it for us. | 480 // with a store that generates it for us. |
| 477 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { | 481 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { |
| 478 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator; | 482 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator; |
| 479 if (cert_gen_method == ALREADY_GENERATED) { | 483 if (cert_gen_method == ALREADY_GENERATED) { |
| 480 configuration_.certificates.push_back( | 484 configuration_.certificates.push_back( |
| 481 FakeRTCCertificateGenerator::GenerateCertificate()); | 485 FakeRTCCertificateGenerator::GenerateCertificate()); |
| 482 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { | 486 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { |
| 483 cert_generator.reset(new FakeRTCCertificateGenerator()); | 487 cert_generator.reset(new FakeRTCCertificateGenerator()); |
| 484 cert_generator->set_should_fail(false); | 488 cert_generator->set_should_fail(false); |
| 485 } else { | 489 } else { |
| 486 RTC_CHECK(false); | 490 RTC_CHECK(false); |
| 487 } | 491 } |
| 488 Init(std::move(cert_generator), | 492 Init(std::move(cert_generator), |
| 489 PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | 493 PeerConnectionInterface::kRtcpMuxPolicyNegotiate, |
| 494 rtc::CryptoOptions()); |
| 490 } | 495 } |
| 491 | 496 |
| 492 // Init with DTLS with a store that will fail to generate a certificate. | 497 // Init with DTLS with a store that will fail to generate a certificate. |
| 493 void InitWithDtlsIdentityGenFail() { | 498 void InitWithDtlsIdentityGenFail() { |
| 494 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( | 499 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( |
| 495 new FakeRTCCertificateGenerator()); | 500 new FakeRTCCertificateGenerator()); |
| 496 cert_generator->set_should_fail(true); | 501 cert_generator->set_should_fail(true); |
| 497 Init(std::move(cert_generator), | 502 Init(std::move(cert_generator), |
| 498 PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | 503 PeerConnectionInterface::kRtcpMuxPolicyNegotiate, |
| 504 rtc::CryptoOptions()); |
| 499 } | 505 } |
| 500 | 506 |
| 501 void InitWithGcm() { | 507 void InitWithGcm() { |
| 502 rtc::CryptoOptions crypto_options; | 508 rtc::CryptoOptions crypto_options; |
| 503 crypto_options.enable_gcm_crypto_suites = true; | 509 crypto_options.enable_gcm_crypto_suites = true; |
| 504 channel_manager_->SetCryptoOptions(crypto_options); | 510 InitWithCryptoOptions(crypto_options); |
| 505 with_gcm_ = true; | |
| 506 Init(); | |
| 507 } | 511 } |
| 508 | 512 |
| 509 void SendAudioVideoStream1() { | 513 void SendAudioVideoStream1() { |
| 510 send_stream_1_ = true; | 514 send_stream_1_ = true; |
| 511 send_stream_2_ = false; | 515 send_stream_2_ = false; |
| 512 send_audio_ = true; | 516 send_audio_ = true; |
| 513 send_video_ = true; | 517 send_video_ = true; |
| 514 } | 518 } |
| 515 | 519 |
| 516 void SendAudioVideoStream2() { | 520 void SendAudioVideoStream2() { |
| (...skipping 2846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 // should not receive any changes in the ICE state. | 3367 // should not receive any changes in the ICE state. |
| 3364 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { | 3368 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { |
| 3365 LoopbackNetworkConfiguration config; | 3369 LoopbackNetworkConfiguration config; |
| 3366 LoopbackNetworkManager loopback_network_manager(this, config); | 3370 LoopbackNetworkManager loopback_network_manager(this, config); |
| 3367 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain | 3371 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain |
| 3368 // connected. Disabling either of these two means that we need to wait for the | 3372 // connected. Disabling either of these two means that we need to wait for the |
| 3369 // answer to find out if more transports are needed. | 3373 // answer to find out if more transports are needed. |
| 3370 configuration_.bundle_policy = | 3374 configuration_.bundle_policy = |
| 3371 PeerConnectionInterface::kBundlePolicyMaxBundle; | 3375 PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 3372 options_.disable_encryption = true; | 3376 options_.disable_encryption = true; |
| 3373 Init(PeerConnectionInterface::kRtcpMuxPolicyRequire); | 3377 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); |
| 3374 | 3378 |
| 3375 // Negotiate an audio channel with MAX_BUNDLE enabled. | 3379 // Negotiate an audio channel with MAX_BUNDLE enabled. |
| 3376 SendAudioOnlyStream2(); | 3380 SendAudioOnlyStream2(); |
| 3377 SessionDescriptionInterface* offer = CreateOffer(); | 3381 SessionDescriptionInterface* offer = CreateOffer(); |
| 3378 SetLocalDescriptionWithoutError(offer); | 3382 SetLocalDescriptionWithoutError(offer); |
| 3379 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, | 3383 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, |
| 3380 observer_.ice_gathering_state_, kIceCandidatesTimeout); | 3384 observer_.ice_gathering_state_, kIceCandidatesTimeout); |
| 3381 std::string sdp; | 3385 std::string sdp; |
| 3382 offer->ToString(&sdp); | 3386 offer->ToString(&sdp); |
| 3383 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( | 3387 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4346 } | 4350 } |
| 4347 | 4351 |
| 4348 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4352 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4349 // currently fails because upon disconnection and reconnection OnIceComplete is | 4353 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4350 // called more than once without returning to IceGatheringGathering. | 4354 // called more than once without returning to IceGatheringGathering. |
| 4351 | 4355 |
| 4352 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4356 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4353 WebRtcSessionTest, | 4357 WebRtcSessionTest, |
| 4354 testing::Values(ALREADY_GENERATED, | 4358 testing::Values(ALREADY_GENERATED, |
| 4355 DTLS_IDENTITY_STORE)); | 4359 DTLS_IDENTITY_STORE)); |
| OLD | NEW |