rtp_packet_pacer.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 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 MODULES_PACING_RTP_PACKET_PACER_H_
  11. #define MODULES_PACING_RTP_PACKET_PACER_H_
  12. #include <stdint.h>
  13. #include "absl/types/optional.h"
  14. #include "api/units/data_rate.h"
  15. #include "api/units/data_size.h"
  16. #include "api/units/time_delta.h"
  17. #include "api/units/timestamp.h"
  18. #include "modules/rtp_rtcp/include/rtp_packet_sender.h"
  19. namespace webrtc {
  20. class RtpPacketPacer {
  21. public:
  22. virtual ~RtpPacketPacer() = default;
  23. virtual void CreateProbeCluster(DataRate bitrate, int cluster_id) = 0;
  24. // Temporarily pause all sending.
  25. virtual void Pause() = 0;
  26. // Resume sending packets.
  27. virtual void Resume() = 0;
  28. virtual void SetCongestionWindow(DataSize congestion_window_size) = 0;
  29. virtual void UpdateOutstandingData(DataSize outstanding_data) = 0;
  30. // Sets the pacing rates. Must be called once before packets can be sent.
  31. virtual void SetPacingRates(DataRate pacing_rate, DataRate padding_rate) = 0;
  32. // Time since the oldest packet currently in the queue was added.
  33. virtual TimeDelta OldestPacketWaitTime() const = 0;
  34. // Sum of payload + padding bytes of all packets currently in the pacer queue.
  35. virtual DataSize QueueSizeData() const = 0;
  36. // Returns the time when the first packet was sent.
  37. virtual absl::optional<Timestamp> FirstSentPacketTime() const = 0;
  38. // Returns the expected number of milliseconds it will take to send the
  39. // current packets in the queue, given the current size and bitrate, ignoring
  40. // priority.
  41. virtual TimeDelta ExpectedQueueTime() const = 0;
  42. // Set the average upper bound on pacer queuing delay. The pacer may send at
  43. // a higher rate than what was configured via SetPacingRates() in order to
  44. // keep ExpectedQueueTimeMs() below |limit_ms| on average.
  45. virtual void SetQueueTimeLimit(TimeDelta limit) = 0;
  46. // Currently audio traffic is not accounted by pacer and passed through.
  47. // With the introduction of audio BWE audio traffic will be accounted for
  48. // the pacer budget calculation. The audio traffic still will be injected
  49. // at high priority.
  50. virtual void SetAccountForAudioPackets(bool account_for_audio) = 0;
  51. virtual void SetIncludeOverhead() = 0;
  52. virtual void SetTransportOverhead(DataSize overhead_per_packet) = 0;
  53. };
  54. } // namespace webrtc
  55. #endif // MODULES_PACING_RTP_PACKET_PACER_H_