[vlc-commits] demux: adaptative: merge timelines/segments boundaries

Francois Cartegnie git at videolan.org
Sun Aug 30 22:45:50 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Aug 30 22:39:34 2015 +0200| [ef001ee42c974f63c4c4cf1abe3c567e17b57c86] | committer: Francois Cartegnie

demux: adaptative: merge timelines/segments boundaries

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef001ee42c974f63c4c4cf1abe3c567e17b57c86
---

 .../demux/adaptative/playlist/AbstractPlaylist.cpp |   18 ------------------
 .../demux/adaptative/playlist/AbstractPlaylist.hpp |    1 -
 .../adaptative/playlist/SegmentInformation.cpp     |   20 ++++++++++++--------
 .../adaptative/playlist/SegmentInformation.hpp     |    1 -
 modules/demux/dash/DASHManager.cpp                 |    2 +-
 5 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/modules/demux/adaptative/playlist/AbstractPlaylist.cpp b/modules/demux/adaptative/playlist/AbstractPlaylist.cpp
index f846545..254c9b2 100644
--- a/modules/demux/adaptative/playlist/AbstractPlaylist.cpp
+++ b/modules/demux/adaptative/playlist/AbstractPlaylist.cpp
@@ -110,24 +110,6 @@ BasePeriod* AbstractPlaylist::getNextPeriod(BasePeriod *period)
     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
 {
diff --git a/modules/demux/adaptative/playlist/AbstractPlaylist.hpp b/modules/demux/adaptative/playlist/AbstractPlaylist.hpp
index 3e22365..bb67591 100644
--- a/modules/demux/adaptative/playlist/AbstractPlaylist.hpp
+++ b/modules/demux/adaptative/playlist/AbstractPlaylist.hpp
@@ -55,7 +55,6 @@ namespace adaptative
 
                 void                mergeWith(AbstractPlaylist *, mtime_t = 0);
                 void                pruneBySegmentNumber(uint64_t);
-                void                getTimeLinesBoundaries(mtime_t *, mtime_t *) const;
                 void                getPlaylistDurationsRange(mtime_t *, mtime_t *) const;
 
                 Property<mtime_t>                   duration;
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index ac467ba..3bb12fa 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -244,15 +244,7 @@ mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) cons
     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
 {
@@ -276,6 +268,18 @@ void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const
     if(total > *max)
         *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++)
         childs.at(i)->getDurationsRange(min, max);
 }
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.hpp b/modules/demux/adaptative/playlist/SegmentInformation.hpp
index 11c4160..005471d 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.hpp
@@ -80,7 +80,6 @@ namespace adaptative
                 ISegment * getSegment(SegmentInfoType, uint64_t = 0) const;
                 bool getSegmentNumberByTime(mtime_t, uint64_t *) const;
                 mtime_t getPlaybackTimeBySegmentNumber(uint64_t) const;
-                void collectTimelines(std::vector<SegmentTimeline *> *) const;
                 void getDurationsRange(mtime_t *, mtime_t *) const;
                 virtual void mergeWith(SegmentInformation *, mtime_t);
                 virtual void pruneBySegmentNumber(uint64_t);
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index b6f1146..be942ba 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -133,7 +133,7 @@ bool DASHManager::updatePlaylist()
     /* Compute new MPD update time */
     mtime_t mininterval = 0;
     mtime_t maxinterval = 0;
-    playlist->getTimeLinesBoundaries(&mininterval, &maxinterval);
+    playlist->getPlaylistDurationsRange(&mininterval, &maxinterval);
 
     if(playlist->minUpdatePeriod.Get() > mininterval)
         mininterval = playlist->minUpdatePeriod.Get();



More information about the vlc-commits mailing list