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

Zhao Zhili quinkblack at foxmail.com
Thu Nov 2 15:10:56 CET 2017


It's supposed to return the duration of the current segment, not the
previous segment.
---
  modules/demux/adaptive/playlist/SegmentList.cpp | 23 
++++++++++++++++-------
  1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentList.cpp 
b/modules/demux/adaptive/playlist/SegmentList.cpp
index 59755da..5f5f401 100644
--- a/modules/demux/adaptive/playlist/SegmentList.cpp
+++ b/modules/demux/adaptive/playlist/SegmentList.cpp
@@ -152,7 +152,9 @@ 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)
      {
@@ -160,21 +162,28 @@ bool 
SegmentList::getPlaybackTimeDurationBySegmentNumber(uint64_t number,
          /* Assuming there won't be any discontinuity in sequence */
          if(seg->getSequenceNumber() == number)
          {
+            if(seg->duration.Get())
+                seg_dura = seg->duration.Get();
+            else
+                seg_dura = duration.Get();
+
+            found = true;
              break;
          }
          else if(seg->duration.Get())
          {
-            *time += seg->duration.Get();
-            *dur = seg->duration.Get();
+            seg_start += seg->duration.Get();
          }
          else
          {
-            *time += duration.Get();
-            *dur = duration.Get();
+            seg_start += duration.Get();
          }
      }

-    *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: 2188 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20171102/34711cbe/attachment.bin>


More information about the vlc-devel mailing list