Commit e5de71d0 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: prune expired live timeline elements

parent 5d66046d
...@@ -223,10 +223,20 @@ bool DASHManager::updateMPD() ...@@ -223,10 +223,20 @@ bool DASHManager::updateMPD()
return false; return false;
} }
mtime_t minsegmentTime = 0;
for(int type=0; type<Streams::count; type++)
{
if(!streams[type])
continue;
mtime_t segmentTime = streams[type]->getPosition();
if(!minsegmentTime || segmentTime < minsegmentTime)
minsegmentTime = segmentTime;
}
MPD *newmpd = MPDFactory::create(parser.getRootNode(), mpdstream, parser.getProfile()); MPD *newmpd = MPDFactory::create(parser.getRootNode(), mpdstream, parser.getProfile());
if(newmpd) if(newmpd)
{ {
mpd->mergeWith(newmpd); mpd->mergeWith(newmpd, minsegmentTime);
delete newmpd; delete newmpd;
} }
stream_Delete(mpdstream); stream_Delete(mpdstream);
......
...@@ -108,3 +108,11 @@ bool SegmentTracker::setPosition(mtime_t time, bool tryonly) ...@@ -108,3 +108,11 @@ bool SegmentTracker::setPosition(mtime_t time, bool tryonly)
} }
return false; return false;
} }
mtime_t SegmentTracker::getSegmentStart() const
{
if(prevRepresentation)
return prevRepresentation->getPlaybackTimeBySegmentNumber(count);
else
return 0;
}
...@@ -57,6 +57,7 @@ namespace dash ...@@ -57,6 +57,7 @@ namespace dash
void resetCounter(); void resetCounter();
http::Chunk* getNextChunk(Streams::Type); http::Chunk* getNextChunk(Streams::Type);
bool setPosition(mtime_t, bool); bool setPosition(mtime_t, bool);
mtime_t getSegmentStart() const;
private: private:
bool initializing; bool initializing;
......
...@@ -223,6 +223,11 @@ bool Stream::setPosition(mtime_t time, bool tryonly) ...@@ -223,6 +223,11 @@ bool Stream::setPosition(mtime_t time, bool tryonly)
return ret; return ret;
} }
mtime_t Stream::getPosition() const
{
return segmentTracker->getSegmentStart();
}
AbstractStreamOutput::AbstractStreamOutput(demux_t *demux) AbstractStreamOutput::AbstractStreamOutput(demux_t *demux)
{ {
realdemux = demux; realdemux = demux;
......
...@@ -56,6 +56,7 @@ namespace dash ...@@ -56,6 +56,7 @@ namespace dash
bool seekAble() const; bool seekAble() const;
size_t read(http::HTTPConnectionManager *); size_t read(http::HTTPConnectionManager *);
bool setPosition(mtime_t, bool); bool setPosition(mtime_t, bool);
mtime_t getPosition() const;
private: private:
http::Chunk *getChunk(); http::Chunk *getChunk();
......
...@@ -154,7 +154,7 @@ void MPD::getTimeLinesBoundaries(mtime_t *min, mtime_t *max) const ...@@ -154,7 +154,7 @@ void MPD::getTimeLinesBoundaries(mtime_t *min, mtime_t *max) const
} }
} }
void MPD::mergeWith(MPD *updatedMPD) void MPD::mergeWith(MPD *updatedMPD, mtime_t prunebarrier)
{ {
availabilityEndTime.Set(updatedMPD->availabilityEndTime.Get()); availabilityEndTime.Set(updatedMPD->availabilityEndTime.Get());
/* Only merge timelines for now */ /* Only merge timelines for now */
...@@ -166,6 +166,10 @@ void MPD::mergeWith(MPD *updatedMPD) ...@@ -166,6 +166,10 @@ void MPD::mergeWith(MPD *updatedMPD)
updatedMPD->periods.at(i)->collectTimelines(&timelinesUpdate); updatedMPD->periods.at(i)->collectTimelines(&timelinesUpdate);
for(size_t j = 0; j < timelines.size() && j < timelinesUpdate.size(); j++) for(size_t j = 0; j < timelines.size() && j < timelinesUpdate.size(); j++)
{
timelines.at(j)->mergeWith(*timelinesUpdate.at(j)); timelines.at(j)->mergeWith(*timelinesUpdate.at(j));
if(prunebarrier)
timelines.at(j)->prune(prunebarrier);
}
} }
} }
...@@ -60,7 +60,7 @@ namespace dash ...@@ -60,7 +60,7 @@ namespace dash
virtual Period* getFirstPeriod(); virtual Period* getFirstPeriod();
virtual Period* getNextPeriod(Period *period); virtual Period* getNextPeriod(Period *period);
void mergeWith(MPD *); void mergeWith(MPD *, mtime_t = 0);
void getTimeLinesBoundaries(mtime_t *, mtime_t *) const; void getTimeLinesBoundaries(mtime_t *, mtime_t *) const;
Property<time_t> duration; Property<time_t> duration;
......
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