Commit 0771fb4b authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: compute segment time in segmentlist

parent 2bf7935f
......@@ -223,11 +223,10 @@ mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) cons
{
SegmentList *segList;
MediaSegmentTemplate *mediaTemplate;
uint64_t timescale = 1;
mtime_t time = 0;
if( (mediaTemplate = inheritSegmentTemplate()) )
{
timescale = mediaTemplate->inheritTimescale();
uint64_t timescale = mediaTemplate->inheritTimescale();
if(mediaTemplate->segmentTimeline.Get())
{
time = mediaTemplate->segmentTimeline.Get()->
......@@ -237,16 +236,13 @@ mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) cons
{
time = number * mediaTemplate->duration.Get();
}
time = CLOCK_FREQ * time / timescale;
}
else if ( (segList = inheritSegmentList()) )
{
timescale = segList->inheritTimescale();
time = number * segList->duration.Get();
time = segList->getPlaybackTimeBySegmentNumber(number);
}
if(time)
time = CLOCK_FREQ * time / timescale;
return time;
}
......
......@@ -86,6 +86,29 @@ void SegmentList::pruneBySegmentNumber(uint64_t tobelownum)
}
}
mtime_t SegmentList::getPlaybackTimeBySegmentNumber(uint64_t number)
{
if(number < pruned || segments.empty())
return 0;
uint64_t timescale = inheritTimescale();
mtime_t time = segments.at(0)->startTime.Get();
if(segments.at(0)->duration.Get())
{
number -= pruned;
for(size_t i=0; i<number && i<segments.size(); i++)
time += segments.at(i)->duration.Get();
}
else
{
time = number * duration.Get();
}
return CLOCK_FREQ * time / timescale;
}
std::size_t SegmentList::getOffset() const
{
return pruned;
......
......@@ -49,6 +49,7 @@ namespace adaptative
void addSegment(Segment *seg);
void mergeWith(SegmentList *);
void pruneBySegmentNumber(uint64_t);
mtime_t getPlaybackTimeBySegmentNumber(uint64_t);
std::size_t getOffset() const;
private:
......
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