[MSE] Appends of overlapping sample data do not clear existing samples properly.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jun 2014 05:16:46 +0000 (05:16 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jun 2014 05:16:46 +0000 (05:16 +0000)
commit8ba9939740c07cfe055d54f005c1e71a35f6688d
tree200bee2bc634b4408d6a559cd6b582e02f24f973
parentd3720b56d4f64fd0624e3fa3bdb3bd537896beea
[MSE] Appends of overlapping sample data do not clear existing samples properly.
https://bugs.webkit.org/show_bug.cgi?id=133435

Reviewed by Darin Adler.

Source/WebCore:
Test: media/media-source/media-source-overlapping-append.html

The MSE spec has a spec error in how it removes overlapping frames. The intention seems to be
to check for overlapping samples only when the incoming sample increases the highest presentation time
field. But due to a mismatch in the range of a sample, defined as [start, end), and the check, which
treats the end as inclusive, the overlapping check is almost never run.

Add the sample comparison logic to match [start, end) ranges, and rename the existing check to differentiate
it from the new one:
* Modules/mediasource/SampleMap.cpp:
(WebCore::SamplePresentationTimeIsInsideRangeComparator::operator()):
(WebCore::SamplePresentationTimeIsWithinRangeComparator::operator()):
(WebCore::SampleMap::findSamplesBetweenPresentationTimes):
(WebCore::SampleMap::findSamplesWithinPresentationRange):
* Modules/mediasource/SampleMap.h:

Update the overlapping check to occur whenever the highest presentation time increases, and update the
logic within that check to catch all overlapping frames.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
(WebCore::SourceBuffer::bufferedSamplesForTrackID):
* Modules/mediasource/SourceBuffer.h:
* WebCore.exp.in:

Add a dump method to MediaSample so that samples can be easily converted to a string for testing.
* platform/MediaSample.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::presentationSize):
(WebCore::MediaSampleAVFObjC::dump):

Update the Mock MSE implementation to pass along a "generation" field, to aid in testing.
* platform/mock/mediasource/MockBox.cpp:
(WebCore::MockSampleBox::MockSampleBox):
* platform/mock/mediasource/MockBox.h:
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockMediaSample::dump):

Add a method to internals to dump the buffered samples to string.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::bufferedSamplesForTrackID):
* Modules/mediasource/SourceBuffer.h:
* testing/Internals.cpp:
(WebCore::Internals::bufferedSamplesForTrackID):
* testing/Internals.h:
* testing/Internals.idl:

Source/WTF:
Add a dump method to MediaTime, so that MediaTimes can be easily converted to strings (for logging purposes).

* wtf/MediaTime.cpp:
(WTF::MediaTime::dump):
* wtf/MediaTime.h:

LayoutTests:
* media/media-source/media-source-overlapping-append-expected.txt: Added.
* media/media-source/media-source-overlapping-append.html: Added.
* media/media-source/mock-media-source.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-overlapping-append-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-overlapping-append.html [new file with mode: 0644]
LayoutTests/media/media-source/mock-media-source.js
Source/WTF/ChangeLog
Source/WTF/wtf/MediaTime.cpp
Source/WTF/wtf/MediaTime.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/SampleMap.cpp
Source/WebCore/Modules/mediasource/SampleMap.h
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/MediaSample.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/mock/mediasource/MockBox.cpp
Source/WebCore/platform/mock/mediasource/MockBox.h
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl