blob: 002ab8fc980fa73fc85705d94511b65e33247da7 [file] [log] [blame]
pwestin@webrtc.org1cd11622012-04-19 12:13:52 +00001/*
2 * Copyright (c) 2012 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 * Usage: this class will register multiple RtcpBitrateObserver's one at each
11 * RTCP module. It will aggregate the results and run one bandwidth estimation
12 * and push the result to the encoders via BitrateObserver(s).
13 */
14
15#ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
16#define WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
17
18#include "modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
19
20namespace webrtc {
21
22class BitrateObserver {
23 /*
24 * Observer class for the encoders, each encoder should implement this class
25 * to get the target bitrate. It also get the fraction loss and rtt to
26 * optimize its settings for this type of network.
27 */
28 public:
29 virtual void OnNetworkChanged(const uint32_t targer_bitrate,
30 const uint8_t fraction_loss, // 0 - 255.
31 const uint32_t rtt) = 0;
32
pwestin@webrtc.org1cd11622012-04-19 12:13:52 +000033 virtual ~BitrateObserver() {}
34};
35
pwestin@webrtc.org1cd11622012-04-19 12:13:52 +000036class BitrateController {
37/*
38 * This class collects feedback from all streams sent to a peer (via
39 * RTCPBandwidthObservers). It does one aggregated send side bandwidth
40 * estimation and divide the available bitrate between all its registered
41 * BitrateObservers.
42 */
43 public:
44 static BitrateController* CreateBitrateController();
45 virtual ~BitrateController() {}
46
47 virtual RtcpBandwidthObserver* CreateRtcpBandwidthObserver() = 0;
48
pwestin@webrtc.orga2cd7322012-04-23 08:32:47 +000049 virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0;
50
pwestin@webrtc.org1cd11622012-04-19 12:13:52 +000051 /*
52 * Set the start and max send bitrate used by the bandwidth management.
53 *
54 * observer, updates bitrates if already in use.
55 * min_bitrate_kbit = 0 equals no min bitrate.
56 * max_bitrate_kit = 0 equals no max bitrate.
57 */
58 virtual void SetBitrateObserver(BitrateObserver* observer,
59 const uint32_t start_bitrate,
60 const uint32_t min_bitrate,
61 const uint32_t max_bitrate) = 0;
62
63 virtual void RemoveBitrateObserver(BitrateObserver* observer) = 0;
64};
65} // namespace webrtc
66#endif // WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_