/* * @Author: DI JUNKUN * @Date: 2025-01-03 * Copyright (c) 2025 by DI JUNKUN, All Rights Reserved. */ #ifndef _VIDEO_CHANNEL_SEND_H_ #define _VIDEO_CHANNEL_SEND_H_ #include "api/transport/network_types.h" #include "api/units/timestamp.h" #include "clock/system_clock.h" #include "congestion_control.h" #include "congestion_control_feedback.h" #include "encoded_frame.h" #include "ice_agent.h" #include "packet_sender.h" #include "rtp_packet_history.h" #include "rtp_packetizer.h" #include "rtp_video_sender.h" #include "transport_feedback_adapter.h" class VideoChannelSend { public: VideoChannelSend(std::shared_ptr clock, std::shared_ptr ice_agent, std::shared_ptr packet_sender, std::shared_ptr ice_io_statistics, std::function on_sent_packet_func_); ~VideoChannelSend(); void OnSentRtpPacket(std::unique_ptr packet); void OnReceiveNack(const std::vector& nack_sequence_numbers); std::vector> GeneratePadding( uint32_t payload_size, int64_t captured_timestamp_us); public: void Initialize(rtp::PAYLOAD_TYPE payload_type); void Destroy(); uint32_t GetSsrc() { return ssrc_; } uint32_t GetRtxSsrc() { return rtx_ssrc_; } int SendVideo(const EncodedFrame& encoded_frame); void OnReceiverReport(const ReceiverReport& receiver_report) { std::vector reports = receiver_report.GetReportBlocks(); for (auto r : reports) { LOG_WARN( "r_ssrc [{}], f_lost [{}], c_lost [{}], h_seq [{}], jitter [{}], " "lsr [{}], dlsr [{}] ", r.SourceSsrc(), r.FractionLost() / 255.0, r.CumulativeLost(), r.ExtendedHighSeqNum(), r.Jitter(), r.LastSr(), r.DelaySinceLastSr()); } } private: int32_t ReSendPacket(uint16_t packet_id); private: std::shared_ptr packet_sender_ = nullptr; std::shared_ptr ice_agent_ = nullptr; std::shared_ptr ice_io_statistics_ = nullptr; std::unique_ptr rtp_packetizer_ = nullptr; std::function on_sent_packet_func_ = nullptr; private: uint32_t ssrc_ = 0; uint32_t rtx_ssrc_ = 0; std::shared_ptr clock_; RtpPacketHistory rtp_packet_history_; int64_t delta_ntp_internal_ms_; private: FILE* file_rtp_sent_ = nullptr; }; #endif