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 | |
| 13 | #include <map> |
| 14 | #include <utility> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "api/transport/test/feedback_generator_interface.h" |
| 18 | #include "call/simulated_network.h" |
Artem Titov | 386802e | 2019-07-05 10:48:17 +0200 | [diff] [blame] | 19 | #include "test/network/network_emulation.h" |
| 20 | #include "test/network/network_emulation_manager.h" |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 21 | #include "test/time_controller/simulated_time_controller.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 25 | class FeedbackGeneratorImpl |
| 26 | : public FeedbackGenerator, |
| 27 | public TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback>:: |
| 28 | TrafficHandlerInterface { |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 29 | public: |
| 30 | explicit FeedbackGeneratorImpl(Config config); |
| 31 | Timestamp Now() override; |
| 32 | void Sleep(TimeDelta duration) override; |
| 33 | void SendPacket(size_t size) override; |
| 34 | std::vector<TransportPacketsFeedback> PopFeedback() override; |
| 35 | |
| 36 | void SetSendConfig(BuiltInNetworkBehaviorConfig config) override; |
| 37 | void SetReturnConfig(BuiltInNetworkBehaviorConfig config) override; |
| 38 | |
| 39 | void SetSendLinkCapacity(DataRate capacity) override; |
| 40 | |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 41 | void OnRequest(SentPacket packet, Timestamp arrival_time) override; |
| 42 | void OnResponse(TransportPacketsFeedback packet, |
| 43 | Timestamp arrival_time) override; |
| 44 | |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 45 | private: |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 46 | Config conf_; |
| 47 | GlobalSimulatedTimeController time_controller_; |
| 48 | ::webrtc::test::NetworkEmulationManagerImpl net_; |
| 49 | SimulatedNetwork* const send_link_; |
| 50 | SimulatedNetwork* const ret_link_; |
Sebastian Jansson | b13ccc5 | 2019-06-07 13:06:00 +0200 | [diff] [blame] | 51 | TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback> route_; |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 52 | |
| 53 | TransportPacketsFeedback builder_; |
| 54 | std::vector<TransportPacketsFeedback> feedback_; |
Sebastian Jansson | ad9113f | 2019-08-13 18:18:29 +0200 | [diff] [blame^] | 55 | int64_t sequence_number_ = 1; |
Sebastian Jansson | 3525f86 | 2019-05-17 17:44:04 +0200 | [diff] [blame] | 56 | }; |
| 57 | } // namespace webrtc |
Artem Titov | 386802e | 2019-07-05 10:48:17 +0200 | [diff] [blame] | 58 | #endif // TEST_NETWORK_FEEDBACK_GENERATOR_H_ |