Skip to content

Commit 2144900

Browse files
authored
Merge pull request #1995 from CastagnaIT/seek_preceeding
[Session] Removed SeekTime preceeding
2 parents afe3414 + b63f68c commit 2144900

20 files changed

+31
-36
lines changed

src/Session.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ bool SESSION::CSession::GetNextSample(ISampleReader*& sampleReader)
911911
return false;
912912
}
913913

914-
bool SESSION::CSession::SeekTime(double seekTime, bool preceeding)
914+
bool SESSION::CSession::SeekTime(double seekTime)
915915
{
916916
bool ret{false};
917917

@@ -989,16 +989,15 @@ bool SESSION::CSession::SeekTime(double seekTime, bool preceeding)
989989
};
990990

991991
// Helper lambda to perform seek on adaptive stream segment buffer
992-
auto SeekAdStream = [](CStream& stream, double seekSecs, bool preceeding) -> bool
992+
auto SeekAdStream = [](CStream& stream, double seekSecs) -> bool
993993
{
994994
if (!stream.m_adStream.seek_time(seekSecs))
995995
{
996996
stream.GetReader()->Reset(true);
997997
return false;
998998
}
999-
if (!preceeding)
1000-
stream.GetReader()->Reset(false);
1001999

1000+
stream.GetReader()->Reset(false);
10021001
return true;
10031002
};
10041003

@@ -1023,7 +1022,7 @@ bool SESSION::CSession::SeekTime(double seekTime, bool preceeding)
10231022

10241023
const double seekSecs = static_cast<double>(seekTimeCorrected) / STREAM_TIME_BASE;
10251024

1026-
if (!SeekAdStream(*m_timingStream, seekSecs, preceeding))
1025+
if (!SeekAdStream(*m_timingStream, seekSecs))
10271026
return false;
10281027

10291028
if (!CheckReaderRunning(*m_timingStream))
@@ -1063,7 +1062,7 @@ bool SESSION::CSession::SeekTime(double seekTime, bool preceeding)
10631062
{
10641063
const double seekSecs{static_cast<double>(seekTimeCorrected - ptsDiff) / STREAM_TIME_BASE};
10651064

1066-
if (!SeekAdStream(*stream, seekSecs, preceeding))
1065+
if (!SeekAdStream(*stream, seekSecs))
10671066
continue;
10681067
}
10691068

@@ -1072,7 +1071,7 @@ bool SESSION::CSession::SeekTime(double seekTime, bool preceeding)
10721071

10731072
streamReader->SetPTSDiff(ptsDiff);
10741073

1075-
if (!streamReader->TimeSeek(seekTimeCorrected, preceeding))
1074+
if (!streamReader->TimeSeek(seekTimeCorrected))
10761075
{
10771076
streamReader->Reset(true);
10781077
}
@@ -1090,7 +1089,6 @@ bool SESSION::CSession::SeekTime(double seekTime, bool preceeding)
10901089
{
10911090
seekTime = destTime;
10921091
seekTimeCorrected = streamReader->PTS();
1093-
preceeding = false;
10941092
}
10951093
ret = true;
10961094
}

src/Session.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,10 @@ class ATTR_DLL_LOCAL CSession : public adaptive::AdaptiveStreamObserver
149149

150150
/*! \brief Seek streams and readers to a specified time
151151
* \param seekTime The seek time in seconds
152-
* \param preceeding True to seek to keyframe preceeding seektime,
153-
* false to clamp to the start of the next segment
154152
* \return True if seeking to another chapter or 1+ streams successfully
155153
* seeked, false on error or no streams seeked
156154
*/
157-
bool SeekTime(double seekTime, bool preceeding = true);
155+
bool SeekTime(double seekTime);
158156

