[vlc-devel] [PATCH 1/2] demux: adaptive: fix incorrect segment duration

Zhao Zhili quinkblack at foxmail.com
Fri Nov 3 02:32:26 CET 2017


It's supposed to return the duration of the current segment, not the
previous segment.
---
  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 59755da..415a37c 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;
  }
-- 
2.7.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-demux-adaptive-fix-incorrect-segment-duration.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20171103/2004b2b0/attachment.bin>


More information about the vlc-devel mailing list