| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 * | 9 * |
| 10 * Usage: this class will register multiple RtcpBitrateObserver's one at each | 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 | 11 * RTCP module. It will aggregate the results and run one bandwidth estimation |
| 12 * and push the result to the encoders via BitrateObserver(s). | 12 * and push the result to the encoders via BitrateObserver(s). |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ | 15 #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ |
| 16 #define WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ | 16 #define WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ |
| 17 | 17 |
| 18 #include <map> | 18 #include <map> |
| 19 | 19 |
| 20 #include "webrtc/modules/include/module.h" | 20 #include "webrtc/modules/include/module.h" |
| 21 #include "webrtc/modules/pacing/paced_sender.h" | |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 23 | 22 |
| 24 namespace webrtc { | 23 namespace webrtc { |
| 25 | 24 |
| 26 class CriticalSectionWrapper; | 25 class CriticalSectionWrapper; |
| 27 class RtcEventLog; | 26 class RtcEventLog; |
| 28 struct PacketInfo; | 27 struct PacketInfo; |
| 29 | 28 |
| 30 // Deprecated | |
| 31 // TODO(perkj): Remove BitrateObserver when no implementations use it. | |
| 32 class BitrateObserver { | 29 class BitrateObserver { |
| 33 // Observer class for bitrate changes announced due to change in bandwidth | 30 // Observer class for bitrate changes announced due to change in bandwidth |
| 34 // estimate or due to bitrate allocation changes. Fraction loss and rtt is | 31 // 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 | 32 // 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 | 33 // for different types of network environments. The bitrate does not include |
| 37 // packet headers and is measured in bits per second. | 34 // packet headers and is measured in bits per second. |
| 38 public: | 35 public: |
| 39 virtual void OnNetworkChanged(uint32_t bitrate_bps, | 36 virtual void OnNetworkChanged(uint32_t bitrate_bps, |
| 40 uint8_t fraction_loss, // 0 - 255. | 37 uint8_t fraction_loss, // 0 - 255. |
| 41 int64_t rtt_ms) = 0; | 38 int64_t rtt_ms) = 0; |
| 42 | 39 |
| 43 virtual ~BitrateObserver() {} | 40 virtual ~BitrateObserver() {} |
| 44 }; | 41 }; |
| 45 | 42 |
| 46 class BitrateController : public Module { | 43 class BitrateController : public Module { |
| 47 // This class collects feedback from all streams sent to a peer (via | 44 // This class collects feedback from all streams sent to a peer (via |
| 48 // RTCPBandwidthObservers). It does one aggregated send side bandwidth | 45 // RTCPBandwidthObservers). It does one aggregated send side bandwidth |
| 49 // estimation and divide the available bitrate between all its registered | 46 // estimation and divide the available bitrate between all its registered |
| 50 // BitrateObservers. | 47 // BitrateObservers. |
| 51 public: | 48 public: |
| 52 static const int kDefaultStartBitratebps = 300000; | 49 static const int kDefaultStartBitrateKbps = 300; |
| 53 | 50 |
| 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. | |
| 57 static BitrateController* CreateBitrateController(Clock* clock, | 51 static BitrateController* CreateBitrateController(Clock* clock, |
| 58 BitrateObserver* observer); | 52 BitrateObserver* observer); |
| 59 static BitrateController* CreateBitrateController(Clock* clock); | |
| 60 | |
| 61 virtual ~BitrateController() {} | 53 virtual ~BitrateController() {} |
| 62 | 54 |
| 63 virtual RtcpBandwidthObserver* CreateRtcpBandwidthObserver() = 0; | 55 virtual RtcpBandwidthObserver* CreateRtcpBandwidthObserver() = 0; |
| 64 | 56 |
| 65 // Deprecated | 57 // Deprecated |
| 66 virtual void SetStartBitrate(int start_bitrate_bps) = 0; | 58 virtual void SetStartBitrate(int start_bitrate_bps) = 0; |
| 67 // Deprecated | 59 // Deprecated |
| 68 virtual void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) = 0; | 60 virtual void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) = 0; |
| 69 virtual void SetBitrates(int start_bitrate_bps, | 61 virtual void SetBitrates(int start_bitrate_bps, |
| 70 int min_bitrate_bps, | 62 int min_bitrate_bps, |
| 71 int max_bitrate_bps) = 0; | 63 int max_bitrate_bps) = 0; |
| 72 | 64 |
| 73 virtual void UpdateDelayBasedEstimate(uint32_t bitrate_bps) = 0; | 65 virtual void UpdateDelayBasedEstimate(uint32_t bitrate_bps) = 0; |
| 74 | 66 |
| 75 virtual void SetEventLog(RtcEventLog* event_log) = 0; | 67 virtual void SetEventLog(RtcEventLog* event_log) = 0; |
| 76 | 68 |
| 77 // Gets the available payload bandwidth in bits per second. Note that | 69 // Gets the available payload bandwidth in bits per second. Note that |
| 78 // this bandwidth excludes packet headers. | 70 // this bandwidth excludes packet headers. |
| 79 virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0; | 71 virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0; |
| 80 | 72 |
| 81 virtual void SetReservedBitrate(uint32_t reserved_bitrate_bps) = 0; | 73 virtual void SetReservedBitrate(uint32_t reserved_bitrate_bps) = 0; |
| 82 | |
| 83 virtual bool GetNetworkParameters(uint32_t* bitrate, | |
| 84 uint8_t* fraction_loss, | |
| 85 int64_t* rtt) = 0; | |
| 86 }; | 74 }; |
| 87 } // namespace webrtc | 75 } // namespace webrtc |
| 88 #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ | 76 #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ |
| OLD | NEW |