Commit 5f8fc0c9 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: have chunks ref segments

parent be6bf779
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "Segment.h" #include "Segment.h"
#include "BaseRepresentation.h" #include "BaseRepresentation.h"
#include <cassert>
using namespace adaptative::http; using namespace adaptative::http;
using namespace adaptative::playlist; using namespace adaptative::playlist;
...@@ -42,6 +43,12 @@ ISegment::ISegment(const ICanonicalUrl *parent): ...@@ -42,6 +43,12 @@ ISegment::ISegment(const ICanonicalUrl *parent):
classId = CLASSID_ISEGMENT; classId = CLASSID_ISEGMENT;
startTime.Set(VLC_TS_INVALID); startTime.Set(VLC_TS_INVALID);
duration.Set(0); duration.Set(0);
chunksuse.Set(0);
}
ISegment::~ISegment()
{
assert(chunksuse.Get() == 0);
} }
Chunk * ISegment::getChunk(const std::string &url) Chunk * ISegment::getChunk(const std::string &url)
...@@ -114,6 +121,13 @@ ISegment::SegmentChunk::SegmentChunk(ISegment *segment_, const std::string &url) ...@@ -114,6 +121,13 @@ ISegment::SegmentChunk::SegmentChunk(ISegment *segment_, const std::string &url)
Chunk(url) Chunk(url)
{ {
segment = segment_; segment = segment_;
segment->chunksuse.Set(segment->chunksuse.Get() + 1);
}
ISegment::SegmentChunk::~SegmentChunk()
{
assert(segment->chunksuse.Get() > 0);
segment->chunksuse.Set(segment->chunksuse.Get() - 1);
} }
void ISegment::SegmentChunk::setRepresentation(BaseRepresentation *rep_) void ISegment::SegmentChunk::setRepresentation(BaseRepresentation *rep_)
......
...@@ -45,7 +45,7 @@ namespace adaptative ...@@ -45,7 +45,7 @@ namespace adaptative
{ {
public: public:
ISegment(const ICanonicalUrl *parent); ISegment(const ICanonicalUrl *parent);
virtual ~ISegment(){} virtual ~ISegment();
/** /**
* @return true if the segment should be dropped after being read. * @return true if the segment should be dropped after being read.
* That is basically true when using an Url, and false * That is basically true when using an Url, and false
...@@ -61,6 +61,7 @@ namespace adaptative ...@@ -61,6 +61,7 @@ namespace adaptative
int getClassId () const; int getClassId () const;
Property<mtime_t> startTime; Property<mtime_t> startTime;
Property<mtime_t> duration; Property<mtime_t> duration;
Property<unsigned> chunksuse;
static const int CLASSID_ISEGMENT = 0; static const int CLASSID_ISEGMENT = 0;
...@@ -74,6 +75,7 @@ namespace adaptative ...@@ -74,6 +75,7 @@ namespace adaptative
{ {
public: public:
SegmentChunk(ISegment *segment, const std::string &url); SegmentChunk(ISegment *segment, const std::string &url);
virtual ~SegmentChunk();
void setRepresentation(BaseRepresentation *); void setRepresentation(BaseRepresentation *);
virtual void onDownload(block_t **); // reimpl virtual void onDownload(block_t **); // 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