feedback_generator_interface.h (2821B)
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 API_TRANSPORT_TEST_FEEDBACK_GENERATOR_INTERFACE_H_ 11 #define API_TRANSPORT_TEST_FEEDBACK_GENERATOR_INTERFACE_H_ 12 13 #include <cstddef> 14 #include <vector> 15 16 #include "api/rtc_event_log/rtc_event_log.h" 17 #include "api/test/network_emulation_manager.h" 18 #include "api/test/simulated_network.h" 19 #include "api/transport/network_types.h" 20 #include "api/units/data_rate.h" 21 #include "api/units/data_size.h" 22 #include "api/units/time_delta.h" 23 #include "api/units/timestamp.h" 24 25 namespace webrtc { 26 class FeedbackGenerator { 27 public: 28 struct Config { 29 BuiltInNetworkBehaviorConfig send_link; 30 BuiltInNetworkBehaviorConfig return_link; 31 TimeDelta feedback_interval = TimeDelta::Millis(50); 32 DataSize feedback_packet_size = DataSize::Bytes(20); 33 }; 34 virtual ~FeedbackGenerator() = default; 35 virtual Timestamp Now() = 0; 36 virtual void Sleep(TimeDelta duration) = 0; 37 // Send a packet of the given size over the simulated network. 38 virtual void SendPacket(size_t size) = 0; 39 virtual std::vector<TransportPacketsFeedback> PopFeedback() = 0; 40 virtual void SetSendConfig(BuiltInNetworkBehaviorConfig config) = 0; 41 virtual void SetReturnConfig(BuiltInNetworkBehaviorConfig config) = 0; 42 virtual void SetSendLinkCapacity(DataRate capacity) = 0; 43 virtual RtcEventLog& event_log() = 0; 44 }; 45 46 // Same as FeedbackGenerator, but NetworkEmulationManager is owned externally. 47 // Packets can be sent and received via multiple nodes. 48 class FeedbackGeneratorWithoutNetwork { 49 public: 50 struct Config { 51 std::vector<EmulatedNetworkNode*> sent_via_nodes; 52 std::vector<EmulatedNetworkNode*> received_via_nodes; 53 TimeDelta feedback_interval = TimeDelta::Millis(50); 54 DataSize feedback_packet_size = DataSize::Bytes(20); 55 }; 56 57 virtual ~FeedbackGeneratorWithoutNetwork() = default; 58 59 // Send a packet of the given size over the simulated network. 60 // The packet size logged in the event log is `total_size` - `overhead`. 61 // This allows a user to ensure that LoggedPacketInfo.size + 62 // LoggedPacketInfo.overhead in the event log is `total_size`. 63 // Note that ParsedRtcEventLog estimate the overhead depending on the 64 // selected ice candidate. 65 virtual void SendPacket(size_t total_size, size_t overhead) = 0; 66 virtual std::vector<TransportPacketsFeedback> PopFeedback() = 0; 67 virtual RtcEventLog& event_log() = 0; 68 }; 69 70 } // namespace webrtc 71 #endif // API_TRANSPORT_TEST_FEEDBACK_GENERATOR_INTERFACE_H_