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

demux: dash: prune expired live timeline elements

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