xref: /aosp_15_r20/external/webrtc/call/simulated_packet_receiver.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2018 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 
11 #ifndef CALL_SIMULATED_PACKET_RECEIVER_H_
12 #define CALL_SIMULATED_PACKET_RECEIVER_H_
13 
14 #include "api/test/simulated_network.h"
15 #include "call/packet_receiver.h"
16 
17 namespace webrtc {
18 
19 // Private API that is fixing surface between DirectTransport and underlying
20 // network conditions simulation implementation.
21 class SimulatedPacketReceiverInterface : public PacketReceiver {
22  public:
23   // Must not be called in parallel with DeliverPacket or Process.
24   // Destination receiver will be injected with this method
25   virtual void SetReceiver(PacketReceiver* receiver) = 0;
26 
27   // Reports average packet delay.
28   virtual int AverageDelay() = 0;
29 
30   // Process any pending tasks such as timeouts.
31   // Called on a worker thread.
32   virtual void Process() = 0;
33 
34   // Returns the time until next process or nullopt to indicate that the next
35   // process time is unknown. If the next process time is unknown, this should
36   // be checked again any time a packet is enqueued.
37   virtual absl::optional<int64_t> TimeUntilNextProcess() = 0;
38 };
39 
40 }  // namespace webrtc
41 
42 #endif  // CALL_SIMULATED_PACKET_RECEIVER_H_
43