覆盖时间戳需要明确参数指定,防止误判

This commit is contained in:
xiongziliang 2019-10-12 22:44:16 +08:00
parent 4642bbeb4c
commit 08386b958c
4 changed files with 8 additions and 10 deletions

View File

@ -51,12 +51,9 @@ void DeltaStamp::setPlayBack(bool playback) {
_playback = playback; _playback = playback;
} }
void Stamp::revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out) { void Stamp::revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out,bool modifyStamp) {
if(!dts && !pts){ if(!pts){
//没有时间戳,我们生成时间戳 //没有播放时间戳,使其赋值为解码时间戳
pts = dts = _ticker.elapsedTime();
}else if(!pts){
//只是没有播放时间戳,使其赋值为解码时间戳
pts = dts; pts = dts;
} }
@ -64,7 +61,7 @@ void Stamp::revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out)
int pts_dts_diff = pts - dts; int pts_dts_diff = pts - dts;
//相对时间戳 //相对时间戳
_relativeStamp += deltaStamp(dts); _relativeStamp += deltaStamp(modifyStamp ? _ticker.elapsedTime() : dts);
dts_out = _relativeStamp; dts_out = _relativeStamp;
//////////////以下是播放时间戳的计算////////////////// //////////////以下是播放时间戳的计算//////////////////

View File

@ -67,8 +67,9 @@ public:
* @param pts pts0dts * @param pts pts0dts
* @param dts_out dts * @param dts_out dts
* @param pts_out pts * @param pts_out pts
* @param modifyStamp
*/ */
void revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out); void revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out,bool modifyStamp = false);
/** /**
* seek用 * seek用

View File

@ -486,7 +486,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); _stamp[chunkData.typeId % 2].revise(0, 0, 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

@ -932,7 +932,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); _stamp[trackidx].revise(0, 0, dts_out, dts_out, true);
rtppt->timeStamp = dts_out; rtppt->timeStamp = dts_out;
} }
_pushSrc->onWrite(rtppt, false); _pushSrc->onWrite(rtppt, false);