mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 12:45:35 +08:00
[feat] implementation for qos module
This commit is contained in:
@@ -10,43 +10,22 @@
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "congestion_control_feedback_tracker.h"
|
||||
#include "rtcp_packet.h"
|
||||
#include "rtp_packet_received.h"
|
||||
|
||||
class RtpTransportFeedbackGenerator {
|
||||
class CongestionControlFeedbackGenerator {
|
||||
public:
|
||||
// Function intented to be used for sending RTCP messages generated by an
|
||||
// implementation of this class.
|
||||
using RtcpSender =
|
||||
std::function<void(std::vector<std::unique_ptr<RtcpPacket>> packets)>;
|
||||
virtual ~RtpTransportFeedbackGenerator() = default;
|
||||
|
||||
virtual void OnReceivedPacket(const RtpPacketReceived& packet) = 0;
|
||||
|
||||
// Sends periodic feedback if it is time to send it.
|
||||
// Returns time until next call to Process should be made.
|
||||
virtual int64_t Process(int64_t now) = 0;
|
||||
|
||||
virtual void OnSendBandwidthEstimateChanged(int64_t estimate) = 0;
|
||||
|
||||
// Overhead from transport layers below RTP. Ie, IP, SRTP.
|
||||
virtual void SetTransportOverhead(DataSize overhead_per_packet) = 0;
|
||||
};
|
||||
|
||||
class CongestionControlFeedbackGenerator
|
||||
: public RtpTransportFeedbackGenerator {
|
||||
public:
|
||||
CongestionControlFeedbackGenerator(
|
||||
RtpTransportFeedbackGenerator::RtcpSender feedback_sender);
|
||||
CongestionControlFeedbackGenerator(RtcpSender feedback_sender);
|
||||
~CongestionControlFeedbackGenerator() = default;
|
||||
|
||||
void OnReceivedPacket(const RtpPacketReceived& packet) override;
|
||||
void OnReceivedPacket(RtpPacketReceived& packet);
|
||||
|
||||
void OnSendBandwidthEstimateChanged(int64_t estimate) override;
|
||||
void OnSendBandwidthEstimateChanged(int64_t estimate);
|
||||
|
||||
int64_t Process(int64_t now_ms) override;
|
||||
int64_t Process(int64_t now_ms);
|
||||
|
||||
void SetTransportOverhead(DataSize overhead_per_packet) override;
|
||||
void SetTransportOverhead(int64_t overhead_per_packet);
|
||||
|
||||
private:
|
||||
int64_t NextFeedbackTime() const;
|
||||
@@ -55,6 +34,8 @@ class CongestionControlFeedbackGenerator
|
||||
|
||||
void CalculateNextPossibleSendTime(int64_t feedback_size, int64_t now_ms);
|
||||
|
||||
const RtcpSender rtcp_sender_;
|
||||
|
||||
private:
|
||||
// Feedback should not use more than 5% of the configured send bandwidth
|
||||
// estimate. Min and max duration between feedback is configurable using field
|
||||
@@ -73,6 +54,9 @@ class CongestionControlFeedbackGenerator
|
||||
int64_t packet_overhead_ = 0;
|
||||
int64_t send_rate_debt_ = 0;
|
||||
|
||||
std::map</*ssrc=*/uint32_t, CongestionControlFeedbackTracker>
|
||||
feedback_trackers_;
|
||||
|
||||
std::optional<int64_t> first_arrival_time_since_feedback_;
|
||||
int64_t next_possible_feedback_send_time_ = 0;
|
||||
int64_t last_feedback_sent_time_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user