2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
10 * FEC and NACK added bitrate is handled outside class
13 #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_
14 #define WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_
16 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
20 class SendSideBandwidthEstimation {
22 SendSideBandwidthEstimation();
23 virtual ~SendSideBandwidthEstimation();
25 // Call when we receive a RTCP message with TMMBR or REMB
26 // Return true if new_bitrate is valid.
27 bool UpdateBandwidthEstimate(const uint32_t bandwidth,
28 uint32_t* new_bitrate,
29 uint8_t* fraction_lost,
32 // Call when we receive a RTCP message with a ReceiveBlock
33 // Return true if new_bitrate is valid.
34 bool UpdatePacketLoss(const int number_of_packets,
36 const uint32_t now_ms,
38 uint32_t* new_bitrate);
40 // Return false if no bandwidth estimate is available
41 bool AvailableBandwidth(uint32_t* bandwidth) const;
42 void SetSendBitrate(const uint32_t bitrate);
43 void SetMinMaxBitrate(const uint32_t min_bitrate, const uint32_t max_bitrate);
46 bool ShapeSimple(const uint8_t loss, const uint32_t rtt,
47 const uint32_t now_ms, uint32_t* bitrate);
49 uint32_t CalcTFRCbps(uint16_t rtt, uint8_t loss);
51 enum { kBWEIncreaseIntervalMs = 1000 };
52 enum { kBWEDecreaseIntervalMs = 300 };
53 enum { kLimitNumPackets = 20 };
54 enum { kAvgPacketSizeBytes = 1000 };
56 CriticalSectionWrapper* critsect_;
59 int accumulate_lost_packets_Q8_;
60 int accumulate_expected_packets_;
63 uint32_t min_bitrate_configured_;
64 uint32_t max_bitrate_configured_;
66 uint8_t last_fraction_loss_;
67 uint16_t last_round_trip_time_;
69 uint32_t bwe_incoming_;
70 uint32_t time_last_increase_;
71 uint32_t time_last_decrease_;
74 #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_