[MSE] Support fastSeek() in MediaSource.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Nov 2013 21:39:43 +0000 (21:39 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Nov 2013 21:39:43 +0000 (21:39 +0000)
commit28104106ed7612914381e08490972f310351c882
treec1390ccd20d3aa6e61a303f62b55acf6c5f3ac87
parent2b997a965881627ca9ff094874a67ddd22047665
[MSE] Support fastSeek() in MediaSource.
https://bugs.webkit.org/show_bug.cgi?id=124422

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-fastseek.html

* Modules/mediasource/MediaSource.cpp:
* Modules/mediasource/MediaSource.h:

Add support for "seek to the next fastest time" in MediaSource by
returning the time of the nearest Sync sample.

Move the data structure logic out of SourceBuffer and into it's own
class:
* Modules/mediasource/SampleMap.cpp: Added.
(WebCore::SampleIsLessThanMediaTimeComparator::operator()):
(WebCore::SampleIsGreaterThanMediaTimeComparator::operator()):
(WebCore::SampleIsRandomAccess::operator()):
(WebCore::SamplePresentationTimeIsWithinRangeComparator::operator()):
(WebCore::SampleMap::addSample):
(WebCore::SampleMap::removeSample):
(WebCore::SampleMap::findSampleContainingPresentationTime):
(WebCore::SampleMap::findSampleAfterPresentationTime):
(WebCore::SampleMap::findSampleWithDecodeTime):
(WebCore::SampleMap::reverseFindSampleContainingPresentationTime):
(WebCore::SampleMap::reverseFindSampleBeforePresentationTime):
(WebCore::SampleMap::reverseFindSampleWithDecodeTime):
(WebCore::SampleMap::findSyncSamplePriorToPresentationTime):
(WebCore::SampleMap::findSyncSamplePriorToDecodeIterator):
(WebCore::SampleMap::findSyncSampleAfterPresentationTime):
(WebCore::SampleMap::findSyncSampleAfterDecodeIterator):
(WebCore::SampleMap::findSamplesBetweenPresentationTimes):
(WebCore::SampleMap::findDependentSamples):
* Modules/mediasource/SampleMap.h: Added.
(WebCore::SampleMap::presentationBegin):
(WebCore::SampleMap::presentationEnd):
(WebCore::SampleMap::decodeBegin):
(WebCore::SampleMap::decodeEnd):
(WebCore::SampleMap::reversePresentationBegin):
(WebCore::SampleMap::reversePresentationEnd):
(WebCore::SampleMap::reverseDecodeBegin):
(WebCore::SampleMap::reverseDecodeEnd):

Add logic to find and return the time of the next & previous sync
sample, within the threshold provided:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::TrackBuffer::TrackBuffer):
(WebCore::SourceBuffer::sourceBufferPrivateSeekToTime):
(WebCore::SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime):
(WebCore::SourceBuffer::appendBufferTimerFired):
(WebCore::SourceBuffer::setActive):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
(WebCore::SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples):
(WebCore::SourceBuffer::provideMediaData):
* Modules/mediasource/SourceBuffer.h:
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::setActive):
* platform/graphics/SourceBufferPrivateClient.h:
(WebCore::SourceBufferPrivateClient::sourceBufferPrivateFastSeekTimeForMediaTime):
(WebCore::SourceBufferPrivateClient::sourceBufferPrivateSeekToTime):

Add new files to the project:
* WebCore.xcodeproj/project.pbxproj:

Drive-by fixes in HTMLMediaElement:
* html/HTMLMediaSource.h:
* html/HTMLMediaElement.cpp:
(HTMLMediaElement::finishSeek): Cause the MediaSource to check the ready state of all its buffers.
(HTMLMediaElement::selectNextSourceChild): Pass in whether the source element has a MediaSource URL.

Implement the seekWithTolerance behavior in MockMediaPlayerMediaSource:
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::maxTimeSeekableDouble):
(WebCore::MockMediaPlayerMediaSource::currentTimeDouble):
(WebCore::MockMediaPlayerMediaSource::seekWithTolerance):
(WebCore::MockMediaPlayerMediaSource::advanceCurrentTime):
* platform/mock/mediasource/MockMediaPlayerMediaSource.h:
* platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::seekToTime):
* platform/mock/mediasource/MockMediaSourcePrivate.h:
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockMediaSample::flags):
(WebCore::MockSourceBufferPrivate::setActive):
(WebCore::MockSourceBufferPrivate::fastSeekTimeForMediaTime):
(WebCore::MockSourceBufferPrivate::seekToTime):
* platform/mock/mediasource/MockSourceBufferPrivate.h:

LayoutTests:

* media/media-source/media-source-fastseek-expected.txt: Added.
* media/media-source/media-source-fastseek.html: Added.
* media/media-source/mock-media-source.js:
(var):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159519 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-fastseek-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-fastseek.html [new file with mode: 0644]
LayoutTests/media/media-source/mock-media-source.js
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/MediaSource.h
Source/WebCore/Modules/mediasource/SampleMap.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediasource/SampleMap.h [new file with mode: 0644]
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaSource.h
Source/WebCore/platform/MediaSample.h
Source/WebCore/platform/graphics/SourceBufferPrivate.h
Source/WebCore/platform/graphics/SourceBufferPrivateClient.h
Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp
Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h
Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp
Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h