Commit 3ed98457 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: move pcr/flushing to commands queue

parent e0981252
......@@ -43,10 +43,8 @@ AbstractStream::AbstractStream(demux_t * demux_)
eof = false;
dead = false;
disabled = false;
flushing = false;
discontinuity = false;
segmentTracker = NULL;
pcr = VLC_TS_INVALID;
demuxersource = NULL;
commandsqueue = NULL;
demuxer = NULL;
......@@ -139,7 +137,7 @@ bool AbstractStream::isEOF() const
mtime_t AbstractStream::getPCR() const
{
return pcr;
return commandsqueue->getPCR();
}
mtime_t AbstractStream::getMinAheadTime() const
......@@ -169,7 +167,7 @@ bool AbstractStream::seekAble() const
return (demuxer &&
!fakeesout->restarting() &&
!discontinuity &&
!flushing );
!commandsqueue->isFlushing() );
}
bool AbstractStream::isSelected() const
......@@ -232,18 +230,16 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
if(!segmentTracker || !connManager || dead)
return AbstractStream::status_eof;
if(flushing)
if(commandsqueue->isFlushing())
{
if(!send)
return AbstractStream::status_buffering;
pcr = commandsqueue->Process(p_realdemux->out, VLC_TS_0 + nz_deadline);
(void) commandsqueue->Process(p_realdemux->out, VLC_TS_0 + nz_deadline);
if(!commandsqueue->isEmpty())
return AbstractStream::status_demuxed;
commandsqueue->Abort(true); /* reset buffering level */
flushing = false;
pcr = 0;
return AbstractStream::status_dis;
}
......@@ -258,7 +254,7 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
msg_Dbg( p_realdemux, "Flushing on format change" );
prepareFormatChange();
discontinuity = false;
flushing = true;
commandsqueue->setFlush();
return AbstractStream::status_buffering;
}
dead = true; /* Prevent further retries */
......@@ -280,7 +276,7 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
msg_Dbg( p_realdemux, "Flushing on discontinuity" );
prepareFormatChange();
discontinuity = false;
flushing = true;
commandsqueue->setFlush();
return AbstractStream::status_buffering;
}
......@@ -298,7 +294,7 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
description.c_str(), getPCR(), getFirstDTS(), nz_deadline, getBufferingLevel()));
if(send)
pcr = commandsqueue->Process( p_realdemux->out, VLC_TS_0 + nz_deadline );
(void) commandsqueue->Process( p_realdemux->out, VLC_TS_0 + nz_deadline );
/* Disable streams that are not selected (alternate streams) */
if(esCount() && !isSelected() && !fakeesout->restarting())
......@@ -368,8 +364,8 @@ bool AbstractStream::setPosition(mtime_t time, bool tryonly)
setTimeOffset();
}
else commandsqueue->Abort( true );
pcr = VLC_TS_INVALID;
es_out_Control(p_realdemux->out, ES_OUT_SET_NEXT_DISPLAY_TIME,
VLC_TS_0 + time);
}
......
......@@ -107,8 +107,6 @@ namespace adaptive
bool disabled;
bool eof;
bool dead;
bool flushing;
mtime_t pcr;
std::string language;
std::string description;
......
......@@ -196,7 +196,9 @@ EsOutControlResetPCRCommand * CommandsFactory::creatEsOutControlResetPCRCommand(
CommandsQueue::CommandsQueue( CommandsFactory *f )
{
bufferinglevel = VLC_TS_INVALID;
pcr = VLC_TS_INVALID;
b_drop = false;
b_flushing = false;
commandsFactory = f;
vlc_mutex_init(&lock);
}
......@@ -265,6 +267,11 @@ mtime_t CommandsQueue::Process( es_out_t *out, mtime_t barrier )
command->Execute( out );
delete command;
}
pcr = lastdts;
if(commands.empty() && b_flushing)
b_flushing = false;
vlc_mutex_unlock(&lock);
return lastdts;
......@@ -295,7 +302,11 @@ void CommandsQueue::Abort( bool b_reset )
}
if( b_reset )
{
bufferinglevel = VLC_TS_INVALID;
pcr = VLC_TS_INVALID;
b_flushing = false;
}
vlc_mutex_unlock(&lock);
}
......@@ -314,6 +325,22 @@ void CommandsQueue::setDrop( bool b )
vlc_mutex_unlock(&lock);
}
void CommandsQueue::setFlush()
{
vlc_mutex_lock(&lock);
LockedCommit();
b_flushing = !commands.empty();
vlc_mutex_unlock(&lock);
}
bool CommandsQueue::isFlushing() const
{
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
bool b = b_flushing;
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return b;
}
mtime_t CommandsQueue::getDemuxedAmount() const
{
return bufferinglevel - getFirstDTS();
......@@ -344,3 +371,11 @@ mtime_t CommandsQueue::getFirstDTS() const
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return i_dts;
}
mtime_t CommandsQueue::getPCR() const
{
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
mtime_t i_pcr = pcr;
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return i_pcr;
}
......@@ -145,9 +145,12 @@ namespace adaptive
void Commit();
bool isEmpty() const;
void setDrop( bool );
void setFlush();
bool isFlushing() const;
mtime_t getDemuxedAmount() const;
mtime_t getBufferingLevel() const;
mtime_t getFirstDTS() const;
mtime_t getPCR() const;
private:
CommandsFactory *commandsFactory;
......@@ -156,6 +159,8 @@ namespace adaptive
std::list<AbstractCommand *> incoming;
std::list<AbstractCommand *> commands;
mtime_t bufferinglevel;
mtime_t pcr;
bool b_flushing;
bool b_drop;
};
}
......
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