| Index: webrtc/api/peerconnection_unittest.cc
|
| diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc
|
| index 521486f98b8e8cd79d76148f661eefdfeca46143..39904eb05c995fe392f8778fce51def3e578ae92 100644
|
| --- a/webrtc/api/peerconnection_unittest.cc
|
| +++ b/webrtc/api/peerconnection_unittest.cc
|
| @@ -154,12 +154,14 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
|
| const std::string& id,
|
| const MediaConstraintsInterface* constraints,
|
| const PeerConnectionFactory::Options* options,
|
| + const PeerConnectionInterface::RTCConfiguration& config,
|
| std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
|
| bool prefer_constraint_apis,
|
| rtc::Thread* worker_thread) {
|
| PeerConnectionTestClient* client(new PeerConnectionTestClient(id));
|
| - if (!client->Init(constraints, options, std::move(dtls_identity_store),
|
| - prefer_constraint_apis, worker_thread)) {
|
| + if (!client->Init(constraints, options, config,
|
| + std::move(dtls_identity_store), prefer_constraint_apis,
|
| + worker_thread)) {
|
| delete client;
|
| return nullptr;
|
| }
|
| @@ -170,12 +172,13 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
|
| const std::string& id,
|
| const MediaConstraintsInterface* constraints,
|
| const PeerConnectionFactory::Options* options,
|
| + const PeerConnectionInterface::RTCConfiguration& config,
|
| rtc::Thread* worker_thread) {
|
| std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
|
| rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
|
| : nullptr);
|
|
|
| - return CreateClientWithDtlsIdentityStore(id, constraints, options,
|
| + return CreateClientWithDtlsIdentityStore(id, constraints, options, config,
|
| std::move(dtls_identity_store),
|
| true, worker_thread);
|
| }
|
| @@ -183,12 +186,13 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
|
| static PeerConnectionTestClient* CreateClientPreferNoConstraints(
|
| const std::string& id,
|
| const PeerConnectionFactory::Options* options,
|
| + const PeerConnectionInterface::RTCConfiguration& config,
|
| rtc::Thread* worker_thread) {
|
| std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
|
| rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
|
| : nullptr);
|
|
|
| - return CreateClientWithDtlsIdentityStore(id, nullptr, options,
|
| + return CreateClientWithDtlsIdentityStore(id, nullptr, options, config,
|
| std::move(dtls_identity_store),
|
| false, worker_thread);
|
| }
|
| @@ -431,8 +435,10 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
|
| data_observer_.reset(new MockDataChannelObserver(data_channel));
|
| }
|
|
|
| - void CreateDataChannel() {
|
| - data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr);
|
| + void CreateDataChannel() { CreateDataChannel(nullptr); }
|
| +
|
| + void CreateDataChannel(const webrtc::DataChannelInit* init) {
|
| + data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, init);
|
| ASSERT_TRUE(data_channel_.get() != nullptr);
|
| data_observer_.reset(new MockDataChannelObserver(data_channel_));
|
| }
|
| @@ -804,6 +810,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
|
| bool Init(
|
| const MediaConstraintsInterface* constraints,
|
| const PeerConnectionFactory::Options* options,
|
| + const PeerConnectionInterface::RTCConfiguration& config,
|
| std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
|
| bool prefer_constraint_apis,
|
| rtc::Thread* worker_thread) {
|
| @@ -832,21 +839,17 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
|
| if (options) {
|
| peer_connection_factory_->SetOptions(*options);
|
| }
|
| - peer_connection_ = CreatePeerConnection(
|
| - std::move(port_allocator), constraints, std::move(dtls_identity_store));
|
| + peer_connection_ =
|
| + CreatePeerConnection(std::move(port_allocator), constraints, config,
|
| + std::move(dtls_identity_store));
|
| return peer_connection_.get() != nullptr;
|
| }
|
|
|
| rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
|
| std::unique_ptr<cricket::PortAllocator> port_allocator,
|
| const MediaConstraintsInterface* constraints,
|
| + const PeerConnectionInterface::RTCConfiguration& config,
|
| std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
|
| - // CreatePeerConnection with RTCConfiguration.
|
| - webrtc::PeerConnectionInterface::RTCConfiguration config;
|
| - webrtc::PeerConnectionInterface::IceServer ice_server;
|
| - ice_server.uri = "stun:stun.l.google.com:19302";
|
| - config.servers.push_back(ice_server);
|
| -
|
| return peer_connection_factory_->CreatePeerConnection(
|
| config, constraints, std::move(port_allocator),
|
| std::move(dtls_identity_store), this);
|
| @@ -1026,6 +1029,9 @@ class P2PTestConductor : public testing::Test {
|
| ss_(new rtc::VirtualSocketServer(pss_.get())),
|
| ss_scope_(ss_.get()) {
|
| RTC_CHECK(worker_thread_.Start());
|
| + webrtc::PeerConnectionInterface::IceServer ice_server;
|
| + ice_server.uri = "stun:stun.l.google.com:19302";
|
| + config_.servers.push_back(ice_server);
|
| }
|
|
|
| bool SessionActive() {
|
| @@ -1135,10 +1141,10 @@ class P2PTestConductor : public testing::Test {
|
| bool CreateTestClientsThatPreferNoConstraints() {
|
| initiating_client_.reset(
|
| PeerConnectionTestClient::CreateClientPreferNoConstraints(
|
| - "Caller: ", nullptr, &worker_thread_));
|
| + "Caller: ", nullptr, config_, &worker_thread_));
|
| receiving_client_.reset(
|
| PeerConnectionTestClient::CreateClientPreferNoConstraints(
|
| - "Callee: ", nullptr, &worker_thread_));
|
| + "Callee: ", nullptr, config_, &worker_thread_));
|
| if (!initiating_client_ || !receiving_client_) {
|
| return false;
|
| }
|
| @@ -1158,9 +1164,9 @@ class P2PTestConductor : public testing::Test {
|
| MediaConstraintsInterface* recv_constraints,
|
| PeerConnectionFactory::Options* recv_options) {
|
| initiating_client_.reset(PeerConnectionTestClient::CreateClient(
|
| - "Caller: ", init_constraints, init_options, &worker_thread_));
|
| + "Caller: ", init_constraints, init_options, config_, &worker_thread_));
|
| receiving_client_.reset(PeerConnectionTestClient::CreateClient(
|
| - "Callee: ", recv_constraints, recv_options, &worker_thread_));
|
| + "Callee: ", recv_constraints, recv_options, config_, &worker_thread_));
|
| if (!initiating_client_ || !receiving_client_) {
|
| return false;
|
| }
|
| @@ -1260,7 +1266,7 @@ class P2PTestConductor : public testing::Test {
|
|
|
| // Make sure the new client is using a different certificate.
|
| return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore(
|
| - "New Peer: ", &setup_constraints, nullptr,
|
| + "New Peer: ", &setup_constraints, nullptr, config_,
|
| std::move(dtls_identity_store), prefer_constraint_apis_,
|
| &worker_thread_);
|
| }
|
| @@ -1300,6 +1306,9 @@ class P2PTestConductor : public testing::Test {
|
| receiving_client_.reset(client);
|
| return old;
|
| }
|
| + webrtc::PeerConnectionInterface::RTCConfiguration* config() {
|
| + return &config_;
|
| + }
|
|
|
| private:
|
| // |worker_thread_| is used by both |initiating_client_| and
|
| @@ -1311,6 +1320,7 @@ class P2PTestConductor : public testing::Test {
|
| std::unique_ptr<PeerConnectionTestClient> initiating_client_;
|
| std::unique_ptr<PeerConnectionTestClient> receiving_client_;
|
| bool prefer_constraint_apis_ = true;
|
| + webrtc::PeerConnectionInterface::RTCConfiguration config_;
|
| };
|
|
|
| // Disable for TSan v2, see
|
| @@ -1981,6 +1991,78 @@ TEST_F(P2PTestConductor, EarlyWarmupTest) {
|
| kMaxWaitForFramesMs);
|
| }
|
|
|
| +#ifdef HAVE_QUIC
|
| + // This test sets up a call between two parties using QUIC instead of DTLS
|
| + // for
|
| + // audio and video, and a QUIC data channel.
|
| + TEST_F(P2PTestConductor, LocalP2PTestQuicDataChannel) {
|
| + config()->enable_quic = true;
|
| + ASSERT_TRUE(CreateTestClients());
|
| + webrtc::DataChannelInit init;
|
| + init.ordered = false;
|
| + init.reliable = true;
|
| + init.id = 1;
|
| + initializing_client()->CreateDataChannel(&init);
|
| + receiving_client()->CreateDataChannel(&init);
|
| + LocalP2PTest();
|
| + ASSERT_NE(nullptr, initializing_client()->data_channel());
|
| + ASSERT_NE(nullptr, receiving_client()->data_channel());
|
| + EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(),
|
| + kMaxWaitMs);
|
| + EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), kMaxWaitMs);
|
| +
|
| + std::string data = "hello world";
|
| +
|
| + initializing_client()->data_channel()->Send(DataBuffer(data));
|
| + EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(),
|
| + kMaxWaitMs);
|
| +
|
| + receiving_client()->data_channel()->Send(DataBuffer(data));
|
| + EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(),
|
| + kMaxWaitMs);
|
| +}
|
| +
|
| +// Tests that negotiation of QUIC data channels is completed without error.
|
| +TEST_F(P2PTestConductor, CreateOfferWithQuicDataChannel) {
|
| + config()->enable_quic = true;
|
| + FakeConstraints constraints;
|
| + constraints.SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true);
|
| + ASSERT_TRUE(CreateTestClients(&constraints, &constraints));
|
| + webrtc::DataChannelInit init;
|
| + init.ordered = false;
|
| + init.reliable = true;
|
| + init.id = 1;
|
| + initializing_client()->CreateDataChannel(&init);
|
| + initializing_client()->Negotiate(false, false);
|
| +}
|
| +
|
| +// This test sets up a Jsep call using QUIC. The callee only receives video.
|
| +TEST_F(P2PTestConductor, LocalP2PTestAnswerVideoQuic) {
|
| + config()->enable_quic = true;
|
| + ASSERT_TRUE(CreateTestClients());
|
| + receiving_client()->SetReceiveAudioVideo(false, true);
|
| + LocalP2PTest();
|
| +}
|
| +
|
| +// This test sets up a Jsep call using QUIC. The callee only receives audio.
|
| +TEST_F(P2PTestConductor, LocalP2PTestAnswerAudioQuic) {
|
| + config()->enable_quic = true;
|
| + ASSERT_TRUE(CreateTestClients());
|
| + receiving_client()->SetReceiveAudioVideo(true, false);
|
| + LocalP2PTest();
|
| +}
|
| +
|
| +// This test sets up a Jsep call between two parties using QUIC. The callee
|
| +// rejects both audio and video.
|
| +TEST_F(P2PTestConductor, LocalP2PTestAnswerNoneQuic) {
|
| + config()->enable_quic = true;
|
| + ASSERT_TRUE(CreateTestClients());
|
| + receiving_client()->SetReceiveAudioVideo(false, false);
|
| + LocalP2PTest();
|
| +}
|
| +
|
| +#endif // HAVE_QUIC
|
| +
|
| TEST_F(P2PTestConductor, ForwardVideoOnlyStream) {
|
| ASSERT_TRUE(CreateTestClients());
|
| // One-way stream
|
|
|