[vlc-commits] demux: adaptive: provide full abstraction for demux_t

Francois Cartegnie git at videolan.org
Fri Nov 22 05:50:45 CET 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jul 31 16:15:27 2019 +0200| [6bd9d8e0b43741bf398244ab9564987fbf222fc1] | committer: Francois Cartegnie

demux: adaptive: provide full abstraction for demux_t

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

 modules/demux/adaptive/Streams.cpp          |  4 ++--
 modules/demux/adaptive/plumbing/Demuxer.cpp | 31 ++++++++++++++++++++---------
 modules/demux/adaptive/plumbing/Demuxer.hpp | 15 ++++++++++----
 3 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index bff61f1088..0ccaec35b4 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -380,9 +380,9 @@ AbstractStream::buffering_status AbstractStream::doBufferize(vlc_tick_t nz_deadl
 
         /* need to read, demuxer still buffering, ... */
         vlc_mutex_unlock(&lock);
-        int i_ret = demuxer->demux(nz_deadline);
+        Demuxer::Status demuxStatus = demuxer->demux(nz_deadline);
         vlc_mutex_lock(&lock);
-        if(i_ret != VLC_DEMUXER_SUCCESS)
+        if(demuxStatus != Demuxer::Status::STATUS_SUCCESS)
         {
             if(discontinuity || needrestart)
             {
diff --git a/modules/demux/adaptive/plumbing/Demuxer.cpp b/modules/demux/adaptive/plumbing/Demuxer.cpp
index 69776bfbb8..f194a6247e 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.cpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.cpp
@@ -76,6 +76,19 @@ bool AbstractDemuxer::needsRestartOnSeek() const
     return b_reinitsonseek;
 }
 
+AbstractDemuxer::Status AbstractDemuxer::returnCode(int i_ret)
+{
+    switch(i_ret)
+    {
+        case VLC_DEMUXER_SUCCESS:
+            return Status::STATUS_SUCCESS;
+        case VLC_DEMUXER_EGENERIC:
+            return Status::STATUS_END_OF_FILE;
+        default:
+            return Status::STATUS_ERROR;
+    };
+}
+
 MimeDemuxer::MimeDemuxer(vlc_object_t *p_obj_,
                          const DemuxerFactoryInterface *factory_,
                          es_out_t *out, AbstractSourceStream *source)
@@ -148,10 +161,10 @@ void MimeDemuxer::drain()
         demuxer->drain();
 }
 
-int MimeDemuxer::demux(vlc_tick_t t)
+AbstractDemuxer::Status MimeDemuxer::demux(vlc_tick_t t)
 {
     if(!demuxer)
-        return VLC_DEMUXER_EOF;
+        return Status::STATUS_END_OF_FILE;
     return demuxer->demux(t);
 }
 
@@ -220,14 +233,14 @@ void Demuxer::drain()
     while(p_demux && demux_Demux(p_demux) == VLC_DEMUXER_SUCCESS);
 }
 
-int Demuxer::demux(vlc_tick_t)
+Demuxer::Status Demuxer::demux(vlc_tick_t)
 {
     if(!p_demux || b_eof)
-        return VLC_DEMUXER_EOF;
+        return Status::STATUS_END_OF_FILE;
     int i_ret = demux_Demux(p_demux);
     if(i_ret != VLC_DEMUXER_SUCCESS)
         b_eof = true;
-    return i_ret;
+    return returnCode(i_ret);
 }
 
 SlaveDemuxer::SlaveDemuxer(vlc_object_t *p_obj, const std::string &name,
@@ -256,16 +269,16 @@ bool SlaveDemuxer::create()
     return false;
 }
 
-int SlaveDemuxer::demux(vlc_tick_t nz_deadline)
+AbstractDemuxer::Status SlaveDemuxer::demux(vlc_tick_t nz_deadline)
 {
     /* Always call with increment or buffering will get slow stuck */
     vlc_tick_t i_next_demux_time = VLC_TICK_0 + nz_deadline + VLC_TICK_FROM_MS(250);
     if( demux_Control(p_demux, DEMUX_SET_NEXT_DEMUX_TIME, i_next_demux_time ) != VLC_SUCCESS )
     {
         b_eof = true;
-        return VLC_DEMUXER_EOF;
+        return Status::STATUS_END_OF_FILE;
     }
-    int ret = Demuxer::demux(i_next_demux_time);
+    Status status = Demuxer::demux(i_next_demux_time);
     es_out_Control(p_es_out, ES_OUT_SET_GROUP_PCR, 0, i_next_demux_time);
-    return ret;
+    return status;
 }
diff --git a/modules/demux/adaptive/plumbing/Demuxer.hpp b/modules/demux/adaptive/plumbing/Demuxer.hpp
index b023715dbe..14218d7e38 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.hpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.hpp
@@ -32,9 +32,15 @@ namespace adaptive
     class AbstractDemuxer
     {
         public:
+            enum Status
+            {
+                STATUS_SUCCESS,
+                STATUS_ERROR,
+                STATUS_END_OF_FILE,
+            };
             AbstractDemuxer();
             virtual ~AbstractDemuxer();
-            virtual int demux(vlc_tick_t) = 0;
+            virtual Status demux(vlc_tick_t) = 0;
             virtual void drain() = 0;
             virtual bool create() = 0;
             virtual void destroy() = 0;
@@ -46,6 +52,7 @@ namespace adaptive
             void setRestartsOnEachSegment(bool);
 
         protected:
+            static Status returnCode(int);
             bool b_startsfromzero;
             bool b_reinitsonseek;
             bool b_alwaysrestarts;
@@ -58,7 +65,7 @@ namespace adaptive
             MimeDemuxer(vlc_object_t *, const DemuxerFactoryInterface *,
                         es_out_t *, AbstractSourceStream *);
             virtual ~MimeDemuxer();
-            virtual int demux(vlc_tick_t); /* impl */
+            virtual Status demux(vlc_tick_t); /* impl */
             virtual void drain(); /* impl */
             virtual bool create(); /* impl */
             virtual void destroy(); /* impl */
@@ -76,7 +83,7 @@ namespace adaptive
         public:
             Demuxer(vlc_object_t *, const std::string &, es_out_t *, AbstractSourceStream *);
             virtual ~Demuxer();
-            virtual int demux(vlc_tick_t); /* impl */
+            virtual Status demux(vlc_tick_t); /* impl */
             virtual void drain(); /* impl */
             virtual bool create(); /* impl */
             virtual void destroy(); /* impl */
@@ -96,7 +103,7 @@ namespace adaptive
             SlaveDemuxer(vlc_object_t *, const std::string &, es_out_t *, AbstractSourceStream *);
             virtual ~SlaveDemuxer();
             virtual bool create(); /* reimpl */
-            virtual int demux(vlc_tick_t); /* reimpl */
+            virtual Status demux(vlc_tick_t); /* reimpl */
 
         private:
             vlc_tick_t length;



More information about the vlc-commits mailing list