vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Fri May 15 
17:12:44 2015 +0200| [727ef47639dc87cd9ba909b52bccd2f5e6476541] | committer: 
Francois Cartegnie

demux: adaptative: seek on subsegments by time

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

 .../adaptative/playlist/SegmentInformation.cpp     |   36 ++++++++++++--------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp 
b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index 3200b9a..e8b2ee8 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -171,26 +171,32 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType 
type, uint64_t pos) co
 
 bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) 
const
 {
-    SegmentList *segList;
     MediaSegmentTemplate *mediaTemplate;
-    uint64_t timescale = 1;
-    mtime_t duration = 0;
-
     if( (mediaTemplate = inheritSegmentTemplate()) )
     {
-        timescale = mediaTemplate->inheritTimescale();
-        duration = mediaTemplate->duration.Get();
-    }
-    else if ( (segList = inheritSegmentList()) )
-    {
-        timescale = segList->inheritTimescale();
-        duration = segList->duration.Get();
+        uint64_t timescale = mediaTemplate->inheritTimescale();
+        mtime_t duration = mediaTemplate->duration.Get();
+        if(duration)
+        {
+            *ret = time / (CLOCK_FREQ * duration / timescale);
+            return true;
+        }
     }
-
-    if(duration)
+    else
     {
-        *ret = time / (CLOCK_FREQ * duration / timescale);
-        return true;
+        const std::vector<ISegment *> segments = getSegments(INFOTYPE_MEDIA);
+        std::vector<ISegment *>::const_iterator it;
+        *ret = 0;
+        for(it = segments.begin(); it != segments.end(); ++it)
+        {
+            if((*it)->startTime.Get() > VLC_TS_INVALID &&
+               (*it)->startTime.Get() > time &&
+                it != segments.begin())
+            {
+                return true;
+            }
+            (*ret)++;
+        }
     }
 
     return false;

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to