mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] implementation for qos module
This commit is contained in:
94
src/channel/rtp_channel/rtp_video_receiver.h
Normal file
94
src/channel/rtp_channel/rtp_video_receiver.h
Normal file
@@ -0,0 +1,94 @@
|
||||
#ifndef _RTP_VIDEO_RECEIVER_H_
|
||||
#define _RTP_VIDEO_RECEIVER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
#include "fec_decoder.h"
|
||||
#include "io_statistics.h"
|
||||
#include "receive_side_congestion_controller.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "rtcp_receiver_report.h"
|
||||
#include "rtp_codec.h"
|
||||
#include "rtp_statistics.h"
|
||||
#include "thread_base.h"
|
||||
#include "video_frame.h"
|
||||
|
||||
class RtpVideoReceiver : public ThreadBase {
|
||||
public:
|
||||
RtpVideoReceiver();
|
||||
RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics);
|
||||
virtual ~RtpVideoReceiver();
|
||||
|
||||
public:
|
||||
void InsertRtpPacket(RtpPacket& rtp_packet);
|
||||
|
||||
void SetSendDataFunc(std::function<int(const char*, size_t)> data_send_func);
|
||||
|
||||
void SetOnReceiveCompleteFrame(
|
||||
std::function<void(VideoFrame&)> on_receive_complete_frame) {
|
||||
on_receive_complete_frame_ = on_receive_complete_frame;
|
||||
}
|
||||
|
||||
private:
|
||||
void ProcessAv1RtpPacket(RtpPacket& rtp_packet);
|
||||
bool CheckIsAv1FrameCompleted(RtpPacket& rtp_packet);
|
||||
|
||||
private:
|
||||
void ProcessH264RtpPacket(RtpPacket& rtp_packet);
|
||||
bool CheckIsH264FrameCompleted(RtpPacket& rtp_packet);
|
||||
|
||||
private:
|
||||
bool CheckIsTimeSendRR();
|
||||
int SendRtcpRR(RtcpReceiverReport& rtcp_rr);
|
||||
|
||||
void SendCombinedRtcpPacket(std::vector<std::unique_ptr<RtcpPacket>> packets);
|
||||
|
||||
private:
|
||||
bool Process() override;
|
||||
void RtcpThread();
|
||||
|
||||
private:
|
||||
std::map<uint16_t, RtpPacket> incomplete_frame_list_;
|
||||
uint8_t* nv12_data_ = nullptr;
|
||||
std::function<void(VideoFrame&)> on_receive_complete_frame_ = nullptr;
|
||||
uint32_t last_complete_frame_ts_ = 0;
|
||||
RingBuffer<VideoFrame> compelete_video_frame_queue_;
|
||||
|
||||
private:
|
||||
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
||||
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
||||
uint32_t last_recv_bytes_ = 0;
|
||||
uint32_t total_rtp_packets_recv_ = 0;
|
||||
uint32_t total_rtp_payload_recv_ = 0;
|
||||
|
||||
uint32_t last_send_rtcp_rr_packet_ts_ = 0;
|
||||
std::function<int(const char*, size_t)> data_send_func_ = nullptr;
|
||||
|
||||
private:
|
||||
bool fec_enable_ = false;
|
||||
FecDecoder fec_decoder_;
|
||||
uint64_t last_packet_ts_ = 0;
|
||||
// std::map<uint16_t, RtpPacket> incomplete_fec_frame_list_;
|
||||
// std::map<uint32_t, std::map<uint16_t, RtpPacket>> fec_source_symbol_list_;
|
||||
// std::map<uint32_t, std::map<uint16_t, RtpPacket>> fec_repair_symbol_list_;
|
||||
std::set<uint64_t> incomplete_fec_frame_list_;
|
||||
std::map<uint64_t, std::map<uint16_t, RtpPacket>> incomplete_fec_packet_list_;
|
||||
|
||||
private:
|
||||
std::thread rtcp_thread_;
|
||||
std::mutex rtcp_mtx_;
|
||||
std::condition_variable rtcp_cv_;
|
||||
std::chrono::steady_clock::time_point last_send_rtcp_rr_ts_;
|
||||
std::atomic<bool> send_rtcp_rr_triggered_ = false;
|
||||
std::atomic<bool> rtcp_stop_ = false;
|
||||
int rtcp_rr_interval_ms_ = 5000;
|
||||
int rtcp_tcc_interval_ms_ = 200;
|
||||
|
||||
private:
|
||||
ReceiveSideCongestionController receive_side_congestion_controller_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user