mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
86 lines
2.4 KiB
C++
86 lines
2.4 KiB
C++
/*
|
|
* @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 "ice_agent.h"
|
|
#include "rtp_packetizer.h"
|
|
#include "rtp_video_sender.h"
|
|
#include "transport_feedback_adapter.h"
|
|
#include "video_frame_wrapper.h"
|
|
|
|
class VideoChannelSend {
|
|
public:
|
|
VideoChannelSend();
|
|
VideoChannelSend(std::shared_ptr<SystemClock> clock,
|
|
std::shared_ptr<IceAgent> ice_agent,
|
|
std::shared_ptr<IOStatistics> ice_io_statistics,
|
|
std::function<void(const webrtc::RtpPacketToSend& packet)>
|
|
on_sent_packet_func_);
|
|
~VideoChannelSend();
|
|
|
|
void SetEnqueuePacketsFunc(
|
|
std::function<
|
|
void(std::vector<std::unique_ptr<webrtc::RtpPacketToSend>>&)>
|
|
enqueue_packets_func);
|
|
|
|
std::vector<std::unique_ptr<RtpPacket>> GeneratePadding(
|
|
uint32_t payload_size, int64_t capture_timestamp_ms);
|
|
|
|
int64_t GetTransportSeqAndIncrement() {
|
|
int64_t transport_seq = rtp_video_sender_->GetTransportSequenceNumber();
|
|
rtp_video_sender_->IncrementTransportSequenceNumber();
|
|
return transport_seq;
|
|
}
|
|
|
|
public:
|
|
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
|
void Destroy();
|
|
|
|
uint32_t GetSsrc() {
|
|
if (rtp_video_sender_) {
|
|
return rtp_video_sender_->GetSsrc();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int SendVideo(std::shared_ptr<VideoFrameWrapper> encoded_frame);
|
|
|
|
void OnCongestionControlFeedback(
|
|
Timestamp recv_ts,
|
|
const webrtc::rtcp::CongestionControlFeedback& feedback);
|
|
|
|
void OnReceiverReport(const ReceiverReport& receiver_report) {
|
|
if (rtp_video_sender_) {
|
|
rtp_video_sender_->OnReceiverReport(receiver_report);
|
|
}
|
|
}
|
|
|
|
private:
|
|
void PostUpdates(webrtc::NetworkControlUpdate update);
|
|
void UpdateControlState();
|
|
void UpdateCongestedState();
|
|
|
|
private:
|
|
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
|
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
|
std::unique_ptr<RtpPacketizer> rtp_packetizer_ = nullptr;
|
|
std::unique_ptr<RtpVideoSender> rtp_video_sender_ = nullptr;
|
|
|
|
std::function<void(const webrtc::RtpPacketToSend& packet)>
|
|
on_sent_packet_func_ = nullptr;
|
|
|
|
private:
|
|
std::shared_ptr<SystemClock> clock_;
|
|
};
|
|
|
|
#endif |