Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
Artem Titov | 386802e | 2019-07-05 10:48:17 +0200 | [diff] [blame] | 10 | #ifndef TEST_NETWORK_FEEDBACK_GENERATOR_H_ |
| 11 | #define TEST_NETWORK_FEEDBACK_GENERATOR_H_ |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 12 | |
Per Kjellander | 1ca57b9 | 2022-01-19 14:14:02 +0100 | [diff] [blame] | 13 | #include <cstdint> |
| 14 | #include <queue> |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 15 | #include <utility> |
| 16 | #include <vector> |
| 17 | |
Per Kjellander | 1ca57b9 | 2022-01-19 14:14:02 +0100 | [diff] [blame] | 18 | #include "api/transport/network_types.h" |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 19 | #include "api/transport/test/feedback_generator_interface.h" |
| 20 | #include "call/simulated_network.h" |
Artem Titov | 386802e | 2019-07-05 10:48:17 +0200 | [diff] [blame] | 21 | #include "test/network/network_emulation.h" |
| 22 | #include "test/network/network_emulation_manager.h" |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 23 | #include "test/time_controller/simulated_time_controller.h" |
| 24 | |
| 25 | namespace webrtc { |
| 26 | |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 27 | class FeedbackGeneratorImpl |
| 28 | : public FeedbackGenerator, |
Per Kjellander | 1ca57b9 | 2022-01-19 14:14:02 +0100 | [diff] [blame] | 29 | public TwoWayFakeTrafficRoute<SentPacket, std::vector<PacketResult>>:: |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 30 | TrafficHandlerInterface { |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 31 | public: |
| 32 | explicit FeedbackGeneratorImpl(Config config); |
| 33 | Timestamp Now() override; |
| 34 | void Sleep(TimeDelta duration) override; |
| 35 | void SendPacket(size_t size) override; |
| 36 | std::vector<TransportPacketsFeedback> PopFeedback() override; |
| 37 | |
| 38 | void SetSendConfig(BuiltInNetworkBehaviorConfig config) override; |
| 39 | void SetReturnConfig(BuiltInNetworkBehaviorConfig config) override; |
| 40 | |
| 41 | void SetSendLinkCapacity(DataRate capacity) override; |
| 42 | |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 43 | void OnRequest(SentPacket packet, Timestamp arrival_time) override; |
Per Kjellander | 1ca57b9 | 2022-01-19 14:14:02 +0100 | [diff] [blame] | 44 | void OnResponse(std::vector<PacketResult> packet_results, |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 45 | Timestamp arrival_time) override; |
| 46 | |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 47 | private: |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 48 | Config conf_; |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 49 | ::webrtc::test::NetworkEmulationManagerImpl net_; |
| 50 | SimulatedNetwork* const send_link_; |
| 51 | SimulatedNetwork* const ret_link_; |
Per Kjellander | 1ca57b9 | 2022-01-19 14:14:02 +0100 | [diff] [blame] | 52 | TwoWayFakeTrafficRoute<SentPacket, std::vector<PacketResult>> route_; |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 53 | |
Per Kjellander | 1ca57b9 | 2022-01-19 14:14:02 +0100 | [diff] [blame] | 54 | std::queue<SentPacket> sent_packets_; |
| 55 | std::vector<PacketResult> received_packets_; |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 56 | std::vector<TransportPacketsFeedback> feedback_; |
Sebastian Jansson | ad9113f | 2019-08-13 18:18:29 +0200 | [diff] [blame] | 57 | int64_t sequence_number_ = 1; |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 58 | }; |
| 59 | } // namespace webrtc |
Artem Titov | 386802e | 2019-07-05 10:48:17 +0200 | [diff] [blame] | 60 | #endif // TEST_NETWORK_FEEDBACK_GENERATOR_H_ |