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

Unified Diff: webrtc/api/peerconnection_unittest.cc

Issue 1968393002: Propogate network-worker thread split to api (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase including nits Created 4 years, 7 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
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/peerconnection_unittest.cc
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc
index 1c3d0731da8854a5604f5ce9fbe913910aa4eb69..24411ab729060c09c9658aab987b49e0b9db85f5 100644
--- a/webrtc/api/peerconnection_unittest.cc
+++ b/webrtc/api/peerconnection_unittest.cc
@@ -156,10 +156,11 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const PeerConnectionFactory::Options* options,
std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
bool prefer_constraint_apis,
+ rtc::Thread* network_thread,
rtc::Thread* worker_thread) {
PeerConnectionTestClient* client(new PeerConnectionTestClient(id));
if (!client->Init(constraints, options, std::move(dtls_identity_store),
- prefer_constraint_apis, worker_thread)) {
+ prefer_constraint_apis, network_thread, worker_thread)) {
delete client;
return nullptr;
}
@@ -170,27 +171,29 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const std::string& id,
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
+ rtc::Thread* network_thread,
rtc::Thread* worker_thread) {
std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
- return CreateClientWithDtlsIdentityStore(id, constraints, options,
- std::move(dtls_identity_store),
- true, worker_thread);
+ return CreateClientWithDtlsIdentityStore(
+ id, constraints, options, std::move(dtls_identity_store), true,
+ network_thread, worker_thread);
}
static PeerConnectionTestClient* CreateClientPreferNoConstraints(
const std::string& id,
const PeerConnectionFactory::Options* options,
+ rtc::Thread* network_thread,
rtc::Thread* worker_thread) {
std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
- return CreateClientWithDtlsIdentityStore(id, nullptr, options,
- std::move(dtls_identity_store),
- false, worker_thread);
+ return CreateClientWithDtlsIdentityStore(
+ id, nullptr, options, std::move(dtls_identity_store), false,
+ network_thread, worker_thread);
}
~PeerConnectionTestClient() {
@@ -806,6 +809,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const PeerConnectionFactory::Options* options,
std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
bool prefer_constraint_apis,
+ rtc::Thread* network_thread,
rtc::Thread* worker_thread) {
EXPECT_TRUE(!peer_connection_);
EXPECT_TRUE(!peer_connection_factory_);
@@ -815,7 +819,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
prefer_constraint_apis_ = prefer_constraint_apis;
std::unique_ptr<cricket::PortAllocator> port_allocator(
- new cricket::FakePortAllocator(worker_thread, nullptr));
+ new cricket::FakePortAllocator(network_thread, nullptr));
fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
if (fake_audio_capture_module_ == nullptr) {
@@ -823,9 +827,11 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
}
fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory();
fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory();
+ rtc::Thread* const signaling_thread = rtc::Thread::Current();
peer_connection_factory_ = webrtc::CreatePeerConnectionFactory(
- worker_thread, rtc::Thread::Current(), fake_audio_capture_module_,
- fake_video_encoder_factory_, fake_video_decoder_factory_);
+ network_thread, worker_thread, signaling_thread,
+ fake_audio_capture_module_, fake_video_encoder_factory_,
+ fake_video_decoder_factory_);
if (!peer_connection_factory_) {
return false;
}
@@ -1022,10 +1028,13 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
class P2PTestConductor : public testing::Test {
public:
P2PTestConductor()
- : pss_(new rtc::PhysicalSocketServer),
+ : network_thread_(rtc::Thread::CreateWithSocketServer()),
+ worker_thread_(rtc::Thread::Create()),
+ pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
ss_scope_(ss_.get()) {
- RTC_CHECK(worker_thread_.Start());
+ RTC_CHECK(network_thread_->Start());
+ RTC_CHECK(worker_thread_->Start());
}
bool SessionActive() {
@@ -1135,10 +1144,10 @@ class P2PTestConductor : public testing::Test {
bool CreateTestClientsThatPreferNoConstraints() {
initiating_client_.reset(
PeerConnectionTestClient::CreateClientPreferNoConstraints(
- "Caller: ", nullptr, &worker_thread_));
+ "Caller: ", nullptr, network_thread_.get(), worker_thread_.get()));
receiving_client_.reset(
PeerConnectionTestClient::CreateClientPreferNoConstraints(
- "Callee: ", nullptr, &worker_thread_));
+ "Callee: ", nullptr, network_thread_.get(), worker_thread_.get()));
if (!initiating_client_ || !receiving_client_) {
return false;
}
@@ -1158,9 +1167,11 @@ 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, network_thread_.get(),
+ worker_thread_.get()));
receiving_client_.reset(PeerConnectionTestClient::CreateClient(
- "Callee: ", recv_constraints, recv_options, &worker_thread_));
+ "Callee: ", recv_constraints, recv_options, network_thread_.get(),
+ worker_thread_.get()));
if (!initiating_client_ || !receiving_client_) {
return false;
}
@@ -1262,7 +1273,7 @@ class P2PTestConductor : public testing::Test {
return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore(
"New Peer: ", &setup_constraints, nullptr,
std::move(dtls_identity_store), prefer_constraint_apis_,
- &worker_thread_);
+ network_thread_.get(), worker_thread_.get());
}
void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) {
@@ -1304,7 +1315,8 @@ class P2PTestConductor : public testing::Test {
private:
// |worker_thread_| is used by both |initiating_client_| and
// |receiving_client_|. Must be destroyed last.
- rtc::Thread worker_thread_;
+ std::unique_ptr<rtc::Thread> network_thread_;
+ std::unique_ptr<rtc::Thread> worker_thread_;
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::SocketServerScope ss_scope_;
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698