• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
10 #ifndef TEST_NETWORK_FEEDBACK_GENERATOR_H_
11 #define TEST_NETWORK_FEEDBACK_GENERATOR_H_
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"
19 #include "test/network/network_emulation.h"
20 #include "test/network/network_emulation_manager.h"
21 #include "test/time_controller/simulated_time_controller.h"
22 
23 namespace webrtc {
24 
25 class FeedbackGeneratorImpl
26     : public FeedbackGenerator,
27       public TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback>::
28           TrafficHandlerInterface {
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 
41   void OnRequest(SentPacket packet, Timestamp arrival_time) override;
42   void OnResponse(TransportPacketsFeedback packet,
43                   Timestamp arrival_time) override;
44 
45  private:
46   Config conf_;
47   ::webrtc::test::NetworkEmulationManagerImpl net_;
48   SimulatedNetwork* const send_link_;
49   SimulatedNetwork* const ret_link_;
50   TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback> route_;
51 
52   TransportPacketsFeedback builder_;
53   std::vector<TransportPacketsFeedback> feedback_;
54   int64_t sequence_number_ = 1;
55 };
56 }  // namespace webrtc
57 #endif  // TEST_NETWORK_FEEDBACK_GENERATOR_H_
58