[vlc-commits] demux: adaptative: add segment by position

Francois Cartegnie git at videolan.org
Wed Sep 23 21:15:08 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 22 22:14:14 2015 +0200| [b40ef13996ce67d79807363321e932d132846bdc] | committer: Francois Cartegnie

demux: adaptative: add segment by position

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

 .../adaptative/playlist/SegmentInformation.cpp     |   39 ++++++++++++++++++++
 .../adaptative/playlist/SegmentInformation.hpp     |    1 +
 2 files changed, 40 insertions(+)

diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index 485b87c..0aaf18c 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -153,6 +153,45 @@ std::size_t SegmentInformation::getAllSegments(std::vector<ISegment *> &retSegme
     return retSegments.size();
 }
 
+/* Returns wanted segment, or next in sequence if not found */
+ISegment * SegmentInformation::getNextSegment(SegmentInfoType type, uint64_t i_pos,
+                                              uint64_t *pi_newpos, bool *pb_gap) const
+{
+    *pb_gap = false;
+    *pi_newpos = i_pos;
+    if( type != INFOTYPE_MEDIA )
+        return NULL;
+
+    std::vector<ISegment *> retSegments;
+    const size_t size = getSegments( type, retSegments );
+    if( size )
+    {
+        std::vector<ISegment *>::const_iterator it;
+        for(it = retSegments.begin(); it != retSegments.end(); ++it)
+        {
+            ISegment *seg = *it;
+            if(seg->isTemplate()) /* we don't care about seq number */
+            {
+                /* Check if we don't exceed timeline */
+                MediaSegmentTemplate *templ = dynamic_cast<MediaSegmentTemplate*>(retSegments[0]);
+                if(templ && templ->segmentTimeline.Get() &&
+                   templ->segmentTimeline.Get()->maxElementNumber() < i_pos)
+                    return NULL;
+                *pi_newpos = std::max(seg->getSequenceNumber(), i_pos);
+                return seg;
+            }
+            else if(seg->getSequenceNumber() >= i_pos)
+            {
+                *pi_newpos = seg->getSequenceNumber();
+                *pb_gap = (*pi_newpos != i_pos);
+                return seg;
+            }
+        }
+    }
+
+    return NULL;
+}
+
 ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) const
 {
     std::vector<ISegment *> retSegments;
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.hpp b/modules/demux/adaptative/playlist/SegmentInformation.hpp
index c20004f..cd5d255 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.hpp
@@ -79,6 +79,7 @@ namespace adaptative
                 static const int InfoTypeCount = INFOTYPE_INDEX + 1;
 
                 ISegment * getSegment(SegmentInfoType, uint64_t = 0) const;
+                ISegment * getNextSegment(SegmentInfoType, uint64_t, uint64_t *, bool *) const;
                 bool getSegmentNumberByTime(mtime_t, uint64_t *) const;
                 mtime_t getPlaybackTimeBySegmentNumber(uint64_t) const;
                 virtual void getDurationsRange(mtime_t *, mtime_t *) const;



More information about the vlc-commits mailing list