From 3822256061814ff6c5679fd739fa9da68fca6c09 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Mon, 8 May 2017 11:39:08 +0200 Subject: [PATCH] Bug 1296531 - Allow MediaSegment::AppendSlice to combine with last chunk. r=jesup This makes it consistent with MediaSegment::AppendFrom. MozReview-Commit-ID: JNvLlURAqE7 --HG-- extra : rebase_source : 2fa023c91c43c19c3df799bab64f275c72eb1994 extra : source : d2c4bebc340fbd579450b42e271181e20f475c59 --- dom/media/MediaSegment.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dom/media/MediaSegment.h b/dom/media/MediaSegment.h index 064f716499ae..5290a679b432 100644 --- a/dom/media/MediaSegment.h +++ b/dom/media/MediaSegment.h @@ -461,7 +461,14 @@ protected: StreamTime nextOffset = offset + c.GetDuration(); StreamTime end = std::min(aEnd, nextOffset); if (start < end) { - mChunks.AppendElement(c)->SliceTo(start - offset, end - offset); + if (!mChunks.IsEmpty() && + mChunks[mChunks.Length() - 1].CanCombineWithFollowing(c)) { + MOZ_ASSERT(start - offset >= 0 && end - offset <= aSource.mDuration, + "Slice out of bounds"); + mChunks[mChunks.Length() - 1].mDuration += end - start; + } else { + mChunks.AppendElement(c)->SliceTo(start - offset, end - offset); + } } offset = nextOffset; }