[fix] fix padding packets building

This commit is contained in:
dijunkun
2025-03-17 10:28:58 +08:00
parent bd65d87137
commit 5c598be51d
4 changed files with 18 additions and 15 deletions

View File

@@ -412,7 +412,6 @@ void PacingController::ProcessPackets() {
PacedPacketInfo pacing_info; PacedPacketInfo pacing_info;
DataSize recommended_probe_size = DataSize::Zero(); DataSize recommended_probe_size = DataSize::Zero();
bool is_probing = prober_.is_probing(); bool is_probing = prober_.is_probing();
LOG_WARN("is probing");
if (is_probing) { if (is_probing) {
// Probe timing is sensitive, and handled explicitly by BitrateProber, so // Probe timing is sensitive, and handled explicitly by BitrateProber, so
// use actual send time rather than target. // use actual send time rather than target.
@@ -474,7 +473,7 @@ void PacingController::ProcessPackets() {
transport_overhead_per_packet_; transport_overhead_per_packet_;
} }
LOG_ERROR("Send packet_size {}", rtp_packet->Size()); // LOG_ERROR("Send packet_size {}", rtp_packet->Size());
packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); packet_sender_->SendPacket(std::move(rtp_packet), pacing_info);
for (auto& packet : packet_sender_->FetchFec()) { for (auto& packet : packet_sender_->FetchFec()) {
EnqueuePacket(std::move(packet)); EnqueuePacket(std::move(packet));

View File

@@ -289,7 +289,8 @@ std::vector<std::unique_ptr<RtpPacket>> RtpPacketizerH264::BuildPadding(
// Add padding bytes // Add padding bytes
uint32_t padding_size = current_payload_size; uint32_t padding_size = current_payload_size;
rtp_packet_frame_.insert(rtp_packet_frame_.end(), padding_size - 1, 0); rtp_packet_frame_.insert(rtp_packet_frame_.end(), padding_size, 0);
rtp_packet_frame_.push_back(padding_size);
if (use_rtp_packet_to_send) { if (use_rtp_packet_to_send) {
std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet = std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet =

View File

@@ -183,7 +183,6 @@ int IceTransportController::SendVideo(const XVideoFrame* video_frame) {
[this](std::shared_ptr<VideoFrameWrapper> encoded_frame) -> int { [this](std::shared_ptr<VideoFrameWrapper> encoded_frame) -> int {
if (video_channel_send_) { if (video_channel_send_) {
video_channel_send_->SendVideo(encoded_frame); video_channel_send_->SendVideo(encoded_frame);
LOG_WARN("SendVideo rtp packets");
} }
return 0; return 0;

View File

@@ -72,17 +72,21 @@ void PacketSender::SetPacingRates(webrtc::DataRate pacing_rate,
void PacketSender::EnqueuePackets( void PacketSender::EnqueuePackets(
std::vector<std::unique_ptr<webrtc::RtpPacketToSend>> packets) { std::vector<std::unique_ptr<webrtc::RtpPacketToSend>> packets) {
task_queue_.PostTask([this, packets = std::move(packets)]() mutable { webrtc::PacedPacketInfo cluster_info;
for (auto &packet : packets) { for (auto &packet : packets) {
size_t packet_size = packet->payload_size() + packet->padding_size(); SendPacket(std::move(packet), cluster_info);
if (include_overhead_) { }
packet_size += packet->headers_size(); // task_queue_.PostTask([this, packets = std::move(packets)]() mutable {
} // for (auto &packet : packets) {
packet_size_.Apply(1, packet_size); // size_t packet_size = packet->payload_size() + packet->padding_size();
pacing_controller_.EnqueuePacket(std::move(packet)); // if (include_overhead_) {
} // packet_size += packet->headers_size();
MaybeProcessPackets(webrtc::Timestamp::MinusInfinity()); // }
}); // packet_size_.Apply(1, packet_size);
// pacing_controller_.EnqueuePacket(std::move(packet));
// }
// MaybeProcessPackets(webrtc::Timestamp::MinusInfinity());
// });
} }
void PacketSender::RemovePacketsForSsrc(uint32_t ssrc) { void PacketSender::RemovePacketsForSsrc(uint32_t ssrc) {