Add Experimental Feature support for SourceBuffer.changeType()
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2018 17:57:01 +0000 (17:57 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2018 17:57:01 +0000 (17:57 +0000)
commitb6eb802b65b0f69d4f4f93c9f3a7d266ead49272
treeeaa14130da9bf1106ba70edc9c8bd0ccc798026a
parentdc6ca8ce973a9d853bdea6cd574527fcc3804078
Add Experimental Feature support for SourceBuffer.changeType()
https://bugs.webkit.org/show_bug.cgi?id=188626
LayoutTests/imported/w3c:

Reviewed by Eric Carlson.

* resources/import-expectations.json:
* web-platform-tests/media-source/mediasource-changetype-expected.txt: Added.
* web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added.
* web-platform-tests/media-source/mediasource-changetype-play.html: Added.
* web-platform-tests/media-source/mediasource-changetype-util.js: Added.
(findSupportedChangeTypeTestTypes):
(appendBuffer):
(trimBuffered):
(trimDuration):
(runChangeTypeTest):
(mediaSourceChangeTypeTest):
* web-platform-tests/media-source/mediasource-changetype.html: Added.
* web-platform-tests/media-source/mp3/sound_5.mp3: Added.
* web-platform-tests/media-source/mp3/w3c-import.log: Added.
* web-platform-tests/media-source/w3c-import.log:
* web-platform-tests/media-source/webm/test-vp9.webm: Added.
* web-platform-tests/media-source/webm/w3c-import.log:

Source/WebCore:

Reviewed by Eric Carlson.

Tests: imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html
       imported/w3c/web-platform-tests/media-source/mediasource-changetype.html

The WICG is incubating a new proposal to allow clients to switch between streams
with different codecs within the same SourceBuffer. The proposal is being tracked
by <https://github.com/w3c/media-source/issues/155> and the proposed spec change
is available at <https://rawgit.com/wicg/media-source/codec-switching/index.html>.

Drive-by fix: One of the wpt tests uses a .mp3 file to test SourceBuffer switching.
The AVStreamDataParser does not necessarily emit every frame appended, and after a
new init segment is appended, it's possible that frames from the previous media
segment will be emitted. This causes an error condition to occur, due to an added
check in the spec for a new flag. When the SourceBuffer asks its private implementation
to reset the parser state, since there's no API on AVStreamDataParser to actually
reset the parser state, just set a flag to drop all emitted buffers until the next
initialization segment is parsed.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::contentTypeShouldGenerateTimestamps):
(WebCore::MediaSource::setDurationInternal):
(WebCore::MediaSource::addSourceBuffer):
* Modules/mediasource/MediaSource.h:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::changeType):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
(WebCore::SourceBuffer::validateInitializationSegment):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
* Modules/mediasource/SourceBuffer.h:
* Modules/mediasource/SourceBuffer.idl:
* page/Settings.yaml:
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::canSwitchToType):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
(WebCore::SourceBufferPrivateAVFObjC::processCodedFrame):
(WebCore::SourceBufferPrivateAVFObjC::resetParserState):
(WebCore::SourceBufferPrivateAVFObjC::canSwitchToType):

Source/WebKit:

Reviewed by Eric Carlson.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetSourceBufferChangeTypeEnabled):
(WKPreferencesGetSourceBufferChangeTypeEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:

Source/WebKitLegacy/mac:

<rdar://problem/43356021>

Reviewed by Eric Carlson.

Add a new WebPreference property mapping to the WebCore SourceBufferChangeTypeEnabled setting.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences sourceBufferChangeTypeEnabled]):
(-[WebPreferences setSourceBufferChangeTypeEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

<rdar://problem/43356021>

Reviewed by Eric Carlson.

* DumpRenderTree/mac/DumpRenderTree.mm:
(enableExperimentalFeatures):
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

Reviewed by Eric Carlson.

* platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
36 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/resources/import-expectations.json
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-changetype-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-changetype-util.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-changetype.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mp3/sound_5.mp3 [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/mp3/w3c-import.log [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/media-source/webm/test-vp9.webm [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/media-source/webm/w3c-import.log
LayoutTests/platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/MediaSource.h
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/Modules/mediasource/SourceBuffer.idl
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/graphics/SourceBufferPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/mac/WebView/WebPreferences.mm
Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/TestController.cpp