[fix] fix qos module

This commit is contained in:
dijunkun
2025-01-20 18:41:52 +08:00
parent 5bbd182a3f
commit 477fd1f13b
62 changed files with 4005 additions and 651 deletions

View File

@@ -38,6 +38,8 @@ RtpPacket::RtpPacket() : buffer_(new uint8_t[DEFAULT_MTU]), size_(DEFAULT_MTU) {
ParseRtpData();
}
RtpPacket::RtpPacket(uint32_t size) : buffer_(new uint8_t[size]), size_(size) {}
RtpPacket::RtpPacket(const uint8_t *buffer, uint32_t size) {
if (size > 0) {
buffer_ = (uint8_t *)malloc(size);

View File

@@ -184,6 +184,7 @@ class RtpPacket {
public:
RtpPacket();
RtpPacket(uint32_t size);
RtpPacket(const uint8_t *buffer, uint32_t size);
RtpPacket(const RtpPacket &rtp_packet);
RtpPacket(RtpPacket &&rtp_packet);
@@ -220,6 +221,31 @@ class RtpPacket {
memcpy(extension_data_, extension_data, extension_len_);
}
void SetAbsoluteSendTimestamp(uint32_t abs_send_time) {
// Absolute Send Time is a 24-bit field, we need to ensure it fits in 24
// bits
abs_send_time &= 0x00FFFFFF;
// Allocate memory for the extension data if not already allocated
if (extension_data_ == nullptr) {
extension_data_ = new uint8_t[4]; // 2 bytes for profile, 2 bytes for
// length, 3 bytes for abs_send_time
extension_len_ = 4;
}
// Set the extension profile to 0xBEDE (one-byte header)
extension_profile_ = 0xBEDE;
// Set the length of the extension data (in 32-bit words minus one)
extension_data_[0] = 0x00;
extension_data_[1] = 0x02; // 2 words (8 bytes)
// Set the absolute send time in the extension data
extension_data_[2] = (abs_send_time >> 16) & 0xFF;
extension_data_[3] = (abs_send_time >> 8) & 0xFF;
extension_data_[4] = abs_send_time & 0xFF;
}
public:
typedef struct {
uint8_t forbidden_bit : 1;
@@ -323,6 +349,18 @@ class RtpPacket {
return extension_data_;
}
uint32_t GetAbsoluteSendTimestamp(uint32_t *abs_send_time) const {
if (extension_data_ == nullptr || extension_len_ < 4) {
return 0;
}
// Absolute Send Time is a 24-bit field
*abs_send_time = (extension_data_[2] << 16) | (extension_data_[3] << 8) |
extension_data_[4];
return *abs_send_time;
}
uint8_t FecSymbolId() { return fec_symbol_id_; }
uint8_t FecSourceSymbolNum() { return fec_source_symbol_num_; }
@@ -355,6 +393,7 @@ class RtpPacket {
// Entire RTP buffer
const uint8_t *Buffer() const { return buffer_; }
size_t Size() const { return size_; }
size_t size() const { return size_; }
// NAL
NAL_UNIT_TYPE NalUnitType() {

View File

@@ -20,8 +20,7 @@
namespace webrtc {
RtpPacketReceived::RtpPacketReceived() = default;
RtpPacketReceived::RtpPacketReceived(
webrtc::Timestamp arrival_time /*= webrtc::Timestamp::MinusInfinity()*/)
RtpPacketReceived::RtpPacketReceived(webrtc::Timestamp arrival_time)
: RtpPacket(), arrival_time_(arrival_time) {}
RtpPacketReceived::RtpPacketReceived(const RtpPacketReceived& packet) = default;
RtpPacketReceived::RtpPacketReceived(RtpPacketReceived&& packet) = default;

View File

@@ -17,8 +17,8 @@
#include "api/array_view.h"
#include "api/ref_counted_base.h"
#include "api/scoped_refptr.h"
#include "api/transport/ecn_marking.h"
#include "api/units/timestamp.h"
#include "rtc_base/network/ecn_marking.h"
#include "rtp_header.h"
#include "rtp_packet.h"
@@ -29,8 +29,7 @@ namespace webrtc {
class RtpPacketReceived : public RtpPacket {
public:
RtpPacketReceived();
explicit RtpPacketReceived(
webrtc::Timestamp arrival_time = webrtc::Timestamp::MinusInfinity());
explicit RtpPacketReceived(webrtc::Timestamp arrival_time);
RtpPacketReceived(const RtpPacketReceived& packet);
RtpPacketReceived(RtpPacketReceived&& packet);
@@ -50,8 +49,8 @@ class RtpPacketReceived : public RtpPacket {
// Explicit Congestion Notification (ECN), RFC-3168, Section 5.
// Used by L4S: https://www.rfc-editor.org/rfc/rfc9331.html
rtc::EcnMarking ecn() const { return ecn_; }
void set_ecn(rtc::EcnMarking ecn) { ecn_ = ecn; }
EcnMarking ecn() const { return ecn_; }
void set_ecn(EcnMarking ecn) { ecn_ = ecn; }
// Flag if packet was recovered via RTX or FEC.
bool recovered() const { return recovered_; }
@@ -73,7 +72,7 @@ class RtpPacketReceived : public RtpPacket {
private:
webrtc::Timestamp arrival_time_ = Timestamp::MinusInfinity();
rtc::EcnMarking ecn_ = rtc::EcnMarking::kNotEct;
EcnMarking ecn_ = EcnMarking::kNotEct;
int payload_type_frequency_ = 0;
bool recovered_ = false;
rtc::scoped_refptr<rtc::RefCountedBase> additional_data_;