[vlc-commits] demux: adaptative: add offset to streams
Francois Cartegnie
git at videolan.org
Thu Jul 16 23:04:28 CEST 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jul 15 20:41:41 2015 +0200| [85e7436627f9ba078bc6014d655a6344466a3634] | committer: Francois Cartegnie
demux: adaptative: add offset to streams
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=85e7436627f9ba078bc6014d655a6344466a3634
---
modules/demux/adaptative/Streams.cpp | 31 ++++++++++++++++++++++++++-----
modules/demux/adaptative/Streams.hpp | 2 ++
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/modules/demux/adaptative/Streams.cpp b/modules/demux/adaptative/Streams.cpp
index 64c5e76..4c87641 100644
--- a/modules/demux/adaptative/Streams.cpp
+++ b/modules/demux/adaptative/Streams.cpp
@@ -308,6 +308,7 @@ BaseStreamOutput::BaseStreamOutput(demux_t *demux, const StreamFormat &format, c
restarting = false;
demuxstream = NULL;
b_drop = false;
+ timestamps_offset = VLC_TS_INVALID;
fakeesout = new es_out_t;
if (!fakeesout)
@@ -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)
{
p_queue = NULL;
@@ -551,6 +559,15 @@ int BaseStreamOutput::esOutSend(es_out_t *fakees, es_out_id_t *p_es, block_t *p_
}
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;
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)
BaseStreamOutput *me = (BaseStreamOutput *) fakees->p_sys;
if (i_query == ES_OUT_SET_PCR )
{
- vlc_mutex_lock(&me->lock);
- me->pcr = (int64_t)va_arg( args, int64_t );
- vlc_mutex_unlock(&me->lock);
+ vlc_mutex_lock(&lock);
+ pcr = (int64_t)va_arg( args, int64_t );
+ 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;
}
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->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;
}
else if( i_query == ES_OUT_GET_ES_STATE )
diff --git a/modules/demux/adaptative/Streams.hpp b/modules/demux/adaptative/Streams.hpp
index caad94a..af1475d 100644
--- a/modules/demux/adaptative/Streams.hpp
+++ b/modules/demux/adaptative/Streams.hpp
@@ -142,6 +142,7 @@ namespace adaptative
virtual void sendToDecoder(mtime_t); /* reimpl */
virtual bool reinitsOnSeek() const; /* reimpl */
virtual bool switchAllowed() const; /* reimpl */
+ void setTimestampOffset(mtime_t);
protected:
es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */
@@ -149,6 +150,7 @@ namespace adaptative
bool seekable;
std::string name;
bool restarting;
+ mtime_t timestamps_offset;
private:
static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *);
More information about the vlc-commits
mailing list