mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] add network controller into video send channel
This commit is contained in:
@@ -59,7 +59,7 @@ int RtpVideoSender::SendRtpPacket(RtpPacket& rtp_packet) {
|
|||||||
|
|
||||||
if (0 != data_send_func_((const char*)rtp_packet.Buffer().data(),
|
if (0 != data_send_func_((const char*)rtp_packet.Buffer().data(),
|
||||||
rtp_packet.Size())) {
|
rtp_packet.Size())) {
|
||||||
LOG_ERROR("Send rtp packet failed");
|
// LOG_ERROR("Send rtp packet failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ VideoChannelSend::VideoChannelSend(
|
|||||||
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics){};
|
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics){};
|
||||||
|
|
||||||
void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||||
|
controller_ = std::make_unique<CongestionControl>();
|
||||||
|
|
||||||
rtp_packetizer_ = RtpPacketizer::Create(payload_type);
|
rtp_packetizer_ = RtpPacketizer::Create(payload_type);
|
||||||
rtp_video_sender_ = std::make_unique<RtpVideoSender>(ice_io_statistics_);
|
rtp_video_sender_ = std::make_unique<RtpVideoSender>(ice_io_statistics_);
|
||||||
rtp_video_sender_->SetSendDataFunc(
|
rtp_video_sender_->SetSendDataFunc(
|
||||||
@@ -25,8 +27,8 @@ void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
|||||||
|
|
||||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||||
LOG_ERROR("Ice is not connected, state = [{}]",
|
// LOG_ERROR("Ice is not connected, state = [{}]",
|
||||||
nice_component_state_to_string(ice_state));
|
// nice_component_state_to_string(ice_state));
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +77,41 @@ void VideoChannelSend::HandleTransportPacketsFeedback(
|
|||||||
// LOG_INFO("Transport is {} ECN capable. Stop sending ECT(1)",
|
// LOG_INFO("Transport is {} ECN capable. Stop sending ECT(1)",
|
||||||
// (feedback.transport_supports_ecn ? "" : " not "));
|
// (feedback.transport_supports_ecn ? "" : " not "));
|
||||||
// }
|
// }
|
||||||
// if (controller_)
|
if (controller_)
|
||||||
// PostUpdates(controller_->OnTransportPacketsFeedback(feedback));
|
PostUpdates(controller_->OnTransportPacketsFeedback(feedback));
|
||||||
|
|
||||||
// // Only update outstanding data if any packet is first time acked.
|
// Only update outstanding data if any packet is first time acked.
|
||||||
// UpdateCongestedState();
|
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());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
#ifndef _VIDEO_CHANNEL_SEND_H_
|
#ifndef _VIDEO_CHANNEL_SEND_H_
|
||||||
#define _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 "congestion_control_feedback.h"
|
||||||
#include "ice_agent.h"
|
#include "ice_agent.h"
|
||||||
#include "rtp_packetizer.h"
|
#include "rtp_packetizer.h"
|
||||||
@@ -33,6 +35,11 @@ class VideoChannelSend {
|
|||||||
void HandleTransportPacketsFeedback(
|
void HandleTransportPacketsFeedback(
|
||||||
const webrtc::TransportPacketsFeedback& feedback);
|
const webrtc::TransportPacketsFeedback& feedback);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void PostUpdates(webrtc::NetworkControlUpdate update);
|
||||||
|
void UpdateControlState();
|
||||||
|
void UpdateCongestedState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||||
@@ -46,6 +53,7 @@ class VideoChannelSend {
|
|||||||
int feedback_count_ = 0;
|
int feedback_count_ = 0;
|
||||||
|
|
||||||
webrtc::TransportFeedbackAdapter transport_feedback_adapter_;
|
webrtc::TransportFeedbackAdapter transport_feedback_adapter_;
|
||||||
|
std::unique_ptr<CongestionControl> controller_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -299,7 +299,7 @@ bool IceTransport::ParseRtcpPacket(const uint8_t *buffer, size_t size,
|
|||||||
case RtcpPacket::PAYLOAD_TYPE::TCC:
|
case RtcpPacket::PAYLOAD_TYPE::TCC:
|
||||||
switch (rtcp_block.fmt()) {
|
switch (rtcp_block.fmt()) {
|
||||||
case webrtc::rtcp::CongestionControlFeedback::kFeedbackMessageType:
|
case webrtc::rtcp::CongestionControlFeedback::kFeedbackMessageType:
|
||||||
LOG_INFO("Congestion Control Feedback");
|
LOG_INFO("Receive congestion control feedback");
|
||||||
valid = HandleCongestionControlFeedback(rtcp_block, rtcp_packet_info);
|
valid = HandleCongestionControlFeedback(rtcp_block, rtcp_packet_info);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user