[vlc-commits] demux: adaptive: allow to declare some ES prior demuxing
Francois Cartegnie
git at videolan.org
Mon May 20 16:58:04 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu May 16 16:36:18 2019 +0200| [2937cad07c457c8e71e37e64f107ef5f1a9dd6b5] | committer: Francois Cartegnie
demux: adaptive: allow to declare some ES prior demuxing
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2937cad07c457c8e71e37e64f107ef5f1a9dd6b5
---
modules/demux/adaptive/plumbing/FakeESOut.cpp | 46 ++++++++++++++++++++++++---
modules/demux/adaptive/plumbing/FakeESOut.hpp | 2 ++
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.cpp b/modules/demux/adaptive/plumbing/FakeESOut.cpp
index de0abf3853..69d00f7e7f 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -151,6 +151,10 @@ void FakeESOut::createOrRecycleRealEsID( FakeESOutID *es_id )
std::list<FakeESOutID *>::iterator it;
es_out_id_t *realid = NULL;
+ /* declared ES must are temporary until real ES decl */
+ recycle_candidates.insert(recycle_candidates.begin(), declared.begin(), declared.end());
+ declared.clear();
+
bool b_preexisting = false;
bool b_select = false;
for( it=recycle_candidates.begin(); it!=recycle_candidates.end(); ++it )
@@ -205,6 +209,9 @@ vlc_tick_t FakeESOut::getTimestampOffset() const
size_t FakeESOut::esCount() const
{
+ if(!declared.empty())
+ return declared.size();
+
size_t i_count = 0;
std::list<FakeESOutID *>::const_iterator it;
for( it=fakeesidlist.begin(); it!=fakeesidlist.end(); ++it )
@@ -248,6 +255,9 @@ void FakeESOut::recycleAll()
void FakeESOut::gc()
{
+ recycle_candidates.insert(recycle_candidates.begin(), declared.begin(), declared.end());
+ declared.clear();
+
if( recycle_candidates.empty() )
{
return;
@@ -269,12 +279,16 @@ void FakeESOut::gc()
bool FakeESOut::hasSelectedEs() const
{
bool b_selected = false;
+ std::list<FakeESOutID *> const * lists[2] = {&declared, &fakeesidlist};
std::list<FakeESOutID *>::const_iterator it;
- for( it=fakeesidlist.begin(); it!=fakeesidlist.end() && !b_selected; ++it )
+ for(int i=0; i<2; i++)
{
- FakeESOutID *esID = *it;
- if( esID->realESID() )
- es_out_Control( real_es_out, ES_OUT_GET_ES_STATE, esID->realESID(), &b_selected );
+ for( it=lists[i]->begin(); it!=lists[i]->end() && !b_selected; ++it )
+ {
+ FakeESOutID *esID = *it;
+ if( esID->realESID() )
+ es_out_Control( real_es_out, ES_OUT_GET_ES_STATE, esID->realESID(), &b_selected );
+ }
}
return b_selected;
}
@@ -311,6 +325,30 @@ void FakeESOut::checkTimestampsStart(vlc_tick_t i_start)
}
}
+void FakeESOut::declareEs(const es_format_t *fmt)
+{
+ /* Declared ES are only visible until stream data flows.
+ They are then recycled to create the real ES. */
+ if(!recycle_candidates.empty() || !fakeesidlist.empty())
+ {
+ assert(recycle_candidates.empty());
+ assert(fakeesidlist.empty());
+ return;
+ }
+
+ FakeESOutID *fakeid = createNewID(fmt);
+ if( likely(fakeid) )
+ {
+ es_out_id_t *realid = es_out_Add( real_es_out, fakeid->getFmt() );
+ if( likely(realid) )
+ {
+ fakeid->setRealESID(realid);
+ declared.push_front(fakeid);
+ }
+ else delete fakeid;
+ }
+}
+
/* Static callbacks */
/* Always pass Fake ES ID to slave demuxes, it is just an opaque struct to them */
es_out_id_t * FakeESOut::esOutAdd_Callback(es_out_t *fakees, const es_format_t *p_fmt)
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.hpp b/modules/demux/adaptive/plumbing/FakeESOut.hpp
index 943f33e1b0..47d05c3c6c 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.hpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.hpp
@@ -62,6 +62,7 @@ namespace adaptive
bool restarting() const;
void setExtraInfoProvider( ExtraFMTInfoInterface * );
void checkTimestampsStart(vlc_tick_t);
+ void declareEs( const es_format_t * );
/* Used by FakeES ID */
void recycle( FakeESOutID *id );
@@ -96,6 +97,7 @@ namespace adaptive
int priority;
std::list<FakeESOutID *> fakeesidlist;
std::list<FakeESOutID *> recycle_candidates;
+ std::list<FakeESOutID *> declared;
};
}
More information about the vlc-commits
mailing list