[fix] fix h264 frame assember

This commit is contained in:
dijunkun
2025-03-28 15:16:41 +08:00
parent 0d9d3c5eca
commit 506ded3027
2 changed files with 29 additions and 19 deletions

View File

@@ -7,7 +7,7 @@
#include "nack.h"
#include "rtcp_sender.h"
#define SAVE_RTP_RECV_STREAM
// #define SAVE_RTP_RECV_STREAM
#define NV12_BUFFER_SIZE (1280 * 720 * 3 / 2)
#define RTCP_RR_INTERVAL 1000
@@ -200,6 +200,18 @@ void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) {
if (rtp_packet.Buffer().data() != nullptr && rtp_packet.Size() > 0 &&
rtp_packet_h264->Build(rtp_packet.Buffer().data(), rtp_packet.Size())) {
rtp_packet_h264->GetFrameHeaderInfo();
rtp::NAL_UNIT_TYPE nalu_type = rtp_packet_h264->NalUnitType();
if (rtp::NAL_UNIT_TYPE::NALU == nalu_type) {
ReceivedFrame received_frame(rtp_packet_h264->Payload(),
rtp_packet_h264->PayloadSize());
received_frame.SetReceivedTimestamp(clock_->CurrentTime().us());
received_frame.SetCapturedTimestamp(
(static_cast<int64_t>(rtp_packet_h264->Timestamp()) /
rtp::kMsToRtpTimestamp -
delta_ntp_internal_ms_) *
1000);
compelete_video_frame_queue_.push(received_frame);
} else if (rtp::NAL_UNIT_TYPE::FU_A == nalu_type) {
std::vector<std::unique_ptr<RtpPacketH264>> complete_frame =
h264_frame_assembler_.InsertPacket(std::move(rtp_packet_h264));
if (!complete_frame.empty()) {
@@ -221,12 +233,10 @@ void RtpVideoReceiver::InsertRtpPacket(RtpPacket& rtp_packet) {
1000);
compelete_video_frame_queue_.push(received_frame);
fwrite((unsigned char*)received_frame.Buffer(), 1,
received_frame.Size(), file_rtp_recv_);
delete[] nv12_data_;
}
}
}
// RtpPacketH264 rtp_packet_h264;
// if (rtp_packet_h264.Build(rtp_packet.Buffer().data(), rtp_packet.Size()))

View File

@@ -3,7 +3,7 @@
#include "log.h"
#include "rtc_base/network/sent_packet.h"
#define SAVE_RTP_SENT_STREAM
// #define SAVE_RTP_SENT_STREAM
VideoChannelSend::VideoChannelSend(
std::shared_ptr<SystemClock> clock, std::shared_ptr<IceAgent> ice_agent,