diff --git a/src/channel/rtp_channel/rtp_video_sender.cpp b/src/channel/rtp_channel/rtp_video_sender.cpp index a310adc..d1f3164 100644 --- a/src/channel/rtp_channel/rtp_video_sender.cpp +++ b/src/channel/rtp_channel/rtp_video_sender.cpp @@ -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; } diff --git a/src/channel/video_channel_send.cpp b/src/channel/video_channel_send.cpp index 2bda4ba..396b144 100644 --- a/src/channel/video_channel_send.cpp +++ b/src/channel/video_channel_send.cpp @@ -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(); + rtp_packetizer_ = RtpPacketizer::Create(payload_type); rtp_video_sender_ = std::make_unique(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 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()); + // } } \ No newline at end of file diff --git a/src/channel/video_channel_send.h b/src/channel/video_channel_send.h index 8989590..55f572a 100644 --- a/src/channel/video_channel_send.h +++ b/src/channel/video_channel_send.h @@ -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 ice_agent_ = nullptr; std::shared_ptr ice_io_statistics_ = nullptr; @@ -46,6 +53,7 @@ class VideoChannelSend { int feedback_count_ = 0; webrtc::TransportFeedbackAdapter transport_feedback_adapter_; + std::unique_ptr controller_; }; #endif \ No newline at end of file diff --git a/src/transport/ice_transport.cpp b/src/transport/ice_transport.cpp index 987fd36..323d0fb 100644 --- a/src/transport/ice_transport.cpp +++ b/src/transport/ice_transport.cpp @@ -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: