[vlc-commits] demux: adaptive: split live delay from max buffer
Francois Cartegnie
git at videolan.org
Mon Mar 30 14:35:40 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Mar 30 12:20:16 2020 +0200| [d7ec70dab5739540242482cb17e1c32e1b517b20] | committer: Francois Cartegnie
demux: adaptive: split live delay from max buffer
min buffer <= max buffer <= live offset
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d7ec70dab5739540242482cb17e1c32e1b517b20
---
modules/demux/adaptive/PlaylistManager.cpp | 2 +-
modules/demux/adaptive/logic/BufferingLogic.cpp | 71 +++++++++++--------------
modules/demux/adaptive/logic/BufferingLogic.hpp | 8 +--
3 files changed, 37 insertions(+), 44 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 95b893c661..c12aa3f474 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -841,7 +841,7 @@ AbstractBufferingLogic *PlaylistManager::createBufferingLogic() const
bl->setUserLiveDelay(VLC_TICK_FROM_MS(v));
v = var_InheritInteger(p_demux, "adaptive-maxbuffer");
if(v)
- bl->setUserMinBuffering(VLC_TICK_FROM_MS(v));
+ bl->setUserMaxBuffering(VLC_TICK_FROM_MS(v));
}
return bl;
}
diff --git a/modules/demux/adaptive/logic/BufferingLogic.cpp b/modules/demux/adaptive/logic/BufferingLogic.cpp
index 6bece82156..9153c298ba 100644
--- a/modules/demux/adaptive/logic/BufferingLogic.cpp
+++ b/modules/demux/adaptive/logic/BufferingLogic.cpp
@@ -104,42 +104,47 @@ vlc_tick_t DefaultBufferingLogic::getMinBuffering(const AbstractPlaylist *p) con
{
if(isLowLatency(p))
return BUFFERING_LOWEST_LIMIT;
- else if(userMinBuffering)
- return std::max(BUFFERING_LOWEST_LIMIT, userMinBuffering);
- else if(p->getMinBuffering())
- return std::max(BUFFERING_LOWEST_LIMIT, p->getMinBuffering());
- else
- return DEFAULT_MIN_BUFFERING;
+
+ vlc_tick_t buffering = userMinBuffering ? userMinBuffering
+ : DEFAULT_MIN_BUFFERING;
+ if(p->getMinBuffering())
+ buffering = std::max(buffering, p->getMinBuffering());
+ return std::max(buffering, BUFFERING_LOWEST_LIMIT);
}
vlc_tick_t DefaultBufferingLogic::getMaxBuffering(const AbstractPlaylist *p) const
{
if(isLowLatency(p))
return getMinBuffering(p);
- else if(p->isLive())
- {
- if(userLiveDelay)
- return std::max(getMinBuffering(p), userLiveDelay);
- else
- return std::max(getMinBuffering(p), DEFAULT_LIVE_BUFFERING);
- }
- else
- {
- if(userMaxBuffering)
- return std::max(getMinBuffering(p), userMaxBuffering);
- else if(p->getMaxBuffering())
- return std::max(getMinBuffering(p), p->getMaxBuffering());
- else
- return std::max(getMinBuffering(p), DEFAULT_MAX_BUFFERING);
- }
+
+ vlc_tick_t buffering = userMaxBuffering ? userMaxBuffering
+ : DEFAULT_MAX_BUFFERING;
+ if(p->isLive())
+ buffering = std::min(buffering, getLiveDelay(p));
+ if(p->getMaxBuffering())
+ buffering = std::min(buffering, p->getMaxBuffering());
+ return std::max(buffering, getMinBuffering(p));
+}
+
+vlc_tick_t DefaultBufferingLogic::getLiveDelay(const AbstractPlaylist *p) const
+{
+ if(isLowLatency(p))
+ return getMinBuffering(p);
+ vlc_tick_t delay = userLiveDelay ? userLiveDelay
+ : DEFAULT_LIVE_BUFFERING;
+ if(p->suggestedPresentationDelay.Get())
+ delay = p->suggestedPresentationDelay.Get();
+ if(p->timeShiftBufferDepth.Get())
+ delay = std::min(delay, p->timeShiftBufferDepth.Get());
+ return std::max(delay, getMinBuffering(p));
}
uint64_t DefaultBufferingLogic::getLiveStartSegmentNumber(BaseRepresentation *rep) const
{
AbstractPlaylist *playlist = rep->getPlaylist();
- /* Get buffering amount */
- vlc_tick_t i_buffering = getBufferingAmount(playlist);
+ /* Get buffering offset min <= max <= live delay */
+ vlc_tick_t i_buffering = getBufferingOffset(playlist);
/* Try to never buffer up to really end */
/* Enforce no overlap for demuxers segments 3.0.0 */
@@ -354,23 +359,9 @@ uint64_t DefaultBufferingLogic::getLiveStartSegmentNumber(BaseRepresentation *re
return std::numeric_limits<uint64_t>::max();
}
-vlc_tick_t DefaultBufferingLogic::getBufferingAmount(const AbstractPlaylist *p) const
+vlc_tick_t DefaultBufferingLogic::getBufferingOffset(const AbstractPlaylist *p) const
{
- const vlc_tick_t i_min_buffering = getMinBuffering(p);
- const vlc_tick_t i_max_buffering = getMaxBuffering(p);
-
- /* Get buffering amount */
- vlc_tick_t i_buffering = i_max_buffering;
- if(p->suggestedPresentationDelay.Get() &&
- p->suggestedPresentationDelay.Get() > i_min_buffering)
- {
- i_buffering = p->suggestedPresentationDelay.Get();
- }
-
- if(p->timeShiftBufferDepth.Get())
- i_buffering = std::min(i_buffering, p->timeShiftBufferDepth.Get());
-
- return i_buffering;
+ return p->isLive() ? getLiveDelay(p) : getMaxBuffering(p);
}
bool DefaultBufferingLogic::isLowLatency(const AbstractPlaylist *p) const
diff --git a/modules/demux/adaptive/logic/BufferingLogic.hpp b/modules/demux/adaptive/logic/BufferingLogic.hpp
index 7c147ccf93..72973b9966 100644
--- a/modules/demux/adaptive/logic/BufferingLogic.hpp
+++ b/modules/demux/adaptive/logic/BufferingLogic.hpp
@@ -45,16 +45,17 @@ namespace adaptive
virtual uint64_t getStartSegmentNumber(BaseRepresentation *) const = 0;
virtual vlc_tick_t getMinBuffering(const AbstractPlaylist *) const = 0;
virtual vlc_tick_t getMaxBuffering(const AbstractPlaylist *) const = 0;
+ virtual vlc_tick_t getLiveDelay(const AbstractPlaylist *) const = 0;
void setUserMinBuffering(vlc_tick_t);
void setUserMaxBuffering(vlc_tick_t);
void setUserLiveDelay(vlc_tick_t);
void setLowDelay(bool);
-
- protected:
static const vlc_tick_t BUFFERING_LOWEST_LIMIT;
static const vlc_tick_t DEFAULT_MIN_BUFFERING;
static const vlc_tick_t DEFAULT_MAX_BUFFERING;
static const vlc_tick_t DEFAULT_LIVE_BUFFERING;
+
+ protected:
vlc_tick_t userMinBuffering;
vlc_tick_t userMaxBuffering;
vlc_tick_t userLiveDelay;
@@ -69,9 +70,10 @@ namespace adaptive
virtual uint64_t getStartSegmentNumber(BaseRepresentation *) const; /* impl */
virtual vlc_tick_t getMinBuffering(const AbstractPlaylist *) const; /* impl */
virtual vlc_tick_t getMaxBuffering(const AbstractPlaylist *) const; /* impl */
+ virtual vlc_tick_t getLiveDelay(const AbstractPlaylist *) const; /* impl */
protected:
- vlc_tick_t getBufferingAmount(const AbstractPlaylist *) const;
+ vlc_tick_t getBufferingOffset(const AbstractPlaylist *) const;
uint64_t getLiveStartSegmentNumber(BaseRepresentation *) const;
bool isLowLatency(const AbstractPlaylist *) const;
};
More information about the vlc-commits
mailing list