2012-04-19 12:13:52 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*
|
|
|
|
|
* FEC and NACK added bitrate is handled outside class
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_
|
|
|
|
|
#define WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_
|
|
|
|
|
|
2014-03-26 21:00:21 +00:00
|
|
|
#include <deque>
|
2016-01-24 23:05:21 -08:00
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2015-11-05 12:02:15 -08:00
|
|
|
|
|
|
|
|
class RtcEventLog;
|
|
|
|
|
|
2012-04-19 12:13:52 +00:00
|
|
|
class SendSideBandwidthEstimation {
|
|
|
|
|
public:
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
SendSideBandwidthEstimation();
|
2012-04-19 12:13:52 +00:00
|
|
|
virtual ~SendSideBandwidthEstimation();
|
|
|
|
|
|
2015-03-26 11:11:06 +01:00
|
|
|
void CurrentEstimate(int* bitrate, uint8_t* loss, int64_t* rtt) const;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2014-03-26 21:00:21 +00:00
|
|
|
// Call periodically to update estimate.
|
2014-12-08 19:46:23 +00:00
|
|
|
void UpdateEstimate(int64_t now_ms);
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2014-03-21 16:51:01 +00:00
|
|
|
// Call when we receive a RTCP message with TMMBR or REMB.
|
2015-09-04 03:04:56 -07:00
|
|
|
void UpdateReceiverEstimate(int64_t now_ms, uint32_t bandwidth);
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2016-01-20 07:13:58 -08:00
|
|
|
// Call when a new delay-based estimate is available.
|
|
|
|
|
void UpdateDelayBasedEstimate(int64_t now_ms, uint32_t bitrate_bps);
|
|
|
|
|
|
2014-03-21 16:51:01 +00:00
|
|
|
// Call when we receive a RTCP message with a ReceiveBlock.
|
|
|
|
|
void UpdateReceiverBlock(uint8_t fraction_loss,
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t rtt,
|
2014-03-21 16:51:01 +00:00
|
|
|
int number_of_packets,
|
2014-12-08 19:46:23 +00:00
|
|
|
int64_t now_ms);
|
2014-03-21 16:51:01 +00:00
|
|
|
|
2016-04-28 15:52:49 +02:00
|
|
|
void SetBitrates(int send_bitrate,
|
|
|
|
|
int min_bitrate,
|
|
|
|
|
int max_bitrate);
|
2015-03-26 11:11:06 +01:00
|
|
|
void SetSendBitrate(int bitrate);
|
|
|
|
|
void SetMinMaxBitrate(int min_bitrate, int max_bitrate);
|
|
|
|
|
int GetMinBitrate() const;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
void SetEventLog(RtcEventLog* event_log);
|
|
|
|
|
|
2012-04-19 12:13:52 +00:00
|
|
|
private:
|
2014-11-04 19:32:10 +00:00
|
|
|
enum UmaState { kNoUpdate, kFirstDone, kDone };
|
|
|
|
|
|
2014-11-03 14:42:43 +00:00
|
|
|
bool IsInStartPhase(int64_t now_ms) const;
|
|
|
|
|
|
2015-01-12 21:51:21 +00:00
|
|
|
void UpdateUmaStats(int64_t now_ms, int64_t rtt, int lost_packets);
|
2014-11-04 19:32:10 +00:00
|
|
|
|
2014-10-23 11:57:05 +00:00
|
|
|
// Returns the input bitrate capped to the thresholds defined by the max,
|
|
|
|
|
// min and incoming bandwidth.
|
2015-09-04 03:04:56 -07:00
|
|
|
uint32_t CapBitrateToThresholds(int64_t now_ms, uint32_t bitrate);
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2014-03-26 21:00:21 +00:00
|
|
|
// Updates history of min bitrates.
|
|
|
|
|
// After this method returns min_bitrate_history_.front().second contains the
|
|
|
|
|
// min bitrate used during last kBweIncreaseIntervalMs.
|
2014-12-08 19:46:23 +00:00
|
|
|
void UpdateMinHistory(int64_t now_ms);
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2014-12-08 19:46:23 +00:00
|
|
|
std::deque<std::pair<int64_t, uint32_t> > min_bitrate_history_;
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2012-04-19 12:13:52 +00:00
|
|
|
// incoming filters
|
2015-10-22 08:52:20 -07:00
|
|
|
int lost_packets_since_last_loss_update_Q8_;
|
|
|
|
|
int expected_packets_since_last_loss_update_;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
uint32_t bitrate_;
|
|
|
|
|
uint32_t min_bitrate_configured_;
|
|
|
|
|
uint32_t max_bitrate_configured_;
|
2015-09-04 03:04:56 -07:00
|
|
|
int64_t last_low_bitrate_log_ms_;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2015-10-22 08:52:20 -07:00
|
|
|
bool has_decreased_since_last_fraction_loss_;
|
2014-12-08 19:46:23 +00:00
|
|
|
int64_t time_last_receiver_block_ms_;
|
2012-04-19 12:13:52 +00:00
|
|
|
uint8_t last_fraction_loss_;
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t last_round_trip_time_ms_;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
uint32_t bwe_incoming_;
|
2016-01-20 07:13:58 -08:00
|
|
|
uint32_t delay_based_bitrate_bps_;
|
2014-12-08 19:46:23 +00:00
|
|
|
int64_t time_last_decrease_ms_;
|
2014-10-23 11:57:05 +00:00
|
|
|
int64_t first_report_time_ms_;
|
2014-11-03 14:42:43 +00:00
|
|
|
int initially_lost_packets_;
|
2014-11-04 19:32:10 +00:00
|
|
|
int bitrate_at_2_seconds_kbps_;
|
|
|
|
|
UmaState uma_update_state_;
|
2015-01-19 15:44:47 +00:00
|
|
|
std::vector<bool> rampup_uma_stats_updated_;
|
2015-11-05 12:02:15 -08:00
|
|
|
RtcEventLog* event_log_;
|
2012-04-19 12:13:52 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
#endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_
|