Avoid negative PTS in the RTSP protocol (#3929 #3815)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled

Optimaztion for issue #3815 ffmpeg rtsp pull stream has negative pts
This commit is contained in:
xiongguangjie 2024-09-26 10:59:41 +08:00 committed by GitHub
parent aca39bbfaa
commit de7afaf992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -54,7 +54,9 @@ void RtspMediaSource::onWrite(RtpPacket::Ptr rtp, bool keyPos) {
assert(rtp->type >= 0 && rtp->type < TrackMax);
auto &track = _tracks[rtp->type];
auto stamp = rtp->getStampMS();
if (track) {
bool is_video = rtp->type == TrackVideo;
// 音频总是更新,视频在关键包时更新
if (track && ((keyPos && _have_video && is_video) || (!is_video))) {
track->_seq = rtp->getSeq();
track->_time_stamp = rtp->getStamp() * uint64_t(1000) / rtp->sample_rate;
track->_ssrc = rtp->getSSRC();
@ -77,7 +79,7 @@ void RtspMediaSource::onWrite(RtpPacket::Ptr rtp, bool keyPos) {
regist();
}
}
bool is_video = rtp->type == TrackVideo;
PacketCache<RtpPacket>::inputPacket(stamp, is_video, std::move(rtp), keyPos);
}

View File

@ -833,7 +833,7 @@ void RtspSession::handleReq_Play(const Parser &parser) {
rtp_info << "url=" << track->getControlUrl(_content_base) << ";"
<< "seq=" << track->_seq << ";"
<< "rtptime=" << (int) (track->_time_stamp * (track->_samplerate / 1000)) << ",";
<< "rtptime=" << (int64_t)(track->_time_stamp) * (int64_t)(track->_samplerate/ 1000) << ",";
}
rtp_info.pop_back();