Commit 727ef476 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: seek on subsegments by time

parent 800a74a5
...@@ -171,27 +171,33 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co ...@@ -171,27 +171,33 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) const bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) const
{ {
SegmentList *segList;
MediaSegmentTemplate *mediaTemplate; MediaSegmentTemplate *mediaTemplate;
uint64_t timescale = 1;
mtime_t duration = 0;
if( (mediaTemplate = inheritSegmentTemplate()) ) if( (mediaTemplate = inheritSegmentTemplate()) )
{ {
timescale = mediaTemplate->inheritTimescale(); uint64_t timescale = mediaTemplate->inheritTimescale();
duration = mediaTemplate->duration.Get(); mtime_t duration = mediaTemplate->duration.Get();
}
else if ( (segList = inheritSegmentList()) )
{
timescale = segList->inheritTimescale();
duration = segList->duration.Get();
}
if(duration) if(duration)
{ {
*ret = time / (CLOCK_FREQ * duration / timescale); *ret = time / (CLOCK_FREQ * duration / timescale);
return true; return true;
} }
}
else
{
const std::vector<ISegment *> segments = getSegments(INFOTYPE_MEDIA);
std::vector<ISegment *>::const_iterator it;
*ret = 0;
for(it = segments.begin(); it != segments.end(); ++it)
{
if((*it)->startTime.Get() > VLC_TS_INVALID &&
(*it)->startTime.Get() > time &&
it != segments.begin())
{
return true;
}
(*ret)++;
}
}
return false; return false;
} }
......
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