2012-03-05 17:12:41 +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.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-02-23 13:30:42 +01:00
|
|
|
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
2012-03-05 17:12:41 +00:00
|
|
|
|
2016-02-16 17:07:21 +01:00
|
|
|
#include <algorithm>
|
2016-03-17 09:17:43 -07:00
|
|
|
#include <memory>
|
2016-02-08 14:31:30 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
2015-03-09 10:06:40 +00:00
|
|
|
#include "webrtc/base/checks.h"
|
2015-12-04 16:13:05 +01:00
|
|
|
#include "webrtc/base/logging.h"
|
2016-07-13 09:11:28 -07:00
|
|
|
#include "webrtc/base/rate_limiter.h"
|
2016-02-08 14:31:30 +01:00
|
|
|
#include "webrtc/base/socket.h"
|
2015-11-12 21:02:42 -08:00
|
|
|
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
2016-09-12 12:28:54 -07:00
|
|
|
#include "webrtc/modules/congestion_controller/probe_controller.h"
|
2016-11-07 04:17:14 -08:00
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
|
2015-07-06 10:50:47 +02:00
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h"
|
|
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
|
2012-03-05 17:12:41 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2016-11-30 03:35:20 -08:00
|
|
|
|
2016-12-21 06:37:18 -08:00
|
|
|
void CongestionController::OnReceivedPacket(int64_t arrival_time_ms,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
const RTPHeader& header) {
|
2017-03-21 06:41:12 -07:00
|
|
|
receive_side_cc_.OnReceivedPacket(arrival_time_ms, payload_size, header);
|
2016-12-21 06:37:18 -08:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
void CongestionController::SetBweBitrates(int min_bitrate_bps,
|
|
|
|
|
int start_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.SetBweBitrates(min_bitrate_bps, start_bitrate_bps,
|
|
|
|
|
max_bitrate_bps);
|
2015-09-28 03:57:14 -07:00
|
|
|
}
|
|
|
|
|
|
2017-03-15 12:40:25 +01:00
|
|
|
// TODO(holmer): Split this up and use SetBweBitrates in combination with
|
|
|
|
|
// OnNetworkRouteChanged.
|
|
|
|
|
void CongestionController::OnNetworkRouteChanged(
|
|
|
|
|
const rtc::NetworkRoute& network_route,
|
|
|
|
|
int bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.OnNetworkRouteChanged(network_route, bitrate_bps,
|
|
|
|
|
min_bitrate_bps, max_bitrate_bps);
|
2016-06-24 11:03:55 -07:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
BitrateController* CongestionController::GetBitrateController() const {
|
2017-03-21 06:41:12 -07:00
|
|
|
return send_side_cc_.GetBitrateController();
|
2012-06-05 10:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator(
|
2016-02-17 15:52:17 +01:00
|
|
|
bool send_side_bwe) {
|
2017-03-21 06:41:12 -07:00
|
|
|
return receive_side_cc_.GetRemoteBitrateEstimator(send_side_bwe);
|
2012-06-07 08:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-13 09:11:28 -07:00
|
|
|
RateLimiter* CongestionController::GetRetransmissionRateLimiter() {
|
2017-03-21 06:41:12 -07:00
|
|
|
return send_side_cc_.GetRetransmissionRateLimiter();
|
2016-07-13 09:11:28 -07:00
|
|
|
}
|
|
|
|
|
|
2016-11-28 13:11:13 -08:00
|
|
|
void CongestionController::EnablePeriodicAlrProbing(bool enable) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.EnablePeriodicAlrProbing(enable);
|
2016-11-28 13:11:13 -08:00
|
|
|
}
|
|
|
|
|
|
2016-06-15 00:47:53 -07:00
|
|
|
void CongestionController::SetAllocatedSendBitrateLimits(
|
|
|
|
|
int min_send_bitrate_bps,
|
|
|
|
|
int max_padding_bitrate_bps) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.SetAllocatedSendBitrateLimits(min_send_bitrate_bps,
|
|
|
|
|
max_padding_bitrate_bps);
|
2015-11-12 21:02:42 -08:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
int64_t CongestionController::GetPacerQueuingDelayMs() const {
|
2017-03-21 06:41:12 -07:00
|
|
|
return send_side_cc_.GetPacerQueuingDelayMs();
|
2015-03-26 11:11:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
void CongestionController::SignalNetworkState(NetworkState state) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.SignalNetworkState(state);
|
2015-10-14 03:12:59 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 08:58:32 -08:00
|
|
|
void CongestionController::SetTransportOverhead(
|
|
|
|
|
size_t transport_overhead_bytes_per_packet) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.SetTransportOverhead(transport_overhead_bytes_per_packet);
|
2017-01-10 08:58:32 -08:00
|
|
|
}
|
|
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.OnSentPacket(sent_packet);
|
2015-10-15 07:26:07 -07:00
|
|
|
}
|
2016-02-17 15:52:17 +01:00
|
|
|
|
|
|
|
|
void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
|
2017-03-21 06:41:12 -07:00
|
|
|
receive_side_cc_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
|
|
|
|
|
send_side_cc_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
|
2016-02-17 15:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t CongestionController::TimeUntilNextProcess() {
|
2017-03-21 06:41:12 -07:00
|
|
|
return std::min(send_side_cc_.TimeUntilNextProcess(),
|
|
|
|
|
receive_side_cc_.TimeUntilNextProcess());
|
2016-02-17 15:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
2016-02-25 04:50:01 -08:00
|
|
|
void CongestionController::Process() {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.Process();
|
|
|
|
|
receive_side_cc_.Process();
|
2016-05-11 06:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
2017-03-23 11:04:48 -07:00
|
|
|
void CongestionController::AddPacket(uint32_t ssrc,
|
|
|
|
|
uint16_t sequence_number,
|
2017-03-09 06:40:08 -08:00
|
|
|
size_t length,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
2017-03-23 11:04:48 -07:00
|
|
|
send_side_cc_.AddPacket(ssrc, sequence_number, length, pacing_info);
|
2017-03-09 06:40:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CongestionController::OnTransportFeedback(
|
|
|
|
|
const rtcp::TransportFeedback& feedback) {
|
2017-03-21 06:41:12 -07:00
|
|
|
send_side_cc_.OnTransportFeedback(feedback);
|
2017-03-09 06:40:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<PacketFeedback> CongestionController::GetTransportFeedbackVector()
|
|
|
|
|
const {
|
2017-03-21 06:41:12 -07:00
|
|
|
return send_side_cc_.GetTransportFeedbackVector();
|
2016-02-17 15:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
} // namespace webrtc
|