Commit a1c9926d authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: first timeline number

parent 3f1a8f84
......@@ -174,10 +174,19 @@ ISegment * SegmentInformation::getNextSegment(SegmentInfoType type, uint64_t i_p
{
/* Check if we don't exceed timeline */
MediaSegmentTemplate *templ = dynamic_cast<MediaSegmentTemplate*>(retSegments[0]);
if(templ && templ->segmentTimeline.Get() &&
templ->segmentTimeline.Get()->maxElementNumber() < i_pos)
return NULL;
*pi_newpos = std::max(seg->getSequenceNumber(), i_pos);
SegmentTimeline *timeline = (templ) ? templ->segmentTimeline.Get() : NULL;
if(timeline)
{
*pi_newpos = std::max(timeline->minElementNumber(), i_pos);
if(timeline->maxElementNumber() < i_pos)
return NULL;
}
else
{
*pi_newpos = i_pos;
/* start number */
*pi_newpos = std::max(templ->startNumber.Get(), i_pos);
}
return seg;
}
else if(seg->getSequenceNumber() >= i_pos)
......
......@@ -115,6 +115,13 @@ uint64_t SegmentTimeline::maxElementNumber() const
return e->number + e->r;
}
uint64_t SegmentTimeline::minElementNumber() const
{
if(elements.empty())
return 0;
return elements.front()->number;
}
size_t SegmentTimeline::prune(mtime_t time)
{
stime_t scaled = time * inheritTimescale() / CLOCK_FREQ;
......
......@@ -47,6 +47,7 @@ namespace adaptative
uint64_t getElementNumberByScaledPlaybackTime(stime_t) const;
stime_t getScaledPlaybackTimeByElementNumber(uint64_t) const;
uint64_t maxElementNumber() const;
uint64_t minElementNumber() const;
size_t prune(mtime_t);
void mergeWith(SegmentTimeline &);
mtime_t start() const;
......
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