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

demux: adaptative: seek on subsegments by time

parent 800a74a5
...@@ -171,26 +171,32 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co ...@@ -171,26 +171,32 @@ 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();
} if(duration)
else if ( (segList = inheritSegmentList()) ) {
{ *ret = time / (CLOCK_FREQ * duration / timescale);
timescale = segList->inheritTimescale(); return true;
duration = segList->duration.Get(); }
} }
else
if(duration)
{ {
*ret = time / (CLOCK_FREQ * duration / timescale); const std::vector<ISegment *> segments = getSegments(INFOTYPE_MEDIA);
return true; 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