Commit 76ece833 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: use demux increments for pcr updates

should appear smoother
parent 0335f634
...@@ -112,16 +112,25 @@ bool PlaylistManager::start(demux_t *demux) ...@@ -112,16 +112,25 @@ bool PlaylistManager::start(demux_t *demux)
return true; return true;
} }
size_t PlaylistManager::read() Streams::Stream::status PlaylistManager::demux(mtime_t nzdeadline)
{ {
size_t i_ret = 0; Streams::Stream::status i_return = Streams::Stream::status_demuxed;
for(int type=0; type<Streams::count; type++) for(int type=0; type<Streams::count; type++)
{ {
if(!streams[type]) if(!streams[type])
continue; continue;
i_ret += streams[type]->read(conManager);
} Streams::Stream::status i_ret =
streams[type]->demux(conManager, nzdeadline);
if(i_ret < Streams::Stream::status_eof)
return i_ret; return i_ret;
else if (i_ret == Streams::Stream::status_buffering)
i_return = Streams::Stream::status_buffering;
}
return i_return;
} }
mtime_t PlaylistManager::getPCR() const mtime_t PlaylistManager::getPCR() const
......
...@@ -48,8 +48,9 @@ namespace adaptative ...@@ -48,8 +48,9 @@ namespace adaptative
AbstractAdaptationLogic::LogicType type, stream_t *stream); AbstractAdaptationLogic::LogicType type, stream_t *stream);
virtual ~PlaylistManager (); virtual ~PlaylistManager ();
bool start (demux_t *); bool start(demux_t *);
size_t read();
Streams::Stream::status demux(mtime_t);
mtime_t getDuration() const; mtime_t getDuration() const;
mtime_t getPCR() const; mtime_t getPCR() const;
int getGroup() const; int getGroup() const;
......
...@@ -151,6 +151,22 @@ bool Stream::seekAble() const ...@@ -151,6 +151,22 @@ bool Stream::seekAble() const
return (output && output->seekAble()); return (output && output->seekAble());
} }
Stream::status Stream::demux(HTTPConnectionManager *connManager, mtime_t nz_deadline)
{
if(nz_deadline + VLC_TS_0 > output->getPCR()) /* not already demuxed */
{
/* need to read, demuxer still buffering, ... */
if(read(connManager) <= 0)
return Stream::status_eof;
if(nz_deadline + VLC_TS_0 > output->getPCR()) /* need to read more */
return Stream::status_buffering;
}
output->sendToDecoder(nz_deadline);
return Stream::status_demuxed;
}
size_t Stream::read(HTTPConnectionManager *connManager) size_t Stream::read(HTTPConnectionManager *connManager)
{ {
Chunk *chunk = getChunk(); Chunk *chunk = getChunk();
...@@ -216,7 +232,6 @@ size_t Stream::read(HTTPConnectionManager *connManager) ...@@ -216,7 +232,6 @@ size_t Stream::read(HTTPConnectionManager *connManager)
readsize = block->i_buffer; readsize = block->i_buffer;
output->pushBlock(block); output->pushBlock(block);
output->sendToDecoder(INT64_MAX - VLC_TS_0);
return readsize; return readsize;
} }
...@@ -239,7 +254,7 @@ AbstractStreamOutput::AbstractStreamOutput(demux_t *demux) ...@@ -239,7 +254,7 @@ AbstractStreamOutput::AbstractStreamOutput(demux_t *demux)
realdemux = demux; realdemux = demux;
demuxstream = NULL; demuxstream = NULL;
pcr = VLC_TS_0; pcr = VLC_TS_0;
group = -1; group = 0;
seekable = true; seekable = true;
fakeesout = new es_out_t; fakeesout = new es_out_t;
...@@ -387,6 +402,7 @@ void AbstractStreamOutput::esOutDel(es_out_t *fakees, es_out_id_t *p_es) ...@@ -387,6 +402,7 @@ void AbstractStreamOutput::esOutDel(es_out_t *fakees, es_out_id_t *p_es)
{ {
if((*it)->es_id == p_es) if((*it)->es_id == p_es)
{ {
me->sendToDecoder(INT64_MAX - VLC_TS_0);
delete *it; delete *it;
me->queues.erase(it); me->queues.erase(it);
break; break;
......
...@@ -66,13 +66,15 @@ namespace adaptative ...@@ -66,13 +66,15 @@ namespace adaptative
int getGroup() const; int getGroup() const;
int esCount() const; int esCount() const;
bool seekAble() const; bool seekAble() const;
size_t read(HTTPConnectionManager *); typedef enum {status_eof, status_buffering, status_demuxed} status;
status demux(HTTPConnectionManager *, mtime_t);
bool setPosition(mtime_t, bool); bool setPosition(mtime_t, bool);
mtime_t getPosition() const; mtime_t getPosition() const;
private: private:
Chunk *getChunk(); Chunk *getChunk();
void init(const Type, const Format); void init(const Type, const Format);
size_t read(HTTPConnectionManager *);
Type type; Type type;
Format format; Format format;
AbstractStreamOutput *output; AbstractStreamOutput *output;
......
...@@ -157,6 +157,8 @@ static int Open(vlc_object_t *p_obj) ...@@ -157,6 +157,8 @@ static int Open(vlc_object_t *p_obj)
p_demux->pf_demux = Demux; p_demux->pf_demux = Demux;
p_demux->pf_control = Control; p_demux->pf_control = Control;
p_sys->i_nzpcr = 0;
msg_Dbg(p_obj,"opening mpd file (%s)", p_demux->s->psz_path); msg_Dbg(p_obj,"opening mpd file (%s)", p_demux->s->psz_path);
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -176,28 +178,30 @@ static void Close(vlc_object_t *p_obj) ...@@ -176,28 +178,30 @@ static void Close(vlc_object_t *p_obj)
/***************************************************************************** /*****************************************************************************
* Callbacks: * Callbacks:
*****************************************************************************/ *****************************************************************************/
#define DEMUX_INCREMENT (CLOCK_FREQ / 20)
static int Demux(demux_t *p_demux) static int Demux(demux_t *p_demux)
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
if ( p_sys->p_dashManager->read() > 0 )
{ Streams::Stream::status status =
if ( p_sys->p_dashManager->esCount() ) p_sys->p_dashManager->demux(p_sys->i_nzpcr + DEMUX_INCREMENT);
switch(status)
{ {
mtime_t pcr = p_sys->p_dashManager->getPCR(); case Streams::Stream::status_eof:
return VLC_DEMUXER_EOF;
case Streams::Stream::status_buffering:
break;
case Streams::Stream::status_demuxed:
p_sys->i_nzpcr += DEMUX_INCREMENT;
int group = p_sys->p_dashManager->getGroup(); int group = p_sys->p_dashManager->getGroup();
if(group > 0) es_out_Control(p_demux->out, ES_OUT_SET_GROUP_PCR, group, VLC_TS_0 + p_sys->i_nzpcr);
es_out_Control(p_demux->out, ES_OUT_SET_GROUP_PCR, group, pcr); break;
else
es_out_Control(p_demux->out, ES_OUT_SET_PCR, pcr);
} }
if( !p_sys->p_dashManager->updatePlaylist() ) if( !p_sys->p_dashManager->updatePlaylist() )
return VLC_DEMUXER_EOF; return VLC_DEMUXER_EOF;
return VLC_DEMUXER_SUCCESS; return VLC_DEMUXER_SUCCESS;
}
else
return VLC_DEMUXER_EOF;
} }
static int Control (demux_t *p_demux, int i_query, va_list args) static int Control (demux_t *p_demux, int i_query, va_list args)
...@@ -219,7 +223,7 @@ static int Control (demux_t *p_demux, int i_query, va_list args) ...@@ -219,7 +223,7 @@ static int Control (demux_t *p_demux, int i_query, va_list args)
break; break;
case DEMUX_GET_TIME: case DEMUX_GET_TIME:
*(va_arg (args, int64_t *)) = p_sys->p_dashManager->getPCR(); *(va_arg (args, int64_t *)) = p_sys->i_nzpcr;
break; break;
case DEMUX_GET_LENGTH: case DEMUX_GET_LENGTH:
...@@ -230,22 +234,30 @@ static int Control (demux_t *p_demux, int i_query, va_list args) ...@@ -230,22 +234,30 @@ static int Control (demux_t *p_demux, int i_query, va_list args)
if(!p_sys->p_dashManager->getDuration()) if(!p_sys->p_dashManager->getDuration())
return VLC_EGENERIC; return VLC_EGENERIC;
*(va_arg (args, double *)) = (double) p_sys->p_dashManager->getPCR() *(va_arg (args, double *)) = (double) p_sys->i_nzpcr
/ p_sys->p_dashManager->getDuration(); / p_sys->p_dashManager->getDuration();
break; break;
case DEMUX_SET_POSITION: case DEMUX_SET_POSITION:
{
int64_t time = p_sys->p_dashManager->getDuration() * va_arg(args, double);
if(p_sys->p_mpd->isLive() || if(p_sys->p_mpd->isLive() ||
!p_sys->p_dashManager->getDuration() || !p_sys->p_dashManager->getDuration() ||
!p_sys->p_dashManager->setPosition( p_sys->p_dashManager->getDuration() * va_arg(args, double))) !p_sys->p_dashManager->setPosition(time))
return VLC_EGENERIC; return VLC_EGENERIC;
p_sys->i_nzpcr = time;
break; break;
}
case DEMUX_SET_TIME: case DEMUX_SET_TIME:
{
int64_t time = va_arg(args, int64_t);
if(p_sys->p_mpd->isLive() || if(p_sys->p_mpd->isLive() ||
!p_sys->p_dashManager->setPosition(va_arg(args, int64_t))) !p_sys->p_dashManager->setPosition(time))
return VLC_EGENERIC; return VLC_EGENERIC;
p_sys->i_nzpcr = time;
break; break;
}
case DEMUX_GET_PTS_DELAY: case DEMUX_GET_PTS_DELAY:
*va_arg (args, int64_t *) = INT64_C(1000) * *va_arg (args, int64_t *) = INT64_C(1000) *
......
...@@ -23,4 +23,5 @@ struct demux_sys_t ...@@ -23,4 +23,5 @@ struct demux_sys_t
{ {
dash::DASHManager *p_dashManager; dash::DASHManager *p_dashManager;
dash::mpd::MPD *p_mpd; dash::mpd::MPD *p_mpd;
mtime_t i_nzpcr;
}; };
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