159157
/*! \brief Report if the current content is dynamic/live
160158
* \return True if live, false if VOD

src/demuxers/ADTSReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ bool ADTSReader::GetInformation(kodi::addon::InputstreamInfo& info)
413413
}
414414

415415
// We assume that m_startpos is the current I-Frame position
416-
bool ADTSReader::SeekTime(uint64_t timeInTs, bool preceeding)
416+
bool ADTSReader::SeekTime(uint64_t timeInTs)
417417
{
418418
while (m_pts < timeInTs)
419419
if (!ReadPacket())

src/demuxers/ADTSReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ATTR_DLL_LOCAL ADTSReader
102102
virtual ~ADTSReader();
103103

104104
void Reset();
105-
bool SeekTime(uint64_t timeInTs, bool preceeding);
105+
bool SeekTime(uint64_t timeInTs);
106106

107107
bool GetInformation(kodi::addon::InputstreamInfo& info);
108108
bool ReadPacket();

src/demuxers/TSReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ bool TSReader::GetInformation(kodi::addon::InputstreamInfo& info)
206206
}
207207

208208
// We assume that m_startpos is the current I-Frame position
209-
bool TSReader::SeekTime(uint64_t timeInTs, bool preceeding)
209+
bool TSReader::SeekTime(uint64_t timeInTs)
210210
{
211211
bool hasVideo(false);
212212
//look if we have video
@@ -218,15 +218,15 @@ bool TSReader::SeekTime(uint64_t timeInTs, bool preceeding)
218218
}
219219

220220
uint64_t lastRecovery(static_cast<uint64_t>(m_startPos));
221-
while (m_pkt.pts == PTS_UNSET || !preceeding || static_cast<uint64_t>(m_pkt.pts) < timeInTs)
221+
while (m_pkt.pts == PTS_UNSET || static_cast<uint64_t>(m_pkt.pts) < timeInTs)
222222
{
223223
uint64_t thisFrameStart(m_AVContext->GetRecoveryPos());
224224
if (!ReadPacket())
225225
return false;
226226
if (!hasVideo || m_pkt.recoveryPoint || thisFrameStart >= m_startPos)
227227
{
228228
lastRecovery = thisFrameStart;
229-
if (!preceeding && static_cast<uint64_t>(m_pkt.pts) >= timeInTs)
229+
if (static_cast<uint64_t>(m_pkt.pts) >= timeInTs)
230230
break;
231231
}
232232
}

src/demuxers/TSReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ATTR_DLL_LOCAL TSReader : public TSDemux::TSDemuxer
3030

3131
void Reset(bool resetPackets = true);
3232
bool StartStreaming(AP4_UI32 typeMask);
33-
bool SeekTime(uint64_t timeInTs, bool preceeding);
33+
bool SeekTime(uint64_t timeInTs);
3434

3535
bool GetInformation(kodi::addon::InputstreamInfo& info);
3636
bool ReadPacket(bool streamInfo = false);

src/demuxers/WebmReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ bool WebmReader::GetInformation(kodi::addon::InputstreamInfo& info)
174174
}
175175

176176
// We assume that m_startpos is the current I-Frame position
177-
bool WebmReader::SeekTime(uint64_t timeInTs, bool preceeding)
177+
bool WebmReader::SeekTime(uint64_t timeInTs)
178178
{
179179
Reset();
180180
return true;

src/demuxers/WebmReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ATTR_DLL_LOCAL WebmReader : public webm::Callback
4141
bool Initialize();
4242

4343
void Reset();
44-
bool SeekTime(uint64_t timeInTs, bool preceeding);
44+
bool SeekTime(uint64_t timeInTs);
4545

4646
bool GetInformation(kodi::addon::InputstreamInfo& info);
4747
bool ReadPacket();

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ DEMUX_PACKET* CInputStreamAdaptive::DemuxRead(void)
304304
if (~m_failedSeekTime)
305305
{
306306
LOG::Log(LOGDEBUG, "Seeking to last failed seek position (%d)", m_failedSeekTime);
307-
m_session->SeekTime(static_cast<double>(m_failedSeekTime) * 0.001f, false);
307+
m_session->SeekTime(static_cast<double>(m_failedSeekTime) * 0.001f);
308308
m_failedSeekTime = ~0;
309309
}
310310

@@ -430,7 +430,7 @@ bool CInputStreamAdaptive::PosTime(int ms)
430430

431431
LOG::Log(LOGINFO, "PosTime (%d)", ms);
432432

433-
bool ret = m_session->SeekTime(static_cast<double>(ms) * 0.001f, false);
433+
bool ret = m_session->SeekTime(static_cast<double>(ms) * 0.001f);
434434
m_failedSeekTime = ret ? ~0 : ms;
435435

436436
return ret;

src/samplereader/ADTSSampleReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ void CADTSSampleReader::Reset(bool bEOS)
5555
m_eos = bEOS;
5656
}
5757

58-
bool CADTSSampleReader::TimeSeek(uint64_t pts, bool preceeding)
58+
bool CADTSSampleReader::TimeSeek(uint64_t pts)
5959
{
6060
AP4_UI64 seekPos{(pts * 9) / 100};
61-
if (ADTSReader::SeekTime(seekPos, preceeding))
61+
if (ADTSReader::SeekTime(seekPos))
6262
{
6363
m_started = true;
6464
return AP4_SUCCEEDED(ReadSample());

0 commit comments

Comments
 (0)