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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 } | 375 } |
376 void RemoveInterface(const SocketAddress& addr) { | 376 void RemoveInterface(const SocketAddress& addr) { |
377 network_manager_.RemoveInterface(addr); | 377 network_manager_.RemoveInterface(addr); |
378 } | 378 } |
379 | 379 |
380 // If |cert_generator| != null or |rtc_configuration| contains |certificates| | 380 // If |cert_generator| != null or |rtc_configuration| contains |certificates| |
381 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| | 381 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| |
382 // options. When DTLS is enabled a certificate will be used if provided, | 382 // options. When DTLS is enabled a certificate will be used if provided, |
383 // otherwise one will be generated using the |cert_generator|. | 383 // otherwise one will be generated using the |cert_generator|. |
384 void Init( | 384 void Init( |
385 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator) { | 385 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
386 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | |
386 ASSERT_TRUE(session_.get() == NULL); | 387 ASSERT_TRUE(session_.get() == NULL); |
387 session_.reset(new WebRtcSessionForTest( | 388 session_.reset(new WebRtcSessionForTest( |
388 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), | 389 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), |
389 rtc::Thread::Current(), allocator_.get(), &observer_)); | 390 rtc::Thread::Current(), allocator_.get(), &observer_)); |
390 session_->SignalDataChannelOpenMessage.connect( | 391 session_->SignalDataChannelOpenMessage.connect( |
391 this, &WebRtcSessionTest::OnDataChannelOpenMessage); | 392 this, &WebRtcSessionTest::OnDataChannelOpenMessage); |
392 session_->GetOnDestroyedSignal()->connect( | 393 session_->GetOnDestroyedSignal()->connect( |
393 this, &WebRtcSessionTest::OnSessionDestroyed); | 394 this, &WebRtcSessionTest::OnSessionDestroyed); |
394 | 395 |
396 configuration_.rtcp_mux_policy = rtcp_mux_policy; | |
395 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 397 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
396 observer_.ice_connection_state_); | 398 observer_.ice_connection_state_); |
397 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 399 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
398 observer_.ice_gathering_state_); | 400 observer_.ice_gathering_state_); |
399 | 401 |
400 EXPECT_TRUE(session_->Initialize(options_, std::move(cert_generator), | 402 EXPECT_TRUE(session_->Initialize(options_, std::move(cert_generator), |
401 configuration_)); | 403 configuration_)); |
402 session_->set_metrics_observer(metrics_observer_); | 404 session_->set_metrics_observer(metrics_observer_); |
403 } | 405 } |
404 | 406 |
405 void OnDataChannelOpenMessage(const std::string& label, | 407 void OnDataChannelOpenMessage(const std::string& label, |
406 const InternalDataChannelInit& config) { | 408 const InternalDataChannelInit& config) { |
407 last_data_channel_label_ = label; | 409 last_data_channel_label_ = label; |
408 last_data_channel_config_ = config; | 410 last_data_channel_config_ = config; |
409 } | 411 } |
410 | 412 |
411 void OnSessionDestroyed() { session_destroyed_ = true; } | 413 void OnSessionDestroyed() { session_destroyed_ = true; } |
412 | 414 |
413 void Init() { Init(nullptr); } | 415 void Init() { |
416 Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | |
417 } | |
Zhi Huang
2016/06/22 00:23:06
In the unit test, the default value for Init() is
| |
418 | |
419 void Init(PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | |
420 Init(nullptr, rtcp_mux_policy); | |
421 } | |
414 | 422 |
415 void InitWithBundlePolicy( | 423 void InitWithBundlePolicy( |
416 PeerConnectionInterface::BundlePolicy bundle_policy) { | 424 PeerConnectionInterface::BundlePolicy bundle_policy) { |
417 configuration_.bundle_policy = bundle_policy; | 425 configuration_.bundle_policy = bundle_policy; |
418 Init(); | 426 Init(); |
419 } | 427 } |
420 | 428 |
421 void InitWithRtcpMuxPolicy( | 429 void InitWithRtcpMuxPolicy( |
422 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 430 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
423 PeerConnectionInterface::RTCConfiguration configuration; | 431 PeerConnectionInterface::RTCConfiguration configuration; |
424 configuration_.rtcp_mux_policy = rtcp_mux_policy; | 432 Init(rtcp_mux_policy); |
425 Init(); | |
426 } | 433 } |
427 | 434 |
428 // Successfully init with DTLS; with a certificate generated and supplied or | 435 // Successfully init with DTLS; with a certificate generated and supplied or |
429 // with a store that generates it for us. | 436 // with a store that generates it for us. |
430 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { | 437 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { |
431 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator; | 438 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator; |
432 if (cert_gen_method == ALREADY_GENERATED) { | 439 if (cert_gen_method == ALREADY_GENERATED) { |
433 configuration_.certificates.push_back( | 440 configuration_.certificates.push_back( |
434 FakeRTCCertificateGenerator::GenerateCertificate()); | 441 FakeRTCCertificateGenerator::GenerateCertificate()); |
435 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { | 442 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { |
436 cert_generator.reset(new FakeRTCCertificateGenerator()); | 443 cert_generator.reset(new FakeRTCCertificateGenerator()); |
437 cert_generator->set_should_fail(false); | 444 cert_generator->set_should_fail(false); |
438 } else { | 445 } else { |
439 RTC_CHECK(false); | 446 RTC_CHECK(false); |
440 } | 447 } |
441 Init(std::move(cert_generator)); | 448 Init(std::move(cert_generator), |
449 PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | |
442 } | 450 } |
443 | 451 |
444 // Init with DTLS with a store that will fail to generate a certificate. | 452 // Init with DTLS with a store that will fail to generate a certificate. |
445 void InitWithDtlsIdentityGenFail() { | 453 void InitWithDtlsIdentityGenFail() { |
446 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( | 454 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( |
447 new FakeRTCCertificateGenerator()); | 455 new FakeRTCCertificateGenerator()); |
448 cert_generator->set_should_fail(true); | 456 cert_generator->set_should_fail(true); |
449 Init(std::move(cert_generator)); | 457 Init(std::move(cert_generator), |
458 PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | |
450 } | 459 } |
451 | 460 |
452 void InitWithDtmfCodec() { | 461 void InitWithDtmfCodec() { |
453 // Add kTelephoneEventCodec for dtmf test. | 462 // Add kTelephoneEventCodec for dtmf test. |
454 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, | 463 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, |
455 0, 1); | 464 0, 1); |
456 std::vector<cricket::AudioCodec> codecs; | 465 std::vector<cricket::AudioCodec> codecs; |
457 codecs.push_back(kTelephoneEventCodec); | 466 codecs.push_back(kTelephoneEventCodec); |
458 media_engine_->SetAudioCodecs(codecs); | 467 media_engine_->SetAudioCodecs(codecs); |
459 desc_factory_->set_audio_codecs(codecs); | 468 desc_factory_->set_audio_codecs(codecs); |
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3272 // should not receive any changes in the ICE state. | 3281 // should not receive any changes in the ICE state. |
3273 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { | 3282 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { |
3274 LoopbackNetworkConfiguration config; | 3283 LoopbackNetworkConfiguration config; |
3275 LoopbackNetworkManager loopback_network_manager(this, config); | 3284 LoopbackNetworkManager loopback_network_manager(this, config); |
3276 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain | 3285 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain |
3277 // connected. Disabling either of these two means that we need to wait for the | 3286 // connected. Disabling either of these two means that we need to wait for the |
3278 // answer to find out if more transports are needed. | 3287 // answer to find out if more transports are needed. |
3279 configuration_.bundle_policy = | 3288 configuration_.bundle_policy = |
3280 PeerConnectionInterface::kBundlePolicyMaxBundle; | 3289 PeerConnectionInterface::kBundlePolicyMaxBundle; |
3281 configuration_.rtcp_mux_policy = | 3290 configuration_.rtcp_mux_policy = |
3282 PeerConnectionInterface::kRtcpMuxPolicyRequire; | 3291 PeerConnectionInterface::kRtcpMuxPolicyRequire; |
Taylor Brandstetter
2016/06/22 17:01:09
If we're passing the policy into Init, we probably
Zhi Huang
2016/06/22 21:41:28
I agree.
| |
3283 options_.disable_encryption = true; | 3292 options_.disable_encryption = true; |
3284 Init(); | 3293 Init(PeerConnectionInterface::kRtcpMuxPolicyRequire); |
3285 | 3294 |
3286 // Negotiate an audio channel with MAX_BUNDLE enabled. | 3295 // Negotiate an audio channel with MAX_BUNDLE enabled. |
3287 SendAudioOnlyStream2(); | 3296 SendAudioOnlyStream2(); |
3288 SessionDescriptionInterface* offer = CreateOffer(); | 3297 SessionDescriptionInterface* offer = CreateOffer(); |
3289 SetLocalDescriptionWithoutError(offer); | 3298 SetLocalDescriptionWithoutError(offer); |
3290 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, | 3299 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, |
3291 observer_.ice_gathering_state_, kIceCandidatesTimeout); | 3300 observer_.ice_gathering_state_, kIceCandidatesTimeout); |
3292 std::string sdp; | 3301 std::string sdp; |
3293 offer->ToString(&sdp); | 3302 offer->ToString(&sdp); |
3294 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( | 3303 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4417 } | 4426 } |
4418 | 4427 |
4419 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4428 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4420 // currently fails because upon disconnection and reconnection OnIceComplete is | 4429 // currently fails because upon disconnection and reconnection OnIceComplete is |
4421 // called more than once without returning to IceGatheringGathering. | 4430 // called more than once without returning to IceGatheringGathering. |
4422 | 4431 |
4423 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4432 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4424 WebRtcSessionTest, | 4433 WebRtcSessionTest, |
4425 testing::Values(ALREADY_GENERATED, | 4434 testing::Values(ALREADY_GENERATED, |
4426 DTLS_IDENTITY_STORE)); | 4435 DTLS_IDENTITY_STORE)); |
OLD | NEW |