Commit ef001ee4 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: merge timelines/segments boundaries

parent 4312d4a1
...@@ -110,24 +110,6 @@ BasePeriod* AbstractPlaylist::getNextPeriod(BasePeriod *period) ...@@ -110,24 +110,6 @@ BasePeriod* AbstractPlaylist::getNextPeriod(BasePeriod *period)
return NULL; return NULL;
} }
void AbstractPlaylist::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 AbstractPlaylist::getPlaylistDurationsRange(mtime_t *min, mtime_t *max) const void AbstractPlaylist::getPlaylistDurationsRange(mtime_t *min, mtime_t *max) const
{ {
......
...@@ -55,7 +55,6 @@ namespace adaptative ...@@ -55,7 +55,6 @@ namespace adaptative
void mergeWith(AbstractPlaylist *, mtime_t = 0); void mergeWith(AbstractPlaylist *, mtime_t = 0);
void pruneBySegmentNumber(uint64_t); void pruneBySegmentNumber(uint64_t);
void getTimeLinesBoundaries(mtime_t *, mtime_t *) const;
void getPlaylistDurationsRange(mtime_t *, mtime_t *) const; void getPlaylistDurationsRange(mtime_t *, mtime_t *) const;
Property<mtime_t> duration; Property<mtime_t> duration;
......
...@@ -244,15 +244,7 @@ mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) cons ...@@ -244,15 +244,7 @@ mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) cons
return time; return time;
} }
void SegmentInformation::collectTimelines(std::vector<SegmentTimeline *> *timelines) const
{
if(mediaSegmentTemplate && mediaSegmentTemplate->segmentTimeline.Get())
timelines->push_back(mediaSegmentTemplate->segmentTimeline.Get());
std::vector<SegmentInformation *>::const_iterator it;
for(it = childs.begin(); it != childs.end(); ++it)
(*it)->collectTimelines(timelines);
}
void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const
{ {
...@@ -276,6 +268,18 @@ void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const ...@@ -276,6 +268,18 @@ void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const
if(total > *max) if(total > *max)
*max = total; *max = total;
if(mediaSegmentTemplate && mediaSegmentTemplate->segmentTimeline.Get())
{
const mtime_t duration = mediaSegmentTemplate->segmentTimeline.Get()->start() -
mediaSegmentTemplate->segmentTimeline.Get()->end();
if (!*min || duration < *min)
*min = duration;
if(duration > *max)
*max = duration;
}
for(size_t i=0; i<childs.size(); i++) for(size_t i=0; i<childs.size(); i++)
childs.at(i)->getDurationsRange(min, max); childs.at(i)->getDurationsRange(min, max);
} }
......
...@@ -80,7 +80,6 @@ namespace adaptative ...@@ -80,7 +80,6 @@ namespace adaptative
ISegment * getSegment(SegmentInfoType, uint64_t = 0) const; ISegment * getSegment(SegmentInfoType, uint64_t = 0) const;
bool getSegmentNumberByTime(mtime_t, uint64_t *) const; bool getSegmentNumberByTime(mtime_t, uint64_t *) const;
mtime_t getPlaybackTimeBySegmentNumber(uint64_t) const; mtime_t getPlaybackTimeBySegmentNumber(uint64_t) const;
void collectTimelines(std::vector<SegmentTimeline *> *) const;
void getDurationsRange(mtime_t *, mtime_t *) const; void getDurationsRange(mtime_t *, mtime_t *) const;
virtual void mergeWith(SegmentInformation *, mtime_t); virtual void mergeWith(SegmentInformation *, mtime_t);
virtual void pruneBySegmentNumber(uint64_t); virtual void pruneBySegmentNumber(uint64_t);
......
...@@ -133,7 +133,7 @@ bool DASHManager::updatePlaylist() ...@@ -133,7 +133,7 @@ bool DASHManager::updatePlaylist()
/* Compute new MPD update time */ /* Compute new MPD update time */
mtime_t mininterval = 0; mtime_t mininterval = 0;
mtime_t maxinterval = 0; mtime_t maxinterval = 0;
playlist->getTimeLinesBoundaries(&mininterval, &maxinterval); playlist->getPlaylistDurationsRange(&mininterval, &maxinterval);
if(playlist->minUpdatePeriod.Get() > mininterval) if(playlist->minUpdatePeriod.Get() > mininterval)
mininterval = playlist->minUpdatePeriod.Get(); mininterval = playlist->minUpdatePeriod.Get();
......
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