Commit be6bf779 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: allow altering block after download

parent 4603cb4a
...@@ -221,7 +221,7 @@ size_t Stream::read(HTTPConnectionManager *connManager) ...@@ -221,7 +221,7 @@ size_t Stream::read(HTTPConnectionManager *connManager)
if (chunk->getBytesToRead() == 0) if (chunk->getBytesToRead() == 0)
{ {
chunk->onDownload(block->p_buffer, block->i_buffer); chunk->onDownload(&block);
chunk->getConnection()->releaseChunk(); chunk->getConnection()->releaseChunk();
currentChunk = NULL; currentChunk = NULL;
delete chunk; delete chunk;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <string> #include <string>
#include <stdint.h> #include <stdint.h>
typedef struct block_t block_t;
namespace adaptative namespace adaptative
{ {
namespace http namespace http
...@@ -65,7 +67,7 @@ namespace adaptative ...@@ -65,7 +67,7 @@ namespace adaptative
void setBitrate (uint64_t bitrate); void setBitrate (uint64_t bitrate);
int getBitrate (); int getBitrate ();
virtual void onDownload (void *, size_t) {} virtual void onDownload (block_t **) {}
private: private:
std::string url; std::string url;
......
...@@ -49,7 +49,7 @@ Chunk * ISegment::getChunk(const std::string &url) ...@@ -49,7 +49,7 @@ Chunk * ISegment::getChunk(const std::string &url)
return new (std::nothrow) SegmentChunk(this, url); return new (std::nothrow) SegmentChunk(this, url);
} }
void ISegment::onChunkDownload(void *, size_t, Chunk *, BaseRepresentation *) void ISegment::onChunkDownload(block_t **, Chunk *, BaseRepresentation *)
{ {
} }
...@@ -121,9 +121,9 @@ void ISegment::SegmentChunk::setRepresentation(BaseRepresentation *rep_) ...@@ -121,9 +121,9 @@ void ISegment::SegmentChunk::setRepresentation(BaseRepresentation *rep_)
rep = rep_; rep = rep_;
} }
void ISegment::SegmentChunk::onDownload(void *data, size_t size) void ISegment::SegmentChunk::onDownload(block_t **pp_block)
{ {
segment->onChunkDownload(data, size, this, rep); segment->onChunkDownload(pp_block, this, rep);
} }
Segment::Segment(ICanonicalUrl *parent) : Segment::Segment(ICanonicalUrl *parent) :
......
...@@ -75,7 +75,7 @@ namespace adaptative ...@@ -75,7 +75,7 @@ namespace adaptative
public: public:
SegmentChunk(ISegment *segment, const std::string &url); SegmentChunk(ISegment *segment, const std::string &url);
void setRepresentation(BaseRepresentation *); void setRepresentation(BaseRepresentation *);
virtual void onDownload(void *, size_t); // reimpl virtual void onDownload(block_t **); // reimpl
protected: protected:
ISegment *segment; ISegment *segment;
...@@ -83,7 +83,7 @@ namespace adaptative ...@@ -83,7 +83,7 @@ namespace adaptative
}; };
virtual Chunk * getChunk(const std::string &); virtual Chunk * getChunk(const std::string &);
virtual void onChunkDownload(void *, size_t, Chunk *, BaseRepresentation *); virtual void onChunkDownload(block_t **, Chunk *, BaseRepresentation *);
}; };
class Segment : public ISegment class Segment : public ISegment
......
...@@ -41,12 +41,12 @@ AtomsReader::~AtomsReader() ...@@ -41,12 +41,12 @@ AtomsReader::~AtomsReader()
delete rootbox; delete rootbox;
} }
bool AtomsReader::parseBlock(void *buffer, size_t size, BaseRepresentation *rep) bool AtomsReader::parseBlock(block_t *p_block, BaseRepresentation *rep)
{ {
if(!rep) if(!rep)
return false; return false;
stream_t *stream = stream_MemoryNew( object, (uint8_t *)buffer, size, true); stream_t *stream = stream_MemoryNew( object, p_block->p_buffer, p_block->i_buffer, true);
if (stream) if (stream)
{ {
rootbox = new MP4_Box_t; rootbox = new MP4_Box_t;
...@@ -57,7 +57,7 @@ bool AtomsReader::parseBlock(void *buffer, size_t size, BaseRepresentation *rep) ...@@ -57,7 +57,7 @@ bool AtomsReader::parseBlock(void *buffer, size_t size, BaseRepresentation *rep)
} }
memset(rootbox, 0, sizeof(*rootbox)); memset(rootbox, 0, sizeof(*rootbox));
rootbox->i_type = ATOM_root; rootbox->i_type = ATOM_root;
rootbox->i_size = size; rootbox->i_size = p_block->i_buffer;
if ( MP4_ReadBoxContainerChildren( stream, rootbox, 0 ) == 1 ) if ( MP4_ReadBoxContainerChildren( stream, rootbox, 0 ) == 1 )
{ {
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -49,7 +49,7 @@ namespace dash ...@@ -49,7 +49,7 @@ namespace dash
public: public:
AtomsReader(vlc_object_t *); AtomsReader(vlc_object_t *);
~AtomsReader(); ~AtomsReader();
bool parseBlock(void *, size_t, adaptative::playlist::BaseRepresentation *); bool parseBlock(block_t *, adaptative::playlist::BaseRepresentation *);
protected: protected:
vlc_object_t *object; vlc_object_t *object;
......
...@@ -49,11 +49,11 @@ Chunk* DashIndexSegment::toChunk(size_t index, BaseRepresentation *ctxrep) ...@@ -49,11 +49,11 @@ Chunk* DashIndexSegment::toChunk(size_t index, BaseRepresentation *ctxrep)
return chunk; return chunk;
} }
void DashIndexSegment::onChunkDownload(void *data, size_t size, Chunk *, BaseRepresentation *rep) void DashIndexSegment::onChunkDownload(block_t **pp_block, Chunk *, BaseRepresentation *rep)
{ {
if(!rep) if(!rep)
return; return;
AtomsReader br(rep->getPlaylist()->getVLCObject()); AtomsReader br(rep->getPlaylist()->getVLCObject());
br.parseBlock(data, size, rep); br.parseBlock(*pp_block, rep);
} }
...@@ -41,7 +41,7 @@ namespace dash ...@@ -41,7 +41,7 @@ namespace dash
virtual Chunk* toChunk(size_t, BaseRepresentation * = NULL); //reimpl virtual Chunk* toChunk(size_t, BaseRepresentation * = NULL); //reimpl
protected: protected:
virtual void onChunkDownload(void *, size_t, Chunk *, BaseRepresentation *); //reimpl virtual void onChunkDownload(block_t **, Chunk *, BaseRepresentation *); //reimpl
}; };
} }
......
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