pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 18 | #include <map> |
| 19 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 20 | #include "webrtc/modules/include/module.h" |
perkj | ec81bcd | 2016-05-11 06:01:13 -0700 | [diff] [blame] | 21 | #include "webrtc/modules/pacing/paced_sender.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 22 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
| 25 | |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 26 | class CriticalSectionWrapper; |
terelius | 006d93d | 2015-11-05 12:02:15 -0800 | [diff] [blame] | 27 | class RtcEventLog; |
sprang | 867fb52 | 2015-08-03 04:38:41 -0700 | [diff] [blame] | 28 | struct PacketInfo; |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 29 | |
perkj | ec81bcd | 2016-05-11 06:01:13 -0700 | [diff] [blame] | 30 | // Deprecated |
| 31 | // TODO(perkj): Remove BitrateObserver when no implementations use it. |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 32 | class BitrateObserver { |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 33 | // Observer class for bitrate changes announced due to change in bandwidth |
| 34 | // estimate or due to bitrate allocation changes. Fraction loss and rtt is |
| 35 | // also part of this callback to allow the obsevrer to optimize its settings |
| 36 | // for different types of network environments. The bitrate does not include |
| 37 | // packet headers and is measured in bits per second. |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 38 | public: |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 39 | virtual void OnNetworkChanged(uint32_t bitrate_bps, |
stefan@webrtc.org | edeea91 | 2014-12-08 19:46:23 +0000 | [diff] [blame] | 40 | uint8_t fraction_loss, // 0 - 255. |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 41 | int64_t rtt_ms) = 0; |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 42 | |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 43 | virtual ~BitrateObserver() {} |
| 44 | }; |
| 45 | |
andresp@webrtc.org | 44caf01 | 2014-03-26 21:00:21 +0000 | [diff] [blame] | 46 | class BitrateController : public Module { |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 47 | // This class collects feedback from all streams sent to a peer (via |
| 48 | // RTCPBandwidthObservers). It does one aggregated send side bandwidth |
| 49 | // estimation and divide the available bitrate between all its registered |
| 50 | // BitrateObservers. |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 51 | public: |
perkj | ec81bcd | 2016-05-11 06:01:13 -0700 | [diff] [blame] | 52 | static const int kDefaultStartBitratebps = 300000; |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 53 | |
perkj | ec81bcd | 2016-05-11 06:01:13 -0700 | [diff] [blame] | 54 | // Deprecated: |
| 55 | // TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC. |
| 56 | // Remove this method once other other projects does not use it. |
andresp@webrtc.org | 44caf01 | 2014-03-26 21:00:21 +0000 | [diff] [blame] | 57 | static BitrateController* CreateBitrateController(Clock* clock, |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 58 | BitrateObserver* observer); |
perkj | ec81bcd | 2016-05-11 06:01:13 -0700 | [diff] [blame] | 59 | static BitrateController* CreateBitrateController(Clock* clock); |
| 60 | |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 61 | virtual ~BitrateController() {} |
| 62 | |
| 63 | virtual RtcpBandwidthObserver* CreateRtcpBandwidthObserver() = 0; |
| 64 | |
philipel | c6957c7 | 2016-04-28 15:52:49 +0200 | [diff] [blame] | 65 | // Deprecated |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 66 | virtual void SetStartBitrate(int start_bitrate_bps) = 0; |
philipel | c6957c7 | 2016-04-28 15:52:49 +0200 | [diff] [blame] | 67 | // Deprecated |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 68 | virtual void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) = 0; |
philipel | c6957c7 | 2016-04-28 15:52:49 +0200 | [diff] [blame] | 69 | virtual void SetBitrates(int start_bitrate_bps, |
| 70 | int min_bitrate_bps, |
| 71 | int max_bitrate_bps) = 0; |
stefan@webrtc.org | 792f1a1 | 2015-03-04 12:24:26 +0000 | [diff] [blame] | 72 | |
stefan | 32f8154 | 2016-01-20 07:13:58 -0800 | [diff] [blame] | 73 | virtual void UpdateDelayBasedEstimate(uint32_t bitrate_bps) = 0; |
| 74 | |
terelius | 006d93d | 2015-11-05 12:02:15 -0800 | [diff] [blame] | 75 | virtual void SetEventLog(RtcEventLog* event_log) = 0; |
| 76 | |
stefan@webrtc.org | 42aa10e | 2012-11-13 15:02:13 +0000 | [diff] [blame] | 77 | // Gets the available payload bandwidth in bits per second. Note that |
| 78 | // this bandwidth excludes packet headers. |
pwestin@webrtc.org | a2cd732 | 2012-04-23 08:32:47 +0000 | [diff] [blame] | 79 | virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0; |
| 80 | |
solenberg@webrtc.org | 4e65602 | 2014-03-26 14:32:47 +0000 | [diff] [blame] | 81 | virtual void SetReservedBitrate(uint32_t reserved_bitrate_bps) = 0; |
perkj | ec81bcd | 2016-05-11 06:01:13 -0700 | [diff] [blame] | 82 | |
| 83 | virtual bool GetNetworkParameters(uint32_t* bitrate, |
| 84 | uint8_t* fraction_loss, |
| 85 | int64_t* rtt) = 0; |
pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame] | 86 | }; |
| 87 | } // namespace webrtc |
| 88 | #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ |