From 52f0d89d7a1c6a6f3c1d53bfdc87f935a625fcd7 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 26 Oct 2018 14:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E6=88=B3?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MediaFile/MediaReader.cpp | 4 ++-- src/MediaFile/MediaReader.h | 4 ++-- src/Rtmp/RtmpPlayer.cpp | 2 +- src/Rtsp/RtspPlayer.cpp | 2 +- src/Rtsp/RtspSession.cpp | 6 +++--- src/RtspMuxer/RtspDemuxer.cpp | 15 --------------- 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/MediaFile/MediaReader.cpp b/src/MediaFile/MediaReader.cpp index 3200e5b5..db58eb36 100644 --- a/src/MediaFile/MediaReader.cpp +++ b/src/MediaFile/MediaReader.cpp @@ -274,7 +274,7 @@ inline MP4SampleId MediaReader::getAudioSampleId(int iTimeInc) { audio_current = MAX(0,MIN(_audio_num_samples,audio_current)); return audio_current; } -inline void MediaReader::setSeekTime(int iSeekTime){ +inline void MediaReader::setSeekTime(uint32_t iSeekTime){ _iSeekTime = MAX(0, MIN(iSeekTime,_iDuration)); _ticker.resetTime(); if (_audio_trId != MP4_INVALID_TRACK_ID) { @@ -288,7 +288,7 @@ inline void MediaReader::setSeekTime(int iSeekTime){ inline uint32_t MediaReader::getVideoCurrentTime(){ return (double)_video_current * _video_ms /_video_num_samples; } -void MediaReader::seek(int iSeekTime,bool bReStart){ +void MediaReader::seek(uint32_t iSeekTime,bool bReStart){ lock_guard lck(_mtx); if(iSeekTime == 0 || _video_trId == MP4_INVALID_TRACK_ID){ setSeekTime(iSeekTime); diff --git a/src/MediaFile/MediaReader.h b/src/MediaFile/MediaReader.h index b1428a69..e2263f2b 100644 --- a/src/MediaFile/MediaReader.h +++ b/src/MediaFile/MediaReader.h @@ -83,8 +83,8 @@ private: Ticker _alive; recursive_mutex _mtx; - void seek(int iSeekTime,bool bReStart = true); - inline void setSeekTime(int iSeekTime); + void seek(uint32_t iSeekTime,bool bReStart = true); + inline void setSeekTime(uint32_t iSeekTime); inline uint32_t getVideoCurrentTime(); void startReadMP4(); inline MP4SampleId getVideoSampleId(int iTimeInc = 0); diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 91469a5d..62035567 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -339,7 +339,7 @@ void RtmpPlayer::seekToMilliSecond(uint32_t seekMS){ //TraceL << "seek result"; _aNowStampTicker[0].resetTime(); _aNowStampTicker[1].resetTime(); - auto iTimeInc = seekMS - getProgressMilliSecond(); + int iTimeInc = seekMS - getProgressMilliSecond(); for(auto i = 0 ;i < 2 ;i++){ _aiFistStamp[i] = _aiNowStamp[i] + iTimeInc; _aiNowStamp[i] = _aiFistStamp[i]; diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 110233e0..18bc0bf1 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -435,7 +435,7 @@ bool RtspPlayer::sendPause(bool bPause,uint32_t seekMS){ //修改时间轴 _aNowStampTicker[0].resetTime(); _aNowStampTicker[1].resetTime(); - auto iTimeInc = seekMS - getProgressMilliSecond(); + int iTimeInc = seekMS - getProgressMilliSecond(); for(unsigned int i = 0 ;i < _aTrackInfo.size() ;i++){ _aiFistStamp[i] = _aiNowStamp[i] + iTimeInc; _aiNowStamp[i] = _aiFistStamp[i]; diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 2b848276..b2cb9a9e 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -720,9 +720,9 @@ bool RtspSession::handleReq_Play() { if (strStart == "now") { strStart = "0"; } - auto iStartTime = atof(strStart.data()); - InfoL << "rtsp seekTo:" << iStartTime; - pMediaSrc->seekTo(iStartTime * 1000); + auto iStartTime = 1000 * atof(strStart.data()); + InfoL << "rtsp seekTo(ms):" << iStartTime; + pMediaSrc->seekTo(iStartTime); iStamp = pMediaSrc->getStamp(); }else if(pMediaSrc->getRing()->readerCount() == 1){ //第一个消费者 diff --git a/src/RtspMuxer/RtspDemuxer.cpp b/src/RtspMuxer/RtspDemuxer.cpp index 26bec3c1..e1672325 100644 --- a/src/RtspMuxer/RtspDemuxer.cpp +++ b/src/RtspMuxer/RtspDemuxer.cpp @@ -35,21 +35,6 @@ using namespace std; namespace mediakit { -static int getTimeInSDP(const string &sdp) { - auto strRange = FindField(sdp.data(), "a=range:npt=", "\r\n"); - strRange.append(" "); - auto iPos = strRange.find('-'); - if (iPos == string::npos) { - return 0; - } - auto strStart = strRange.substr(0, iPos); - auto strEnd = strRange.substr(iPos + 1); - strEnd.pop_back(); - if (strStart == "now") { - strStart = "0"; - } - return atof(strEnd.data()) - atof(strStart.data()); -} RtspDemuxer::RtspDemuxer(const string& sdp) { loadSdp(SdpAttr(sdp)); }