Commit a98cee48 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: dash: handle index segment

parent 6681e69d
......@@ -30,6 +30,7 @@ SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, AbstractPlaylist
{
count = 0;
initializing = true;
indexed = false;
prevRepresentation = NULL;
setAdaptationLogic(logic_);
playlist = playlist_;
......@@ -82,6 +83,14 @@ Chunk * SegmentTracker::getNextChunk(Streams::Type type)
return segment->toChunk(count, rep);
}
if(!indexed)
{
indexed = true;
segment = rep->getSegment(BaseRepresentation::INFOTYPE_INDEX);
if(segment)
return segment->toChunk(count, rep);
}
segment = rep->getSegment(BaseRepresentation::INFOTYPE_MEDIA, count);
if(!segment)
{
......
......@@ -64,6 +64,7 @@ namespace adaptative
private:
bool initializing;
bool indexed;
uint64_t count;
AbstractAdaptationLogic *logic;
AbstractPlaylist *playlist;
......
......@@ -27,7 +27,8 @@
using namespace adaptative::playlist;
SegmentBase::SegmentBase () :
Initializable()
Initializable(),
Indexable()
{
}
SegmentBase::~SegmentBase ()
......
......@@ -32,7 +32,8 @@ namespace adaptative
{
namespace playlist
{
class SegmentBase : public Initializable<Segment>
class SegmentBase : public Initializable<Segment>,
public Indexable<Segment>
{
public:
SegmentBase ();
......
......@@ -64,7 +64,7 @@ uint64_t TimescaleAble::inheritTimescale() const
}
SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
ICanonicalUrl( parent ), Initializable(),
ICanonicalUrl( parent ), Initializable(), Indexable(),
duration( 0 ),
startIndex( 0 )
{
......
......@@ -52,6 +52,20 @@ namespace adaptative
Property<T *> initialisationSegment;
};
template<class T> class Indexable
{
public:
Indexable()
{
indexSegment.Set(NULL);
}
~Indexable()
{
delete indexSegment.Get();
}
Property<T *> indexSegment;
};
class Timelineable
{
public:
......@@ -88,7 +102,8 @@ namespace adaptative
};
class SegmentInfoCommon : public ICanonicalUrl,
public Initializable<Segment>
public Initializable<Segment>,
public Indexable<Segment>
{
public:
SegmentInfoCommon( ICanonicalUrl *parent = NULL );
......
......@@ -93,6 +93,14 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const
}
}
}
break;
case INFOTYPE_INDEX:
{
ISegment *segment = getSegment( INFOTYPE_INDEX );
if( segment )
retSegments.push_back( segment );
}
default:
break;
......@@ -150,7 +158,17 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
break;
case INFOTYPE_INDEX:
//returned with media for now;
if( segBase && segBase->indexSegment.Get() )
{
segment = segBase->indexSegment.Get();
}
else if( segList && segList->indexSegment.Get() )
{
segment = segList->indexSegment.Get();
}
// templated index ?
break;
default:
break;
}
......
......@@ -265,9 +265,9 @@ size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformat
size_t start = 0, end = 0;
if (std::sscanf(segmentBaseNode->getAttributeValue("indexRange").c_str(), "%zu-%zu", &start, &end) == 2)
{
seg = new DashIndexSegment(info);
seg->setByteRange(start, end);
list->addSegment(seg);
IndexSegment *index = new DashIndexSegment(info);
index->setByteRange(start, end);
list->indexSegment.Set(index);
/* index must be before data, so data starts at index end */
seg = new Segment(info);
seg->setByteRange(end + 1, 0);
......
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