Commit 85e74366 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: add offset to streams

parent 052ac2b0
...@@ -308,6 +308,7 @@ BaseStreamOutput::BaseStreamOutput(demux_t *demux, const StreamFormat &format, c ...@@ -308,6 +308,7 @@ BaseStreamOutput::BaseStreamOutput(demux_t *demux, const StreamFormat &format, c
restarting = false; restarting = false;
demuxstream = NULL; demuxstream = NULL;
b_drop = false; b_drop = false;
timestamps_offset = VLC_TS_INVALID;
fakeesout = new es_out_t; fakeesout = new es_out_t;
if (!fakeesout) if (!fakeesout)
...@@ -466,6 +467,13 @@ void BaseStreamOutput::sendToDecoderUnlocked(mtime_t nzdeadline) ...@@ -466,6 +467,13 @@ void BaseStreamOutput::sendToDecoderUnlocked(mtime_t nzdeadline)
} }
} }
void BaseStreamOutput::setTimestampOffset(mtime_t offset)
{
vlc_mutex_lock(&lock);
timestamps_offset = VLC_TS_0 + offset;
vlc_mutex_unlock(&lock);
}
BaseStreamOutput::Demuxed::Demuxed(es_out_id_t *id, const es_format_t *fmt) BaseStreamOutput::Demuxed::Demuxed(es_out_id_t *id, const es_format_t *fmt)
{ {
p_queue = NULL; p_queue = NULL;
...@@ -551,6 +559,15 @@ int BaseStreamOutput::esOutSend(es_out_t *fakees, es_out_id_t *p_es, block_t *p_ ...@@ -551,6 +559,15 @@ int BaseStreamOutput::esOutSend(es_out_t *fakees, es_out_id_t *p_es, block_t *p_
} }
else else
{ {
if( me->timestamps_offset > VLC_TS_INVALID )
{
if(p_block->i_dts > VLC_TS_INVALID)
p_block->i_dts += (me->timestamps_offset - VLC_TS_0);
if(p_block->i_pts > VLC_TS_INVALID)
p_block->i_pts += (me->timestamps_offset - VLC_TS_0);
}
std::list<Demuxed *>::const_iterator it; std::list<Demuxed *>::const_iterator it;
for(it=me->queues.begin(); it!=me->queues.end();++it) for(it=me->queues.begin(); it!=me->queues.end();++it)
{ {
...@@ -604,17 +621,21 @@ int BaseStreamOutput::esOutControl(es_out_t *fakees, int i_query, va_list args) ...@@ -604,17 +621,21 @@ int BaseStreamOutput::esOutControl(es_out_t *fakees, int i_query, va_list args)
BaseStreamOutput *me = (BaseStreamOutput *) fakees->p_sys; BaseStreamOutput *me = (BaseStreamOutput *) fakees->p_sys;
if (i_query == ES_OUT_SET_PCR ) if (i_query == ES_OUT_SET_PCR )
{ {
vlc_mutex_lock(&me->lock); vlc_mutex_lock(&lock);
me->pcr = (int64_t)va_arg( args, int64_t ); pcr = (int64_t)va_arg( args, int64_t );
vlc_mutex_unlock(&me->lock); if(me->pcr > VLC_TS_INVALID && me->timestamps_offset > VLC_TS_INVALID)
me->pcr += (me->timestamps_offset - VLC_TS_0);
vlc_mutex_unlock(&lock);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
else if( i_query == ES_OUT_SET_GROUP_PCR ) else if( i_query == ES_OUT_SET_GROUP_PCR )
{ {
vlc_mutex_lock(&me->lock); vlc_mutex_lock(&lock);
me->group = (int) va_arg( args, int ); me->group = (int) va_arg( args, int );
me->pcr = (int64_t)va_arg( args, int64_t ); me->pcr = (int64_t)va_arg( args, int64_t );
vlc_mutex_unlock(&me->lock); if(me->pcr > VLC_TS_INVALID && me->timestamps_offset > VLC_TS_INVALID)
me->pcr += (me->timestamps_offset - VLC_TS_0);
vlc_mutex_unlock(&lock);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
else if( i_query == ES_OUT_GET_ES_STATE ) else if( i_query == ES_OUT_GET_ES_STATE )
......
...@@ -142,6 +142,7 @@ namespace adaptative ...@@ -142,6 +142,7 @@ namespace adaptative
virtual void sendToDecoder(mtime_t); /* reimpl */ virtual void sendToDecoder(mtime_t); /* reimpl */
virtual bool reinitsOnSeek() const; /* reimpl */ virtual bool reinitsOnSeek() const; /* reimpl */
virtual bool switchAllowed() const; /* reimpl */ virtual bool switchAllowed() const; /* reimpl */
void setTimestampOffset(mtime_t);
protected: protected:
es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */ es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */
...@@ -149,6 +150,7 @@ namespace adaptative ...@@ -149,6 +150,7 @@ namespace adaptative
bool seekable; bool seekable;
std::string name; std::string name;
bool restarting; bool restarting;
mtime_t timestamps_offset;
private: private:
static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *); static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *);
......
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