[vlc-commits] adaptive: add expected timestamp to fake_esout
Francois Cartegnie
git at videolan.org
Mon Jan 16 17:09:46 CET 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan 16 14:48:09 2017 +0100| [bc669601591e21f4c5b10271ee0ebdf69e5dd693] | committer: Francois Cartegnie
adaptive: add expected timestamp to fake_esout
Tries to detect nonzero timelines instead of guessing
and applying an offset to already offset timelines.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bc669601591e21f4c5b10271ee0ebdf69e5dd693
---
modules/demux/adaptive/plumbing/FakeESOut.cpp | 30 +++++++++++++++++++++++++++
modules/demux/adaptive/plumbing/FakeESOut.hpp | 4 ++++
2 files changed, 34 insertions(+)
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.cpp b/modules/demux/adaptive/plumbing/FakeESOut.cpp
index ca341ff..92b1e57 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -46,6 +46,8 @@ FakeESOut::FakeESOut( es_out_t *es, CommandsQueue *queue )
commandsqueue = queue;
timestamps_offset = 0;
+ timestamps_expected = 0;
+ timestamps_check_done = false;
extrainfo = NULL;
vlc_mutex_init(&lock);
}
@@ -64,10 +66,20 @@ FakeESOut::~FakeESOut()
vlc_mutex_destroy(&lock);
}
+void FakeESOut::setExpectedTimestampOffset(mtime_t offset)
+{
+ vlc_mutex_lock(&lock);
+ timestamps_offset = 0;
+ timestamps_expected = offset;
+ timestamps_check_done = false;
+ vlc_mutex_unlock(&lock);
+}
+
void FakeESOut::setTimestampOffset(mtime_t offset)
{
vlc_mutex_lock(&lock);
timestamps_offset = offset;
+ timestamps_check_done = true;
vlc_mutex_unlock(&lock);
}
@@ -302,11 +314,29 @@ es_out_id_t * FakeESOut::esOutAdd_Callback(es_out_t *fakees, const es_format_t *
return NULL;
}
+void FakeESOut::checkTimestampsStart(mtime_t i_start)
+{
+ if( i_start == VLC_TS_INVALID )
+ return;
+
+ vlc_mutex_lock(&lock);
+ if( !timestamps_check_done )
+ {
+ if( i_start < CLOCK_FREQ ) /* Starts 0 */
+ timestamps_offset = timestamps_expected;
+ timestamps_check_done = true;
+ }
+ vlc_mutex_unlock(&lock);
+}
+
int FakeESOut::esOutSend_Callback(es_out_t *fakees, es_out_id_t *p_es, block_t *p_block)
{
FakeESOut *me = (FakeESOut *) fakees->p_sys;
FakeESOutID *es_id = reinterpret_cast<FakeESOutID *>( p_es );
assert(!es_id->scheduledForDeletion());
+
+ me->checkTimestampsStart( p_block->i_dts );
+
mtime_t offset = me->getTimestampOffset();
if( p_block->i_dts > VLC_TS_INVALID )
{
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.hpp b/modules/demux/adaptive/plumbing/FakeESOut.hpp
index e3ca81b..4a514c5 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.hpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.hpp
@@ -41,11 +41,13 @@ namespace adaptive
~FakeESOut();
es_out_t * getEsOut();
void setTimestampOffset( mtime_t );
+ void setExpectedTimestampOffset(mtime_t);
size_t esCount() const;
bool hasSelectedEs() const;
bool drain();
bool restarting() const;
void setExtraInfoProvider( ExtraFMTInfoInterface * );
+ void checkTimestampsStart(mtime_t);
/* Used by FakeES ID */
void recycle( FakeESOutID *id );
@@ -73,6 +75,8 @@ namespace adaptive
CommandsQueue *commandsqueue;
es_out_t *fakeesout;
mtime_t timestamps_offset;
+ mtime_t timestamps_expected;
+ bool timestamps_check_done;
std::list<FakeESOutID *> fakeesidlist;
std::list<FakeESOutID *> recycle_candidates;
};
More information about the vlc-commits
mailing list