[vlc-commits] demux: adaptive: fix incorrect segment duration

Zhao Zhili git at videolan.org
Wed Nov 8 20:34:50 CET 2017


vlc | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Fri Nov  3 09:27:38 2017 +0800| [2ca29e260219a91e77577e1d4c3040e595b68393] | committer: Francois Cartegnie

demux: adaptive: fix incorrect segment duration

It's supposed to return the duration of the current segment, not the
previous segment.

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>

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

 modules/demux/adaptive/playlist/SegmentList.cpp | 30 ++++++++++++++-----------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentList.cpp b/modules/demux/adaptive/playlist/SegmentList.cpp
index 59755da326..415a37c552 100644
--- a/modules/demux/adaptive/playlist/SegmentList.cpp
+++ b/modules/demux/adaptive/playlist/SegmentList.cpp
@@ -152,29 +152,33 @@ bool SegmentList::getPlaybackTimeDurationBySegmentNumber(uint64_t number,
     if(first->getSequenceNumber() > number)
         return false;
 
-    *time = first->startTime.Get();
+    bool found = false;
+    stime_t seg_start = first->startTime.Get();
+    stime_t seg_dura = 0;
     std::vector<ISegment *>::const_iterator it = segments.begin();
     for(it = segments.begin(); it != segments.end(); ++it)
     {
         const ISegment *seg = *it;
+
+        if(seg->duration.Get())
+            seg_dura = seg->duration.Get();
+        else
+            seg_dura = duration.Get();
+
         /* Assuming there won't be any discontinuity in sequence */
         if(seg->getSequenceNumber() == number)
         {
+            found = true;
             break;
         }
-        else if(seg->duration.Get())
-        {
-            *time += seg->duration.Get();
-            *dur = seg->duration.Get();
-        }
-        else
-        {
-            *time += duration.Get();
-            *dur = duration.Get();
-        }
+
+        seg_start += seg_dura;
     }
 
-    *time = VLC_TS_0 + timescale.ToTime( *time );
-    *dur = VLC_TS_0 + timescale.ToTime( *dur );
+    if(!found)
+        return false;
+
+    *time = VLC_TS_0 + timescale.ToTime(seg_start);
+    *dur = VLC_TS_0 + timescale.ToTime(seg_dura);
     return true;
 }



More information about the vlc-commits mailing list