[vlc-commits] demux: adaptative: merge content by ID

Francois Cartegnie git at videolan.org
Tue Sep 22 00:38:50 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 16 15:39:10 2015 +0200| [24a7a079d85d32f6ec31dfdc84b4d592eb4b275c] | committer: Francois Cartegnie

demux: adaptative: merge content by ID

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

 .../adaptative/playlist/SegmentInformation.cpp     |   20 ++++++++++++++++++--
 .../adaptative/playlist/SegmentInformation.hpp     |    1 +
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index 4093fbc..9519260 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -284,6 +284,17 @@ void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const
         childs.at(i)->getDurationsRange(min, max);
 }
 
+SegmentInformation * SegmentInformation::getChildByID(const ID &id)
+{
+    std::vector<SegmentInformation *>::const_iterator it;
+    for(it=childs.begin(); it!=childs.end(); ++it)
+    {
+        if( (*it)->getID() == id )
+            return *it;
+    }
+    return NULL;
+}
+
 void SegmentInformation::mergeWith(SegmentInformation *updated, mtime_t prunetime)
 {
     /* Support Segment List for now */
@@ -293,10 +304,15 @@ void SegmentInformation::mergeWith(SegmentInformation *updated, mtime_t prunetim
     if(mediaSegmentTemplate && updated->mediaSegmentTemplate)
         mediaSegmentTemplate->mergeWith(updated->mediaSegmentTemplate, prunetime);
 
-    for(size_t i=0; i<childs.size() && i<updated->childs.size(); i++)
+    std::vector<SegmentInformation *>::const_iterator it;
+    for(it=childs.begin(); it!=childs.end(); ++it)
     {
-        childs.at(i)->mergeWith(updated->childs.at(i), prunetime);
+        SegmentInformation *child = *it;
+        SegmentInformation *updatedChild = updated->getChildByID(child->getID());
+        if(updatedChild)
+            child->mergeWith(updatedChild, prunetime);
     }
+    /* FIXME: handle difference */
 }
 
 void SegmentInformation::pruneBySegmentNumber(uint64_t num)
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.hpp b/modules/demux/adaptative/playlist/SegmentInformation.hpp
index 04e4b7f..8594748 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.hpp
@@ -90,6 +90,7 @@ namespace adaptative
                 std::size_t getAllSegments(std::vector<ISegment *> &) const;
                 std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&, std::size_t * = NULL) const;
                 std::vector<SegmentInformation *> childs;
+                SegmentInformation * getChildByID( const ID & );
                 SegmentInformation *parent;
                 SwitchPolicy switchpolicy;
 



More information about the vlc-commits mailing list