Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Unified Diff: webrtc/api/peerconnection_unittest.cc

Issue 1844803002: Modify PeerConnection for end-to-end QuicDataChannel usage (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove webrtcsdp.cc from this CL Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/peerconnection_unittest.cc
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc
index 67b4efbc73f8db9670f4f8c8e59343c91329272f..27595cd835d0e6fe79b8b7e702b21175d5797ff7 100644
--- a/webrtc/api/peerconnection_unittest.cc
+++ b/webrtc/api/peerconnection_unittest.cc
@@ -154,11 +154,12 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const std::string& id,
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
+ const PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
bool prefer_constraint_apis) {
PeerConnectionTestClient* client(new PeerConnectionTestClient(id));
- if (!client->Init(constraints, options, std::move(dtls_identity_store),
- prefer_constraint_apis)) {
+ if (!client->Init(constraints, options, config,
+ std::move(dtls_identity_store), prefer_constraint_apis)) {
delete client;
return nullptr;
}
@@ -168,24 +169,24 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
static PeerConnectionTestClient* CreateClient(
const std::string& id,
const MediaConstraintsInterface* constraints,
- const PeerConnectionFactory::Options* options) {
+ const PeerConnectionFactory::Options* options,
+ const PeerConnectionInterface::RTCConfiguration& config) {
rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
-
return CreateClientWithDtlsIdentityStore(
- id, constraints, options, std::move(dtls_identity_store), true);
+ id, constraints, options, config, std::move(dtls_identity_store), true);
}
static PeerConnectionTestClient* CreateClientPreferNoConstraints(
const std::string& id,
- const PeerConnectionFactory::Options* options) {
+ const PeerConnectionFactory::Options* options,
+ const PeerConnectionInterface::RTCConfiguration& config) {
rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
-
return CreateClientWithDtlsIdentityStore(
- id, nullptr, options, std::move(dtls_identity_store), false);
+ id, nullptr, options, config, std::move(dtls_identity_store), false);
}
~PeerConnectionTestClient() {
@@ -426,8 +427,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_));
}
@@ -799,6 +802,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
bool Init(
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
+ const PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
bool prefer_constraint_apis) {
EXPECT_TRUE(!peer_connection_);
@@ -827,21 +831,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(
rtc::scoped_ptr<cricket::PortAllocator> port_allocator,
const MediaConstraintsInterface* constraints,
+ const PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_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);
@@ -1019,7 +1019,11 @@ class P2PTestConductor : public testing::Test {
P2PTestConductor()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
- ss_scope_(ss_.get()) {}
+ ss_scope_(ss_.get()) {
+ webrtc::PeerConnectionInterface::IceServer ice_server;
+ ice_server.uri = "stun:stun.l.google.com:19302";
+ config_.servers.push_back(ice_server);
+ }
bool SessionActive() {
return initiating_client_->SessionActive() &&
@@ -1127,11 +1131,11 @@ class P2PTestConductor : public testing::Test {
bool CreateTestClientsThatPreferNoConstraints() {
initiating_client_.reset(
- PeerConnectionTestClient::CreateClientPreferNoConstraints("Caller: ",
- nullptr));
+ PeerConnectionTestClient::CreateClientPreferNoConstraints(
+ "Caller: ", nullptr, config_));
receiving_client_.reset(
- PeerConnectionTestClient::CreateClientPreferNoConstraints("Callee: ",
- nullptr));
+ PeerConnectionTestClient::CreateClientPreferNoConstraints(
+ "Callee: ", nullptr, config_));
if (!initiating_client_ || !receiving_client_) {
return false;
}
@@ -1151,9 +1155,9 @@ class P2PTestConductor : public testing::Test {
MediaConstraintsInterface* recv_constraints,
PeerConnectionFactory::Options* recv_options) {
initiating_client_.reset(PeerConnectionTestClient::CreateClient(
- "Caller: ", init_constraints, init_options));
+ "Caller: ", init_constraints, init_options, config_));
receiving_client_.reset(PeerConnectionTestClient::CreateClient(
- "Callee: ", recv_constraints, recv_options));
+ "Callee: ", recv_constraints, recv_options, config_));
if (!initiating_client_ || !receiving_client_) {
return false;
}
@@ -1253,7 +1257,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_);
}
@@ -1293,6 +1297,10 @@ class P2PTestConductor : public testing::Test {
return old;
}
+ webrtc::PeerConnectionInterface::RTCConfiguration* config() {
+ return &config_;
+ }
+
private:
rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_;
rtc::scoped_ptr<rtc::VirtualSocketServer> ss_;
@@ -1300,6 +1308,7 @@ class P2PTestConductor : public testing::Test {
rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_;
rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_;
bool prefer_constraint_apis_ = true;
+ webrtc::PeerConnectionInterface::RTCConfiguration config_;
};
// Disable for TSan v2, see
@@ -1771,6 +1780,37 @@ TEST_F(P2PTestConductor, LocalP2PTestSctpDataChannel) {
EXPECT_TRUE_WAIT(!receiving_client()->data_observer()->IsOpen(), kMaxWaitMs);
}
+#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);
+}
+#endif // HAVE_QUIC
+
// This test sets up a call between two parties and creates a data channel.
// The test tests that received data is buffered unless an observer has been
// registered.
@@ -1857,6 +1897,22 @@ TEST_F(P2PTestConductor, CreateOfferWithSctpDataChannel) {
}
#endif
+// Tests negotiation of QUIC data channels is completed without error.
+#ifdef HAVE_QUIC
+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);
+}
+#endif // HAVE_QUIC
+
// This test sets up a call between two parties with audio, and video.
// During the call, the initializing side restart ice and the test verifies that
// new ice candidates are generated and audio and video still can flow.

Powered by Google App Engine
This is Rietveld 408576698