mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[fix] fix qos module
This commit is contained in:
@@ -9,18 +9,29 @@
|
||||
|
||||
RtpVideoReceiver::RtpVideoReceiver()
|
||||
: feedback_ssrc_(GenerateUniqueSsrc()),
|
||||
active_remb_module_(nullptr),
|
||||
receive_side_congestion_controller_(
|
||||
clock_,
|
||||
[this](std::vector<std::unique_ptr<RtcpPacket>> packets) {
|
||||
SendCombinedRtcpPacket(std::move(packets));
|
||||
}) {}
|
||||
},
|
||||
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
||||
SendRemb(bitrate_bps, ssrcs);
|
||||
}),
|
||||
clock_(Clock::GetRealTimeClock()) {}
|
||||
|
||||
RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
|
||||
: io_statistics_(io_statistics),
|
||||
feedback_ssrc_(GenerateUniqueSsrc()),
|
||||
receive_side_congestion_controller_(
|
||||
clock_,
|
||||
[this](std::vector<std::unique_ptr<RtcpPacket>> packets) {
|
||||
SendCombinedRtcpPacket(std::move(packets));
|
||||
}) {
|
||||
},
|
||||
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
||||
SendRemb(bitrate_bps, ssrcs);
|
||||
}),
|
||||
clock_(Clock::GetRealTimeClock()) {
|
||||
rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
||||
}
|
||||
|
||||
@@ -45,16 +56,15 @@ void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) {
|
||||
rtp_statistics_->Start();
|
||||
}
|
||||
|
||||
RtpPacketReceived rtp_packet_received;
|
||||
webrtc::RtpPacketReceived rtp_packet_received;
|
||||
rtp_packet_received.Build(rtp_packet.Buffer(), rtp_packet.Size());
|
||||
|
||||
rtp_packet_received.set_arrival_time(
|
||||
std::chrono::system_clock::now().time_since_epoch().count());
|
||||
rtp_packet_received.set_ecn(rtc::EcnMarking::kEct0);
|
||||
rtp_packet_received.set_arrival_time(clock_->CurrentTime());
|
||||
rtp_packet_received.set_ecn(EcnMarking::kEct0);
|
||||
rtp_packet_received.set_recovered(false);
|
||||
rtp_packet_received.set_payload_type_frequency(0);
|
||||
receive_side_congestion_controller_.OnReceivedPacket(
|
||||
rtp_packet_received, ReceiveSideCongestionController::MediaType::VIDEO);
|
||||
receive_side_congestion_controller_.OnReceivedPacket(rtp_packet_received,
|
||||
MediaType::VIDEO);
|
||||
|
||||
last_recv_bytes_ = (uint32_t)rtp_packet.PayloadSize();
|
||||
total_rtp_payload_recv_ += (uint32_t)rtp_packet.PayloadSize();
|
||||
@@ -373,6 +383,17 @@ void RtpVideoReceiver::SendCombinedRtcpPacket(
|
||||
}
|
||||
}
|
||||
|
||||
void RtpVideoReceiver::SendRemb(int64_t bitrate_bps,
|
||||
std::vector<uint32_t> ssrcs) {
|
||||
if (!active_remb_module_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The Add* and Remove* methods above ensure that REMB is disabled on all
|
||||
// other modules, because otherwise, they will send REMB with stale info.
|
||||
active_remb_module_->SetRemb(bitrate_bps, std::move(ssrcs));
|
||||
}
|
||||
|
||||
bool RtpVideoReceiver::CheckIsTimeSendRR() {
|
||||
uint32_t now_ts = static_cast<uint32_t>(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
#include "clock.h"
|
||||
#include "fec_decoder.h"
|
||||
#include "io_statistics.h"
|
||||
#include "receive_side_congestion_controller.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "rtcp_receiver_report.h"
|
||||
#include "rtp_codec.h"
|
||||
#include "rtp_rtcp_defines.h "
|
||||
#include "rtp_statistics.h"
|
||||
#include "thread_base.h"
|
||||
#include "video_frame.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
class RtpVideoReceiver : public ThreadBase {
|
||||
public:
|
||||
RtpVideoReceiver();
|
||||
@@ -47,6 +51,8 @@ class RtpVideoReceiver : public ThreadBase {
|
||||
void SendCombinedRtcpPacket(
|
||||
std::vector<std::unique_ptr<RtcpPacket>> rtcp_packets);
|
||||
|
||||
void SendRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs);
|
||||
|
||||
private:
|
||||
bool Process() override;
|
||||
void RtcpThread();
|
||||
@@ -89,7 +95,9 @@ class RtpVideoReceiver : public ThreadBase {
|
||||
int rtcp_tcc_interval_ms_ = 200;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Clock> clock_;
|
||||
ReceiveSideCongestionController receive_side_congestion_controller_;
|
||||
RtcpFeedbackSenderInterface* active_remb_module_;
|
||||
uint32_t feedback_ssrc_ = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -57,18 +57,18 @@ int VideoChannelSend::SendVideo(char* data, size_t size) {
|
||||
}
|
||||
|
||||
void VideoChannelSend::OnCongestionControlFeedback(
|
||||
int64_t recv_ts, const CongestionControlFeedback& feedback) {
|
||||
int64_t recv_ts, const webrtc::rtcp::CongestionControlFeedback& feedback) {
|
||||
++feedback_count_;
|
||||
std::optional<TransportPacketsFeedback> feedback_msg =
|
||||
transport_feedback_adapter_.ProcessCongestionControlFeedback(feedback,
|
||||
recv_ts);
|
||||
std::optional<webrtc::TransportPacketsFeedback> feedback_msg =
|
||||
transport_feedback_adapter_.ProcessCongestionControlFeedback(
|
||||
feedback, webrtc::Timestamp::Micros(recv_ts));
|
||||
if (feedback_msg) {
|
||||
HandleTransportPacketsFeedback(*feedback_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void VideoChannelSend::HandleTransportPacketsFeedback(
|
||||
const TransportPacketsFeedback& feedback) {
|
||||
const webrtc::TransportPacketsFeedback& feedback) {
|
||||
// if (transport_is_ecn_capable_) {
|
||||
// // If transport does not support ECN, packets should not be sent as
|
||||
// ECT(1).
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#ifndef _VIDEO_CHANNEL_SEND_H_
|
||||
#define _VIDEO_CHANNEL_SEND_H_
|
||||
|
||||
#include "congestion_control_feedback.h"
|
||||
#include "ice_agent.h"
|
||||
#include "rtp_codec.h"
|
||||
#include "rtp_video_sender.h"
|
||||
@@ -25,10 +26,11 @@ class VideoChannelSend {
|
||||
|
||||
int SendVideo(char* data, size_t size);
|
||||
|
||||
void OnCongestionControlFeedback(int64_t recv_ts,
|
||||
const CongestionControlFeedback& feedback);
|
||||
void OnCongestionControlFeedback(
|
||||
int64_t recv_ts, const webrtc::rtcp::CongestionControlFeedback& feedback);
|
||||
|
||||
void HandleTransportPacketsFeedback(const TransportPacketsFeedback& feedback);
|
||||
void HandleTransportPacketsFeedback(
|
||||
const webrtc::TransportPacketsFeedback& feedback);
|
||||
|
||||
private:
|
||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
@@ -42,7 +44,7 @@ class VideoChannelSend {
|
||||
std::optional<uint32_t> last_feedback_compact_ntp_time_;
|
||||
int feedback_count_ = 0;
|
||||
|
||||
TransportFeedbackAdapter transport_feedback_adapter_;
|
||||
webrtc::TransportFeedbackAdapter transport_feedback_adapter_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user