From 2fa539807370c4bcfca9801bde1dd2fdd95ba113 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 27 Aug 2026 22:54:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwebrtc=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E6=97=B6=E6=8F=92=E5=85=A5sps=20pps=20rtp=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcPlayer.cpp | 12 ++++++------ webrtc/WebRtcPlayer.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/webrtc/WebRtcPlayer.cpp b/webrtc/WebRtcPlayer.cpp index 4f11f17d..964b947b 100644 --- a/webrtc/WebRtcPlayer.cpp +++ b/webrtc/WebRtcPlayer.cpp @@ -224,7 +224,7 @@ void WebRtcPlayer::onStartWebRTC() { if (strong_self->_send_config_frames_once && !pkt->empty()) { const auto &first_rtp = pkt->front(); - strong_self->sendConfigFrames(first_rtp->getSeq(), first_rtp->sample_rate, first_rtp->getStamp(), first_rtp->ntp_stamp); + strong_self->sendConfigFrames(first_rtp); strong_self->_send_config_frames_once = false; } @@ -297,7 +297,7 @@ void WebRtcPlayer::onRtcConfigure(RtcConfigure &configure) const { configure.setPlayRtspInfo(playSrc->getSdp()); } -void WebRtcPlayer::sendConfigFrames(uint32_t before_seq, uint32_t sample_rate, uint32_t timestamp, uint64_t ntp_timestamp) { +void WebRtcPlayer::sendConfigFrames(const RtpPacket::Ptr &packet) { auto play_src = _play_src.lock(); if (!play_src) { return; @@ -322,15 +322,15 @@ void WebRtcPlayer::sendConfigFrames(uint32_t before_seq, uint32_t sample_rate, u } GET_CONFIG(uint32_t, video_mtu, Rtp::kVideoMtuSize); - encoder->setRtpInfo(0, video_mtu, sample_rate, 0, 0, 0); + encoder->setRtpInfo(packet->getSSRC(), video_mtu, packet->sample_rate, packet->getHeader()->pt, packet->data()[1], packet->track_index); - auto seq = before_seq - frames.size(); + auto seq = packet->getSeq() - frames.size(); for (const auto &frame : frames) { auto rtp = encoder->getRtpInfo().makeRtp(TrackVideo, frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize(), false, 0); auto header = rtp->getHeader(); header->seq = htons(seq++); - header->stamp = htonl(timestamp); - rtp->ntp_stamp = ntp_timestamp; + header->stamp = htonl(packet->getStamp()); + rtp->ntp_stamp = packet->getStampMS(true); onSendRtp(rtp, false); } } diff --git a/webrtc/WebRtcPlayer.h b/webrtc/WebRtcPlayer.h index 4e47b8ff..9ae049c1 100644 --- a/webrtc/WebRtcPlayer.h +++ b/webrtc/WebRtcPlayer.h @@ -138,7 +138,7 @@ protected: private: WebRtcPlayer(const toolkit::EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src, const MediaInfo &info); - void sendConfigFrames(uint32_t before_seq, uint32_t sample_rate, uint32_t timestamp, uint64_t ntp_timestamp); + void sendConfigFrames(const RtpPacket::Ptr &packet); private: // 媒体相关元数据 [AUTO-TRANSLATED:f4cf8045]