[vlc-commits] demux: adaptive: add drain (GET_EMPTY)

Francois Cartegnie git at videolan.org
Sat Jul 9 18:42:44 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul  4 12:10:06 2016 +0200| [64f08bdf9caadb10cb737616d0c88b4965666a35] | committer: Francois Cartegnie

demux: adaptive: add drain (GET_EMPTY)

Required to correctly switch to another period,
as we disable es on period end.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64f08bdf9caadb10cb737616d0c88b4965666a35
---

 modules/demux/adaptive/PlaylistManager.cpp    |   24 ++++++++++++++++++++++++
 modules/demux/adaptive/PlaylistManager.h      |    2 ++
 modules/demux/adaptive/Streams.cpp            |    9 +++++----
 modules/demux/adaptive/Streams.hpp            |    1 +
 modules/demux/adaptive/plumbing/FakeESOut.cpp |   19 +++++++++++++++++++
 modules/demux/adaptive/plumbing/FakeESOut.hpp |    1 +
 6 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 95a27ef..cb05910 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -195,6 +195,30 @@ AbstractStream::status PlaylistManager::demux(mtime_t *pi_nzbarrier, bool send)
     return i_return;
 }
 
+void PlaylistManager::drain()
+{
+    for(;;)
+    {
+        bool b_drained = true;
+        std::vector<AbstractStream *>::iterator it;
+        for(it=streams.begin(); it!=streams.end(); ++it)
+        {
+            AbstractStream *st = *it;
+
+            if (st->isDisabled())
+                continue;
+
+            b_drained &= st->drain();
+        }
+
+        if(b_drained)
+            break;
+
+        msleep(20*1000); /* ugly, but we have no way to get feedback */
+    }
+    es_out_Control(p_demux->out, ES_OUT_RESET_PCR);
+}
+
 mtime_t PlaylistManager::getPCR() const
 {
     mtime_t pcr = VLC_TS_INVALID;
diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
index 2124dba..b059eb9 100644
--- a/modules/demux/adaptive/PlaylistManager.h
+++ b/modules/demux/adaptive/PlaylistManager.h
@@ -54,6 +54,8 @@ namespace adaptive
             bool    start();
 
             AbstractStream::status demux(mtime_t *, bool);
+            void drain();
+
             virtual bool needsUpdate() const;
             virtual bool updatePlaylist();
             virtual void scheduleNextUpdate();
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index d1860e0..03cac14 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -224,6 +224,11 @@ bool AbstractStream::isDisabled() const
     return disabled;
 }
 
+bool AbstractStream::drain()
+{
+    return fakeesout->drain();
+}
+
 AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
 {
     /* Ensure it is configured */
@@ -279,10 +284,6 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
                 commandsqueue->setFlush();
                 return AbstractStream::status_buffering;
             }
-
-            commandsqueue->Commit();
-            if(commandsqueue->isEmpty())
-                return AbstractStream::status_eof;
         }
         else if(nz_deadline + VLC_TS_0 > getBufferingLevel()) /* need to read more */
         {
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index 73823dc..b3163c2 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -76,6 +76,7 @@ namespace adaptive
                       status_buffering_ahead, /* Special case for live waiting new segments */
                       status_demuxed} status;
         status demux(mtime_t, bool);
+        bool drain();
         virtual bool setPosition(mtime_t, bool);
         mtime_t getPlaybackTime() const;
         void runUpdates();
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.cpp b/modules/demux/adaptive/plumbing/FakeESOut.cpp
index bb53dbc..6b77f50 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -237,6 +237,25 @@ bool FakeESOut::hasSelectedEs() const
     return b_selected;
 }
 
+bool FakeESOut::drain()
+{
+    bool b_drained = true;
+    std::list<FakeESOutID *>::const_iterator it;
+    vlc_mutex_lock(&lock);
+    for( it=fakeesidlist.begin(); it!=fakeesidlist.end(); ++it )
+    {
+        FakeESOutID *esID = *it;
+        if( esID->realESID() )
+        {
+            bool b_empty;
+            es_out_Control( real_es_out, ES_OUT_GET_EMPTY, &b_empty );
+            b_drained &= b_empty;
+        }
+    }
+    vlc_mutex_unlock(&lock);
+    return b_drained;
+}
+
 bool FakeESOut::restarting() const
 {
     vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.hpp b/modules/demux/adaptive/plumbing/FakeESOut.hpp
index d678046..e3ca81b 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.hpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.hpp
@@ -43,6 +43,7 @@ namespace adaptive
             void setTimestampOffset( mtime_t );
             size_t esCount() const;
             bool hasSelectedEs() const;
+            bool drain();
             bool restarting() const;
             void setExtraInfoProvider( ExtraFMTInfoInterface * );
 



More information about the vlc-commits mailing list