Removes Start/Stop on network emulation manager.

Bug: None
Change-Id: I4a1d780d909e9abdd6d09e4da3bec52ca274d36b
Reviewed-on: https://webrtc-review.googlesource.com/c/121950
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26631}
This commit is contained in:
Sebastian Jansson 2019-02-11 09:13:01 +01:00 committed by Commit Bot
parent eb7589e11f
commit b00eb19a0a
5 changed files with 17 additions and 35 deletions

View file

@ -66,7 +66,7 @@ TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) {
/*output_dump_file_name=*/absl::nullopt, cricket::AudioOptions()};
// Setup emulated network
NetworkEmulationManager network_emulation_manager(Clock::GetRealTimeClock());
NetworkEmulationManager network_emulation_manager;
EmulatedNetworkNode* alice_node =
network_emulation_manager.CreateEmulatedNode(
@ -105,16 +105,12 @@ TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) {
auto* video_analyzer = static_cast<ExampleVideoQualityAnalyzer*>(
analyzers->video_quality_analyzer.get());
network_emulation_manager.Start();
auto fixture = CreatePeerConnectionE2EQualityTestFixture(
std::move(alice_components), std::move(alice_params),
std::move(bob_components), absl::make_unique<Params>(),
std::move(analyzers));
fixture->Run(RunParams{TimeDelta::seconds(5)});
network_emulation_manager.Stop();
RTC_LOG(INFO) << "Captured: " << video_analyzer->frames_captured();
RTC_LOG(INFO) << "Sent : " << video_analyzer->frames_sent();
RTC_LOG(INFO) << "Received: " << video_analyzer->frames_received();

View file

@ -25,14 +25,21 @@ constexpr int64_t kPacketProcessingIntervalMs = 1;
} // namespace
NetworkEmulationManager::NetworkEmulationManager(webrtc::Clock* clock)
: clock_(clock),
NetworkEmulationManager::NetworkEmulationManager()
: clock_(Clock::GetRealTimeClock()),
next_node_id_(1),
task_queue_("network_emulation_manager") {}
NetworkEmulationManager::~NetworkEmulationManager() {
Stop();
task_queue_("network_emulation_manager") {
process_task_handle_ = RepeatingTaskHandle::Start(&task_queue_, [this] {
ProcessNetworkPackets();
return TimeDelta::ms(kPacketProcessingIntervalMs);
});
}
// TODO(srte): Ensure that any pending task that must be run for consistency
// (such as stats collection tasks) are not cancelled when the task queue is
// destroyed.
NetworkEmulationManager::~NetworkEmulationManager() = default;
EmulatedNetworkNode* NetworkEmulationManager::CreateEmulatedNode(
std::unique_ptr<NetworkBehaviorInterface> network_behavior) {
auto node =
@ -101,17 +108,6 @@ rtc::Thread* NetworkEmulationManager::CreateNetworkThread(
return out;
}
void NetworkEmulationManager::Start() {
process_task_handle_ = RepeatingTaskHandle::Start(&task_queue_, [this] {
ProcessNetworkPackets();
return TimeDelta::ms(kPacketProcessingIntervalMs);
});
}
void NetworkEmulationManager::Stop() {
process_task_handle_.PostStop();
}
FakeNetworkSocketServer* NetworkEmulationManager::CreateSocketServer(
std::vector<EndpointNode*> endpoints) {
auto socket_server =

View file

@ -22,6 +22,7 @@
#include "rtc_base/task_queue.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/thread.h"
#include "system_wrappers/include/clock.h"
#include "test/scenario/network/fake_network_socket_server.h"
#include "test/scenario/network/network_emulation.h"
@ -30,7 +31,7 @@ namespace test {
class NetworkEmulationManager {
public:
explicit NetworkEmulationManager(Clock* clock);
NetworkEmulationManager();
~NetworkEmulationManager();
EmulatedNetworkNode* CreateEmulatedNode(
@ -49,9 +50,6 @@ class NetworkEmulationManager {
rtc::Thread* CreateNetworkThread(std::vector<EndpointNode*> endpoints);
void Start();
void Stop();
private:
FakeNetworkSocketServer* CreateSocketServer(
std::vector<EndpointNode*> endpoints);

View file

@ -102,7 +102,7 @@ TEST(NetworkEmulationManagerPCTest, Run) {
signaling_thread->Start();
// Setup emulated network
NetworkEmulationManager network_manager(Clock::GetRealTimeClock());
NetworkEmulationManager network_manager;
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
@ -156,8 +156,6 @@ TEST(NetworkEmulationManagerPCTest, Run) {
absl::make_unique<PeerConnectionWrapper>(bob_pcf, bob_pc,
std::move(bob_observer));
network_manager.Start();
signaling_thread->Invoke<void>(RTC_FROM_HERE, [&]() {
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
alice_pcf->CreateAudioSource(cricket::AudioOptions());
@ -191,8 +189,6 @@ TEST(NetworkEmulationManagerPCTest, Run) {
alice.reset();
bob.reset();
});
network_manager.Stop();
}
} // namespace test

View file

@ -58,7 +58,7 @@ class SocketReader : public sigslot::has_slots<> {
};
TEST(NetworkEmulationManagerTest, Run) {
NetworkEmulationManager network_manager(Clock::GetRealTimeClock());
NetworkEmulationManager network_manager;
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
@ -74,8 +74,6 @@ TEST(NetworkEmulationManagerTest, Run) {
auto* nt1 = network_manager.CreateNetworkThread({alice_endpoint});
auto* nt2 = network_manager.CreateNetworkThread({bob_endpoint});
network_manager.Start();
for (uint64_t j = 0; j < 2; j++) {
auto* s1 = nt1->socketserver()->CreateAsyncSocket(AF_INET, SOCK_DGRAM);
auto* s2 = nt2->socketserver()->CreateAsyncSocket(AF_INET, SOCK_DGRAM);
@ -106,8 +104,6 @@ TEST(NetworkEmulationManagerTest, Run) {
delete s1;
delete s2;
}
network_manager.Stop();
}
} // namespace test