blob: afc306892a613712ee0bf0d25cd23348c2bfc472 [file] [log] [blame]
Sebastian Jansson3525f862019-05-17 17:44:04 +02001/*
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 Titov386802e2019-07-05 10:48:17 +020010#ifndef TEST_NETWORK_FEEDBACK_GENERATOR_H_
11#define TEST_NETWORK_FEEDBACK_GENERATOR_H_
Sebastian Jansson3525f862019-05-17 17:44:04 +020012
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 Titov386802e2019-07-05 10:48:17 +020019#include "test/network/network_emulation.h"
20#include "test/network/network_emulation_manager.h"
Sebastian Jansson3525f862019-05-17 17:44:04 +020021#include "test/time_controller/simulated_time_controller.h"
22
23namespace webrtc {
24
Sebastian Janssonb13ccc52019-06-07 13:06:00 +020025class FeedbackGeneratorImpl
26 : public FeedbackGenerator,
27 public TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback>::
28 TrafficHandlerInterface {
Sebastian Jansson3525f862019-05-17 17:44:04 +020029 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 Janssonb13ccc52019-06-07 13:06:00 +020041 void OnRequest(SentPacket packet, Timestamp arrival_time) override;
42 void OnResponse(TransportPacketsFeedback packet,
43 Timestamp arrival_time) override;
44
Sebastian Jansson3525f862019-05-17 17:44:04 +020045 private:
Sebastian Jansson3525f862019-05-17 17:44:04 +020046 Config conf_;
47 GlobalSimulatedTimeController time_controller_;
48 ::webrtc::test::NetworkEmulationManagerImpl net_;
49 SimulatedNetwork* const send_link_;
50 SimulatedNetwork* const ret_link_;
Sebastian Janssonb13ccc52019-06-07 13:06:00 +020051 TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback> route_;
Sebastian Jansson3525f862019-05-17 17:44:04 +020052
53 TransportPacketsFeedback builder_;
54 std::vector<TransportPacketsFeedback> feedback_;
Sebastian Janssonad9113f2019-08-13 18:18:29 +020055 int64_t sequence_number_ = 1;
Sebastian Jansson3525f862019-05-17 17:44:04 +020056};
57} // namespace webrtc
Artem Titov386802e2019-07-05 10:48:17 +020058#endif // TEST_NETWORK_FEEDBACK_GENERATOR_H_