Commit 5e2ee253 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: merge toChunk/getChunk

AbstractChunk no longer segment chunk
parent de1cde08
......@@ -61,35 +61,32 @@ ISegment::~ISegment()
assert(chunksuse.Get() == 0);
}
SegmentChunk * ISegment::getChunk(const std::string &url, BaseRepresentation *rep, HTTPConnectionManager *connManager)
{
HTTPChunkBufferedSource *source = new HTTPChunkBufferedSource(url, connManager);
if(startByte != endByte)
source->setBytesRange(BytesRange(startByte, endByte));
connManager->downloader->schedule(source);
return new (std::nothrow) SegmentChunk(this, source, rep);
}
void ISegment::onChunkDownload(block_t **, SegmentChunk *, BaseRepresentation *)
{
}
SegmentChunk* ISegment::toChunk(size_t index, BaseRepresentation *ctxrep, HTTPConnectionManager *connManager)
SegmentChunk* ISegment::toChunk(size_t index, BaseRepresentation *rep, HTTPConnectionManager *connManager)
{
SegmentChunk *chunk;
try
const std::string url = getUrlSegment().toString(index, rep);
HTTPChunkBufferedSource *source = new (std::nothrow) HTTPChunkBufferedSource(url, connManager);
if( source )
{
chunk = getChunk(getUrlSegment().toString(index, ctxrep), ctxrep, connManager);
if (!chunk)
return NULL;
if(startByte != endByte)
source->setBytesRange(BytesRange(startByte, endByte));
SegmentChunk *chunk = new (std::nothrow) SegmentChunk(this, source, rep);
if( chunk )
{
connManager->downloader->schedule(source);
return chunk;
}
else
{
delete source;
}
}
catch (int)
{
return NULL;
};
return chunk;
return NULL;
}
bool ISegment::isTemplate() const
......
......@@ -88,8 +88,6 @@ namespace adaptive
uint64_t sequence;
static const int SEQUENCE_INVALID;
static const int SEQUENCE_FIRST;
virtual SegmentChunk * getChunk(const std::string &, BaseRepresentation *, HTTPConnectionManager *);
};
class Segment : public ISegment
......
......@@ -299,14 +299,20 @@ block_t * ForgedInitSegment::buildMoovBox()
return moov;
}
SegmentChunk * ForgedInitSegment::getChunk(const std::string &, BaseRepresentation *rep, HTTPConnectionManager *)
SegmentChunk* ForgedInitSegment::toChunk(size_t, BaseRepresentation *rep, HTTPConnectionManager *)
{
block_t *moov = buildMoovBox();
if(moov)
{
MemoryChunkSource *source = new (std::nothrow) MemoryChunkSource(moov);
return new (std::nothrow) SegmentChunk(this, source, rep);
if( source )
{
SegmentChunk *chunk = new (std::nothrow) SegmentChunk(this, source, rep);
if( chunk )
return chunk;
else
delete source;
}
}
return NULL;
}
......@@ -39,6 +39,7 @@ namespace smooth
ForgedInitSegment(ICanonicalUrl *parent, const std::string &,
uint64_t, uint64_t);
virtual ~ForgedInitSegment();
virtual SegmentChunk* toChunk(size_t, BaseRepresentation *, HTTPConnectionManager *); /* reimpl */
void setWaveFormatEx(const std::string &);
void setCodecPrivateData(const std::string &);
void setChannels(uint16_t);
......@@ -51,9 +52,6 @@ namespace smooth
void setTrackID(unsigned);
void setLanguage(const std::string &);
protected:
virtual SegmentChunk * getChunk(const std::string &, BaseRepresentation *, HTTPConnectionManager *); /* reimpl */
private:
void fromWaveFormatEx(const uint8_t *p_data, size_t i_data);
void fromVideoInfoHeader(const uint8_t *p_data, size_t i_data);
......
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