Commit a98cee48 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: handle index segment

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