[feat] update rtp packet history module

This commit is contained in:
dijunkun
2025-02-17 17:05:45 +08:00
parent 1ef7c536f1
commit 71b9c78dd5
23 changed files with 174 additions and 46 deletions

View File

@@ -11,8 +11,12 @@
RtpVideoSender::RtpVideoSender() {}
RtpVideoSender::RtpVideoSender(std::shared_ptr<IOStatistics> io_statistics)
: ssrc_(GenerateUniqueSsrc()), io_statistics_(io_statistics) {
RtpVideoSender::RtpVideoSender(std::shared_ptr<webrtc::Clock> clock,
std::shared_ptr<IOStatistics> io_statistics)
: ssrc_(GenerateUniqueSsrc()),
clock_(clock),
io_statistics_(io_statistics),
rtp_packet_history_(std::make_unique<RtpPacketHistory>(clock)) {
SetPeriod(std::chrono::milliseconds(5));
#ifdef SAVE_RTP_SENT_STREAM
file_rtp_sent_ = fopen("rtp_sent_stream.h264", "w+b");
@@ -67,11 +71,12 @@ int RtpVideoSender::SendRtpPacket(std::shared_ptr<RtpPacket> rtp_packet) {
}
if (on_sent_packet_func_) {
webrtc::RtpPacketToSend* rtp_packet_to_send =
dynamic_cast<webrtc::RtpPacketToSend*>(rtp_packet.get());
std::shared_ptr<webrtc::RtpPacketToSend> rtp_packet_to_send =
std::dynamic_pointer_cast<webrtc::RtpPacketToSend>(rtp_packet);
rtp_packet_to_send->set_transport_sequence_number(transport_seq_++);
rtp_packet_to_send->set_packet_type(webrtc::RtpPacketMediaType::kVideo);
on_sent_packet_func_(*rtp_packet_to_send);
rtp_packet_history_->AddPacket(rtp_packet_to_send, clock_->CurrentTime());
}
if (0 != data_send_func_((const char*)rtp_packet->Buffer().data(),