Commit 08386b95 by xiongziliang

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

parent 4642bbeb
...@@ -51,12 +51,9 @@ void DeltaStamp::setPlayBack(bool playback) { ...@@ -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) ...@@ -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;
//////////////以下是播放时间戳的计算////////////////// //////////////以下是播放时间戳的计算//////////////////
......
...@@ -67,8 +67,9 @@ public: ...@@ -67,8 +67,9 @@ public:
* @param pts 输入pts,如果为0则等于dts * @param pts 输入pts,如果为0则等于dts
* @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用
......
...@@ -486,7 +486,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) { ...@@ -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()){
......
...@@ -932,7 +932,7 @@ void RtspSession::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx) { ...@@ -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);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论