[vlc-commits] demux: adaptive: refactor getting available buffering
Francois Cartegnie
git at videolan.org
Fri Jan 22 15:12:25 UTC 2021
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jan 14 14:03:26 2021 +0100| [37f75e10ccd43949c71eaa76887a8a853d0dc3c1] | committer: Francois Cartegnie
demux: adaptive: refactor getting available buffering
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=37f75e10ccd43949c71eaa76887a8a853d0dc3c1
---
modules/demux/adaptive/PlaylistManager.cpp | 15 +++++++++++++++
modules/demux/adaptive/PlaylistManager.h | 1 +
modules/demux/dash/DASHManager.cpp | 11 +----------
modules/demux/smooth/SmoothManager.cpp | 14 +-------------
4 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 8f05521b9a..9f007892bc 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -405,6 +405,21 @@ vlc_tick_t PlaylistManager::getCurrentDemuxTime() const
return demux.i_nzpcr;
}
+vlc_tick_t PlaylistManager::getMinAheadTime() const
+{
+ vlc_tick_t minbuffer = 0;
+ std::for_each(streams.cbegin(), streams.cend(),
+ [&minbuffer](const AbstractStream *st) {
+ if(st->isValid() && !st->isDisabled() && st->isSelected())
+ {
+ const vlc_tick_t m = st->getMinAheadTime();
+ if(m > 0 && (m < minbuffer || minbuffer == 0))
+ minbuffer = m;
+ }
+ });
+ return minbuffer;
+}
+
bool PlaylistManager::reactivateStream(AbstractStream *stream)
{
return stream->reactivate(getResumeTime());
diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
index 9484f3cf60..e1ab594e46 100644
--- a/modules/demux/adaptive/PlaylistManager.h
+++ b/modules/demux/adaptive/PlaylistManager.h
@@ -83,6 +83,7 @@ namespace adaptive
virtual vlc_tick_t getFirstPlaybackTime() const;
vlc_tick_t getCurrentDemuxTime() const;
+ vlc_tick_t getMinAheadTime() const;
virtual bool reactivateStream(AbstractStream *);
bool setupPeriod();
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index 79a5384296..7b2d3adb81 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -67,16 +67,7 @@ void DASHManager::scheduleNextUpdate()
{
time_t now = time(nullptr);
- vlc_tick_t minbuffer = 0;
- std::vector<AbstractStream *>::const_iterator it;
- for(it=streams.begin(); it!=streams.end(); ++it)
- {
- const AbstractStream *st = *it;
- const vlc_tick_t m = st->getMinAheadTime();
- if(m > 0 && (m < minbuffer || minbuffer == 0))
- minbuffer = m;
- }
- minbuffer /= 2;
+ vlc_tick_t minbuffer = getMinAheadTime() / 2;
if(playlist->minUpdatePeriod.Get() > minbuffer)
minbuffer = playlist->minUpdatePeriod.Get();
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index c36236946e..90bc6481fd 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -119,19 +119,7 @@ void SmoothManager::scheduleNextUpdate()
{
time_t now = time(nullptr);
- vlc_tick_t minbuffer = 0;
- std::vector<AbstractStream *>::const_iterator it;
- for(it=streams.begin(); it!=streams.end(); ++it)
- {
- const AbstractStream *st = *it;
- if(!st->isValid() || st->isDisabled() || !st->isSelected())
- continue;
- const vlc_tick_t m = st->getMinAheadTime();
- if(m > 0 && (m < minbuffer || minbuffer == 0))
- minbuffer = m;
- }
-
- minbuffer /= 2;
+ vlc_tick_t minbuffer = getMinAheadTime() / 2;
if(playlist->minUpdatePeriod.Get() > minbuffer)
minbuffer = playlist->minUpdatePeriod.Get();
More information about the vlc-commits
mailing list