[feat] add network controller into video send channel

This commit is contained in:
dijunkun
2025-02-06 17:36:35 +08:00
parent 3accdf2192
commit 316a0220a8
4 changed files with 50 additions and 8 deletions

View File

@@ -59,7 +59,7 @@ int RtpVideoSender::SendRtpPacket(RtpPacket& rtp_packet) {
if (0 != data_send_func_((const char*)rtp_packet.Buffer().data(),
rtp_packet.Size())) {
LOG_ERROR("Send rtp packet failed");
// LOG_ERROR("Send rtp packet failed");
return -1;
}

View File

@@ -12,6 +12,8 @@ VideoChannelSend::VideoChannelSend(
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics){};
void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
controller_ = std::make_unique<CongestionControl>();
rtp_packetizer_ = RtpPacketizer::Create(payload_type);
rtp_video_sender_ = std::make_unique<RtpVideoSender>(ice_io_statistics_);
rtp_video_sender_->SetSendDataFunc(
@@ -25,8 +27,8 @@ void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
ice_state != NICE_COMPONENT_STATE_READY) {
LOG_ERROR("Ice is not connected, state = [{}]",
nice_component_state_to_string(ice_state));
// LOG_ERROR("Ice is not connected, state = [{}]",
// nice_component_state_to_string(ice_state));
return -2;
}
@@ -75,9 +77,41 @@ void VideoChannelSend::HandleTransportPacketsFeedback(
// LOG_INFO("Transport is {} ECN capable. Stop sending ECT(1)",
// (feedback.transport_supports_ecn ? "" : " not "));
// }
// if (controller_)
// PostUpdates(controller_->OnTransportPacketsFeedback(feedback));
if (controller_)
PostUpdates(controller_->OnTransportPacketsFeedback(feedback));
// // Only update outstanding data if any packet is first time acked.
// UpdateCongestedState();
// Only update outstanding data if any packet is first time acked.
UpdateCongestedState();
}
void VideoChannelSend::PostUpdates(webrtc::NetworkControlUpdate update) {
// if (update.congestion_window) {
// congestion_window_size_ = *update.congestion_window;
// UpdateCongestedState();
// }
// if (update.pacer_config) {
// pacer_.SetPacingRates(update.pacer_config->data_rate(),
// update.pacer_config->pad_rate());
// }
// if (!update.probe_cluster_configs.empty()) {
// pacer_.CreateProbeClusters(std::move(update.probe_cluster_configs));
// }
// if (update.target_rate) {
// control_handler_->SetTargetRate(*update.target_rate);
// UpdateControlState();
// }
}
void VideoChannelSend::UpdateControlState() {
// std::optional<TargetTransferRate> update = control_handler_->GetUpdate();
// if (!update) return;
// retransmission_rate_limiter_.SetMaxRate(update->target_rate.bps());
// observer_->OnTargetTransferRate(*update);
}
void VideoChannelSend::UpdateCongestedState() {
// if (auto update = GetCongestedStateUpdate()) {
// is_congested_ = update.value();
// pacer_.SetCongested(update.value());
// }
}

View File

@@ -7,6 +7,8 @@
#ifndef _VIDEO_CHANNEL_SEND_H_
#define _VIDEO_CHANNEL_SEND_H_
#include "api/transport/network_types.h"
#include "congestion_control.h"
#include "congestion_control_feedback.h"
#include "ice_agent.h"
#include "rtp_packetizer.h"
@@ -33,6 +35,11 @@ class VideoChannelSend {
void HandleTransportPacketsFeedback(
const webrtc::TransportPacketsFeedback& feedback);
private:
void PostUpdates(webrtc::NetworkControlUpdate update);
void UpdateControlState();
void UpdateCongestedState();
private:
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
@@ -46,6 +53,7 @@ class VideoChannelSend {
int feedback_count_ = 0;
webrtc::TransportFeedbackAdapter transport_feedback_adapter_;
std::unique_ptr<CongestionControl> controller_;
};
#endif

View File

@@ -299,7 +299,7 @@ bool IceTransport::ParseRtcpPacket(const uint8_t *buffer, size_t size,
case RtcpPacket::PAYLOAD_TYPE::TCC:
switch (rtcp_block.fmt()) {
case webrtc::rtcp::CongestionControlFeedback::kFeedbackMessageType:
LOG_INFO("Congestion Control Feedback");
LOG_INFO("Receive congestion control feedback");
valid = HandleCongestionControlFeedback(rtcp_block, rtcp_packet_info);
break;
default: