修复webrtc播放时插入sps pps rtp相关字段不正确的bug

This commit is contained in:
xiongziliang
2026-08-27 22:54:11 +08:00
parent 2049df6d1a
commit 2fa5398073
2 changed files with 7 additions and 7 deletions

View File

@@ -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);
}
}

View File

@@ -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]