优化时间戳覆盖逻辑:#148

This commit is contained in:
xiongziliang 2019-11-29 09:54:48 +08:00
parent bf70a01f6a
commit c42ee1dc5d
4 changed files with 8 additions and 4 deletions

View File

@ -60,8 +60,11 @@ void Stamp::revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out,
//pts和dts的差值 //pts和dts的差值
int pts_dts_diff = pts - dts; int pts_dts_diff = pts - dts;
//相对时间戳 if(_last_dts != dts){
_relativeStamp += deltaStamp(modifyStamp ? _ticker.elapsedTime() : dts); //时间戳发生变更
_relativeStamp += deltaStamp(modifyStamp ? _ticker.elapsedTime() : dts);
_last_dts = dts;
}
dts_out = _relativeStamp; dts_out = _relativeStamp;
//////////////以下是播放时间戳的计算////////////////// //////////////以下是播放时间戳的计算//////////////////

View File

@ -84,6 +84,7 @@ public:
int64_t getRelativeStamp() const ; int64_t getRelativeStamp() const ;
private: private:
int64_t _relativeStamp = 0; int64_t _relativeStamp = 0;
int64_t _last_dts = -1;
SmoothTicker _ticker; SmoothTicker _ticker;
}; };

View File

@ -493,7 +493,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
GET_CONFIG(bool,rtmp_modify_stamp,Rtmp::kModifyStamp); GET_CONFIG(bool,rtmp_modify_stamp,Rtmp::kModifyStamp);
if(rtmp_modify_stamp){ if(rtmp_modify_stamp){
int64_t dts_out; int64_t dts_out;
_stamp[chunkData.typeId % 2].revise(0, 0, dts_out, dts_out, true); _stamp[chunkData.typeId % 2].revise(chunkData.timeStamp, chunkData.timeStamp, dts_out, dts_out, true);
chunkData.timeStamp = dts_out; chunkData.timeStamp = dts_out;
} }
if(!_metadata_got && !chunkData.isCfgFrame()){ if(!_metadata_got && !chunkData.isCfgFrame()){

View File

@ -940,7 +940,7 @@ void RtspSession::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx) {
GET_CONFIG(bool,modify_stamp,Rtsp::kModifyStamp); GET_CONFIG(bool,modify_stamp,Rtsp::kModifyStamp);
if(modify_stamp){ if(modify_stamp){
int64_t dts_out; int64_t dts_out;
_stamp[trackidx].revise(0, 0, dts_out, dts_out, true); _stamp[trackidx].revise(rtppt->timeStamp, rtppt->timeStamp, dts_out, dts_out, true);
rtppt->timeStamp = dts_out; rtppt->timeStamp = dts_out;
} }
_pushSrc->onWrite(rtppt, false); _pushSrc->onWrite(rtppt, false);