[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

@@ -6,7 +6,7 @@
#include <queue>
#include <set>
#include "clock.h"
#include "api/clock/clock.h"
#include "fec_decoder.h"
#include "io_statistics.h"
#include "nack_requester.h"

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(),

View File

@@ -7,6 +7,7 @@
#include "ringbuffer.h"
#include "rtcp_sender_report.h"
#include "rtp_packet.h"
#include "rtp_packet_history.h"
#include "rtp_packet_to_send.h"
#include "rtp_statistics.h"
#include "thread_base.h"
@@ -14,7 +15,8 @@
class RtpVideoSender : public ThreadBase {
public:
RtpVideoSender();
RtpVideoSender(std::shared_ptr<IOStatistics> io_statistics);
RtpVideoSender(std::shared_ptr<webrtc::Clock> clock,
std::shared_ptr<IOStatistics> io_statistics);
virtual ~RtpVideoSender();
public:
@@ -41,8 +43,10 @@ class RtpVideoSender : public ThreadBase {
private:
uint32_t ssrc_ = 0;
std::shared_ptr<webrtc::Clock> clock_ = nullptr;
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
std::unique_ptr<RtpPacketHistory> rtp_packet_history_ = nullptr;
uint32_t last_send_bytes_ = 0;
uint32_t last_send_rtcp_sr_packet_ts_ = 0;
uint32_t total_rtp_payload_sent_ = 0;