[vlc-commits] demux: adaptive: handle cache missing segments

Francois Cartegnie git at videolan.org
Fri Oct 12 17:15:45 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Oct 12 17:10:44 2018 +0200| [abba9191d151005ead951842adbd688b507caa89] | committer: Francois Cartegnie

demux: adaptive: handle cache missing segments

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

 modules/demux/adaptive/Streams.cpp    |  8 ++++++++
 modules/demux/adaptive/Streams.hpp    |  1 +
 modules/demux/adaptive/http/Chunk.cpp | 18 ++++++++++++++----
 modules/demux/adaptive/http/Chunk.h   |  3 +++
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 202bf41033..b53206704d 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -54,6 +54,7 @@ AbstractStream::AbstractStream(demux_t * demux_)
     commandsqueue = NULL;
     demuxer = NULL;
     fakeesout = NULL;
+    notfound_sequence = 0;
     last_buffer_status = buffering_lessthanmin;
     vlc_mutex_init(&lock);
 }
@@ -482,10 +483,16 @@ block_t * AbstractStream::readNextBlock()
     block_t *block = currentChunk->readBlock();
     if(block == NULL)
     {
+        if(currentChunk->getRequestStatus() == RequestStatus::NotFound &&
+           ++notfound_sequence < 3)
+        {
+            discontinuity = true;
+        }
         delete currentChunk;
         currentChunk = NULL;
         return NULL;
     }
+    else notfound_sequence = 0;
 
     if (currentChunk->isEmpty())
     {
@@ -508,6 +515,7 @@ bool AbstractStream::setPosition(vlc_tick_t time, bool tryonly)
     {
         // clear eof flag before restartDemux() to prevent readNextBlock() fail
         eof = false;
+        notfound_sequence = 0;
         if(demuxer->needsRestartOnSeek())
         {
             if(currentChunk)
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index f74db017ee..4e7bedbcd5 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -138,6 +138,7 @@ namespace adaptive
         buffering_status last_buffer_status;
         bool dead;
         bool disabled;
+        unsigned notfound_sequence;
     };
 
     class AbstractStreamFactory
diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index 0674231ee5..3ec89fd4a1 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -40,6 +40,7 @@ using namespace adaptive::http;
 AbstractChunkSource::AbstractChunkSource()
 {
     contentLength = 0;
+    requeststatus = RequestStatus::Success;
 }
 
 AbstractChunkSource::~AbstractChunkSource()
@@ -64,6 +65,11 @@ std::string AbstractChunkSource::getContentType() const
     return std::string();
 }
 
+enum RequestStatus AbstractChunkSource::getRequestStatus() const
+{
+    return requeststatus;
+}
+
 AbstractChunk::AbstractChunk(AbstractChunkSource *source_)
 {
     bytesRead = 0;
@@ -80,6 +86,11 @@ std::string AbstractChunk::getContentType()
     return source->getContentType();
 }
 
+enum RequestStatus AbstractChunk::getRequestStatus() const
+{
+    return source->getRequestStatus();
+}
+
 size_t AbstractChunk::getBytesRead() const
 {
     return this->bytesRead;
@@ -250,11 +261,10 @@ bool HTTPChunkSource::prepare()
                 break;
         }
 
-        enum RequestStatus status =
-                connection->request(connparams.getPath(), bytesRange);
-        if(status != RequestStatus::Success)
+        requeststatus = connection->request(connparams.getPath(), bytesRange);
+        if(requeststatus != RequestStatus::Success)
         {
-            if(status == RequestStatus::Redirection)
+            if(requeststatus == RequestStatus::Redirection)
             {
                 HTTPConnection *httpconn = dynamic_cast<HTTPConnection *>(connection);
                 if(httpconn)
diff --git a/modules/demux/adaptive/http/Chunk.h b/modules/demux/adaptive/http/Chunk.h
index 0b5efd5fe9..c1eb3ba2e5 100644
--- a/modules/demux/adaptive/http/Chunk.h
+++ b/modules/demux/adaptive/http/Chunk.h
@@ -53,8 +53,10 @@ namespace adaptive
                 void                setBytesRange   (const BytesRange &);
                 const BytesRange &  getBytesRange   () const;
                 virtual std::string getContentType  () const;
+                enum RequestStatus  getRequestStatus() const;
 
             protected:
+                enum RequestStatus  requeststatus;
                 size_t              contentLength;
                 BytesRange          bytesRange;
         };
@@ -65,6 +67,7 @@ namespace adaptive
                 virtual ~AbstractChunk();
 
                 std::string         getContentType          ();
+                enum RequestStatus  getRequestStatus        () const;
                 size_t              getBytesRead            () const;
                 uint64_t            getStartByteInFile      () const;
                 bool                isEmpty                 () const;



More information about the vlc-commits mailing list