Introduce SimulatedNetworkReceiverInterface.
Introduce SimulatedNetworkReceiverInterface and switch DirectTransport
on this interface. Also switch part of related users on
DefaultNetworkSimulationConfig.
This two changes united into single CL to prevent work duplication.
Most changes were done because of stop including fake_network_pipe.h
into direct_transport.h, so splitting this into 2 CLs will require
first fix all imports of fake_network_pipe.h and then replace them
on new API imports again.
Bug: webrtc:9630
Change-Id: I87d4a6ff1bab72d04a9871a40441f4fbe028f4e6
Reviewed-on: https://webrtc-review.googlesource.com/94762
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24336}
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index 2aaacc7..be534a0 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -99,6 +99,7 @@
]
deps = [
":audio",
+ "../api:simulated_network_api",
"../system_wrappers:system_wrappers",
"../test:test_common",
"../test:test_support",
@@ -175,6 +176,7 @@
deps = [
":audio_end_to_end_test",
+ "../api:simulated_network_api",
"../common_audio",
"../rtc_base:rtc_base_approved",
"../system_wrappers",
@@ -246,6 +248,7 @@
"test/audio_bwe_integration_test.h",
]
deps = [
+ "../api:simulated_network_api",
"../common_audio",
"../rtc_base:rtc_base_approved",
"../system_wrappers",
diff --git a/audio/test/audio_bwe_integration_test.cc b/audio/test/audio_bwe_integration_test.cc
index 4d8ac80..6640f6d 100644
--- a/audio/test/audio_bwe_integration_test.cc
+++ b/audio/test/audio_bwe_integration_test.cc
@@ -115,8 +115,8 @@
return test::ResourcePath("voice_engine/audio_dtx16", "wav");
}
- FakeNetworkPipe::Config GetNetworkPipeConfig() override {
- FakeNetworkPipe::Config pipe_config;
+ DefaultNetworkSimulationConfig GetNetworkPipeConfig() override {
+ DefaultNetworkSimulationConfig pipe_config;
pipe_config.link_capacity_kbps = 50;
pipe_config.queue_length_packets = 1500;
pipe_config.queue_delay_ms = 300;
diff --git a/audio/test/audio_bwe_integration_test.h b/audio/test/audio_bwe_integration_test.h
index a88b047..c70ad1c 100644
--- a/audio/test/audio_bwe_integration_test.h
+++ b/audio/test/audio_bwe_integration_test.h
@@ -13,6 +13,7 @@
#include <memory>
#include <string>
+#include "api/test/simulated_network.h"
#include "test/call_test.h"
#include "test/single_threaded_task_queue.h"
@@ -26,7 +27,7 @@
protected:
virtual std::string AudioInputFile() = 0;
- virtual FakeNetworkPipe::Config GetNetworkPipeConfig() = 0;
+ virtual DefaultNetworkSimulationConfig GetNetworkPipeConfig() = 0;
size_t GetNumVideoStreams() const override;
size_t GetNumAudioStreams() const override;
diff --git a/audio/test/audio_end_to_end_test.cc b/audio/test/audio_end_to_end_test.cc
index 820b464..8ba9a04 100644
--- a/audio/test/audio_end_to_end_test.cc
+++ b/audio/test/audio_end_to_end_test.cc
@@ -26,8 +26,8 @@
AudioEndToEndTest::AudioEndToEndTest()
: EndToEndTest(CallTest::kDefaultTimeoutMs) {}
-FakeNetworkPipe::Config AudioEndToEndTest::GetNetworkPipeConfig() const {
- return FakeNetworkPipe::Config();
+DefaultNetworkSimulationConfig AudioEndToEndTest::GetNetworkPipeConfig() const {
+ return DefaultNetworkSimulationConfig();
}
size_t AudioEndToEndTest::GetNumVideoStreams() const {
diff --git a/audio/test/audio_end_to_end_test.h b/audio/test/audio_end_to_end_test.h
index cbe25f5..9dda834 100644
--- a/audio/test/audio_end_to_end_test.h
+++ b/audio/test/audio_end_to_end_test.h
@@ -14,6 +14,7 @@
#include <string>
#include <vector>
+#include "api/test/simulated_network.h"
#include "test/call_test.h"
namespace webrtc {
@@ -28,7 +29,7 @@
const AudioSendStream* send_stream() const { return send_stream_; }
const AudioReceiveStream* receive_stream() const { return receive_stream_; }
- virtual FakeNetworkPipe::Config GetNetworkPipeConfig() const;
+ virtual DefaultNetworkSimulationConfig GetNetworkPipeConfig() const;
size_t GetNumVideoStreams() const override;
size_t GetNumAudioStreams() const override;
diff --git a/audio/test/audio_stats_test.cc b/audio/test/audio_stats_test.cc
index ee225c0..019679e 100644
--- a/audio/test/audio_stats_test.cc
+++ b/audio/test/audio_stats_test.cc
@@ -32,8 +32,8 @@
NoLossTest() = default;
- FakeNetworkPipe::Config GetNetworkPipeConfig() const override {
- FakeNetworkPipe::Config pipe_config;
+ DefaultNetworkSimulationConfig GetNetworkPipeConfig() const override {
+ DefaultNetworkSimulationConfig pipe_config;
pipe_config.queue_delay_ms = kRttMs / 2;
return pipe_config;
}
diff --git a/audio/test/low_bandwidth_audio_test.cc b/audio/test/low_bandwidth_audio_test.cc
index 169f4bf..16a3b91 100644
--- a/audio/test/low_bandwidth_audio_test.cc
+++ b/audio/test/low_bandwidth_audio_test.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "audio/test/audio_end_to_end_test.h"
#include "rtc_base/flags.h"
#include "system_wrappers/include/sleep.h"
@@ -88,8 +89,8 @@
{{"maxaveragebitrate", "6000"}, {"ptime", "60"}, {"stereo", "1"}}});
}
- FakeNetworkPipe::Config GetNetworkPipeConfig() const override {
- FakeNetworkPipe::Config pipe_config;
+ DefaultNetworkSimulationConfig GetNetworkPipeConfig() const override {
+ DefaultNetworkSimulationConfig pipe_config;
pipe_config.link_capacity_kbps = 12;
pipe_config.queue_length_packets = 1500;
pipe_config.queue_delay_ms = 400;
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 7965097..3ec2a2c 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -261,6 +261,17 @@
]
}
+rtc_source_set("simulated_packet_receiver") {
+ sources = [
+ "simulated_packet_receiver.h",
+ ]
+ deps = [
+ ":call_interfaces",
+ "../api:simulated_network_api",
+ "../modules:module_api",
+ ]
+}
+
rtc_source_set("fake_network") {
sources = [
"fake_network_pipe.cc",
@@ -269,6 +280,7 @@
deps = [
":call_interfaces",
":simulated_network",
+ ":simulated_packet_receiver",
"..:webrtc_common",
"../api:simulated_network_api",
"../api:transport_api",
@@ -360,6 +372,7 @@
":call_interfaces",
":video_stream_api",
"..:webrtc_common",
+ "../api:simulated_network_api",
"../api/audio_codecs:builtin_audio_encoder_factory",
"../api/video:video_bitrate_allocation",
"../api/video_codecs:video_codecs_api",
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc
index 54e01b1..00cfada 100644
--- a/call/call_perf_tests.cc
+++ b/call/call_perf_tests.cc
@@ -15,6 +15,7 @@
#include "absl/memory/memory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
+#include "api/test/simulated_network.h"
#include "api/video/video_bitrate_allocation.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/call.h"
@@ -60,7 +61,7 @@
void TestMinTransmitBitrate(bool pad_to_min_bitrate);
- void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config,
+ void TestCaptureNtpTime(const DefaultNetworkSimulationConfig& net_config,
int threshold_ms,
int start_time_ms,
int run_time_ms);
@@ -148,7 +149,7 @@
const uint32_t kAudioSendSsrc = 1234;
const uint32_t kAudioRecvSsrc = 5678;
- FakeNetworkPipe::Config audio_net_config;
+ DefaultNetworkSimulationConfig audio_net_config;
audio_net_config.queue_delay_ms = 500;
audio_net_config.loss_percent = 5;
@@ -207,13 +208,13 @@
video_send_transport = absl::make_unique<test::PacketTransport>(
&task_queue_, sender_call_.get(), &observer,
test::PacketTransport::kSender, video_pt_map,
- FakeNetworkPipe::Config());
+ DefaultNetworkSimulationConfig());
video_send_transport->SetReceiver(receiver_call_->Receiver());
receive_transport = absl::make_unique<test::PacketTransport>(
&task_queue_, receiver_call_.get(), &observer,
test::PacketTransport::kReceiver, payload_type_map_,
- FakeNetworkPipe::Config());
+ DefaultNetworkSimulationConfig());
receive_transport->SetReceiver(sender_call_->Receiver());
CreateSendConfig(1, 0, 0, video_send_transport.get());
@@ -323,14 +324,15 @@
DriftingClock::PercentsSlower(30.0f), "_video_faster");
}
-void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config,
- int threshold_ms,
- int start_time_ms,
- int run_time_ms) {
+void CallPerfTest::TestCaptureNtpTime(
+ const DefaultNetworkSimulationConfig& net_config,
+ int threshold_ms,
+ int start_time_ms,
+ int run_time_ms) {
class CaptureNtpTimeObserver : public test::EndToEndTest,
public rtc::VideoSinkInterface<VideoFrame> {
public:
- CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config,
+ CaptureNtpTimeObserver(const DefaultNetworkSimulationConfig& net_config,
int threshold_ms,
int start_time_ms,
int run_time_ms)
@@ -441,7 +443,7 @@
}
rtc::CriticalSection crit_;
- const FakeNetworkPipe::Config net_config_;
+ const DefaultNetworkSimulationConfig net_config_;
Clock* const clock_;
int threshold_ms_;
int start_time_ms_;
@@ -461,7 +463,7 @@
// Flaky tests, disabled on Mac due to webrtc:8291.
#if !(defined(WEBRTC_MAC))
TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkDelay) {
- FakeNetworkPipe::Config net_config;
+ DefaultNetworkSimulationConfig net_config;
net_config.queue_delay_ms = 100;
// TODO(wu): lower the threshold as the calculation/estimatation becomes more
// accurate.
@@ -472,7 +474,7 @@
}
TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkJitter) {
- FakeNetworkPipe::Config net_config;
+ DefaultNetworkSimulationConfig net_config;
net_config.queue_delay_ms = 100;
net_config.delay_standard_deviation_ms = 10;
// TODO(wu): lower the threshold as the calculation/estimatation becomes more
@@ -828,8 +830,8 @@
max_bwe_(max_bwe) {}
protected:
- FakeNetworkPipe::Config GetFakeNetworkPipeConfig() {
- FakeNetworkPipe::Config pipe_config;
+ DefaultNetworkSimulationConfig GetFakeNetworkPipeConfig() {
+ DefaultNetworkSimulationConfig pipe_config;
pipe_config.link_capacity_kbps = test_bitrate_from_;
return pipe_config;
}
@@ -856,7 +858,7 @@
? test_bitrate <= test_bitrate_to_
: test_bitrate >= test_bitrate_to_;
test_bitrate += test_bitrate_step_) {
- FakeNetworkPipe::Config pipe_config;
+ DefaultNetworkSimulationConfig pipe_config;
pipe_config.link_capacity_kbps = test_bitrate;
send_transport_->SetConfig(pipe_config);
receive_transport_->SetConfig(pipe_config);
diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h
index a46cd75..546014d 100644
--- a/call/fake_network_pipe.h
+++ b/call/fake_network_pipe.h
@@ -22,8 +22,8 @@
#include "api/call/transport.h"
#include "api/test/simulated_network.h"
#include "call/call.h"
+#include "call/simulated_packet_receiver.h"
#include "common_types.h" // NOLINT(build/include)
-#include "modules/include/module.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/thread_annotations.h"
@@ -87,7 +87,8 @@
// Class faking a network link, internally is uses an implementation of a
// SimulatedNetworkInterface to simulate network behavior.
-class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
+class FakeNetworkPipe : public webrtc::SimulatedPacketReceiverInterface,
+ public Transport {
public:
using Config = NetworkSimulationInterface::SimulatedNetworkConfig;
@@ -135,15 +136,16 @@
~FakeNetworkPipe() override;
- void SetClockOffset(int64_t offset_ms);
+ // Deprecated. DO NOT USE. Will be removed soon.
+ void SetClockOffset(int64_t offset_ms) override;
// Deprecated. DO NOT USE. Hold direct reference on NetworkSimulationInterface
// instead and call SetConfig on that object directly. Will be removed soon.
// Sets a new configuration. This won't affect packets already in the pipe.
- void SetConfig(const FakeNetworkPipe::Config& config);
+ void SetConfig(const DefaultNetworkSimulationConfig& config) override;
// Must not be called in parallel with DeliverPacket or Process.
- void SetReceiver(PacketReceiver* receiver);
+ void SetReceiver(PacketReceiver* receiver) override;
// Implements Transport interface. When/if packets are delivered, they will
// be passed to the transport instance given in SetReceiverTransport(). These
@@ -174,7 +176,7 @@
// Get statistics.
float PercentageLoss();
- int AverageDelay();
+ int AverageDelay() override;
size_t DroppedPackets();
size_t SentPackets();
void ResetStats();
diff --git a/call/rampup_tests.h b/call/rampup_tests.h
index a22dfc9..5fd089f 100644
--- a/call/rampup_tests.h
+++ b/call/rampup_tests.h
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include "api/test/simulated_network.h"
#include "call/call.h"
#include "logging/rtc_event_log/rtc_event_log.h"
#include "rtc_base/event.h"
@@ -64,7 +65,7 @@
rtc::Event stop_event_;
Clock* const clock_;
- FakeNetworkPipe::Config forward_transport_config_;
+ DefaultNetworkSimulationConfig forward_transport_config_;
const size_t num_video_streams_;
const size_t num_audio_streams_;
const size_t num_flexfec_streams_;
diff --git a/call/simulated_packet_receiver.h b/call/simulated_packet_receiver.h
new file mode 100644
index 0000000..6630427
--- /dev/null
+++ b/call/simulated_packet_receiver.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef CALL_SIMULATED_PACKET_RECEIVER_H_
+#define CALL_SIMULATED_PACKET_RECEIVER_H_
+
+#include "api/test/simulated_network.h"
+#include "call/packet_receiver.h"
+#include "modules/include/module.h"
+
+namespace webrtc {
+
+// Private API that is fixing surface between DirectTransport and underlying
+// network conditions simulation implementation.
+class SimulatedPacketReceiverInterface : public PacketReceiver, public Module {
+ public:
+ // Must not be called in parallel with DeliverPacket or Process.
+ // Destination receiver will be injected with this method
+ virtual void SetReceiver(PacketReceiver* receiver) = 0;
+
+ // Reports average packet delay.
+ virtual int AverageDelay() = 0;
+
+ // Deprecated. DO NOT USE. Temporary added to be able to introduce
+ // SimulatedPacketReceiverInterface into DirectTransport instead of
+ // FakeNetworkPipe, will be removed soon.
+ virtual void SetClockOffset(int64_t offset_ms) = 0;
+
+ // Deprecated. DO NOT USE. Temporary added to be able to introduce
+ // SimulatedPacketReceiverInterface into DirectTransport instead of
+ // FakeNetworkPipe, will be removed soon.
+ virtual void SetConfig(const DefaultNetworkSimulationConfig& config) = 0;
+};
+
+} // namespace webrtc
+
+#endif // CALL_SIMULATED_PACKET_RECEIVER_H_
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 9b4ba41..8431cf2 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -459,8 +459,10 @@
}
deps = [
"..:webrtc_common",
+ "../api:simulated_network_api",
"../api:transport_api",
"../call:call_interfaces",
+ "../call:simulated_packet_receiver",
"../modules/rtp_rtcp",
"../rtc_base:rtc_base_approved",
"../rtc_base:sequenced_task_checker",
@@ -538,6 +540,7 @@
":video_test_common",
"..:webrtc_common",
"../api:libjingle_peerconnection_api",
+ "../api:simulated_network_api",
"../api:transport_api",
"../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory",
@@ -548,6 +551,7 @@
"../call",
"../call:call_interfaces",
"../call:rtp_sender",
+ "../call:simulated_packet_receiver",
"../call:video_stream_api",
"../common_video",
"../logging:rtc_event_log_api",
diff --git a/test/call_test.cc b/test/call_test.cc
index 4df054b..18a5b9a 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -730,14 +730,14 @@
Call* sender_call) {
return new PacketTransport(
task_queue, sender_call, this, test::PacketTransport::kSender,
- CallTest::payload_type_map_, FakeNetworkPipe::Config());
+ CallTest::payload_type_map_, DefaultNetworkSimulationConfig());
}
test::PacketTransport* BaseTest::CreateReceiveTransport(
SingleThreadedTaskQueueForTesting* task_queue) {
return new PacketTransport(
task_queue, nullptr, this, test::PacketTransport::kReceiver,
- CallTest::payload_type_map_, FakeNetworkPipe::Config());
+ CallTest::payload_type_map_, DefaultNetworkSimulationConfig());
}
size_t BaseTest::GetNumVideoStreams() const {
diff --git a/test/direct_transport.cc b/test/direct_transport.cc
index 93221a6..351210e 100644
--- a/test/direct_transport.cc
+++ b/test/direct_transport.cc
@@ -11,6 +11,7 @@
#include "absl/memory/memory.h"
#include "call/call.h"
+#include "call/fake_network_pipe.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "system_wrappers/include/clock.h"
#include "test/single_threaded_task_queue.h"
@@ -40,13 +41,13 @@
Call* send_call,
const std::map<uint8_t, MediaType>& payload_type_map)
: DirectTransport(task_queue,
- FakeNetworkPipe::Config(),
+ DefaultNetworkSimulationConfig(),
send_call,
payload_type_map) {}
DirectTransport::DirectTransport(
SingleThreadedTaskQueueForTesting* task_queue,
- const FakeNetworkPipe::Config& config,
+ const DefaultNetworkSimulationConfig& config,
Call* send_call,
const std::map<uint8_t, MediaType>& payload_type_map)
: send_call_(send_call),
@@ -59,7 +60,7 @@
DirectTransport::DirectTransport(
SingleThreadedTaskQueueForTesting* task_queue,
- std::unique_ptr<FakeNetworkPipe> pipe,
+ std::unique_ptr<SimulatedPacketReceiverInterface> pipe,
Call* send_call,
const std::map<uint8_t, MediaType>& payload_type_map)
: send_call_(send_call),
@@ -81,7 +82,7 @@
fake_network_->SetClockOffset(offset_ms);
}
-void DirectTransport::SetConfig(const FakeNetworkPipe::Config& config) {
+void DirectTransport::SetConfig(const DefaultNetworkSimulationConfig& config) {
fake_network_->SetConfig(config);
}
diff --git a/test/direct_transport.h b/test/direct_transport.h
index 2d47307..c5c2d94 100644
--- a/test/direct_transport.h
+++ b/test/direct_transport.h
@@ -15,8 +15,9 @@
#include <memory>
#include "api/call/transport.h"
+#include "api/test/simulated_network.h"
#include "call/call.h"
-#include "call/fake_network_pipe.h"
+#include "call/simulated_packet_receiver.h"
#include "rtc_base/sequenced_task_checker.h"
#include "rtc_base/thread_annotations.h"
#include "test/single_threaded_task_queue.h"
@@ -46,12 +47,12 @@
const std::map<uint8_t, MediaType>& payload_type_map);
DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
- const FakeNetworkPipe::Config& config,
+ const DefaultNetworkSimulationConfig& config,
Call* send_call,
const std::map<uint8_t, MediaType>& payload_type_map);
DirectTransport(SingleThreadedTaskQueueForTesting* task_queue,
- std::unique_ptr<FakeNetworkPipe> pipe,
+ std::unique_ptr<SimulatedPacketReceiverInterface> pipe,
Call* send_call,
const std::map<uint8_t, MediaType>& payload_type_map);
@@ -59,7 +60,7 @@
void SetClockOffset(int64_t offset_ms);
- void SetConfig(const FakeNetworkPipe::Config& config);
+ void SetConfig(const DefaultNetworkSimulationConfig& config);
RTC_DEPRECATED void StopSending();
@@ -86,7 +87,7 @@
RTC_GUARDED_BY(&sequence_checker_);
const Demuxer demuxer_;
- const std::unique_ptr<FakeNetworkPipe> fake_network_;
+ const std::unique_ptr<SimulatedPacketReceiverInterface> fake_network_;
rtc::SequencedTaskChecker sequence_checker_;
};
diff --git a/test/layer_filtering_transport.cc b/test/layer_filtering_transport.cc
index 1f36619..d2861db5 100644
--- a/test/layer_filtering_transport.cc
+++ b/test/layer_filtering_transport.cc
@@ -22,7 +22,7 @@
LayerFilteringTransport::LayerFilteringTransport(
SingleThreadedTaskQueueForTesting* task_queue,
- const FakeNetworkPipe::Config& config,
+ const DefaultNetworkSimulationConfig& config,
Call* send_call,
uint8_t vp8_video_payload_type,
uint8_t vp9_video_payload_type,
@@ -42,7 +42,7 @@
LayerFilteringTransport::LayerFilteringTransport(
SingleThreadedTaskQueueForTesting* task_queue,
- std::unique_ptr<FakeNetworkPipe> pipe,
+ std::unique_ptr<SimulatedPacketReceiverInterface> pipe,
Call* send_call,
uint8_t vp8_video_payload_type,
uint8_t vp9_video_payload_type,
@@ -62,7 +62,7 @@
LayerFilteringTransport::LayerFilteringTransport(
SingleThreadedTaskQueueForTesting* task_queue,
- const FakeNetworkPipe::Config& config,
+ const DefaultNetworkSimulationConfig& config,
Call* send_call,
uint8_t vp8_video_payload_type,
uint8_t vp9_video_payload_type,
@@ -80,7 +80,7 @@
LayerFilteringTransport::LayerFilteringTransport(
SingleThreadedTaskQueueForTesting* task_queue,
- std::unique_ptr<FakeNetworkPipe> pipe,
+ std::unique_ptr<SimulatedPacketReceiverInterface> pipe,
Call* send_call,
uint8_t vp8_video_payload_type,
uint8_t vp9_video_payload_type,
diff --git a/test/layer_filtering_transport.h b/test/layer_filtering_transport.h
index bd5f2e8..7d2fe4f 100644
--- a/test/layer_filtering_transport.h
+++ b/test/layer_filtering_transport.h
@@ -12,8 +12,9 @@
#include <map>
+#include "api/test/simulated_network.h"
#include "call/call.h"
-#include "call/fake_network_pipe.h"
+#include "call/simulated_packet_receiver.h"
#include "test/direct_transport.h"
#include "test/single_threaded_task_queue.h"
@@ -24,7 +25,7 @@
class LayerFilteringTransport : public test::DirectTransport {
public:
LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue,
- const FakeNetworkPipe::Config& config,
+ const DefaultNetworkSimulationConfig& config,
Call* send_call,
uint8_t vp8_video_payload_type,
uint8_t vp9_video_payload_type,
@@ -34,31 +35,33 @@
uint32_t ssrc_to_filter_min,
uint32_t ssrc_to_filter_max);
LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue,
- const FakeNetworkPipe::Config& config,
+ const DefaultNetworkSimulationConfig& config,
Call* send_call,
uint8_t vp8_video_payload_type,
uint8_t vp9_video_payload_type,
int selected_tl,
int selected_sl,
const std::map<uint8_t, MediaType>& payload_type_map);
- LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue,
- std::unique_ptr<FakeNetworkPipe> pipe,
- Call* send_call,
- uint8_t vp8_video_payload_type,
- uint8_t vp9_video_payload_type,
- int selected_tl,
- int selected_sl,
- const std::map<uint8_t, MediaType>& payload_type_map,
- uint32_t ssrc_to_filter_min,
- uint32_t ssrc_to_filter_max);
- LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue,
- std::unique_ptr<FakeNetworkPipe> pipe,
- Call* send_call,
- uint8_t vp8_video_payload_type,
- uint8_t vp9_video_payload_type,
- int selected_tl,
- int selected_sl,
- const std::map<uint8_t, MediaType>& payload_type_map);
+ LayerFilteringTransport(
+ SingleThreadedTaskQueueForTesting* task_queue,
+ std::unique_ptr<SimulatedPacketReceiverInterface> pipe,
+ Call* send_call,
+ uint8_t vp8_video_payload_type,
+ uint8_t vp9_video_payload_type,
+ int selected_tl,
+ int selected_sl,
+ const std::map<uint8_t, MediaType>& payload_type_map,
+ uint32_t ssrc_to_filter_min,
+ uint32_t ssrc_to_filter_max);
+ LayerFilteringTransport(
+ SingleThreadedTaskQueueForTesting* task_queue,
+ std::unique_ptr<SimulatedPacketReceiverInterface> pipe,
+ Call* send_call,
+ uint8_t vp8_video_payload_type,
+ uint8_t vp9_video_payload_type,
+ int selected_tl,
+ int selected_sl,
+ const std::map<uint8_t, MediaType>& payload_type_map);
bool DiscardedLastPacket() const;
bool SendRtp(const uint8_t* data,
size_t length,
diff --git a/test/rtp_rtcp_observer.h b/test/rtp_rtcp_observer.h
index d946b5f..aa6fc49 100644
--- a/test/rtp_rtcp_observer.h
+++ b/test/rtp_rtcp_observer.h
@@ -14,6 +14,8 @@
#include <memory>
#include <vector>
+#include "api/test/simulated_network.h"
+#include "call/simulated_packet_receiver.h"
#include "call/video_send_stream.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/criticalsection.h"
@@ -96,7 +98,7 @@
RtpRtcpObserver* observer,
TransportType transport_type,
const std::map<uint8_t, MediaType>& payload_type_map,
- const FakeNetworkPipe::Config& configuration)
+ const DefaultNetworkSimulationConfig& configuration)
: test::DirectTransport(task_queue,
configuration,
send_call,
@@ -109,7 +111,7 @@
RtpRtcpObserver* observer,
TransportType transport_type,
const std::map<uint8_t, MediaType>& payload_type_map,
- std::unique_ptr<FakeNetworkPipe> nw_pipe)
+ std::unique_ptr<SimulatedPacketReceiverInterface> nw_pipe)
: test::DirectTransport(task_queue,
std::move(nw_pipe),
send_call,
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 5f9455c..5901fb9 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -424,6 +424,7 @@
":video",
":video_mocks",
":video_stream_encoder_impl",
+ "../api:simulated_network_api",
"../api/video:video_frame",
"../api/video:video_frame_i420",
"../api/video_codecs:video_codecs_api",
diff --git a/video/end_to_end_tests/bandwidth_tests.cc b/video/end_to_end_tests/bandwidth_tests.cc
index 3b1df3c..e33feca 100644
--- a/video/end_to_end_tests/bandwidth_tests.cc
+++ b/video/end_to_end_tests/bandwidth_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
#include "rtc_base/rate_limiter.h"
#include "system_wrappers/include/sleep.h"
@@ -164,7 +165,7 @@
test::SingleThreadedTaskQueueForTesting* task_queue) override {
receive_transport_ = new test::PacketTransport(
task_queue, nullptr, this, test::PacketTransport::kReceiver,
- payload_type_map_, FakeNetworkPipe::Config());
+ payload_type_map_, DefaultNetworkSimulationConfig());
return receive_transport_;
}
diff --git a/video/end_to_end_tests/fec_tests.cc b/video/end_to_end_tests/fec_tests.cc
index 4493bde..043f0cb 100644
--- a/video/end_to_end_tests/fec_tests.cc
+++ b/video/end_to_end_tests/fec_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "test/call_test.h"
@@ -239,7 +240,7 @@
Call* sender_call) override {
// At low RTT (< kLowRttNackMs) -> NACK only, no FEC.
const int kNetworkDelayMs = 100;
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.queue_delay_ms = kNetworkDelayMs;
return new test::PacketTransport(task_queue, sender_call, this,
test::PacketTransport::kSender,
@@ -424,7 +425,7 @@
// At low RTT (< kLowRttNackMs) -> NACK only, no FEC.
// Configure some network delay.
const int kNetworkDelayMs = 50;
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.queue_delay_ms = kNetworkDelayMs;
return new test::PacketTransport(task_queue, sender_call, this,
test::PacketTransport::kSender,
diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc
index d4ab3ee..3999c83 100644
--- a/video/end_to_end_tests/multi_codec_receive_tests.cc
+++ b/video/end_to_end_tests/multi_codec_receive_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "modules/video_coding/codecs/h264/include/h264.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "modules/video_coding/codecs/vp9/include/vp9.h"
@@ -149,13 +150,13 @@
send_transport_.reset(new test::PacketTransport(
&task_queue_, sender_call_.get(), &observer_,
test::PacketTransport::kSender, kPayloadTypeMap,
- FakeNetworkPipe::Config()));
+ DefaultNetworkSimulationConfig()));
send_transport_->SetReceiver(receiver_call_->Receiver());
receive_transport_.reset(new test::PacketTransport(
&task_queue_, receiver_call_.get(), &observer_,
test::PacketTransport::kReceiver, kPayloadTypeMap,
- FakeNetworkPipe::Config()));
+ DefaultNetworkSimulationConfig()));
receive_transport_->SetReceiver(sender_call_->Receiver());
});
}
diff --git a/video/end_to_end_tests/probing_tests.cc b/video/end_to_end_tests/probing_tests.cc
index 4d0009f..0520c6f 100644
--- a/video/end_to_end_tests/probing_tests.cc
+++ b/video/end_to_end_tests/probing_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "test/call_test.h"
#include "test/field_trial.h"
#include "test/gtest.h"
@@ -220,7 +221,7 @@
Call* sender_call) override {
send_transport_ = new test::PacketTransport(
task_queue, sender_call, this, test::PacketTransport::kSender,
- CallTest::payload_type_map_, FakeNetworkPipe::Config());
+ CallTest::payload_type_map_, DefaultNetworkSimulationConfig());
return send_transport_;
}
@@ -239,7 +240,7 @@
// bitrate).
if (stats.send_bandwidth_bps >= 250000 &&
stats.send_bandwidth_bps <= 350000) {
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.link_capacity_kbps = 200;
send_transport_->SetConfig(config);
@@ -254,7 +255,7 @@
break;
case 1:
if (stats.send_bandwidth_bps <= 210000) {
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.link_capacity_kbps = 5000;
send_transport_->SetConfig(config);
diff --git a/video/end_to_end_tests/receive_time_tests.cc b/video/end_to_end_tests/receive_time_tests.cc
index 9e025cb..c676d66 100644
--- a/video/end_to_end_tests/receive_time_tests.cc
+++ b/video/end_to_end_tests/receive_time_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/timeutils.h"
#include "test/call_test.h"
@@ -93,7 +94,8 @@
Call* sender_call) override {
return send_transport_ = new test::PacketTransport(
task_queue, sender_call, this, test::PacketTransport::kSender,
- test::CallTest::payload_type_map_, FakeNetworkPipe::Config());
+ test::CallTest::payload_type_map_,
+ DefaultNetworkSimulationConfig());
}
void PerformTest() override {
observation_complete_.Wait(test::CallTest::kDefaultTimeoutMs);
diff --git a/video/end_to_end_tests/retransmission_tests.cc b/video/end_to_end_tests/retransmission_tests.cc
index 7145b02..8f30f14 100644
--- a/video/end_to_end_tests/retransmission_tests.cc
+++ b/video/end_to_end_tests/retransmission_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "system_wrappers/include/sleep.h"
#include "test/call_test.h"
@@ -137,7 +138,7 @@
test::SingleThreadedTaskQueueForTesting* task_queue) override {
test::PacketTransport* receive_transport = new test::PacketTransport(
task_queue, nullptr, this, test::PacketTransport::kReceiver,
- payload_type_map_, FakeNetworkPipe::Config());
+ payload_type_map_, DefaultNetworkSimulationConfig());
receive_transport_ = receive_transport;
return receive_transport;
}
diff --git a/video/end_to_end_tests/rtp_rtcp_tests.cc b/video/end_to_end_tests/rtp_rtcp_tests.cc
index c8eb802..c974065 100644
--- a/video/end_to_end_tests/rtp_rtcp_tests.cc
+++ b/video/end_to_end_tests/rtp_rtcp_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "test/call_test.h"
#include "test/gtest.h"
@@ -277,10 +278,10 @@
send_transport = absl::make_unique<test::PacketTransport>(
&task_queue_, sender_call_.get(), &observer,
test::PacketTransport::kSender, payload_type_map_,
- FakeNetworkPipe::Config());
+ DefaultNetworkSimulationConfig());
receive_transport = absl::make_unique<test::PacketTransport>(
&task_queue_, nullptr, &observer, test::PacketTransport::kReceiver,
- payload_type_map_, FakeNetworkPipe::Config());
+ payload_type_map_, DefaultNetworkSimulationConfig());
send_transport->SetReceiver(receiver_call_->Receiver());
receive_transport->SetReceiver(sender_call_->Receiver());
@@ -465,7 +466,7 @@
task_queue_.SendTask([&]() {
CreateCalls();
- FakeNetworkPipe::Config lossy_delayed_link;
+ DefaultNetworkSimulationConfig lossy_delayed_link;
lossy_delayed_link.loss_percent = 2;
lossy_delayed_link.queue_delay_ms = 50;
@@ -474,7 +475,7 @@
test::PacketTransport::kSender, payload_type_map_, lossy_delayed_link);
send_transport->SetReceiver(receiver_call_->Receiver());
- FakeNetworkPipe::Config flawless_link;
+ DefaultNetworkSimulationConfig flawless_link;
receive_transport = absl::make_unique<test::PacketTransport>(
&task_queue_, nullptr, &observer, test::PacketTransport::kReceiver,
payload_type_map_, flawless_link);
diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc
index ae25911..c1b45b0 100644
--- a/video/end_to_end_tests/stats_tests.cc
+++ b/video/end_to_end_tests/stats_tests.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "api/test/simulated_network.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "modules/video_coding/include/video_coding_defines.h"
#include "system_wrappers/include/metrics.h"
@@ -228,7 +229,7 @@
test::PacketTransport* CreateSendTransport(
test::SingleThreadedTaskQueueForTesting* task_queue,
Call* sender_call) override {
- FakeNetworkPipe::Config network_config;
+ DefaultNetworkSimulationConfig network_config;
network_config.loss_percent = 5;
return new test::PacketTransport(task_queue, sender_call, this,
test::PacketTransport::kSender,
@@ -707,7 +708,7 @@
std::unique_ptr<test::DirectTransport> receiver_transport;
task_queue_.SendTask([this, &sender_transport, &receiver_transport]() {
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.queue_delay_ms = kSendDelayMs;
CreateCalls();
sender_transport = absl::make_unique<test::DirectTransport>(
diff --git a/video/picture_id_tests.cc b/video/picture_id_tests.cc
index 3c43d7d..60f11ca 100644
--- a/video/picture_id_tests.cc
+++ b/video/picture_id_tests.cc
@@ -7,6 +7,8 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
+
+#include "api/test/simulated_network.h"
#include "media/engine/internalencoderfactory.h"
#include "media/engine/simulcast_encoder_adapter.h"
#include "modules/rtp_rtcp/source/rtp_format.h"
@@ -290,7 +292,7 @@
send_transport_.reset(new test::PacketTransport(
&task_queue_, sender_call_.get(), observer_.get(),
test::PacketTransport::kSender, payload_type_map_,
- FakeNetworkPipe::Config()));
+ DefaultNetworkSimulationConfig()));
CreateSendConfig(kNumSimulcastStreams, 0, 0, send_transport_.get());
GetVideoSendConfig()->encoder_settings.encoder_factory = encoder_factory;
diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc
index 4bf5b99..7a2ded0 100644
--- a/video/video_send_stream_tests.cc
+++ b/video/video_send_stream_tests.cc
@@ -11,6 +11,7 @@
#include <memory>
#include <vector>
+#include "api/test/simulated_network.h"
#include "call/call.h"
#include "call/rtp_transport_controller_send.h"
#include "common_video/include/frame_callback.h"
@@ -524,7 +525,7 @@
// At low RTT (< kLowRttNackMs) -> NACK only, no FEC.
// Configure some network delay.
const int kNetworkDelayMs = 100;
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.loss_percent = 5;
config.queue_delay_ms = kNetworkDelayMs;
return new test::PacketTransport(
@@ -711,7 +712,7 @@
// At low RTT (< kLowRttNackMs) -> NACK only, no FEC.
// Therefore we need some network delay.
const int kNetworkDelayMs = 100;
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.loss_percent = 5;
config.queue_delay_ms = kNetworkDelayMs;
return new test::PacketTransport(
@@ -1455,7 +1456,7 @@
test::SingleThreadedTaskQueueForTesting* task_queue,
Call* sender_call) override {
const int kNetworkDelayMs = 50;
- FakeNetworkPipe::Config config;
+ DefaultNetworkSimulationConfig config;
config.loss_percent = 10;
config.link_capacity_kbps = kCapacityKbps;
config.queue_delay_ms = kNetworkDelayMs;