[vlc-commits] demux: adaptive: rework pl update, keep played segments
Francois Cartegnie
git at videolan.org
Sun May 26 16:58:40 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 24 10:35:39 2019 +0200| [740c1ad4ea1f44a46379e564ccf1cc799f929e5f] | committer: Francois Cartegnie
demux: adaptive: rework pl update, keep played segments
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=740c1ad4ea1f44a46379e564ccf1cc799f929e5f
---
modules/demux/adaptive/playlist/AbstractPlaylist.cpp | 9 ++-------
modules/demux/adaptive/playlist/AbstractPlaylist.hpp | 3 +--
.../demux/adaptive/playlist/SegmentInformation.cpp | 19 ++++++++++---------
.../demux/adaptive/playlist/SegmentInformation.hpp | 4 ++--
modules/demux/adaptive/playlist/SegmentList.cpp | 9 ++++++++-
modules/demux/adaptive/playlist/SegmentList.h | 2 +-
modules/demux/adaptive/playlist/SegmentTemplate.cpp | 8 ++++----
modules/demux/adaptive/playlist/SegmentTemplate.h | 2 +-
modules/demux/adaptive/playlist/SegmentTimeline.cpp | 2 +-
modules/demux/adaptive/playlist/SegmentTimeline.h | 2 +-
modules/demux/dash/DASHManager.cpp | 11 +----------
modules/demux/dash/mpd/IsoffMainParser.cpp | 2 +-
modules/demux/hls/playlist/Parser.cpp | 2 +-
modules/demux/hls/playlist/Representation.cpp | 5 +----
modules/demux/smooth/SmoothManager.cpp | 2 +-
15 files changed, 36 insertions(+), 46 deletions(-)
diff --git a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
index 539d23312a..68ddecad06 100644
--- a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
+++ b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
@@ -142,17 +142,12 @@ bool AbstractPlaylist::needsUpdates() const
return b_needsUpdates;
}
-void AbstractPlaylist::mergeWith(AbstractPlaylist *updatedAbstractPlaylist, vlc_tick_t prunebarrier)
+void AbstractPlaylist::updateWith(AbstractPlaylist *updatedAbstractPlaylist)
{
availabilityEndTime.Set(updatedAbstractPlaylist->availabilityEndTime.Get());
for(size_t i = 0; i < periods.size() && i < updatedAbstractPlaylist->periods.size(); i++)
- periods.at(i)->mergeWith(updatedAbstractPlaylist->periods.at(i), prunebarrier);
+ periods.at(i)->updateWith(updatedAbstractPlaylist->periods.at(i));
}
-void AbstractPlaylist::pruneByPlaybackTime(vlc_tick_t time)
-{
- for(size_t i = 0; i < periods.size(); i++)
- periods.at(i)->pruneByPlaybackTime(time);
-}
diff --git a/modules/demux/adaptive/playlist/AbstractPlaylist.hpp b/modules/demux/adaptive/playlist/AbstractPlaylist.hpp
index a4bd8d29f1..d9e22e4812 100644
--- a/modules/demux/adaptive/playlist/AbstractPlaylist.hpp
+++ b/modules/demux/adaptive/playlist/AbstractPlaylist.hpp
@@ -59,8 +59,7 @@ namespace adaptive
virtual BasePeriod* getNextPeriod(BasePeriod *period);
bool needsUpdates() const;
- void mergeWith(AbstractPlaylist *, vlc_tick_t = 0);
- void pruneByPlaybackTime(vlc_tick_t);
+ void updateWith(AbstractPlaylist *);
Property<vlc_tick_t> duration;
Property<time_t> playbackStart;
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index 7fe3d07296..021b874882 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -542,14 +542,14 @@ SegmentInformation * SegmentInformation::getChildByID(const adaptive::ID &id)
return NULL;
}
-void SegmentInformation::mergeWith(SegmentInformation *updated, vlc_tick_t prunetime)
+void SegmentInformation::updateWith(SegmentInformation *updated)
{
/* Support Segment List for now */
if(segmentList && updated->segmentList)
- segmentList->mergeWith(updated->segmentList);
+ segmentList->updateWith(updated->segmentList);
if(mediaSegmentTemplate && updated->mediaSegmentTemplate)
- mediaSegmentTemplate->mergeWith(updated->mediaSegmentTemplate, prunetime);
+ mediaSegmentTemplate->updateWith(updated->mediaSegmentTemplate);
std::vector<SegmentInformation *>::const_iterator it;
for(it=childs.begin(); it!=childs.end(); ++it)
@@ -557,7 +557,7 @@ void SegmentInformation::mergeWith(SegmentInformation *updated, vlc_tick_t prune
SegmentInformation *child = *it;
SegmentInformation *updatedChild = updated->getChildByID(child->getID());
if(updatedChild)
- child->mergeWith(updatedChild, prunetime);
+ child->updateWith(updatedChild);
}
/* FIXME: handle difference */
}
@@ -569,7 +569,7 @@ void SegmentInformation::mergeWithTimeline(SegmentTimeline *updated)
{
SegmentTimeline *timeline = templ->inheritSegmentTimeline();
if(timeline)
- timeline->mergeWith(*updated);
+ timeline->updateWith(*updated);
}
}
@@ -625,15 +625,16 @@ vlc_tick_t SegmentInformation::getPeriodStart() const
return 0;
}
-void SegmentInformation::appendSegmentList(SegmentList *list, bool restamp)
+void SegmentInformation::updateSegmentList(SegmentList *list, bool restamp)
{
- if(segmentList)
+ if(segmentList && restamp)
{
- segmentList->mergeWith(list, restamp);
+ segmentList->updateWith(list, restamp);
delete list;
}
else
{
+ delete segmentList;
segmentList = list;
}
}
@@ -649,7 +650,7 @@ void SegmentInformation::setSegmentTemplate(MediaSegmentTemplate *templ)
{
if(mediaSegmentTemplate)
{
- mediaSegmentTemplate->mergeWith(templ, 0);
+ mediaSegmentTemplate->updateWith(templ);
delete templ;
}
else
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.hpp b/modules/demux/adaptive/playlist/SegmentInformation.hpp
index 1be759ea43..6eff4e035b 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp
@@ -85,7 +85,7 @@ namespace adaptive
uint64_t getLiveSegmentNumberByTime(uint64_t, vlc_tick_t) const;
uint64_t getLiveStartSegmentNumber(uint64_t) const;
bool getMediaPlaybackRange(vlc_tick_t *, vlc_tick_t *, vlc_tick_t *) const;
- virtual void mergeWith(SegmentInformation *, vlc_tick_t);
+ virtual void updateWith(SegmentInformation *);
virtual void mergeWithTimeline(SegmentTimeline *); /* ! don't use with global merge */
virtual void pruneBySegmentNumber(uint64_t);
virtual void pruneByPlaybackTime(vlc_tick_t);
@@ -101,7 +101,7 @@ namespace adaptive
SegmentInformation *parent;
public:
- void appendSegmentList(SegmentList *, bool = false);
+ void updateSegmentList(SegmentList *, bool = false);
void setSegmentBase(SegmentBase *);
void setSegmentTemplate(MediaSegmentTemplate *);
virtual Url getUrlSegment() const; /* impl */
diff --git a/modules/demux/adaptive/playlist/SegmentList.cpp b/modules/demux/adaptive/playlist/SegmentList.cpp
index 4be39a99a5..7985e3ee85 100644
--- a/modules/demux/adaptive/playlist/SegmentList.cpp
+++ b/modules/demux/adaptive/playlist/SegmentList.cpp
@@ -73,11 +73,16 @@ void SegmentList::addSegment(ISegment *seg)
totalLength += seg->duration.Get();
}
-void SegmentList::mergeWith(SegmentList *updated, bool b_restamp)
+void SegmentList::updateWith(SegmentList *updated, bool b_restamp)
{
const ISegment * lastSegment = (segments.empty()) ? NULL : segments.back();
const ISegment * prevSegment = lastSegment;
+ if(updated->segments.empty())
+ return;
+
+ uint64_t firstnumber = updated->segments.front()->getSequenceNumber();
+
std::vector<ISegment *>::iterator it;
for(it = updated->segments.begin(); it != updated->segments.end(); ++it)
{
@@ -100,6 +105,8 @@ void SegmentList::mergeWith(SegmentList *updated, bool b_restamp)
delete cur;
}
updated->segments.clear();
+
+ pruneBySegmentNumber(firstnumber);
}
void SegmentList::pruneByPlaybackTime(vlc_tick_t time)
diff --git a/modules/demux/adaptive/playlist/SegmentList.h b/modules/demux/adaptive/playlist/SegmentList.h
index 5b2ad6c183..8bad67f6b6 100644
--- a/modules/demux/adaptive/playlist/SegmentList.h
+++ b/modules/demux/adaptive/playlist/SegmentList.h
@@ -44,7 +44,7 @@ namespace adaptive
const std::vector<ISegment *>& getSegments() const;
ISegment * getSegmentByNumber(uint64_t);
void addSegment(ISegment *seg);
- void mergeWith(SegmentList *, bool = false);
+ void updateWith(SegmentList *, bool = false);
void pruneBySegmentNumber(uint64_t);
void pruneByPlaybackTime(vlc_tick_t);
bool getSegmentNumberByScaledTime(stime_t, uint64_t *) const;
diff --git a/modules/demux/adaptive/playlist/SegmentTemplate.cpp b/modules/demux/adaptive/playlist/SegmentTemplate.cpp
index cd45094810..eddf971822 100644
--- a/modules/demux/adaptive/playlist/SegmentTemplate.cpp
+++ b/modules/demux/adaptive/playlist/SegmentTemplate.cpp
@@ -64,19 +64,19 @@ MediaSegmentTemplate::~MediaSegmentTemplate()
delete segmentTimeline;
}
-void MediaSegmentTemplate::mergeWith(MediaSegmentTemplate *updated, vlc_tick_t prunebarrier)
+void MediaSegmentTemplate::updateWith(MediaSegmentTemplate *updated)
{
SegmentTimeline *timeline = segmentTimeline;
if(timeline && updated->segmentTimeline)
{
- timeline->mergeWith(*updated->segmentTimeline);
- if(prunebarrier)
+ timeline->updateWith(*updated->segmentTimeline);
+ /*if(prunebarrier)
{
const Timescale timescale = timeline->inheritTimescale();
const uint64_t number =
timeline->getElementNumberByScaledPlaybackTime(timescale.ToScaled(prunebarrier));
timeline->pruneBySequenceNumber(number);
- }
+ }*/
}
}
diff --git a/modules/demux/adaptive/playlist/SegmentTemplate.h b/modules/demux/adaptive/playlist/SegmentTemplate.h
index 74d5532363..9d100439f1 100644
--- a/modules/demux/adaptive/playlist/SegmentTemplate.h
+++ b/modules/demux/adaptive/playlist/SegmentTemplate.h
@@ -53,7 +53,7 @@ namespace adaptive
virtual ~MediaSegmentTemplate();
void setStartNumber( uint64_t );
void setSegmentTimeline( SegmentTimeline * );
- void mergeWith( MediaSegmentTemplate *, vlc_tick_t );
+ void updateWith( MediaSegmentTemplate * );
virtual uint64_t getSequenceNumber() const; /* reimpl */
uint64_t getLiveTemplateNumber(vlc_tick_t) const;
stime_t getMinAheadScaledTime(uint64_t) const;
diff --git a/modules/demux/adaptive/playlist/SegmentTimeline.cpp b/modules/demux/adaptive/playlist/SegmentTimeline.cpp
index f9f99cadbf..80891ab988 100644
--- a/modules/demux/adaptive/playlist/SegmentTimeline.cpp
+++ b/modules/demux/adaptive/playlist/SegmentTimeline.cpp
@@ -204,7 +204,7 @@ size_t SegmentTimeline::pruneBySequenceNumber(uint64_t number)
return prunednow;
}
-void SegmentTimeline::mergeWith(SegmentTimeline &other)
+void SegmentTimeline::updateWith(SegmentTimeline &other)
{
if(elements.empty())
{
diff --git a/modules/demux/adaptive/playlist/SegmentTimeline.h b/modules/demux/adaptive/playlist/SegmentTimeline.h
index d95b0e82db..7489e7a740 100644
--- a/modules/demux/adaptive/playlist/SegmentTimeline.h
+++ b/modules/demux/adaptive/playlist/SegmentTimeline.h
@@ -49,7 +49,7 @@ namespace adaptive
uint64_t minElementNumber() const;
void pruneByPlaybackTime(vlc_tick_t);
size_t pruneBySequenceNumber(uint64_t);
- void mergeWith(SegmentTimeline &);
+ void updateWith(SegmentTimeline &);
void debug(vlc_object_t *, int = 0) const;
private:
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index dad8ae9c28..33b403eeea 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -123,21 +123,12 @@ bool DASHManager::updatePlaylist()
return false;
}
- vlc_tick_t minsegmentTime = 0;
- std::vector<AbstractStream *>::iterator it;
- for(it=streams.begin(); it!=streams.end(); it++)
- {
- vlc_tick_t segmentTime = (*it)->getPlaybackTime();
- if(!minsegmentTime || segmentTime < minsegmentTime)
- minsegmentTime = segmentTime;
- }
-
IsoffMainParser mpdparser(parser.getRootNode(), VLC_OBJECT(p_demux),
mpdstream, Helper::getDirectoryPath(url).append("/"));
MPD *newmpd = mpdparser.parse();
if(newmpd)
{
- playlist->mergeWith(newmpd, minsegmentTime);
+ playlist->updateWith(newmpd);
delete newmpd;
}
vlc_stream_Delete(mpdstream);
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 4197026c0c..cb063c2db0 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -417,7 +417,7 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
total++;
}
- info->appendSegmentList(list, true);
+ info->updateSegmentList(list, true);
}
}
return total;
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 84a1cace63..dc467aae23 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -372,7 +372,7 @@ void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::l
rep->getPlaylist()->duration.Set(totalduration);
}
- rep->appendSegmentList(segmentList, true);
+ rep->updateSegmentList(segmentList, true);
}
M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::string &playlisturl)
{
diff --git a/modules/demux/hls/playlist/Representation.cpp b/modules/demux/hls/playlist/Representation.cpp
index 8257bfdf56..ddb6a7ad7f 100644
--- a/modules/demux/hls/playlist/Representation.cpp
+++ b/modules/demux/hls/playlist/Representation.cpp
@@ -137,7 +137,7 @@ bool Representation::needsUpdate() const
}
bool Representation::runLocalUpdates(SharedResources *res,
- vlc_tick_t, uint64_t number, bool prune)
+ vlc_tick_t, uint64_t, bool)
{
const time_t now = time(NULL);
AbstractPlaylist *playlist = getPlaylist();
@@ -147,9 +147,6 @@ bool Representation::runLocalUpdates(SharedResources *res,
parser.appendSegmentsFromPlaylistURI(playlist->getVLCObject(), this);
b_loaded = true;
- if(prune)
- pruneBySegmentNumber(number);
-
return true;
}
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index e5e0f0c84b..f1dc476bf7 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -164,7 +164,7 @@ bool SmoothManager::updatePlaylist(bool forcemanifest)
Manifest *newManifest = fetchManifest();
if(newManifest)
{
- playlist->mergeWith(newManifest, 0);
+ playlist->updateWith(newManifest);
delete newManifest;
#ifdef NDEBUG
More information about the vlc-commits
mailing list