Skip to content

Commit 5f4bc11

Browse files
committed
[DashTree] Allow template segment with partial duration
fix possible missing last segment at the end of stream due to partial segment duration
1 parent 7e8fc3f commit 5f4bc11

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/parser/DASHTree.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,8 +1826,15 @@ void adaptive::CDashTree::GenerateTemplatedSegments(PLAYLIST::CSegmentTemplate&
18261826
const uint64_t timeEnd = wndEnd * segTimescale / 1000;
18271827

18281828
// Create segments within time window
1829-
while (time + segDuration <= timeEnd && segNumber <= segNumberEnd)
1829+
while (time < timeEnd && segNumber <= segNumberEnd)
18301830
{
1831+
const uint64_t remainingDur = timeEnd - time;
1832+
uint64_t duration = segDuration;
1833+
1834+
// Allow segment with partial duration for the end of stream
1835+
if (remainingDur < duration && !m_isLive)
1836+
duration = remainingDur;
1837+
18311838
CSegment seg;
18321839
seg.startPTS_ = time;
18331840
seg.m_endPts = time + segDuration;

0 commit comments

Comments
 (0)