congestion_control.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_CAST_SENDER_CONGESTION_CONTROL_H_
  5. #define MEDIA_CAST_SENDER_CONGESTION_CONTROL_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <memory>
  9. #include <vector>
  10. #include "base/time/tick_clock.h"
  11. #include "base/time/time.h"
  12. #include "media/cast/common/frame_id.h"
  13. namespace media {
  14. namespace cast {
  15. class CongestionControl {
  16. public:
  17. virtual ~CongestionControl();
  18. // Called with latest measured rtt value.
  19. virtual void UpdateRtt(base::TimeDelta rtt) = 0;
  20. // Called with an updated target playout delay value.
  21. virtual void UpdateTargetPlayoutDelay(base::TimeDelta delay) = 0;
  22. // Called when an encoded frame is enqueued for transport.
  23. virtual void WillSendFrameToTransport(FrameId frame_id,
  24. size_t frame_size_in_bytes,
  25. base::TimeTicks when) = 0;
  26. // Called when we receive an ACK for a frame.
  27. virtual void AckFrame(FrameId frame_id, base::TimeTicks when) = 0;
  28. // Called when the RTP receiver received frames that have frame ID larger
  29. // than |last_acked_frame_|.
  30. virtual void AckLaterFrames(std::vector<FrameId> received_frames,
  31. base::TimeTicks when) = 0;
  32. // Returns the bitrate we should use for the next frame.
  33. virtual int GetBitrate(base::TimeTicks playout_time,
  34. base::TimeDelta playout_delay) = 0;
  35. };
  36. CongestionControl* NewAdaptiveCongestionControl(const base::TickClock* clock,
  37. int max_bitrate_configured,
  38. int min_bitrate_configured,
  39. double max_frame_rate);
  40. CongestionControl* NewFixedCongestionControl(int bitrate);
  41. } // namespace cast
  42. } // namespace media
  43. #endif // MEDIA_CAST_SENDER_CONGESTION_CONTROL_H_