Only process cross traffic simulation if added.

This avoids extra processing overhead when there's no cross traffic
simulation active.

Bug: webrtc:10365
Change-Id: I8c8ae2fb823a47af2406e62ae350ebb551169646
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133620
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27705}
This commit is contained in:
Sebastian Jansson
2019-04-23 09:55:38 +02:00
committed by Commit Bot
parent 081768a5a3
commit 2d87a50b46
3 changed files with 21 additions and 19 deletions

View File

@ -25,7 +25,13 @@
namespace webrtc {
namespace webrtc_pc_e2e {
TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) {
// IOS debug builds can be quite slow, disabling to avoid issues with timeouts.
#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64) && !defined(NDEBUG)
#define MAYBE_RunWithEmulatedNetwork DISABLED_RunWithEmulatedNetwork
#else
#define MAYBE_RunWithEmulatedNetwork RunWithEmulatedNetwork
#endif
TEST(PeerConnectionE2EQualityTestSmokeTest, MAYBE_RunWithEmulatedNetwork) {
using PeerConfigurer = PeerConnectionE2EQualityTestFixture::PeerConfigurer;
using RunParams = PeerConnectionE2EQualityTestFixture::RunParams;
using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig;

View File

@ -23,7 +23,6 @@ namespace webrtc {
namespace test {
namespace {
constexpr int64_t kPacketProcessingIntervalMs = 1;
// uint32_t representation of 192.168.0.0 address
constexpr uint32_t kMinIPv4Address = 0xC0A80000;
// uint32_t representation of 192.168.255.255 address
@ -64,10 +63,6 @@ NetworkEmulationManagerImpl::NetworkEmulationManagerImpl(
task_queue_(time_controller->GetTaskQueueFactory()->CreateTaskQueue(
"NetworkEmulation",
TaskQueueFactory::Priority::NORMAL)) {
process_task_handle_ = RepeatingTaskHandle::Start(task_queue_.Get(), [this] {
ProcessNetworkPackets();
return TimeDelta::ms(kPacketProcessingIntervalMs);
});
}
// TODO(srte): Ensure that any pending task that must be run for consistency
@ -195,8 +190,14 @@ NetworkEmulationManagerImpl::CreateRandomWalkCrossTraffic(
task_queue_.PostTask(CreateResourceOwningTask(
std::move(traffic),
[this](std::unique_ptr<RandomWalkCrossTraffic> traffic) {
[this, config](std::unique_ptr<RandomWalkCrossTraffic> traffic) {
auto* traffic_ptr = traffic.get();
random_cross_traffics_.push_back(std::move(traffic));
RepeatingTaskHandle::Start(task_queue_.Get(),
[this, config, traffic_ptr] {
traffic_ptr->Process(Now());
return config.min_packet_interval;
});
}));
return out;
}
@ -210,8 +211,14 @@ NetworkEmulationManagerImpl::CreatePulsedPeaksCrossTraffic(
PulsedPeaksCrossTraffic* out = traffic.get();
task_queue_.PostTask(CreateResourceOwningTask(
std::move(traffic),
[this](std::unique_ptr<PulsedPeaksCrossTraffic> traffic) {
[this, config](std::unique_ptr<PulsedPeaksCrossTraffic> traffic) {
auto* traffic_ptr = traffic.get();
pulsed_cross_traffics_.push_back(std::move(traffic));
RepeatingTaskHandle::Start(task_queue_.Get(),
[this, config, traffic_ptr] {
traffic_ptr->Process(Now());
return config.min_packet_interval;
});
}));
return out;
}
@ -256,16 +263,6 @@ NetworkEmulationManagerImpl::GetNextIPv4Address() {
return absl::nullopt;
}
void NetworkEmulationManagerImpl::ProcessNetworkPackets() {
Timestamp current_time = Now();
for (auto& traffic : random_cross_traffics_) {
traffic->Process(current_time);
}
for (auto& traffic : pulsed_cross_traffics_) {
traffic->Process(current_time);
}
}
Timestamp NetworkEmulationManagerImpl::Now() const {
return Timestamp::us(clock_->TimeInMicroseconds());
}

View File

@ -67,7 +67,6 @@ class NetworkEmulationManagerImpl : public NetworkEmulationManager {
private:
absl::optional<rtc::IPAddress> GetNextIPv4Address();
void ProcessNetworkPackets();
Timestamp Now() const;
Clock* const clock_;