2017-03-21 06:41:12 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_CONTROLLER_H_
|
|
|
|
|
#define MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_CONTROLLER_H_
|
2017-03-21 06:41:12 -07:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2024-05-06 19:51:23 +02:00
|
|
|
#include "absl/base/nullability.h"
|
|
|
|
|
#include "api/environment/environment.h"
|
2019-09-10 19:28:06 +02:00
|
|
|
#include "api/transport/network_control.h"
|
2021-04-21 11:56:32 +02:00
|
|
|
#include "api/units/data_rate.h"
|
2022-06-29 12:26:20 +02:00
|
|
|
#include "api/units/time_delta.h"
|
2021-04-21 11:56:32 +02:00
|
|
|
#include "modules/congestion_controller/remb_throttler.h"
|
|
|
|
|
#include "modules/pacing/packet_router.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/remote_bitrate_estimator/remote_estimator_proxy.h"
|
2023-01-30 12:26:17 +01:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
2020-07-07 22:03:26 +02:00
|
|
|
#include "rtc_base/synchronization/mutex.h"
|
2022-07-01 16:28:55 +02:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2017-03-21 06:41:12 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
class RemoteBitrateEstimator;
|
|
|
|
|
|
|
|
|
|
// This class represents the congestion control state for receive
|
|
|
|
|
// streams. For send side bandwidth estimation, this is simply
|
|
|
|
|
// relaying for each received RTP packet back to the sender. While for
|
|
|
|
|
// receive side bandwidth estimation, we do the estimation locally and
|
|
|
|
|
// send our results back to the sender.
|
2022-06-20 12:46:30 +02:00
|
|
|
class ReceiveSideCongestionController : public CallStatsObserver {
|
2017-03-21 06:41:12 -07:00
|
|
|
public:
|
2021-04-21 11:56:32 +02:00
|
|
|
ReceiveSideCongestionController(
|
2024-05-06 19:51:23 +02:00
|
|
|
const Environment& env,
|
|
|
|
|
RemoteEstimatorProxy::TransportFeedbackSender feedback_sender,
|
|
|
|
|
RembThrottler::RembSender remb_sender,
|
|
|
|
|
absl::Nullable<NetworkStateEstimator*> network_state_estimator);
|
|
|
|
|
|
|
|
|
|
[[deprecated]] ReceiveSideCongestionController(
|
2021-04-21 11:56:32 +02:00
|
|
|
Clock* clock,
|
|
|
|
|
RemoteEstimatorProxy::TransportFeedbackSender feedback_sender,
|
|
|
|
|
RembThrottler::RembSender remb_sender,
|
|
|
|
|
NetworkStateEstimator* network_state_estimator);
|
|
|
|
|
|
2024-05-06 19:51:23 +02:00
|
|
|
~ReceiveSideCongestionController() override = default;
|
2017-03-21 06:41:12 -07:00
|
|
|
|
2023-01-30 12:26:17 +01:00
|
|
|
void OnReceivedPacket(const RtpPacketReceived& packet, MediaType media_type);
|
|
|
|
|
|
2017-03-21 06:41:12 -07:00
|
|
|
// Implements CallStatsObserver.
|
|
|
|
|
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
|
|
|
|
|
|
|
|
|
// This is send bitrate, used to control the rate of feedback messages.
|
|
|
|
|
void OnBitrateChanged(int bitrate_bps);
|
|
|
|
|
|
2021-04-21 11:56:32 +02:00
|
|
|
// Ensures the remote party is notified of the receive bitrate no larger than
|
2021-07-28 20:26:13 +02:00
|
|
|
// `bitrate` using RTCP REMB.
|
2021-04-21 11:56:32 +02:00
|
|
|
void SetMaxDesiredReceiveBitrate(DataRate bitrate);
|
|
|
|
|
|
2022-06-09 12:45:36 +02:00
|
|
|
void SetTransportOverhead(DataSize overhead_per_packet);
|
|
|
|
|
|
2022-06-22 10:11:00 +02:00
|
|
|
// Returns latest receive side bandwidth estimation.
|
|
|
|
|
// Returns zero if receive side bandwidth estimation is unavailable.
|
|
|
|
|
DataRate LatestReceiveSideEstimate() const;
|
|
|
|
|
|
|
|
|
|
// Removes stream from receive side bandwidth estimation.
|
|
|
|
|
// Noop if receive side bwe is not used or stream doesn't participate in it.
|
|
|
|
|
void RemoveStream(uint32_t ssrc);
|
|
|
|
|
|
2022-06-20 12:46:30 +02:00
|
|
|
// Runs periodic tasks if it is time to run them, returns time until next
|
|
|
|
|
// call to `MaybeProcess` should be non idle.
|
|
|
|
|
TimeDelta MaybeProcess();
|
2017-03-21 06:41:12 -07:00
|
|
|
|
|
|
|
|
private:
|
2023-03-09 18:36:20 +01:00
|
|
|
void PickEstimator(bool has_absolute_send_time)
|
2022-07-01 16:28:55 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2017-03-21 06:41:12 -07:00
|
|
|
|
2022-06-29 08:16:18 +00:00
|
|
|
Clock& clock_;
|
2021-04-21 11:56:32 +02:00
|
|
|
RembThrottler remb_throttler_;
|
2017-03-21 06:41:12 -07:00
|
|
|
RemoteEstimatorProxy remote_estimator_proxy_;
|
2022-07-01 16:28:55 +02:00
|
|
|
|
|
|
|
|
mutable Mutex mutex_;
|
|
|
|
|
std::unique_ptr<RemoteBitrateEstimator> rbe_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool using_absolute_send_time_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
uint32_t packets_since_absolute_send_time_ RTC_GUARDED_BY(mutex_);
|
2017-03-21 06:41:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_CONTROLLER_H_
|