Commit a53fc8ff authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: rewrite segments inheritance

parent eb1dd719
...@@ -69,24 +69,32 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const ...@@ -69,24 +69,32 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const
case INFOTYPE_INIT: case INFOTYPE_INIT:
{ {
/* init segments are always single segment */ /* init segments are always single segment */
ISegment *segment = getSegment( INFOTYPE_INIT ); if( segmentBase && segmentBase->initialisationSegment.Get() )
if( segment ) {
retSegments.push_back( segment ); retSegments.push_back( segmentBase->initialisationSegment.Get() );
}
else if( segmentList && segmentList->initialisationSegment.Get() )
{
retSegments.push_back( segmentList->initialisationSegment.Get() );
}
else if( mediaSegmentTemplate && mediaSegmentTemplate->initialisationSegment.Get() )
{
retSegments.push_back( mediaSegmentTemplate->initialisationSegment.Get() );
}
} }
break; break;
case INFOTYPE_MEDIA: case INFOTYPE_MEDIA:
{ {
SegmentList *segList = inheritSegmentList(); if( mediaSegmentTemplate )
if( inheritSegmentTemplate() )
{ {
retSegments.push_back( inheritSegmentTemplate() ); retSegments.push_back( mediaSegmentTemplate );
} }
else if ( segList && !segList->getSegments().empty() ) else if ( segmentList && !segmentList->getSegments().empty() )
{ {
std::vector<Segment *>::const_iterator it; std::vector<Segment *>::const_iterator it;
for(it=segList->getSegments().begin(); for(it=segmentList->getSegments().begin();
it!=segList->getSegments().end(); it++) it!=segmentList->getSegments().end(); it++)
{ {
std::vector<ISegment *> list = (*it)->subSegments(); std::vector<ISegment *> list = (*it)->subSegments();
retSegments.insert( retSegments.end(), list.begin(), list.end() ); retSegments.insert( retSegments.end(), list.begin(), list.end() );
...@@ -97,16 +105,26 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const ...@@ -97,16 +105,26 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const
case INFOTYPE_INDEX: case INFOTYPE_INDEX:
{ {
ISegment *segment = getSegment( INFOTYPE_INDEX ); /* index segments are always single segment */
if( segment ) if( segmentBase && segmentBase->indexSegment.Get() )
retSegments.push_back( segment ); {
retSegments.push_back( segmentBase->indexSegment.Get() );
}
else if( segmentList && segmentList->indexSegment.Get() )
{
retSegments.push_back( segmentList->indexSegment.Get() );
}
// templated index ?
} }
default: default:
break; break;
} }
return retSegments; if( retSegments.empty() && parent )
return parent->getSegments( type );
else
return retSegments;
} }
vector<ISegment *> SegmentInformation::getSegments() const vector<ISegment *> SegmentInformation::getSegments() const
...@@ -122,55 +140,22 @@ vector<ISegment *> SegmentInformation::getSegments() const ...@@ -122,55 +140,22 @@ vector<ISegment *> SegmentInformation::getSegments() const
ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) const ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) const
{ {
SegmentBase *segBase = inheritSegmentBase();
SegmentList *segList = inheritSegmentList();
ISegment *segment = NULL; ISegment *segment = NULL;
switch(type) vector<ISegment *> retSegments = getSegments( type );
const size_t size = retSegments.size();
if( size )
{ {
case INFOTYPE_INIT: /* check if that's a template (fixme: find a better way) */
if( segBase && segBase->initialisationSegment.Get() ) BaseSegmentTemplate *templ;
{ if( size == 1 && (templ = dynamic_cast<BaseSegmentTemplate*>(retSegments[0])) )
segment = segBase->initialisationSegment.Get(); {
} return templ;
else if( segList && segList->initialisationSegment.Get() ) }
{ else if( pos < size )
segment = segList->initialisationSegment.Get(); {
} segment = retSegments[pos];
else if( inheritSegmentTemplate() ) }
{
segment = inheritSegmentTemplate()->initialisationSegment.Get();
}
break;
case INFOTYPE_MEDIA:
if( inheritSegmentTemplate() )
{
segment = inheritSegmentTemplate();
}
else if ( segList && !segList->getSegments().empty() )
{
std::vector<Segment *> list = segList->getSegments();
if(pos < list.size())
segment = list.at(pos);
}
break;
case INFOTYPE_INDEX:
if( segBase && segBase->indexSegment.Get() )
{
segment = segBase->indexSegment.Get();
}
else if( segList && segList->indexSegment.Get() )
{
segment = segList->indexSegment.Get();
}
// templated index ?
break;
default:
break;
} }
return segment; return segment;
......
...@@ -250,23 +250,7 @@ void IsoffMainParser::setRepresentations (Node *adaptationSetNode, Adaptation ...@@ -250,23 +250,7 @@ void IsoffMainParser::setRepresentations (Node *adaptationSetNode, Adaptation
if(repNode->hasAttribute("mimeType")) if(repNode->hasAttribute("mimeType"))
currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType")); currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType"));
size_t totalmediasegments = parseSegmentInformation(repNode, currentRepresentation); parseSegmentInformation(repNode, currentRepresentation);
if(!totalmediasegments)
{
/* unranged & segment less representation, add fake segment */
SegmentList *list = new SegmentList();
Segment *seg = new Segment(currentRepresentation);
if(list && seg)
{
list->addSegment(seg);
currentRepresentation->setSegmentList(list);
}
else
{
delete seg;
delete list;
}
}
adaptationSet->addRepresentation(currentRepresentation); adaptationSet->addRepresentation(currentRepresentation);
} }
......
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