mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] receive and parse congestion control feedback supported
This commit is contained in:
@@ -16,7 +16,7 @@ void VideoChannelSend::Initialize(RtpPacket::PAYLOAD_TYPE payload_type) {
|
||||
|
||||
rtp_video_sender_ = std::make_unique<RtpVideoSender>(ice_io_statistics_);
|
||||
rtp_video_sender_->SetSendDataFunc(
|
||||
[this](const char *data, size_t size) -> int {
|
||||
[this](const char* data, size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
@@ -44,14 +44,43 @@ void VideoChannelSend::Destroy() {
|
||||
}
|
||||
}
|
||||
|
||||
int VideoChannelSend::SendVideo(char *data, size_t size) {
|
||||
int VideoChannelSend::SendVideo(char* data, size_t size) {
|
||||
std::vector<RtpPacket> packets;
|
||||
if (rtp_video_sender_) {
|
||||
if (video_rtp_codec_) {
|
||||
video_rtp_codec_->Encode((uint8_t *)data, (uint32_t)size, packets);
|
||||
video_rtp_codec_->Encode((uint8_t*)data, (uint32_t)size, packets);
|
||||
}
|
||||
rtp_video_sender_->Enqueue(packets);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VideoChannelSend::OnCongestionControlFeedback(
|
||||
int64_t recv_ts, const CongestionControlFeedback& feedback) {
|
||||
++feedback_count_;
|
||||
std::optional<TransportPacketsFeedback> feedback_msg =
|
||||
transport_feedback_adapter_.ProcessCongestionControlFeedback(feedback,
|
||||
recv_ts);
|
||||
if (feedback_msg) {
|
||||
HandleTransportPacketsFeedback(*feedback_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void VideoChannelSend::HandleTransportPacketsFeedback(
|
||||
const TransportPacketsFeedback& feedback) {
|
||||
// if (transport_is_ecn_capable_) {
|
||||
// // If transport does not support ECN, packets should not be sent as
|
||||
// ECT(1).
|
||||
// // TODO: bugs.webrtc.org/42225697 - adapt to ECN feedback and continue to
|
||||
// // send packets as ECT(1) if transport is ECN capable.
|
||||
// transport_is_ecn_capable_ = false;
|
||||
// LOG_INFO("Transport is {} ECN capable. Stop sending ECT(1)",
|
||||
// (feedback.transport_supports_ecn ? "" : " not "));
|
||||
// }
|
||||
// if (controller_)
|
||||
// PostUpdates(controller_->OnTransportPacketsFeedback(feedback));
|
||||
|
||||
// // Only update outstanding data if any packet is first time acked.
|
||||
// UpdateCongestedState();
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "ice_agent.h"
|
||||
#include "rtp_codec.h"
|
||||
#include "rtp_video_sender.h"
|
||||
#include "transport_feedback_adapter.h"
|
||||
|
||||
class VideoChannelSend {
|
||||
public:
|
||||
@@ -22,13 +23,26 @@ class VideoChannelSend {
|
||||
void Initialize(RtpPacket::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
int SendVideo(char *data, size_t size);
|
||||
int SendVideo(char* data, size_t size);
|
||||
|
||||
void OnCongestionControlFeedback(int64_t recv_ts,
|
||||
const CongestionControlFeedback& feedback);
|
||||
|
||||
void HandleTransportPacketsFeedback(const TransportPacketsFeedback& feedback);
|
||||
|
||||
private:
|
||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||
std::unique_ptr<RtpCodec> video_rtp_codec_ = nullptr;
|
||||
std::unique_ptr<RtpVideoSender> rtp_video_sender_ = nullptr;
|
||||
|
||||
private:
|
||||
int64_t current_offset_ = std::numeric_limits<int64_t>::min();
|
||||
// Used by RFC 8888 congestion control feedback to track base time.
|
||||
std::optional<uint32_t> last_feedback_compact_ntp_time_;
|
||||
int feedback_count_ = 0;
|
||||
|
||||
TransportFeedbackAdapter transport_feedback_adapter_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user