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 10 matching lines...) Expand all Loading... |
21 #include "webrtc/api/rtpreceiverinterface.h" | 21 #include "webrtc/api/rtpreceiverinterface.h" |
22 #include "webrtc/api/rtpsenderinterface.h" | 22 #include "webrtc/api/rtpsenderinterface.h" |
23 #include "webrtc/api/test/fakeconstraints.h" | 23 #include "webrtc/api/test/fakeconstraints.h" |
24 #include "webrtc/base/gunit.h" | 24 #include "webrtc/base/gunit.h" |
25 #include "webrtc/base/ssladapter.h" | 25 #include "webrtc/base/ssladapter.h" |
26 #include "webrtc/base/sslstreamadapter.h" | 26 #include "webrtc/base/sslstreamadapter.h" |
27 #include "webrtc/base/stringutils.h" | 27 #include "webrtc/base/stringutils.h" |
28 #include "webrtc/base/thread.h" | 28 #include "webrtc/base/thread.h" |
29 #include "webrtc/base/virtualsocketserver.h" | 29 #include "webrtc/base/virtualsocketserver.h" |
30 #include "webrtc/media/base/fakevideocapturer.h" | 30 #include "webrtc/media/base/fakevideocapturer.h" |
| 31 #include "webrtc/media/engine/webrtcmediaengine.h" |
31 #include "webrtc/media/sctp/sctptransportinternal.h" | 32 #include "webrtc/media/sctp/sctptransportinternal.h" |
32 #include "webrtc/p2p/base/fakeportallocator.h" | 33 #include "webrtc/p2p/base/fakeportallocator.h" |
33 #include "webrtc/pc/audiotrack.h" | 34 #include "webrtc/pc/audiotrack.h" |
34 #include "webrtc/pc/mediasession.h" | 35 #include "webrtc/pc/mediasession.h" |
35 #include "webrtc/pc/mediastream.h" | 36 #include "webrtc/pc/mediastream.h" |
36 #include "webrtc/pc/peerconnection.h" | 37 #include "webrtc/pc/peerconnection.h" |
37 #include "webrtc/pc/streamcollection.h" | 38 #include "webrtc/pc/streamcollection.h" |
38 #include "webrtc/pc/test/fakertccertificategenerator.h" | 39 #include "webrtc/pc/test/fakertccertificategenerator.h" |
39 #include "webrtc/pc/test/fakevideotracksource.h" | 40 #include "webrtc/pc/test/fakevideotracksource.h" |
40 #include "webrtc/pc/test/mockpeerconnectionobservers.h" | 41 #include "webrtc/pc/test/mockpeerconnectionobservers.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 }; | 635 }; |
635 | 636 |
636 } // namespace | 637 } // namespace |
637 | 638 |
638 // The PeerConnectionMediaConfig tests below verify that configuration and | 639 // The PeerConnectionMediaConfig tests below verify that configuration and |
639 // constraints are propagated into the PeerConnection's MediaConfig. These | 640 // constraints are propagated into the PeerConnection's MediaConfig. These |
640 // settings are intended for MediaChannel constructors, but that is not | 641 // settings are intended for MediaChannel constructors, but that is not |
641 // exercised by these unittest. | 642 // exercised by these unittest. |
642 class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { | 643 class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { |
643 public: | 644 public: |
644 PeerConnectionFactoryForTest() | 645 static rtc::scoped_refptr<PeerConnectionFactoryForTest> |
645 : webrtc::PeerConnectionFactory( | 646 CreatePeerConnectionFactoryForTest() { |
646 webrtc::CreateBuiltinAudioEncoderFactory(), | 647 auto audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); |
647 webrtc::CreateBuiltinAudioDecoderFactory()) {} | 648 auto audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); |
| 649 |
| 650 auto media_engine = std::unique_ptr<cricket::MediaEngineInterface>( |
| 651 cricket::WebRtcMediaEngineFactory::Create( |
| 652 nullptr, audio_encoder_factory, audio_decoder_factory, nullptr, |
| 653 nullptr, nullptr)); |
| 654 |
| 655 std::unique_ptr<webrtc::CallFactoryInterface> call_factory = |
| 656 webrtc::CreateCallFactory(); |
| 657 |
| 658 std::unique_ptr<webrtc::RtcEventLogFactoryInterface> event_log_factory = |
| 659 webrtc::CreateRtcEventLogFactory(); |
| 660 |
| 661 return new rtc::RefCountedObject<PeerConnectionFactoryForTest>( |
| 662 rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), |
| 663 nullptr, audio_encoder_factory, audio_decoder_factory, nullptr, nullptr, |
| 664 nullptr, std::move(media_engine), std::move(call_factory), |
| 665 std::move(event_log_factory)); |
| 666 } |
| 667 |
| 668 PeerConnectionFactoryForTest( |
| 669 rtc::Thread* network_thread, |
| 670 rtc::Thread* worker_thread, |
| 671 rtc::Thread* signaling_thread, |
| 672 webrtc::AudioDeviceModule* default_adm, |
| 673 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, |
| 674 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, |
| 675 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 676 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
| 677 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, |
| 678 std::unique_ptr<cricket::MediaEngineInterface> media_engine, |
| 679 std::unique_ptr<webrtc::CallFactoryInterface> call_factory, |
| 680 std::unique_ptr<webrtc::RtcEventLogFactoryInterface> event_log_factory) |
| 681 : webrtc::PeerConnectionFactory(network_thread, |
| 682 worker_thread, |
| 683 signaling_thread, |
| 684 default_adm, |
| 685 audio_encoder_factory, |
| 686 audio_decoder_factory, |
| 687 video_encoder_factory, |
| 688 video_decoder_factory, |
| 689 audio_mixer, |
| 690 std::move(media_engine), |
| 691 std::move(call_factory), |
| 692 std::move(event_log_factory)) {} |
648 | 693 |
649 cricket::TransportController* CreateTransportController( | 694 cricket::TransportController* CreateTransportController( |
650 cricket::PortAllocator* port_allocator, | 695 cricket::PortAllocator* port_allocator, |
651 bool redetermine_role_on_ice_restart) override { | 696 bool redetermine_role_on_ice_restart) override { |
652 transport_controller = new cricket::TransportController( | 697 transport_controller = new cricket::TransportController( |
653 rtc::Thread::Current(), rtc::Thread::Current(), port_allocator, | 698 rtc::Thread::Current(), rtc::Thread::Current(), port_allocator, |
654 redetermine_role_on_ice_restart, rtc::CryptoOptions()); | 699 redetermine_role_on_ice_restart, rtc::CryptoOptions()); |
655 return transport_controller; | 700 return transport_controller; |
656 } | 701 } |
657 | 702 |
658 cricket::TransportController* transport_controller; | 703 cricket::TransportController* transport_controller; |
659 }; | 704 }; |
660 | 705 |
661 class PeerConnectionInterfaceTest : public testing::Test { | 706 class PeerConnectionInterfaceTest : public testing::Test { |
662 protected: | 707 protected: |
663 PeerConnectionInterfaceTest() | 708 PeerConnectionInterfaceTest() |
664 : vss_(new rtc::VirtualSocketServer()), main_(vss_.get()) { | 709 : vss_(new rtc::VirtualSocketServer()), main_(vss_.get()) { |
665 #ifdef WEBRTC_ANDROID | 710 #ifdef WEBRTC_ANDROID |
666 webrtc::InitializeAndroidObjects(); | 711 webrtc::InitializeAndroidObjects(); |
667 #endif | 712 #endif |
668 } | 713 } |
669 | 714 |
670 virtual void SetUp() { | 715 virtual void SetUp() { |
671 pc_factory_ = webrtc::CreatePeerConnectionFactory( | 716 pc_factory_ = webrtc::CreatePeerConnectionFactory( |
672 rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), | 717 rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), |
673 nullptr, nullptr, nullptr); | 718 nullptr, nullptr, nullptr); |
674 ASSERT_TRUE(pc_factory_); | 719 ASSERT_TRUE(pc_factory_); |
675 pc_factory_for_test_ = | 720 pc_factory_for_test_ = |
676 new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); | 721 PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); |
677 pc_factory_for_test_->Initialize(); | 722 pc_factory_for_test_->Initialize(); |
678 } | 723 } |
679 | 724 |
680 void CreatePeerConnection() { | 725 void CreatePeerConnection() { |
681 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr); | 726 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr); |
682 } | 727 } |
683 | 728 |
684 // DTLS does not work in a loopback call, so is disabled for most of the | 729 // DTLS does not work in a loopback call, so is disabled for most of the |
685 // tests in this file. | 730 // tests in this file. |
686 void CreatePeerConnectionWithoutDtls() { | 731 void CreatePeerConnectionWithoutDtls() { |
(...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3360 TEST_F(PeerConnectionInterfaceTest, SetBitrateCurrentLessThanImplicitMin) { | 3405 TEST_F(PeerConnectionInterfaceTest, SetBitrateCurrentLessThanImplicitMin) { |
3361 CreatePeerConnection(); | 3406 CreatePeerConnection(); |
3362 PeerConnectionInterface::BitrateParameters bitrate; | 3407 PeerConnectionInterface::BitrateParameters bitrate; |
3363 bitrate.current_bitrate_bps = rtc::Optional<int>(1); | 3408 bitrate.current_bitrate_bps = rtc::Optional<int>(1); |
3364 EXPECT_TRUE(pc_->SetBitrate(bitrate).ok()); | 3409 EXPECT_TRUE(pc_->SetBitrate(bitrate).ok()); |
3365 } | 3410 } |
3366 | 3411 |
3367 class PeerConnectionMediaConfigTest : public testing::Test { | 3412 class PeerConnectionMediaConfigTest : public testing::Test { |
3368 protected: | 3413 protected: |
3369 void SetUp() override { | 3414 void SetUp() override { |
3370 pcf_ = new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); | 3415 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); |
3371 pcf_->Initialize(); | 3416 pcf_->Initialize(); |
3372 } | 3417 } |
3373 const cricket::MediaConfig TestCreatePeerConnection( | 3418 const cricket::MediaConfig TestCreatePeerConnection( |
3374 const PeerConnectionInterface::RTCConfiguration& config, | 3419 const PeerConnectionInterface::RTCConfiguration& config, |
3375 const MediaConstraintsInterface *constraints) { | 3420 const MediaConstraintsInterface *constraints) { |
3376 | 3421 |
3377 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( | 3422 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( |
3378 config, constraints, nullptr, nullptr, &observer_)); | 3423 config, constraints, nullptr, nullptr, &observer_)); |
3379 EXPECT_TRUE(pc.get()); | 3424 EXPECT_TRUE(pc.get()); |
3380 return pc->GetConfiguration().media_config; | 3425 return pc->GetConfiguration().media_config; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3649 EXPECT_NE(a, f); | 3694 EXPECT_NE(a, f); |
3650 | 3695 |
3651 PeerConnectionInterface::RTCConfiguration g; | 3696 PeerConnectionInterface::RTCConfiguration g; |
3652 g.disable_ipv6 = true; | 3697 g.disable_ipv6 = true; |
3653 EXPECT_NE(a, g); | 3698 EXPECT_NE(a, g); |
3654 | 3699 |
3655 PeerConnectionInterface::RTCConfiguration h( | 3700 PeerConnectionInterface::RTCConfiguration h( |
3656 PeerConnectionInterface::RTCConfigurationType::kAggressive); | 3701 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
3657 EXPECT_NE(a, h); | 3702 EXPECT_NE(a, h); |
3658 } | 3703 } |
OLD | NEW |