[feat] move rtp packet sender out of channel module

This commit is contained in:
dijunkun
2025-03-13 21:11:20 +08:00
parent 23df1f3b60
commit d2b45b91e7
32 changed files with 681 additions and 266 deletions

View File

@@ -17,7 +17,7 @@ void RtpPacketHistory::SetRtt(webrtc::TimeDelta rtt) {
}
void RtpPacketHistory::AddPacket(
std::shared_ptr<webrtc::RtpPacketToSend> rtp_packet,
std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet,
webrtc::Timestamp send_time) {
RemoveDeadPackets();
const uint16_t rtp_seq_no = rtp_packet->SequenceNumber();
@@ -40,7 +40,7 @@ void RtpPacketHistory::AddPacket(
rtp_packet_history_.emplace_back();
}
rtp_packet_history_[packet_index] = {rtp_packet, send_time,
rtp_packet_history_[packet_index] = {std::move(rtp_packet), send_time,
packets_inserted_++};
}
@@ -79,10 +79,10 @@ void RtpPacketHistory::RemoveDeadPackets() {
}
}
std::shared_ptr<webrtc::RtpPacketToSend> RtpPacketHistory::RemovePacket(
std::unique_ptr<webrtc::RtpPacketToSend> RtpPacketHistory::RemovePacket(
int packet_index) {
// Move the packet out from the StoredPacket container.
std::shared_ptr<webrtc::RtpPacketToSend> rtp_packet =
std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet =
std::move(rtp_packet_history_[packet_index].rtp_packet);
if (packet_index == 0) {
while (!rtp_packet_history_.empty() &&

View File

@@ -31,25 +31,27 @@ class RtpPacketHistory {
public:
void SetRtt(webrtc::TimeDelta rtt);
void AddPacket(std::shared_ptr<webrtc::RtpPacketToSend> rtp_packet,
void AddPacket(std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet,
webrtc::Timestamp send_time);
void RemoveDeadPackets();
private:
std::shared_ptr<webrtc::RtpPacketToSend> RemovePacket(int packet_index);
std::unique_ptr<webrtc::RtpPacketToSend> RemovePacket(int packet_index);
int GetPacketIndex(uint16_t sequence_number) const;
private:
struct RtpPacketToSendInfo {
RtpPacketToSendInfo() = default;
RtpPacketToSendInfo(std::shared_ptr<webrtc::RtpPacketToSend> rtp_packet,
RtpPacketToSendInfo(std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet,
webrtc::Timestamp send_time, uint64_t index)
: rtp_packet(rtp_packet), send_time(send_time), index(index) {}
: rtp_packet(std::move(rtp_packet)),
send_time(send_time),
index(index) {}
RtpPacketToSendInfo(RtpPacketToSendInfo&&) = default;
RtpPacketToSendInfo& operator=(RtpPacketToSendInfo&&) = default;
~RtpPacketToSendInfo() = default;
std::shared_ptr<webrtc::RtpPacketToSend> rtp_packet;
std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet;
webrtc::Timestamp send_time = webrtc::Timestamp::Zero();
uint64_t index;
};