if(segmentBase.front()->hasAttribute("indexRange"))
{
SegmentList *list = new SegmentList();
- Segment *seg = new Segment(rep);
+ Segment *seg;
size_t start = 0, end = 0;
if (std::sscanf(segmentBase.front()->getAttributeValue("indexRange").c_str(), "%"PRIu64"-%"PRIu64, &start, &end) == 2)
{
+ seg = new IndexSegment(rep);
seg->setByteRange(start, end);
list->addSegment(seg);
/* index must be before data, so data starts at index end */
seg = new Segment(rep);
seg->setByteRange(end + 1, 0);
}
+ else
+ {
+ seg = new Segment(rep);
+ }
list->addSegment(seg);
rep->setSegmentList(list);
if(initSeg.size() > 0)
{
- Segment *seg = new Segment( currentRepresentation, true );
+ Segment *seg = new InitSegment( currentRepresentation );
seg->setSourceUrl(initSeg.at(0)->getAttributeValue("sourceURL"));
if(initSeg.at(0)->hasAttribute("range"))
startByte (0),
endByte (0)
{
+ debugName = "Segment";
+}
+dash::http::Chunk * ISegment::getChunk()
+{
+ return new SegmentChunk(this);
}
dash::http::Chunk* ISegment::toChunk()
{
- Chunk *chunk = new SegmentChunk(this);
+ Chunk *chunk = getChunk();
if (!chunk)
return NULL;
std::string ISegment::toString() const
{
- return std::string(" Segment url=").append(getUrlSegment());
+ std::stringstream ss(" ");
+ ss << debugName << " url=" << getUrlSegment();
+ if(startByte!=endByte)
+ ss << " @" << startByte << ".." << endByte;
+ return ss.str();
}
ISegment::SegmentChunk::SegmentChunk(ISegment *segment_) :
- Chunk()
+ dash::http::Chunk()
{
segment = segment_;
}
}
-Segment::Segment(Representation *parent, bool isinit, bool tosplit) :
+Segment::Segment(Representation *parent) :
ISegment(parent),
- parentRepresentation( parent ),
- init( isinit ),
- needssplit( tosplit )
+ parentRepresentation( parent )
{
assert( parent != NULL );
if ( parent->getSegmentInfo() != NULL && parent->getSegmentInfo()->getDuration() >= 0 )
this->sourceUrl = url;
}
-bool Segment::needsSplit() const
+Representation *Segment::getRepresentation() const
{
- return needssplit;
+ return parentRepresentation;
}
-Representation *Segment::getRepresentation() const
+
+std::string Segment::toString() const
{
- return parentRepresentation;
+ if (subsegments.empty())
+ {
+ return ISegment::toString();
+ }
+ else
+ {
+ std::string ret;
+ std::vector<SubSegment *>::const_iterator l;
+ for(l = subsegments.begin(); l != subsegments.end(); l++)
+ {
+ ret.append( (*l)->toString() );
+ }
+ return ret;
+ }
}
std::string Segment::getUrlSegment() const
return list;
}
-std::string Segment::toString() const
+InitSegment::InitSegment(Representation *parent) :
+ Segment(parent)
+{
+ debugName = "InitSegment";
+}
+
+IndexSegment::IndexSegment(Representation *parent) :
+ Segment(parent)
+{
+ debugName = "IndexSegment";
+}
+
+dash::http::Chunk * IndexSegment::getChunk()
+{
+ return new IndexSegmentChunk(this);
+}
+
+IndexSegment::IndexSegmentChunk::IndexSegmentChunk(ISegment *segment)
+ : SegmentChunk(segment)
+{
+
+}
+
+void IndexSegment::IndexSegmentChunk::onDownload(void *buffer, size_t size)
{
- if (init)
- return std::string(" InitSeg url=")
- .append(getUrlSegment());
- else
- return ISegment::toString();
}
SubSegment::SubSegment(Segment *main, size_t start, size_t end) :
ISegment(main), parent(main)
{
setByteRange(start, end);
+ debugName = "SubSegment";
}
std::string SubSegment::getUrlSegment() const
protected:
size_t startByte;
size_t endByte;
+ std::string debugName;
class SegmentChunk : public dash::http::Chunk
{
SegmentChunk(ISegment *segment);
virtual void onDownload(void *, size_t);
- private:
+ protected:
ISegment *segment;
};
+
+ virtual dash::http::Chunk * getChunk();
};
class Segment : public ISegment
{
public:
- Segment( Representation *parent, bool isinit = false, bool tosplit = false );
+ Segment( Representation *parent );
~Segment();
virtual void setSourceUrl( const std::string &url );
- virtual bool needsSplit() const;
virtual std::string getUrlSegment() const; /* impl */
virtual dash::http::Chunk* toChunk();
virtual std::vector<ISegment*> subSegments();
- virtual std::string toString() const;
virtual Representation* getRepresentation() const;
protected:
Representation* parentRepresentation;
- bool init;
- bool needssplit;
std::vector<SubSegment *> subsegments;
std::string sourceUrl;
int size;
};
+ class InitSegment : public Segment
+ {
+ public:
+ InitSegment( Representation *parent );
+ };
+
+ class IndexSegment : public Segment
+ {
+ public:
+ IndexSegment( Representation *parent );
+
+ protected:
+ class IndexSegmentChunk : public SegmentChunk
+ {
+ public:
+ IndexSegmentChunk(ISegment *segment);
+ virtual void onDownload(void *, size_t);
+ };
+
+ virtual dash::http::Chunk * getChunk();
+ };
+
class SubSegment : public ISegment
{
public: