[vlc-commits] demux: adaptative: wait segments when starving
Francois Cartegnie
git at videolan.org
Tue Dec 29 19:17:17 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 29 16:01:12 2015 +0100| [4bf1e07ad8207cea0d57071fbd55a42db551edd8] | committer: Francois Cartegnie
demux: adaptative: wait segments when starving
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4bf1e07ad8207cea0d57071fbd55a42db551edd8
---
modules/demux/adaptative/PlaylistManager.cpp | 12 +++++++++++-
modules/demux/adaptative/SegmentTracker.cpp | 10 ++++++++++
modules/demux/adaptative/SegmentTracker.hpp | 1 +
modules/demux/adaptative/Streams.cpp | 3 +++
modules/demux/adaptative/Streams.hpp | 7 ++++++-
5 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/modules/demux/adaptative/PlaylistManager.cpp b/modules/demux/adaptative/PlaylistManager.cpp
index 604cff0..52e4467 100644
--- a/modules/demux/adaptative/PlaylistManager.cpp
+++ b/modules/demux/adaptative/PlaylistManager.cpp
@@ -159,7 +159,12 @@ AbstractStream::status PlaylistManager::demux(mtime_t nzdeadline, bool send)
}
AbstractStream::status i_ret = st->demux(nzdeadline, send);
- if(i_ret == AbstractStream::status_buffering)
+ if(i_ret == AbstractStream::status_buffering_ahead ||
+ i_return == AbstractStream::status_buffering_ahead)
+ {
+ i_return = AbstractStream::status_buffering_ahead;
+ }
+ else if(i_ret == AbstractStream::status_buffering)
{
i_return = AbstractStream::status_buffering;
}
@@ -332,6 +337,7 @@ int PlaylistManager::doDemux(int64_t increment)
case AbstractStream::status_eof:
return VLC_DEMUXER_EOF;
case AbstractStream::status_buffering:
+ case AbstractStream::status_buffering_ahead:
break;
case AbstractStream::status_dis:
case AbstractStream::status_eop:
@@ -355,6 +361,10 @@ int PlaylistManager::doDemux(int64_t increment)
failedupdates++;
}
+ /* Live starved and update still not there ? */
+ if(status == AbstractStream::status_buffering_ahead && needsUpdate())
+ msleep(CLOCK_FREQ / 20); /* Ugly */
+
return VLC_DEMUXER_SUCCESS;
}
diff --git a/modules/demux/adaptative/SegmentTracker.cpp b/modules/demux/adaptative/SegmentTracker.cpp
index 0d4536f..c8ae4e1 100644
--- a/modules/demux/adaptative/SegmentTracker.cpp
+++ b/modules/demux/adaptative/SegmentTracker.cpp
@@ -72,6 +72,16 @@ void SegmentTracker::setAdaptationLogic(AbstractAdaptationLogic *logic_)
registerListener(logic);
}
+bool SegmentTracker::segmentsListReady() const
+{
+ BaseRepresentation *rep = curRepresentation;
+ if(!rep)
+ rep = logic->getNextRepresentation(adaptationSet, NULL);
+ if(rep && rep->getPlaylist()->isLive())
+ return rep->getMinAheadTime((count) ? count -1 : count) > 0;
+ return true;
+}
+
void SegmentTracker::reset()
{
notify(SegmentTrackerEvent(curRepresentation, NULL));
diff --git a/modules/demux/adaptative/SegmentTracker.hpp b/modules/demux/adaptative/SegmentTracker.hpp
index 7373aae..026dbb8 100644
--- a/modules/demux/adaptative/SegmentTracker.hpp
+++ b/modules/demux/adaptative/SegmentTracker.hpp
@@ -95,6 +95,7 @@ namespace adaptative
~SegmentTracker();
void setAdaptationLogic(AbstractAdaptationLogic *);
+ bool segmentsListReady() const;
void reset();
SegmentChunk* getNextChunk(bool, HTTPConnectionManager *);
bool setPositionByTime(mtime_t, bool, bool);
diff --git a/modules/demux/adaptative/Streams.cpp b/modules/demux/adaptative/Streams.cpp
index 2671314..5b9fcd6 100644
--- a/modules/demux/adaptative/Streams.cpp
+++ b/modules/demux/adaptative/Streams.cpp
@@ -245,6 +245,9 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
if(nz_deadline + VLC_TS_0 > getBufferingLevel()) /* not already demuxed */
{
+ if(!segmentTracker->segmentsListReady()) /* Live Streams */
+ return AbstractStream::status_buffering_ahead;
+
/* need to read, demuxer still buffering, ... */
if(demuxer->demux(nz_deadline) != VLC_DEMUXER_SUCCESS)
{
diff --git a/modules/demux/adaptative/Streams.hpp b/modules/demux/adaptative/Streams.hpp
index 57180e5..d39fd37 100644
--- a/modules/demux/adaptative/Streams.hpp
+++ b/modules/demux/adaptative/Streams.hpp
@@ -73,7 +73,12 @@ namespace adaptative
bool isSelected() const;
virtual bool reactivate(mtime_t);
bool isDisabled() const;
- typedef enum {status_eof, status_eop, status_dis, status_buffering, status_demuxed} status;
+ typedef enum {status_eof,
+ status_eop,
+ status_dis,
+ status_buffering,
+ status_buffering_ahead, /* Special case for live waiting new segments */
+ status_demuxed} status;
status demux(mtime_t, bool);
virtual bool setPosition(mtime_t, bool);
mtime_t getPlaybackTime() const;
More information about the vlc-commits
mailing list