Commit 4bf1e07a authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: wait segments when starving

parent 0579ca71
......@@ -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;
}
......
......@@ -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));
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment