Commit 2f04d039 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: compute timelines boundaries

parent 4f6a2a57
......@@ -135,6 +135,25 @@ Period* MPD::getNextPeriod(Period *period)
return NULL;
}
void MPD::getTimeLinesBoundaries(mtime_t *min, mtime_t *max) const
{
*min = *max = 0;
for(size_t i = 0; i < periods.size(); i++)
{
std::vector<SegmentTimeline *> timelines;
periods.at(i)->collectTimelines(&timelines);
for(size_t j = 0; j < timelines.size(); j++)
{
const SegmentTimeline *timeline = timelines.at(j);
if(timeline->start() > *min)
*min = timeline->start();
if(!*max || timeline->end() < *max)
*max = timeline->end();
}
}
}
void MPD::mergeWith(MPD *updatedMPD)
{
availabilityEndTime.Set(updatedMPD->availabilityEndTime.Get());
......
......@@ -61,6 +61,7 @@ namespace dash
virtual Period* getNextPeriod(Period *period);
void mergeWith(MPD *);
void getTimeLinesBoundaries(mtime_t *, mtime_t *) const;
Property<time_t> duration;
Property<time_t> playbackStart;
......
......@@ -176,6 +176,22 @@ void SegmentTimeline::mergeWith(SegmentTimeline &other)
}
}
mtime_t SegmentTimeline::start() const
{
if(elements.empty())
return 0;
return CLOCK_FREQ * elements.front()->t / inheritTimescale();
}
mtime_t SegmentTimeline::end() const
{
if(elements.empty())
return 0;
const Element *last = elements.back();
mtime_t scaled = last->t + last->d * (last->r + 1);
return CLOCK_FREQ * scaled / inheritTimescale();
}
SegmentTimeline::Element::Element(mtime_t d_, uint64_t r_, mtime_t t_)
{
d = d_;
......
......@@ -43,6 +43,8 @@ namespace dash
mtime_t getScaledPlaybackTimeByElementNumber(uint64_t) const;
size_t prune(mtime_t);
void mergeWith(SegmentTimeline &);
mtime_t start() const;
mtime_t end() const;
private:
std::list<Element *> elements;
......
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