mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
优化时间戳覆盖逻辑:#148
This commit is contained in:
parent
bf70a01f6a
commit
c42ee1dc5d
@ -60,8 +60,11 @@ void Stamp::revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out,
|
||||
//pts和dts的差值
|
||||
int pts_dts_diff = pts - dts;
|
||||
|
||||
//相对时间戳
|
||||
if(_last_dts != dts){
|
||||
//时间戳发生变更
|
||||
_relativeStamp += deltaStamp(modifyStamp ? _ticker.elapsedTime() : dts);
|
||||
_last_dts = dts;
|
||||
}
|
||||
dts_out = _relativeStamp;
|
||||
|
||||
//////////////以下是播放时间戳的计算//////////////////
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
int64_t getRelativeStamp() const ;
|
||||
private:
|
||||
int64_t _relativeStamp = 0;
|
||||
int64_t _last_dts = -1;
|
||||
SmoothTicker _ticker;
|
||||
};
|
||||
|
||||
|
@ -493,7 +493,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
|
||||
GET_CONFIG(bool,rtmp_modify_stamp,Rtmp::kModifyStamp);
|
||||
if(rtmp_modify_stamp){
|
||||
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;
|
||||
}
|
||||
if(!_metadata_got && !chunkData.isCfgFrame()){
|
||||
|
@ -940,7 +940,7 @@ void RtspSession::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx) {
|
||||
GET_CONFIG(bool,modify_stamp,Rtsp::kModifyStamp);
|
||||
if(modify_stamp){
|
||||
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;
|
||||
}
|
||||
_pushSrc->onWrite(rtppt, false);
|
||||
|
Loading…
Reference in New Issue
Block a user