From 46c4e609396acdc8874aa18017c201c60dc19a5d Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Fri, 17 Aug 2018 14:26:54 +0200 Subject: [PATCH] Introduce SimulatedNetworkReceiverInterface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Erik Språng Reviewed-by: Sebastian Jansson Reviewed-by: Patrik Höglund Cr-Commit-Position: refs/heads/master@{#24336} --- audio/BUILD.gn | 3 ++ audio/test/audio_bwe_integration_test.cc | 4 +- audio/test/audio_bwe_integration_test.h | 3 +- audio/test/audio_end_to_end_test.cc | 4 +- audio/test/audio_end_to_end_test.h | 3 +- audio/test/audio_stats_test.cc | 4 +- audio/test/low_bandwidth_audio_test.cc | 5 ++- call/BUILD.gn | 13 ++++++ call/call_perf_tests.cc | 32 ++++++------- call/fake_network_pipe.h | 14 +++--- call/rampup_tests.h | 3 +- call/simulated_packet_receiver.h | 44 ++++++++++++++++++ test/BUILD.gn | 4 ++ test/call_test.cc | 4 +- test/direct_transport.cc | 9 ++-- test/direct_transport.h | 11 ++--- test/layer_filtering_transport.cc | 8 ++-- test/layer_filtering_transport.h | 45 ++++++++++--------- test/rtp_rtcp_observer.h | 6 ++- video/BUILD.gn | 1 + video/end_to_end_tests/bandwidth_tests.cc | 3 +- video/end_to_end_tests/fec_tests.cc | 5 ++- .../multi_codec_receive_tests.cc | 5 ++- video/end_to_end_tests/probing_tests.cc | 7 +-- video/end_to_end_tests/receive_time_tests.cc | 4 +- .../end_to_end_tests/retransmission_tests.cc | 3 +- video/end_to_end_tests/rtp_rtcp_tests.cc | 9 ++-- video/end_to_end_tests/stats_tests.cc | 5 ++- video/picture_id_tests.cc | 4 +- video/video_send_stream_tests.cc | 7 +-- 30 files changed, 182 insertions(+), 90 deletions(-) create mode 100644 call/simulated_packet_receiver.h diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 2aaacc75a0..be534a0c37 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -99,6 +99,7 @@ if (rtc_include_tests) { ] deps = [ ":audio", + "../api:simulated_network_api", "../system_wrappers:system_wrappers", "../test:test_common", "../test:test_support", @@ -175,6 +176,7 @@ if (rtc_include_tests) { deps = [ ":audio_end_to_end_test", + "../api:simulated_network_api", "../common_audio", "../rtc_base:rtc_base_approved", "../system_wrappers", @@ -246,6 +248,7 @@ if (rtc_include_tests) { "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 4d8ac804c8..6640f6d2ac 100644 --- a/audio/test/audio_bwe_integration_test.cc +++ b/audio/test/audio_bwe_integration_test.cc @@ -115,8 +115,8 @@ class NoBandwidthDropAfterDtx : public AudioBweTest { 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 a88b047993..c70ad1c91b 100644 --- a/audio/test/audio_bwe_integration_test.h +++ b/audio/test/audio_bwe_integration_test.h @@ -13,6 +13,7 @@ #include #include +#include "api/test/simulated_network.h" #include "test/call_test.h" #include "test/single_threaded_task_queue.h" @@ -26,7 +27,7 @@ class AudioBweTest : public test::EndToEndTest { 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 820b46444e..8ba9a047f3 100644 --- a/audio/test/audio_end_to_end_test.cc +++ b/audio/test/audio_end_to_end_test.cc @@ -26,8 +26,8 @@ constexpr int kSampleRate = 48000; 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 cbe25f5b3a..9dda834d22 100644 --- a/audio/test/audio_end_to_end_test.h +++ b/audio/test/audio_end_to_end_test.h @@ -14,6 +14,7 @@ #include #include +#include "api/test/simulated_network.h" #include "test/call_test.h" namespace webrtc { @@ -28,7 +29,7 @@ class AudioEndToEndTest : public test::EndToEndTest { 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 ee225c0b50..019679e078 100644 --- a/audio/test/audio_stats_test.cc +++ b/audio/test/audio_stats_test.cc @@ -32,8 +32,8 @@ class NoLossTest : public AudioEndToEndTest { 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 169f4bf592..16a3b91e87 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 @@ class Mobile2GNetworkTest : public AudioQualityTest { {{"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 796509746b..3ec2a2c1ae 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -261,6 +261,17 @@ rtc_source_set("simulated_network") { ] } +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 @@ rtc_source_set("fake_network") { deps = [ ":call_interfaces", ":simulated_network", + ":simulated_packet_receiver", "..:webrtc_common", "../api:simulated_network_api", "../api:transport_api", @@ -360,6 +372,7 @@ if (rtc_include_tests) { ":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 54e01b1232..00cfada83a 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 @@ class CallPerfTest : public test::CallTest { 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 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, 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 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, video_send_transport = absl::make_unique( &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( &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 @@ TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoFasterThanAudioDrift) { 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 { 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 @@ void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, } 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 @@ void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, // 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, CaptureNtpTimeWithNetworkDelay) { } 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 @@ void CallPerfTest::TestMinAudioVideoBitrate( 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 @@ void CallPerfTest::TestMinAudioVideoBitrate( ? 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 a46cd75f18..546014d39d 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 NetworkPacket { // 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 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module { ~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 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module { // 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 a22dfc9934..5fd089fb27 100644 --- a/call/rampup_tests.h +++ b/call/rampup_tests.h @@ -15,6 +15,7 @@ #include #include +#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 @@ class RampUpTester : public test::EndToEndTest { 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 0000000000..6630427b1a --- /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 9b4ba418f7..8431cf27c1 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -459,8 +459,10 @@ rtc_source_set("direct_transport") { } 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 @@ rtc_source_set("test_common") { ":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 @@ rtc_source_set("test_common") { "../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 4df054b5cc..18a5b9a5fa 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -730,14 +730,14 @@ test::PacketTransport* BaseTest::CreateSendTransport( 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 93221a6055..351210ee5c 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 @@ DirectTransport::DirectTransport( Call* send_call, const std::map& 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& payload_type_map) : send_call_(send_call), @@ -59,7 +60,7 @@ DirectTransport::DirectTransport( DirectTransport::DirectTransport( SingleThreadedTaskQueueForTesting* task_queue, - std::unique_ptr pipe, + std::unique_ptr pipe, Call* send_call, const std::map& payload_type_map) : send_call_(send_call), @@ -81,7 +82,7 @@ void DirectTransport::SetClockOffset(int64_t offset_ms) { 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 2d473073e9..c5c2d94322 100644 --- a/test/direct_transport.h +++ b/test/direct_transport.h @@ -15,8 +15,9 @@ #include #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 @@ class DirectTransport : public Transport { const std::map& payload_type_map); DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, - const FakeNetworkPipe::Config& config, + const DefaultNetworkSimulationConfig& config, Call* send_call, const std::map& payload_type_map); DirectTransport(SingleThreadedTaskQueueForTesting* task_queue, - std::unique_ptr pipe, + std::unique_ptr pipe, Call* send_call, const std::map& payload_type_map); @@ -59,7 +60,7 @@ class DirectTransport : public Transport { 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 @@ class DirectTransport : public Transport { RTC_GUARDED_BY(&sequence_checker_); const Demuxer demuxer_; - const std::unique_ptr fake_network_; + const std::unique_ptr fake_network_; rtc::SequencedTaskChecker sequence_checker_; }; diff --git a/test/layer_filtering_transport.cc b/test/layer_filtering_transport.cc index 1f36619bdd..d2861db591 100644 --- a/test/layer_filtering_transport.cc +++ b/test/layer_filtering_transport.cc @@ -22,7 +22,7 @@ namespace test { 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( LayerFilteringTransport::LayerFilteringTransport( SingleThreadedTaskQueueForTesting* task_queue, - std::unique_ptr pipe, + std::unique_ptr pipe, Call* send_call, uint8_t vp8_video_payload_type, uint8_t vp9_video_payload_type, @@ -62,7 +62,7 @@ LayerFilteringTransport::LayerFilteringTransport( 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( LayerFilteringTransport::LayerFilteringTransport( SingleThreadedTaskQueueForTesting* task_queue, - std::unique_ptr pipe, + std::unique_ptr 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 bd5f2e8ab9..7d2fe4f2c7 100644 --- a/test/layer_filtering_transport.h +++ b/test/layer_filtering_transport.h @@ -12,8 +12,9 @@ #include +#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 @@ namespace test { 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 @@ class LayerFilteringTransport : public test::DirectTransport { uint32_t ssrc_to_filter_min, uint32_t ssrc_to_filter_max); LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue, - const FakeNetworkPipe::Config& 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& payload_type_map); - LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue, - std::unique_ptr 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& payload_type_map, - uint32_t ssrc_to_filter_min, - uint32_t ssrc_to_filter_max); - LayerFilteringTransport(SingleThreadedTaskQueueForTesting* task_queue, - std::unique_ptr pipe, + 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& payload_type_map); + LayerFilteringTransport( + SingleThreadedTaskQueueForTesting* task_queue, + std::unique_ptr 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& payload_type_map, + uint32_t ssrc_to_filter_min, + uint32_t ssrc_to_filter_max); + LayerFilteringTransport( + SingleThreadedTaskQueueForTesting* task_queue, + std::unique_ptr 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& 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 d946b5f675..aa6fc490f0 100644 --- a/test/rtp_rtcp_observer.h +++ b/test/rtp_rtcp_observer.h @@ -14,6 +14,8 @@ #include #include +#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 @@ class PacketTransport : public test::DirectTransport { RtpRtcpObserver* observer, TransportType transport_type, const std::map& payload_type_map, - const FakeNetworkPipe::Config& configuration) + const DefaultNetworkSimulationConfig& configuration) : test::DirectTransport(task_queue, configuration, send_call, @@ -109,7 +111,7 @@ class PacketTransport : public test::DirectTransport { RtpRtcpObserver* observer, TransportType transport_type, const std::map& payload_type_map, - std::unique_ptr nw_pipe) + std::unique_ptr nw_pipe) : test::DirectTransport(task_queue, std::move(nw_pipe), send_call, diff --git a/video/BUILD.gn b/video/BUILD.gn index 5f9455c500..5901fb98b0 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -424,6 +424,7 @@ if (rtc_include_tests) { ":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 3b1df3c590..e33feca478 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_P(BandwidthEndToEndTest, RembWithSendSideBwe) { 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 4493bde019..043f0cbec2 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 @@ class FlexfecRenderObserver : public test::EndToEndTest, 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 @@ TEST_P(FecEndToEndTest, ReceivedUlpfecPacketsNotNacked) { // 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 d4ab3ee194..3999c83eb0 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 @@ class MultiCodecReceiveTest : public test::CallTest { 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 4d0009f41c..0520c6f53a 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 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { 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 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { // 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 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { 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 9e025cb553..c676d666b6 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 @@ class ReportedReceiveTimeTester : public test::EndToEndTest { 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 7145b02211..8f30f14b00 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_P(RetransmissionEndToEndTest, ReceivesNackAndRetransmitsAudio) { 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 c8eb802ce9..c9740650f6 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 @@ void RtpRtcpEndToEndTest::TestRtpStatePreservation( send_transport = absl::make_unique( &task_queue_, sender_call_.get(), &observer, test::PacketTransport::kSender, payload_type_map_, - FakeNetworkPipe::Config()); + DefaultNetworkSimulationConfig()); receive_transport = absl::make_unique( &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 @@ TEST_F(RtpRtcpEndToEndTest, TestFlexfecRtpStatePreservation) { 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_F(RtpRtcpEndToEndTest, TestFlexfecRtpStatePreservation) { 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( &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 ae259111d8..c1b45b0bc7 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_F(StatsEndToEndTest, GetStats) { 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 @@ TEST_F(StatsEndToEndTest, CallReportsRttForSender) { std::unique_ptr 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( diff --git a/video/picture_id_tests.cc b/video/picture_id_tests.cc index 3c43d7d112..60f11ca4e6 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 @@ void PictureIdTest::SetupEncoder(VideoEncoderFactory* encoder_factory, 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 4bf5b99035..7a2ded0e15 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -11,6 +11,7 @@ #include #include +#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 @@ class UlpfecObserver : public test::EndToEndTest { // 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 @@ class FlexfecObserver : public test::EndToEndTest { // 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_F(VideoSendStreamTest, PaddingIsPrimarilyRetransmissions) { 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;