summaryrefslogtreecommitdiffstats
path: root/media/cast/sender/congestion_control.h
blob: 8e1713409435754b8020c1c24bd0166b9d891122 (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
52
53
// 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 "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 enqueued for transport.
  virtual void SendFrameToTransport(uint32 frame_id,
                                    size_t frame_size_in_bits,
                                    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.  |soft_max_bitrate|
  // is a soft upper-bound applied to the computed target bitrate before the
  // hard upper- and lower-bounds are applied.
  virtual int GetBitrate(base::TimeTicks playout_time,
                         base::TimeDelta playout_delay,
                         int soft_max_bitrate) = 0;
};

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

CongestionControl* NewFixedCongestionControl(int bitrate);

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_