Commit 3bb8d715 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: add chunk prepare

parent 422cceae
......@@ -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;
......
......@@ -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 &);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment