summaryrefslogtreecommitdiffstats
path: root/media/cast/sender/congestion_control.h
blob: 8c3d764e20fc73f19e11936a1722066746446663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_
#define MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_

#include <deque>

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"

namespace media {
namespace cast {

class CongestionControl {
 public:
  virtual ~CongestionControl();

  // Called with latest measured rtt value.
  virtual void UpdateRtt(base::TimeDelta rtt) = 0;

  // Called with an updated target playout delay value.
  virtual void UpdateTargetPlayoutDelay(base::TimeDelta delay) = 0;

  // Called when an encoded frame is sent to the transport.
  virtual void SendFrameToTransport(uint32 frame_id,
                                    size_t frame_size,
                                    base::TimeTicks when) = 0;
  // Called when we receive an ACK for a frame.
  virtual void AckFrame(uint32 frame_id, base::TimeTicks when) = 0;

  // Returns the bitrate we should use for the next frame.
  virtual uint32 GetBitrate(base::TimeTicks playout_time,
                            base::TimeDelta playout_delay) = 0;
};

CongestionControl* NewAdaptiveCongestionControl(
    base::TickClock* clock,
    uint32 max_bitrate_configured,
    uint32 min_bitrate_configured,
    double max_frame_rate);

CongestionControl* NewFixedCongestionControl(uint32 bitrate);

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_