feedback_generator.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include <map>
  13. #include <utility>
  14. #include <vector>
  15. #include "api/transport/test/feedback_generator_interface.h"
  16. #include "call/simulated_network.h"
  17. #include "test/network/network_emulation.h"
  18. #include "test/network/network_emulation_manager.h"
  19. #include "test/time_controller/simulated_time_controller.h"
  20. namespace webrtc {
  21. class FeedbackGeneratorImpl
  22. : public FeedbackGenerator,
  23. public TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback>::
  24. TrafficHandlerInterface {
  25. public:
  26. explicit FeedbackGeneratorImpl(Config config);
  27. Timestamp Now() override;
  28. void Sleep(TimeDelta duration) override;
  29. void SendPacket(size_t size) override;
  30. std::vector<TransportPacketsFeedback> PopFeedback() override;
  31. void SetSendConfig(BuiltInNetworkBehaviorConfig config) override;
  32. void SetReturnConfig(BuiltInNetworkBehaviorConfig config) override;
  33. void SetSendLinkCapacity(DataRate capacity) override;
  34. void OnRequest(SentPacket packet, Timestamp arrival_time) override;
  35. void OnResponse(TransportPacketsFeedback packet,
  36. Timestamp arrival_time) override;
  37. private:
  38. Config conf_;
  39. ::webrtc::test::NetworkEmulationManagerImpl net_;
  40. SimulatedNetwork* const send_link_;
  41. SimulatedNetwork* const ret_link_;
  42. TwoWayFakeTrafficRoute<SentPacket, TransportPacketsFeedback> route_;
  43. TransportPacketsFeedback builder_;
  44. std::vector<TransportPacketsFeedback> feedback_;
  45. int64_t sequence_number_ = 1;
  46. };
  47. } // namespace webrtc
  48. #endif // TEST_NETWORK_FEEDBACK_GENERATOR_H_