[vlc-commits] demux: adaptative: add chunk prepare
Francois Cartegnie
git at videolan.org
Thu Nov 19 14:47:38 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 16 15:55:35 2015 +0100| [3bb8d715351243d10df046a02d057f0693e0c8bd] | committer: Francois Cartegnie
demux: adaptative: add chunk prepare
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3bb8d715351243d10df046a02d057f0693e0c8bd
---
modules/demux/adaptative/http/Chunk.cpp | 30 ++++++++++++++++++++----------
modules/demux/adaptative/http/Chunk.h | 2 ++
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/modules/demux/adaptative/http/Chunk.cpp b/modules/demux/adaptative/http/Chunk.cpp
index cd34374..747d7d9 100644
--- a/modules/demux/adaptative/http/Chunk.cpp
+++ b/modules/demux/adaptative/http/Chunk.cpp
@@ -115,6 +115,7 @@ HTTPChunkSource::HTTPChunkSource(const std::string& url, HTTPConnectionManager *
consumed (0),
port (0)
{
+ prepared = false;
if(!init(url))
throw VLC_EGENERIC;
}
@@ -188,26 +189,35 @@ block_t * HTTPChunkSource::consume(size_t readsize)
return p_block;
}
-block_t * HTTPChunkSource::read(size_t readsize)
+bool HTTPChunkSource::prepare()
{
+ if(prepared)
+ return true;
+
if(!connManager || !parentChunk)
- return NULL;
+ return false;
if(!connection)
{
connection = connManager->getConnection(scheme, hostname, port);
if(!connection)
- return NULL;
+ return false;
}
- if(consumed == 0)
- {
- if( connection->query(path, bytesRange) != VLC_SUCCESS )
- return NULL;
- /* Because we don't know Chunk size at start, we need to get size
+ if( connection->query(path, bytesRange) != VLC_SUCCESS )
+ return false;
+ /* Because we don't know Chunk size at start, we need to get size
from content length */
- contentLength = connection->getContentLength();
- }
+ contentLength = connection->getContentLength();
+ prepared = true;
+
+ return true;
+}
+
+block_t * HTTPChunkSource::read(size_t readsize)
+{
+ if(!prepare())
+ return NULL;
if(consumed == contentLength && consumed > 0)
return NULL;
diff --git a/modules/demux/adaptative/http/Chunk.h b/modules/demux/adaptative/http/Chunk.h
index dd45573..a100bc3 100644
--- a/modules/demux/adaptative/http/Chunk.h
+++ b/modules/demux/adaptative/http/Chunk.h
@@ -87,10 +87,12 @@ namespace adaptative
static const size_t CHUNK_SIZE = 32768;
protected:
+ virtual bool prepare();
virtual block_t * consume(size_t);
HTTPConnection *connection;
HTTPConnectionManager *connManager;
size_t consumed; /* read pointer */
+ bool prepared;
private:
bool init(const std::string &);
More information about the vlc-commits
mailing list