vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Jan 20 20:34:45 2021 +0100| [704c48efa653154d1373bcdb380b033db804d7dc] | committer: Francois Cartegnie
demux: adaptive: handle position change through event > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=704c48efa653154d1373bcdb380b033db804d7dc --- modules/demux/adaptive/SegmentTracker.cpp | 1 + modules/demux/adaptive/Streams.cpp | 64 +++++++++++++++++-------------- modules/demux/adaptive/Streams.hpp | 1 + 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp index 3d9be10f80..ffe4418212 100644 --- a/modules/demux/adaptive/SegmentTracker.cpp +++ b/modules/demux/adaptive/SegmentTracker.cpp @@ -413,6 +413,7 @@ void SegmentTracker::setPosition(const Position &pos, bool restarted) initializing = true; current = Position(); next = pos; + notify(PositionChangedEvent()); } SegmentTracker::Position SegmentTracker::getStartPosition() diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp index 04cfc39f87..3928a01d34 100644 --- a/modules/demux/adaptive/Streams.cpp +++ b/modules/demux/adaptive/Streams.cpp @@ -141,6 +141,37 @@ void AbstractStream::prepareRestart(bool b_discontinuity) } } +bool AbstractStream::resetForNewPosition(vlc_tick_t seekMediaTime) +{ + // clear eof flag before restartDemux() to prevent readNextBlock() fail + eof = false; + demuxfirstchunk = true; + notfound_sequence = 0; + if(!demuxer || demuxer->needsRestartOnSeek()) /* needs (re)start */ + { + delete currentChunk; + currentChunk = nullptr; + needrestart = false; + + fakeEsOut()->resetTimestamps(); + + fakeEsOut()->setExpectedTimestamp(seekMediaTime); + if( !restartDemux() ) + { + msg_Info(p_realdemux, "Restart demux failed"); + eof = true; + valid = false; + return false; + } + else + { + fakeEsOut()->commandsQueue()->setEOF(false); + } + } + else fakeEsOut()->commandsQueue()->Abort( true ); + return true; +} + void AbstractStream::setLanguage(const std::string &lang) { language = lang; @@ -545,35 +576,6 @@ bool AbstractStream::setPosition(vlc_tick_t time, bool tryonly) bool ret = segmentTracker->setPositionByTime(time, b_needs_restart, tryonly); if(!tryonly && ret) { - // clear eof flag before restartDemux() to prevent readNextBlock() fail - eof = false; - demuxfirstchunk = true; - notfound_sequence = 0; - if(b_needs_restart) - { - if(currentChunk) - delete currentChunk; - currentChunk = nullptr; - needrestart = false; - - fakeEsOut()->resetTimestamps(); - - vlc_tick_t seekMediaTime = segmentTracker->getPlaybackTime(true); - fakeEsOut()->setExpectedTimestamp(seekMediaTime); - if( !restartDemux() ) - { - msg_Info(p_realdemux, "Restart demux failed"); - eof = true; - valid = false; - ret = false; - } - else - { - fakeEsOut()->commandsQueue()->setEOF(false); - } - } - else fakeEsOut()->commandsQueue()->Abort( true ); - // in some cases, media time seek != sent dts // es_out_Control(p_realdemux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, // VLC_TICK_0 + time); @@ -692,6 +694,10 @@ void AbstractStream::trackerEvent(const TrackerEvent &ev) } break; + case TrackerEvent::Type::PositionChange: + resetForNewPosition(segmentTracker->getPlaybackTime(true)); + break; + default: break; } diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp index 54ea4e5b72..2b961416f7 100644 --- a/modules/demux/adaptive/Streams.hpp +++ b/modules/demux/adaptive/Streams.hpp @@ -111,6 +111,7 @@ namespace adaptive virtual bool restartDemux(); virtual void prepareRestart(bool = true); + bool resetForNewPosition(vlc_tick_t); bool discontinuity; bool needrestart; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
