[vlc-commits] demux: adaptive: allow to declare some ES prior demuxing

Francois Cartegnie git at videolan.org
Mon Mar 30 16:15:42 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu May 16 16:36:18 2019 +0200| [5064e091d74d03871b3958ff99f31a2a62781eaa] | committer: Francois Cartegnie

demux: adaptive: allow to declare some ES prior demuxing

(cherry picked from commit 2937cad07c457c8e71e37e64f107ef5f1a9dd6b5)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=5064e091d74d03871b3958ff99f31a2a62781eaa
---

 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 dba993f81a..e02d35322e 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -140,6 +140,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 )
@@ -192,6 +196,9 @@ mtime_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 )
@@ -235,6 +242,9 @@ void FakeESOut::recycleAll()
 
 void FakeESOut::gc()
 {
+    recycle_candidates.insert(recycle_candidates.begin(), declared.begin(), declared.end());
+    declared.clear();
+
     if( recycle_candidates.empty() )
     {
         return;
@@ -256,12 +266,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;
 }
@@ -298,6 +312,30 @@ void FakeESOut::checkTimestampsStart(mtime_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 1106c936c6..cc1e1fc248 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.hpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.hpp
@@ -61,6 +61,7 @@ namespace adaptive
             bool restarting() const;
             void setExtraInfoProvider( ExtraFMTInfoInterface * );
             void checkTimestampsStart(mtime_t);
+            void declareEs( const es_format_t * );
 
             /* Used by FakeES ID */
             void recycle( FakeESOutID *id );
@@ -95,6 +96,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