haikuwebkit/LayoutTests/webaudio/decode-audio-data-basic.html

69 lines
2.2 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
Many WebAudio js-tests use waitUntilDone https://bugs.webkit.org/show_bug.cgi?id=172398 Reviewed by Sam Weinig. Corrected the use of js-test harness, updated the tests to use js-test.js instead of js-test-pre.js where possible. * resources/js-test.js: (shouldReject): Copied some funcitonality form js-test-pre.js that wasn't present here. * webaudio/analyser-exception.html: * webaudio/audiobuffer-neuter-expected.txt: * webaudio/audiobuffer-neuter.html: * webaudio/audiobuffersource-channels.html: * webaudio/audiobuffersource-ended-expected.txt: * webaudio/audiobuffersource-ended.html: * webaudio/audiobuffersource-exception.html: * webaudio/audiobuffersource-loop-comprehensive-expected.txt: * webaudio/audiobuffersource-loop-comprehensive.html: * webaudio/audiobuffersource-negative-playbackrate-expected.txt: * webaudio/audiobuffersource-negative-playbackrate-interpolated-expected.txt: * webaudio/audiobuffersource-negative-playbackrate-interpolated-loop-expected.txt: * webaudio/audiobuffersource-negative-playbackrate-interpolated-loop.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated.html: * webaudio/audiobuffersource-negative-playbackrate-loop-expected.txt: * webaudio/audiobuffersource-negative-playbackrate-loop.html: * webaudio/audiobuffersource-negative-playbackrate.html: * webaudio/audiobuffersource-playbackState.html: * webaudio/audiobuffersource-start-expected.txt: * webaudio/audiobuffersource-start.html: * webaudio/audiochannelmerger-basic.html: * webaudio/audiochannelmerger-stereo.html: * webaudio/audiochannelsplitter.html: * webaudio/audiocontext-promise-throwing.html: * webaudio/audiocontext-promise.html: * webaudio/audiocontext-restriction-audiobuffersourcenode-start.html: * webaudio/audiocontext-restriction.html: * webaudio/audiocontext-state-interrupted.html: * webaudio/audiocontext-state.html: * webaudio/audionode-channel-rules.html: * webaudio/audionode-connect-order.html: * webaudio/audionode.html: * webaudio/audioparam-connect-audioratesignal.html: * webaudio/audioparam-summingjunction.html: * webaudio/audioprocessingevent.html: * webaudio/automatic-pull-node.html: * webaudio/biquad-allpass.html: * webaudio/biquad-bandpass.html: * webaudio/biquad-getFrequencyResponse.html: * webaudio/biquad-highpass.html: * webaudio/biquad-highshelf.html: * webaudio/biquad-lowpass.html: * webaudio/biquad-lowshelf.html: * webaudio/biquad-notch.html: * webaudio/biquad-peaking.html: * webaudio/biquadfilternode-basic.html: * webaudio/convolution-mono-mono.html: * webaudio/decode-audio-data-basic.html: * webaudio/decode-audio-data-too-short.html: * webaudio/delaynode-max-default-delay.html: * webaudio/delaynode-max-nondefault-delay.html: * webaudio/delaynode-maxdelay.html: * webaudio/delaynode-maxdelaylimit.html: * webaudio/delaynode-scheduling.html: * webaudio/delaynode.html: * webaudio/distance-exponential.html: * webaudio/distance-inverse.html: * webaudio/distance-linear.html: * webaudio/dynamicscompressor-basic.html: * webaudio/javascriptaudionode-downmix8-2channel-input.html: * webaudio/javascriptaudionode-upmix2-8channel-input.html: * webaudio/javascriptaudionode-zero-input-channels.html: * webaudio/javascriptaudionode.html: * webaudio/mediaelementaudiosourcenode.html: * webaudio/oscillator-basic.html: * webaudio/oscillator-ended-expected.txt: * webaudio/oscillator-ended.html: * webaudio/page-canstartmedia.html: * webaudio/panner-equalpower-stereo.html: * webaudio/panner-equalpower.html: * webaudio/panner-loop.html: * webaudio/pannernode-basic.html: * webaudio/realtimeanalyser-fft-scaling.html: * webaudio/realtimeanalyser-fft-sizing.html: * webaudio/resources/audiobuffersource-testing.js: (checkAllTests): * webaudio/sample-accurate-scheduling.html: * webaudio/stereo2mono-down-mixing.html: * webaudio/test-basic.html: * webaudio/waveshaper.html: Canonical link: https://commits.webkit.org/189368@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217243 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-22 20:49:12 +00:00
<script src="../resources/js-test.js"></script>
<script type="text/javascript" src="resources/audio-testing.js"></script>
</head>
<body>
<script>
description("Basic tests for decodeAudioData function.");
[WebAudio] Add webm/opus container support https://bugs.webkit.org/show_bug.cgi?id=227110 <rdar://problem/79437067> Reviewed by Jer Noble. Source/WebCore: Add support for webm in Web Audio. As decoding needs to be performed in the web content process we need to ensure that the decoders are available there. For security reasons, com.apple.audio.AudioComponentRegistrar mach calls are blocked which prevents registering a new audio component. We instead register it in the UI process so that AudioComponentFetchServerRegistrations SPI can forward the registration in the web process. Unfortunately, for unknown reasons, this fails for Vorbis audio codec (bug 228139). To demux the webm content, we use the existing SourceBufferParserWebM to extract all audio packets. We then iterate over all CM Samples and decode them into PCM, performing resampling as needed on the fly. There are things left to fix. - Opus and Vorbis encoder delay isn't handled (bug 228140) which leaves audible silence at the beginning of the destination buffer. - We can only decode mono and stereo content. Opus and Vorbis let you define a custom channel ordering, this is particularly used with ambisonic audio (with opus 255 mode). CoreMedia doesn't easily deal with such re-ordering as it appears to be essentially designed for audible content. With more than 2 channels, decoding will either fail or produce channels in the wrong order. Test: webaudio/decode-audio-data-webm-opus.html * Headers.cmake: Export header so that we can register the decoder in the UI process. * WebCore.xcodeproj/project.pbxproj: same as above. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canPlayType const): Make canPlayType(webm/audio; codecs=opus) work if features is set. * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebMWebAudioEnabled): (WebCore::RuntimeEnabledFeatures::webMWebAudioEnabled const): * platform/MediaSample.h: Fly-by fix: remove unnecessary WEBCORE_EXPORT * platform/audio/AudioBus.cpp: (WebCore::AudioBus::setLength): * platform/audio/AudioBus.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/AudioChannel.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/cocoa/AudioFileReaderCocoa.cpp: (WebCore::tryCreateAudioBufferList): Fix checkedInt use to catch potential overflow (WebCore::AudioBufferListHolder::AudioBufferListHolder): Add convenience class that free wrapped AudioBufferList object on exit. (WebCore::AudioBufferListHolder::~AudioBufferListHolder): (WebCore::AudioBufferListHolder::operator bool const): (WebCore::AudioBufferListHolder::operator-> const): (WebCore::AudioBufferListHolder::operator* const): (WebCore::AudioBufferListHolder::isValid const): (WebCore::AudioFileReader::AudioFileReader): (WebCore::AudioFileReader::isMaybeWebM const): Method to check if the buffer contains WebM data. (WebCore::passthroughInputDataCallback): Required for AudioConverterFillComplexBuffer. Will feed the decoder the data to decode, splitting the multiple packets found in the CMSampleBuffer. (WebCore::AudioFileReader::numberOfFrames const): Return the total number of decoded frames in the packets. (WebCore::AudioFileReader::fileDataFormat const): Create AudioStreamBasicDescription related to the demuxed audio track. nullopt if unsupported content. (WebCore::AudioFileReader::clientDataFormat const): (WebCore::AudioFileReader::createBus): (WebCore::AudioFileReader::logChannel const): * platform/audio/cocoa/AudioFileReaderCocoa.h: * platform/audio/cocoa/AudioSampleDataSource.h: Remove unused typedef. * platform/audio/cocoa/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::~AudioSampleDataSource): Fly-by fix, make it use PAL softlinks (WebCore::AudioSampleDataSource::setupConverter): Fly-by fix, make it use PAL softlinks * platform/gamepad/mac/HIDGamepadProvider.mm: Fly-by fix, add missing header. * platform/graphics/TrackPrivateBase.cpp: Fly-by fix, add missing header. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: Fly-by fix required by webkit-prepare : don't tag the whole class as WEBCORE_EXPORT. Move constructor and destructor function definitions out-of-line to prevent linkage errors. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): Move code * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Fly-by fix, add missing header. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Export some symbols, add new method definitions. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: (WebCore::registerDecoderFactory): Instead of attempting to register the decoder by dl-opening the required library, first attempting to see if the decoder is already available. Calling AudioComponentRegister in the web content process when the GPU process is enabled will fail due to sandbox settings. Which would incorrectly report the codec to not be available when it was. (WebCore::createAudioFormatDescriptionForFormat): (WebCore::isOpusDecoderAvailable): Fly-by fix, should the method be called on non-mac platform it would have return the unitialized value of the available static variable. (WebCore::registerOpusDecoderIfNeeded): Added (WebCore::isVorbisDecoderAvailable): Same as isOpusDecoderAvailable (WebCore::registerVorbisDecoderIfNeeded): Added Source/WebCore/PAL: Add various AVFoundation (AVAudioConverter) related methods and CoreMedia to access required CMSampleBuffer related methods. * pal/cf/CoreMediaSoftLink.cpp: * pal/cf/CoreMediaSoftLink.h: * pal/cocoa/AVFoundationSoftLink.h: * pal/cocoa/AVFoundationSoftLink.mm: Source/WebKit: Add default value for webm_webaudio feature flag for the different platforms. Disabled by default on all platforms. Fly-by fix: don't make webm parser dependent on VP9 support. * FeatureFlags/WebKit-appletvos.plist: * FeatureFlags/WebKit-ios.plist: * FeatureFlags/WebKit-macos.plist: * FeatureFlags/WebKit-watchos.plist: * GPUProcess/GPUProcess.h: * GPUProcess/GPUProcess.messages.in: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultWebMWebAudioEnabled): * Shared/WebPreferencesDefaultValues.h: * UIProcess/Cocoa/WebProcessProxyCocoa.mm: (WebKit::WebProcessProxy::sendAudioComponentRegistrations): Source/WTF: Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: "audio/webm; codecs=opus" Disabled by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * platform/mac/TestExpectations: Only enable test on macOS Monterey * webaudio/decode-audio-data-basic.html: fix whitespace * webaudio/decode-audio-data-webm-opus-expected.txt: Added. * webaudio/decode-audio-data-webm-opus.html: Added. * webaudio/resources/media/opus.webm: Added. * webaudio/resources/media/vorbis.webm: Added. Canonical link: https://commits.webkit.org/240056@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 04:18:16 +00:00
window.jsTestIsAsync = true;
Turn off the legacy prefixed WebAudio API https://bugs.webkit.org/show_bug.cgi?id=216886 Reviewed by Sam Weinig. LayoutTests/imported/w3c: * web-platform-tests/webaudio/historical-expected.txt: Rebaseline test that is now passing. Source/WebCore: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. No new tests, rebaselined existing tests. * Modules/webaudio/AudioBufferSourceNode.idl: Make sure legacy constants get unexposed if the PrefixedWebAudio setting is disabled. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): (GetRuntimeEnabledStaticProperties): * bindings/scripts/test/JS/JSTestConditionalIncludes.cpp: (WebCore::JSTestConditionalIncludesConstructor::initializeProperties): (WebCore::JSTestConditionalIncludesPrototype::finishCreation): * bindings/scripts/test/JS/JSTestEnabledBySetting.cpp: (WebCore::JSTestEnabledBySettingConstructor::prototypeForStructure): (WebCore::JSTestEnabledBySettingConstructor::initializeProperties): (WebCore::JSTestEnabledBySettingPrototype::finishCreation): * bindings/scripts/test/TestEnabledBySetting.idl: Add support for using [EnabledBySetting=X] on constants. Source/WebKit: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. * Shared/WebPreferencesInternal.yaml: Source/WebKitLegacy/mac: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. * WebView/WebView.mm: (-[WebView _preferencesChanged:]): LayoutTests: Port existing layout tests from the prefixed WebAudio API to the new unprefixed version. * fast/history/page-cache-closed-audiocontext.html: * fast/history/page-cache-running-audiocontext.html: * fast/history/page-cache-suspended-audiocontext.html: * fast/mediastream/getUserMedia-webaudio.html: * fast/mediastream/media-devices-enumerate-devices.html: * fast/mediastream/mediastreamtrack-audio-clone.html: * fast/mediastream/mock-media-source-webaudio.html: * http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html: * http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html: * http/wpt/mediarecorder/MediaRecorder-onremovetrack.html: * http/wpt/webaudio/resources/audiocontext-stopped-iframe.html: * platform/ios/webaudio/realtimeanalyser-fft-sizing-expected.txt: * resources/testharnessreport.js: * webaudio/analyser-exception.html: * webaudio/audiobuffer-crash-expected.txt: * webaudio/audiobuffer-crash.html: * webaudio/audiobuffer-expected.txt: * webaudio/audiobuffer-neuter.html: * webaudio/audiobuffer.html: * webaudio/audiobuffersource-channels-expected.txt: * webaudio/audiobuffersource-channels.html: * webaudio/audiobuffersource-ended.html: * webaudio/audiobuffersource-multi-channels.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated-loop.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated.html: * webaudio/audiobuffersource-negative-playbackrate-loop.html: * webaudio/audiobuffersource-negative-playbackrate.html: * webaudio/audiobuffersource-not-gced-until-ended.html: * webaudio/audiobuffersource-playbackState-expected.txt: Removed. * webaudio/audiobuffersource-playbackState.html: Removed. * webaudio/audiobuffersource-playbackrate.html: * webaudio/audiobuffersource-start.html: * webaudio/audiobuffersource.html: * webaudio/audiobuffersourcenode-legacy-api-expected.txt: * webaudio/audiobuffersourcenode-legacy-api.html: * webaudio/audiochannelmerger-basic.html: * webaudio/audiochannelmerger-stereo.html: * webaudio/audiochannelsplitter.html: * webaudio/audiocontext-promise-throwing-expected.txt: * webaudio/audiocontext-promise-throwing.html: * webaudio/audiocontext-promise.html: * webaudio/audiocontext-restriction-audiobuffersourcenode-start.html: * webaudio/audiocontext-restriction.html: * webaudio/audiocontext-state-interrupted.html: * webaudio/audiocontext-state.html: * webaudio/audionode-connect-order.html: * webaudio/audionode.html: * webaudio/audioparam-connect-audioratesignal.html: * webaudio/audioparam-summingjunction.html: * webaudio/audioprocessingevent.html: * webaudio/automatic-pull-node.html: * webaudio/convolution-mono-mono.html: * webaudio/convolver-channels.html: * webaudio/convolver-setBuffer-different-samplerate.html: * webaudio/convolver-setBuffer-null.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/decode-audio-data-too-short.html: * webaudio/delaynode-max-default-delay.html: * webaudio/delaynode-max-nondefault-delay.html: * webaudio/delaynode-maxdelay.html: * webaudio/delaynode-maxdelaylimit.html: * webaudio/delaynode-scheduling.html: * webaudio/delaynode.html: * webaudio/distance-exponential.html: * webaudio/distance-inverse.html: * webaudio/distance-linear.html: * webaudio/dynamicscompressor-basic.html: * webaudio/finished-audio-buffer-source-nodes-should-be-collectable.html: * webaudio/gain-basic.html: * webaudio/gain.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode-gc.html: * webaudio/mediaelementaudiosourcenode.html: * webaudio/mixing.html: * webaudio/offlineaudiocontext-gc.html: * webaudio/offlineaudiocontext-restriction.html: * webaudio/oscillatornode-legacy-api-expected.txt: * webaudio/oscillatornode-legacy-api.html: * webaudio/page-canstartmedia.html: * webaudio/panner-equalpower-stereo.html: * webaudio/panner-equalpower.html: * webaudio/prefixed-pannernode-basic-expected.txt: Removed. * webaudio/prefixed-pannernode-basic.html: Removed. * webaudio/realtimeanalyser-fft-sizing-expected.txt: * webaudio/realtimeanalyser-fft-sizing.html: * webaudio/resources/audio-codec-test.js: (runDecodingTest): * webaudio/resources/audiobuffersource-ended-detached-frame-iframe.html: * webaudio/resources/audioparam-testing-legacy.js: (createAudioGraphAndTest): * webaudio/resources/compatibility.js: Removed. * webaudio/resources/javascriptaudionode-testing.js: (runJSNodeTest): * webaudio/resources/oscillator-testing-legacy.js: (generateExponentialOscillatorSweep): * webaudio/sample-accurate-scheduling.html: * webaudio/silence-after-playback.html: * webaudio/silent-audio-interrupted-in-background.html: * webaudio/stereo2mono-down-mixing.html: * webaudio/test-basic.html: * webaudio/up-mixing-mono-51.html: * webaudio/up-mixing-mono-stereo.html: * webaudio/up-mixing-stereo-51.html: * webaudio/waveshaper.html: * webaudio/web-audio-is-playing.html: * webaudio/webaudio-gc.html: * webaudio/webkitofflineaudiocontext-startRendering-crash-expected.txt: * webaudio/webkitofflineaudiocontext-startRendering-crash.html: * webrtc/audio-peer-connection-g722.html: * webrtc/audio-peer-connection-webaudio.html: * webrtc/clone-audio-track.html: * webrtc/getUserMedia-webaudio-autoplay.html: * webrtc/peer-connection-audio-mute.html: * webrtc/peer-connection-audio-mute2.html: * webrtc/peer-connection-createMediaStreamDestination.html: * webrtc/peer-connection-remote-audio-mute.html: * webrtc/peer-connection-remote-audio-mute2.html: * webrtc/routines.js: Canonical link: https://commits.webkit.org/229688@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267504 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-23 22:48:05 +00:00
var context = new AudioContext();
Turn off the legacy prefixed WebAudio API https://bugs.webkit.org/show_bug.cgi?id=216886 Reviewed by Sam Weinig. LayoutTests/imported/w3c: * web-platform-tests/webaudio/historical-expected.txt: Rebaseline test that is now passing. Source/WebCore: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. No new tests, rebaselined existing tests. * Modules/webaudio/AudioBufferSourceNode.idl: Make sure legacy constants get unexposed if the PrefixedWebAudio setting is disabled. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): (GetRuntimeEnabledStaticProperties): * bindings/scripts/test/JS/JSTestConditionalIncludes.cpp: (WebCore::JSTestConditionalIncludesConstructor::initializeProperties): (WebCore::JSTestConditionalIncludesPrototype::finishCreation): * bindings/scripts/test/JS/JSTestEnabledBySetting.cpp: (WebCore::JSTestEnabledBySettingConstructor::prototypeForStructure): (WebCore::JSTestEnabledBySettingConstructor::initializeProperties): (WebCore::JSTestEnabledBySettingPrototype::finishCreation): * bindings/scripts/test/TestEnabledBySetting.idl: Add support for using [EnabledBySetting=X] on constants. Source/WebKit: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. * Shared/WebPreferencesInternal.yaml: Source/WebKitLegacy/mac: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. * WebView/WebView.mm: (-[WebView _preferencesChanged:]): LayoutTests: Port existing layout tests from the prefixed WebAudio API to the new unprefixed version. * fast/history/page-cache-closed-audiocontext.html: * fast/history/page-cache-running-audiocontext.html: * fast/history/page-cache-suspended-audiocontext.html: * fast/mediastream/getUserMedia-webaudio.html: * fast/mediastream/media-devices-enumerate-devices.html: * fast/mediastream/mediastreamtrack-audio-clone.html: * fast/mediastream/mock-media-source-webaudio.html: * http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html: * http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html: * http/wpt/mediarecorder/MediaRecorder-onremovetrack.html: * http/wpt/webaudio/resources/audiocontext-stopped-iframe.html: * platform/ios/webaudio/realtimeanalyser-fft-sizing-expected.txt: * resources/testharnessreport.js: * webaudio/analyser-exception.html: * webaudio/audiobuffer-crash-expected.txt: * webaudio/audiobuffer-crash.html: * webaudio/audiobuffer-expected.txt: * webaudio/audiobuffer-neuter.html: * webaudio/audiobuffer.html: * webaudio/audiobuffersource-channels-expected.txt: * webaudio/audiobuffersource-channels.html: * webaudio/audiobuffersource-ended.html: * webaudio/audiobuffersource-multi-channels.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated-loop.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated.html: * webaudio/audiobuffersource-negative-playbackrate-loop.html: * webaudio/audiobuffersource-negative-playbackrate.html: * webaudio/audiobuffersource-not-gced-until-ended.html: * webaudio/audiobuffersource-playbackState-expected.txt: Removed. * webaudio/audiobuffersource-playbackState.html: Removed. * webaudio/audiobuffersource-playbackrate.html: * webaudio/audiobuffersource-start.html: * webaudio/audiobuffersource.html: * webaudio/audiobuffersourcenode-legacy-api-expected.txt: * webaudio/audiobuffersourcenode-legacy-api.html: * webaudio/audiochannelmerger-basic.html: * webaudio/audiochannelmerger-stereo.html: * webaudio/audiochannelsplitter.html: * webaudio/audiocontext-promise-throwing-expected.txt: * webaudio/audiocontext-promise-throwing.html: * webaudio/audiocontext-promise.html: * webaudio/audiocontext-restriction-audiobuffersourcenode-start.html: * webaudio/audiocontext-restriction.html: * webaudio/audiocontext-state-interrupted.html: * webaudio/audiocontext-state.html: * webaudio/audionode-connect-order.html: * webaudio/audionode.html: * webaudio/audioparam-connect-audioratesignal.html: * webaudio/audioparam-summingjunction.html: * webaudio/audioprocessingevent.html: * webaudio/automatic-pull-node.html: * webaudio/convolution-mono-mono.html: * webaudio/convolver-channels.html: * webaudio/convolver-setBuffer-different-samplerate.html: * webaudio/convolver-setBuffer-null.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/decode-audio-data-too-short.html: * webaudio/delaynode-max-default-delay.html: * webaudio/delaynode-max-nondefault-delay.html: * webaudio/delaynode-maxdelay.html: * webaudio/delaynode-maxdelaylimit.html: * webaudio/delaynode-scheduling.html: * webaudio/delaynode.html: * webaudio/distance-exponential.html: * webaudio/distance-inverse.html: * webaudio/distance-linear.html: * webaudio/dynamicscompressor-basic.html: * webaudio/finished-audio-buffer-source-nodes-should-be-collectable.html: * webaudio/gain-basic.html: * webaudio/gain.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode-gc.html: * webaudio/mediaelementaudiosourcenode.html: * webaudio/mixing.html: * webaudio/offlineaudiocontext-gc.html: * webaudio/offlineaudiocontext-restriction.html: * webaudio/oscillatornode-legacy-api-expected.txt: * webaudio/oscillatornode-legacy-api.html: * webaudio/page-canstartmedia.html: * webaudio/panner-equalpower-stereo.html: * webaudio/panner-equalpower.html: * webaudio/prefixed-pannernode-basic-expected.txt: Removed. * webaudio/prefixed-pannernode-basic.html: Removed. * webaudio/realtimeanalyser-fft-sizing-expected.txt: * webaudio/realtimeanalyser-fft-sizing.html: * webaudio/resources/audio-codec-test.js: (runDecodingTest): * webaudio/resources/audiobuffersource-ended-detached-frame-iframe.html: * webaudio/resources/audioparam-testing-legacy.js: (createAudioGraphAndTest): * webaudio/resources/compatibility.js: Removed. * webaudio/resources/javascriptaudionode-testing.js: (runJSNodeTest): * webaudio/resources/oscillator-testing-legacy.js: (generateExponentialOscillatorSweep): * webaudio/sample-accurate-scheduling.html: * webaudio/silence-after-playback.html: * webaudio/silent-audio-interrupted-in-background.html: * webaudio/stereo2mono-down-mixing.html: * webaudio/test-basic.html: * webaudio/up-mixing-mono-51.html: * webaudio/up-mixing-mono-stereo.html: * webaudio/up-mixing-stereo-51.html: * webaudio/waveshaper.html: * webaudio/web-audio-is-playing.html: * webaudio/webaudio-gc.html: * webaudio/webkitofflineaudiocontext-startRendering-crash-expected.txt: * webaudio/webkitofflineaudiocontext-startRendering-crash.html: * webrtc/audio-peer-connection-g722.html: * webrtc/audio-peer-connection-webaudio.html: * webrtc/clone-audio-track.html: * webrtc/getUserMedia-webaudio-autoplay.html: * webrtc/peer-connection-audio-mute.html: * webrtc/peer-connection-audio-mute2.html: * webrtc/peer-connection-createMediaStreamDestination.html: * webrtc/peer-connection-remote-audio-mute.html: * webrtc/peer-connection-remote-audio-mute2.html: * webrtc/routines.js: Canonical link: https://commits.webkit.org/229688@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267504 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-23 22:48:05 +00:00
// decodeAudioData should reject the promise when arraybuffer parameter is null.
context.decodeAudioData(null, function(){}, function(){}).then(() => {
testFailed("Passing a null array to AudioContext.decodeAudioData() did not throw");
}, (e) => {
if (e.name == "TypeError")
testPassed("Passing a null array to AudioContext.decodeAudioData() threw a TypeError");
else
testFailed("Passing a null array to AudioContext.decodeAudioData() threw a " + e.name + " instead of a TypeError");
});
var decodeCaseArray = [{url: "resources/media/24bit-44khz.wav", result: true},
{url: "resources/media/invalid-audio-file.txt", result: false}];
function runDecodeTest(index) {
if (index >= decodeCaseArray.length) {
finishJSTest();
return;
}
var request = new XMLHttpRequest();
request.open("GET", decodeCaseArray[index].url, true);
request.responseType = "arraybuffer";
[WebAudio] Add webm/opus container support https://bugs.webkit.org/show_bug.cgi?id=227110 <rdar://problem/79437067> Reviewed by Jer Noble. Source/WebCore: Add support for webm in Web Audio. As decoding needs to be performed in the web content process we need to ensure that the decoders are available there. For security reasons, com.apple.audio.AudioComponentRegistrar mach calls are blocked which prevents registering a new audio component. We instead register it in the UI process so that AudioComponentFetchServerRegistrations SPI can forward the registration in the web process. Unfortunately, for unknown reasons, this fails for Vorbis audio codec (bug 228139). To demux the webm content, we use the existing SourceBufferParserWebM to extract all audio packets. We then iterate over all CM Samples and decode them into PCM, performing resampling as needed on the fly. There are things left to fix. - Opus and Vorbis encoder delay isn't handled (bug 228140) which leaves audible silence at the beginning of the destination buffer. - We can only decode mono and stereo content. Opus and Vorbis let you define a custom channel ordering, this is particularly used with ambisonic audio (with opus 255 mode). CoreMedia doesn't easily deal with such re-ordering as it appears to be essentially designed for audible content. With more than 2 channels, decoding will either fail or produce channels in the wrong order. Test: webaudio/decode-audio-data-webm-opus.html * Headers.cmake: Export header so that we can register the decoder in the UI process. * WebCore.xcodeproj/project.pbxproj: same as above. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canPlayType const): Make canPlayType(webm/audio; codecs=opus) work if features is set. * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebMWebAudioEnabled): (WebCore::RuntimeEnabledFeatures::webMWebAudioEnabled const): * platform/MediaSample.h: Fly-by fix: remove unnecessary WEBCORE_EXPORT * platform/audio/AudioBus.cpp: (WebCore::AudioBus::setLength): * platform/audio/AudioBus.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/AudioChannel.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/cocoa/AudioFileReaderCocoa.cpp: (WebCore::tryCreateAudioBufferList): Fix checkedInt use to catch potential overflow (WebCore::AudioBufferListHolder::AudioBufferListHolder): Add convenience class that free wrapped AudioBufferList object on exit. (WebCore::AudioBufferListHolder::~AudioBufferListHolder): (WebCore::AudioBufferListHolder::operator bool const): (WebCore::AudioBufferListHolder::operator-> const): (WebCore::AudioBufferListHolder::operator* const): (WebCore::AudioBufferListHolder::isValid const): (WebCore::AudioFileReader::AudioFileReader): (WebCore::AudioFileReader::isMaybeWebM const): Method to check if the buffer contains WebM data. (WebCore::passthroughInputDataCallback): Required for AudioConverterFillComplexBuffer. Will feed the decoder the data to decode, splitting the multiple packets found in the CMSampleBuffer. (WebCore::AudioFileReader::numberOfFrames const): Return the total number of decoded frames in the packets. (WebCore::AudioFileReader::fileDataFormat const): Create AudioStreamBasicDescription related to the demuxed audio track. nullopt if unsupported content. (WebCore::AudioFileReader::clientDataFormat const): (WebCore::AudioFileReader::createBus): (WebCore::AudioFileReader::logChannel const): * platform/audio/cocoa/AudioFileReaderCocoa.h: * platform/audio/cocoa/AudioSampleDataSource.h: Remove unused typedef. * platform/audio/cocoa/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::~AudioSampleDataSource): Fly-by fix, make it use PAL softlinks (WebCore::AudioSampleDataSource::setupConverter): Fly-by fix, make it use PAL softlinks * platform/gamepad/mac/HIDGamepadProvider.mm: Fly-by fix, add missing header. * platform/graphics/TrackPrivateBase.cpp: Fly-by fix, add missing header. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: Fly-by fix required by webkit-prepare : don't tag the whole class as WEBCORE_EXPORT. Move constructor and destructor function definitions out-of-line to prevent linkage errors. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): Move code * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Fly-by fix, add missing header. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Export some symbols, add new method definitions. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: (WebCore::registerDecoderFactory): Instead of attempting to register the decoder by dl-opening the required library, first attempting to see if the decoder is already available. Calling AudioComponentRegister in the web content process when the GPU process is enabled will fail due to sandbox settings. Which would incorrectly report the codec to not be available when it was. (WebCore::createAudioFormatDescriptionForFormat): (WebCore::isOpusDecoderAvailable): Fly-by fix, should the method be called on non-mac platform it would have return the unitialized value of the available static variable. (WebCore::registerOpusDecoderIfNeeded): Added (WebCore::isVorbisDecoderAvailable): Same as isOpusDecoderAvailable (WebCore::registerVorbisDecoderIfNeeded): Added Source/WebCore/PAL: Add various AVFoundation (AVAudioConverter) related methods and CoreMedia to access required CMSampleBuffer related methods. * pal/cf/CoreMediaSoftLink.cpp: * pal/cf/CoreMediaSoftLink.h: * pal/cocoa/AVFoundationSoftLink.h: * pal/cocoa/AVFoundationSoftLink.mm: Source/WebKit: Add default value for webm_webaudio feature flag for the different platforms. Disabled by default on all platforms. Fly-by fix: don't make webm parser dependent on VP9 support. * FeatureFlags/WebKit-appletvos.plist: * FeatureFlags/WebKit-ios.plist: * FeatureFlags/WebKit-macos.plist: * FeatureFlags/WebKit-watchos.plist: * GPUProcess/GPUProcess.h: * GPUProcess/GPUProcess.messages.in: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultWebMWebAudioEnabled): * Shared/WebPreferencesDefaultValues.h: * UIProcess/Cocoa/WebProcessProxyCocoa.mm: (WebKit::WebProcessProxy::sendAudioComponentRegistrations): Source/WTF: Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: "audio/webm; codecs=opus" Disabled by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * platform/mac/TestExpectations: Only enable test on macOS Monterey * webaudio/decode-audio-data-basic.html: fix whitespace * webaudio/decode-audio-data-webm-opus-expected.txt: Added. * webaudio/decode-audio-data-webm-opus.html: Added. * webaudio/resources/media/opus.webm: Added. * webaudio/resources/media/vorbis.webm: Added. Canonical link: https://commits.webkit.org/240056@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 04:18:16 +00:00
request.onload = function() {
context.decodeAudioData(request.response, successCallback, errorCallback);
[WebAudio] Add webm/opus container support https://bugs.webkit.org/show_bug.cgi?id=227110 <rdar://problem/79437067> Reviewed by Jer Noble. Source/WebCore: Add support for webm in Web Audio. As decoding needs to be performed in the web content process we need to ensure that the decoders are available there. For security reasons, com.apple.audio.AudioComponentRegistrar mach calls are blocked which prevents registering a new audio component. We instead register it in the UI process so that AudioComponentFetchServerRegistrations SPI can forward the registration in the web process. Unfortunately, for unknown reasons, this fails for Vorbis audio codec (bug 228139). To demux the webm content, we use the existing SourceBufferParserWebM to extract all audio packets. We then iterate over all CM Samples and decode them into PCM, performing resampling as needed on the fly. There are things left to fix. - Opus and Vorbis encoder delay isn't handled (bug 228140) which leaves audible silence at the beginning of the destination buffer. - We can only decode mono and stereo content. Opus and Vorbis let you define a custom channel ordering, this is particularly used with ambisonic audio (with opus 255 mode). CoreMedia doesn't easily deal with such re-ordering as it appears to be essentially designed for audible content. With more than 2 channels, decoding will either fail or produce channels in the wrong order. Test: webaudio/decode-audio-data-webm-opus.html * Headers.cmake: Export header so that we can register the decoder in the UI process. * WebCore.xcodeproj/project.pbxproj: same as above. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canPlayType const): Make canPlayType(webm/audio; codecs=opus) work if features is set. * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebMWebAudioEnabled): (WebCore::RuntimeEnabledFeatures::webMWebAudioEnabled const): * platform/MediaSample.h: Fly-by fix: remove unnecessary WEBCORE_EXPORT * platform/audio/AudioBus.cpp: (WebCore::AudioBus::setLength): * platform/audio/AudioBus.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/AudioChannel.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/cocoa/AudioFileReaderCocoa.cpp: (WebCore::tryCreateAudioBufferList): Fix checkedInt use to catch potential overflow (WebCore::AudioBufferListHolder::AudioBufferListHolder): Add convenience class that free wrapped AudioBufferList object on exit. (WebCore::AudioBufferListHolder::~AudioBufferListHolder): (WebCore::AudioBufferListHolder::operator bool const): (WebCore::AudioBufferListHolder::operator-> const): (WebCore::AudioBufferListHolder::operator* const): (WebCore::AudioBufferListHolder::isValid const): (WebCore::AudioFileReader::AudioFileReader): (WebCore::AudioFileReader::isMaybeWebM const): Method to check if the buffer contains WebM data. (WebCore::passthroughInputDataCallback): Required for AudioConverterFillComplexBuffer. Will feed the decoder the data to decode, splitting the multiple packets found in the CMSampleBuffer. (WebCore::AudioFileReader::numberOfFrames const): Return the total number of decoded frames in the packets. (WebCore::AudioFileReader::fileDataFormat const): Create AudioStreamBasicDescription related to the demuxed audio track. nullopt if unsupported content. (WebCore::AudioFileReader::clientDataFormat const): (WebCore::AudioFileReader::createBus): (WebCore::AudioFileReader::logChannel const): * platform/audio/cocoa/AudioFileReaderCocoa.h: * platform/audio/cocoa/AudioSampleDataSource.h: Remove unused typedef. * platform/audio/cocoa/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::~AudioSampleDataSource): Fly-by fix, make it use PAL softlinks (WebCore::AudioSampleDataSource::setupConverter): Fly-by fix, make it use PAL softlinks * platform/gamepad/mac/HIDGamepadProvider.mm: Fly-by fix, add missing header. * platform/graphics/TrackPrivateBase.cpp: Fly-by fix, add missing header. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: Fly-by fix required by webkit-prepare : don't tag the whole class as WEBCORE_EXPORT. Move constructor and destructor function definitions out-of-line to prevent linkage errors. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): Move code * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Fly-by fix, add missing header. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Export some symbols, add new method definitions. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: (WebCore::registerDecoderFactory): Instead of attempting to register the decoder by dl-opening the required library, first attempting to see if the decoder is already available. Calling AudioComponentRegister in the web content process when the GPU process is enabled will fail due to sandbox settings. Which would incorrectly report the codec to not be available when it was. (WebCore::createAudioFormatDescriptionForFormat): (WebCore::isOpusDecoderAvailable): Fly-by fix, should the method be called on non-mac platform it would have return the unitialized value of the available static variable. (WebCore::registerOpusDecoderIfNeeded): Added (WebCore::isVorbisDecoderAvailable): Same as isOpusDecoderAvailable (WebCore::registerVorbisDecoderIfNeeded): Added Source/WebCore/PAL: Add various AVFoundation (AVAudioConverter) related methods and CoreMedia to access required CMSampleBuffer related methods. * pal/cf/CoreMediaSoftLink.cpp: * pal/cf/CoreMediaSoftLink.h: * pal/cocoa/AVFoundationSoftLink.h: * pal/cocoa/AVFoundationSoftLink.mm: Source/WebKit: Add default value for webm_webaudio feature flag for the different platforms. Disabled by default on all platforms. Fly-by fix: don't make webm parser dependent on VP9 support. * FeatureFlags/WebKit-appletvos.plist: * FeatureFlags/WebKit-ios.plist: * FeatureFlags/WebKit-macos.plist: * FeatureFlags/WebKit-watchos.plist: * GPUProcess/GPUProcess.h: * GPUProcess/GPUProcess.messages.in: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultWebMWebAudioEnabled): * Shared/WebPreferencesDefaultValues.h: * UIProcess/Cocoa/WebProcessProxyCocoa.mm: (WebKit::WebProcessProxy::sendAudioComponentRegistrations): Source/WTF: Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: "audio/webm; codecs=opus" Disabled by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * platform/mac/TestExpectations: Only enable test on macOS Monterey * webaudio/decode-audio-data-basic.html: fix whitespace * webaudio/decode-audio-data-webm-opus-expected.txt: Added. * webaudio/decode-audio-data-webm-opus.html: Added. * webaudio/resources/media/opus.webm: Added. * webaudio/resources/media/vorbis.webm: Added. Canonical link: https://commits.webkit.org/240056@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 04:18:16 +00:00
function successCallback() {
if (decodeCaseArray[index].result)
testPassed("The " + decodeCaseArray[index].url + " test: successCallback has been called correctly.");
else
testFailed("The " + decodeCaseArray[index].url + " test: successCallback was not called.");
[WebAudio] Add webm/opus container support https://bugs.webkit.org/show_bug.cgi?id=227110 <rdar://problem/79437067> Reviewed by Jer Noble. Source/WebCore: Add support for webm in Web Audio. As decoding needs to be performed in the web content process we need to ensure that the decoders are available there. For security reasons, com.apple.audio.AudioComponentRegistrar mach calls are blocked which prevents registering a new audio component. We instead register it in the UI process so that AudioComponentFetchServerRegistrations SPI can forward the registration in the web process. Unfortunately, for unknown reasons, this fails for Vorbis audio codec (bug 228139). To demux the webm content, we use the existing SourceBufferParserWebM to extract all audio packets. We then iterate over all CM Samples and decode them into PCM, performing resampling as needed on the fly. There are things left to fix. - Opus and Vorbis encoder delay isn't handled (bug 228140) which leaves audible silence at the beginning of the destination buffer. - We can only decode mono and stereo content. Opus and Vorbis let you define a custom channel ordering, this is particularly used with ambisonic audio (with opus 255 mode). CoreMedia doesn't easily deal with such re-ordering as it appears to be essentially designed for audible content. With more than 2 channels, decoding will either fail or produce channels in the wrong order. Test: webaudio/decode-audio-data-webm-opus.html * Headers.cmake: Export header so that we can register the decoder in the UI process. * WebCore.xcodeproj/project.pbxproj: same as above. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canPlayType const): Make canPlayType(webm/audio; codecs=opus) work if features is set. * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebMWebAudioEnabled): (WebCore::RuntimeEnabledFeatures::webMWebAudioEnabled const): * platform/MediaSample.h: Fly-by fix: remove unnecessary WEBCORE_EXPORT * platform/audio/AudioBus.cpp: (WebCore::AudioBus::setLength): * platform/audio/AudioBus.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/AudioChannel.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/cocoa/AudioFileReaderCocoa.cpp: (WebCore::tryCreateAudioBufferList): Fix checkedInt use to catch potential overflow (WebCore::AudioBufferListHolder::AudioBufferListHolder): Add convenience class that free wrapped AudioBufferList object on exit. (WebCore::AudioBufferListHolder::~AudioBufferListHolder): (WebCore::AudioBufferListHolder::operator bool const): (WebCore::AudioBufferListHolder::operator-> const): (WebCore::AudioBufferListHolder::operator* const): (WebCore::AudioBufferListHolder::isValid const): (WebCore::AudioFileReader::AudioFileReader): (WebCore::AudioFileReader::isMaybeWebM const): Method to check if the buffer contains WebM data. (WebCore::passthroughInputDataCallback): Required for AudioConverterFillComplexBuffer. Will feed the decoder the data to decode, splitting the multiple packets found in the CMSampleBuffer. (WebCore::AudioFileReader::numberOfFrames const): Return the total number of decoded frames in the packets. (WebCore::AudioFileReader::fileDataFormat const): Create AudioStreamBasicDescription related to the demuxed audio track. nullopt if unsupported content. (WebCore::AudioFileReader::clientDataFormat const): (WebCore::AudioFileReader::createBus): (WebCore::AudioFileReader::logChannel const): * platform/audio/cocoa/AudioFileReaderCocoa.h: * platform/audio/cocoa/AudioSampleDataSource.h: Remove unused typedef. * platform/audio/cocoa/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::~AudioSampleDataSource): Fly-by fix, make it use PAL softlinks (WebCore::AudioSampleDataSource::setupConverter): Fly-by fix, make it use PAL softlinks * platform/gamepad/mac/HIDGamepadProvider.mm: Fly-by fix, add missing header. * platform/graphics/TrackPrivateBase.cpp: Fly-by fix, add missing header. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: Fly-by fix required by webkit-prepare : don't tag the whole class as WEBCORE_EXPORT. Move constructor and destructor function definitions out-of-line to prevent linkage errors. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): Move code * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Fly-by fix, add missing header. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Export some symbols, add new method definitions. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: (WebCore::registerDecoderFactory): Instead of attempting to register the decoder by dl-opening the required library, first attempting to see if the decoder is already available. Calling AudioComponentRegister in the web content process when the GPU process is enabled will fail due to sandbox settings. Which would incorrectly report the codec to not be available when it was. (WebCore::createAudioFormatDescriptionForFormat): (WebCore::isOpusDecoderAvailable): Fly-by fix, should the method be called on non-mac platform it would have return the unitialized value of the available static variable. (WebCore::registerOpusDecoderIfNeeded): Added (WebCore::isVorbisDecoderAvailable): Same as isOpusDecoderAvailable (WebCore::registerVorbisDecoderIfNeeded): Added Source/WebCore/PAL: Add various AVFoundation (AVAudioConverter) related methods and CoreMedia to access required CMSampleBuffer related methods. * pal/cf/CoreMediaSoftLink.cpp: * pal/cf/CoreMediaSoftLink.h: * pal/cocoa/AVFoundationSoftLink.h: * pal/cocoa/AVFoundationSoftLink.mm: Source/WebKit: Add default value for webm_webaudio feature flag for the different platforms. Disabled by default on all platforms. Fly-by fix: don't make webm parser dependent on VP9 support. * FeatureFlags/WebKit-appletvos.plist: * FeatureFlags/WebKit-ios.plist: * FeatureFlags/WebKit-macos.plist: * FeatureFlags/WebKit-watchos.plist: * GPUProcess/GPUProcess.h: * GPUProcess/GPUProcess.messages.in: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultWebMWebAudioEnabled): * Shared/WebPreferencesDefaultValues.h: * UIProcess/Cocoa/WebProcessProxyCocoa.mm: (WebKit::WebProcessProxy::sendAudioComponentRegistrations): Source/WTF: Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: "audio/webm; codecs=opus" Disabled by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * platform/mac/TestExpectations: Only enable test on macOS Monterey * webaudio/decode-audio-data-basic.html: fix whitespace * webaudio/decode-audio-data-webm-opus-expected.txt: Added. * webaudio/decode-audio-data-webm-opus.html: Added. * webaudio/resources/media/opus.webm: Added. * webaudio/resources/media/vorbis.webm: Added. Canonical link: https://commits.webkit.org/240056@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 04:18:16 +00:00
runDecodeTest(++index);
}
[WebAudio] Add webm/opus container support https://bugs.webkit.org/show_bug.cgi?id=227110 <rdar://problem/79437067> Reviewed by Jer Noble. Source/WebCore: Add support for webm in Web Audio. As decoding needs to be performed in the web content process we need to ensure that the decoders are available there. For security reasons, com.apple.audio.AudioComponentRegistrar mach calls are blocked which prevents registering a new audio component. We instead register it in the UI process so that AudioComponentFetchServerRegistrations SPI can forward the registration in the web process. Unfortunately, for unknown reasons, this fails for Vorbis audio codec (bug 228139). To demux the webm content, we use the existing SourceBufferParserWebM to extract all audio packets. We then iterate over all CM Samples and decode them into PCM, performing resampling as needed on the fly. There are things left to fix. - Opus and Vorbis encoder delay isn't handled (bug 228140) which leaves audible silence at the beginning of the destination buffer. - We can only decode mono and stereo content. Opus and Vorbis let you define a custom channel ordering, this is particularly used with ambisonic audio (with opus 255 mode). CoreMedia doesn't easily deal with such re-ordering as it appears to be essentially designed for audible content. With more than 2 channels, decoding will either fail or produce channels in the wrong order. Test: webaudio/decode-audio-data-webm-opus.html * Headers.cmake: Export header so that we can register the decoder in the UI process. * WebCore.xcodeproj/project.pbxproj: same as above. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canPlayType const): Make canPlayType(webm/audio; codecs=opus) work if features is set. * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebMWebAudioEnabled): (WebCore::RuntimeEnabledFeatures::webMWebAudioEnabled const): * platform/MediaSample.h: Fly-by fix: remove unnecessary WEBCORE_EXPORT * platform/audio/AudioBus.cpp: (WebCore::AudioBus::setLength): * platform/audio/AudioBus.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/AudioChannel.h: Add setLength method. Will change the reported length without touching the underlying storage. * platform/audio/cocoa/AudioFileReaderCocoa.cpp: (WebCore::tryCreateAudioBufferList): Fix checkedInt use to catch potential overflow (WebCore::AudioBufferListHolder::AudioBufferListHolder): Add convenience class that free wrapped AudioBufferList object on exit. (WebCore::AudioBufferListHolder::~AudioBufferListHolder): (WebCore::AudioBufferListHolder::operator bool const): (WebCore::AudioBufferListHolder::operator-> const): (WebCore::AudioBufferListHolder::operator* const): (WebCore::AudioBufferListHolder::isValid const): (WebCore::AudioFileReader::AudioFileReader): (WebCore::AudioFileReader::isMaybeWebM const): Method to check if the buffer contains WebM data. (WebCore::passthroughInputDataCallback): Required for AudioConverterFillComplexBuffer. Will feed the decoder the data to decode, splitting the multiple packets found in the CMSampleBuffer. (WebCore::AudioFileReader::numberOfFrames const): Return the total number of decoded frames in the packets. (WebCore::AudioFileReader::fileDataFormat const): Create AudioStreamBasicDescription related to the demuxed audio track. nullopt if unsupported content. (WebCore::AudioFileReader::clientDataFormat const): (WebCore::AudioFileReader::createBus): (WebCore::AudioFileReader::logChannel const): * platform/audio/cocoa/AudioFileReaderCocoa.h: * platform/audio/cocoa/AudioSampleDataSource.h: Remove unused typedef. * platform/audio/cocoa/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::~AudioSampleDataSource): Fly-by fix, make it use PAL softlinks (WebCore::AudioSampleDataSource::setupConverter): Fly-by fix, make it use PAL softlinks * platform/gamepad/mac/HIDGamepadProvider.mm: Fly-by fix, add missing header. * platform/graphics/TrackPrivateBase.cpp: Fly-by fix, add missing header. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: Fly-by fix required by webkit-prepare : don't tag the whole class as WEBCORE_EXPORT. Move constructor and destructor function definitions out-of-line to prevent linkage errors. * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): Move code * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Fly-by fix, add missing header. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Export some symbols, add new method definitions. * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: (WebCore::registerDecoderFactory): Instead of attempting to register the decoder by dl-opening the required library, first attempting to see if the decoder is already available. Calling AudioComponentRegister in the web content process when the GPU process is enabled will fail due to sandbox settings. Which would incorrectly report the codec to not be available when it was. (WebCore::createAudioFormatDescriptionForFormat): (WebCore::isOpusDecoderAvailable): Fly-by fix, should the method be called on non-mac platform it would have return the unitialized value of the available static variable. (WebCore::registerOpusDecoderIfNeeded): Added (WebCore::isVorbisDecoderAvailable): Same as isOpusDecoderAvailable (WebCore::registerVorbisDecoderIfNeeded): Added Source/WebCore/PAL: Add various AVFoundation (AVAudioConverter) related methods and CoreMedia to access required CMSampleBuffer related methods. * pal/cf/CoreMediaSoftLink.cpp: * pal/cf/CoreMediaSoftLink.h: * pal/cocoa/AVFoundationSoftLink.h: * pal/cocoa/AVFoundationSoftLink.mm: Source/WebKit: Add default value for webm_webaudio feature flag for the different platforms. Disabled by default on all platforms. Fly-by fix: don't make webm parser dependent on VP9 support. * FeatureFlags/WebKit-appletvos.plist: * FeatureFlags/WebKit-ios.plist: * FeatureFlags/WebKit-macos.plist: * FeatureFlags/WebKit-watchos.plist: * GPUProcess/GPUProcess.h: * GPUProcess/GPUProcess.messages.in: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultWebMWebAudioEnabled): * Shared/WebPreferencesDefaultValues.h: * UIProcess/Cocoa/WebProcessProxyCocoa.mm: (WebKit::WebProcessProxy::sendAudioComponentRegistrations): Source/WTF: Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: "audio/webm; codecs=opus" Disabled by default. * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * platform/mac/TestExpectations: Only enable test on macOS Monterey * webaudio/decode-audio-data-basic.html: fix whitespace * webaudio/decode-audio-data-webm-opus-expected.txt: Added. * webaudio/decode-audio-data-webm-opus.html: Added. * webaudio/resources/media/opus.webm: Added. * webaudio/resources/media/vorbis.webm: Added. Canonical link: https://commits.webkit.org/240056@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 04:18:16 +00:00
function errorCallback() {
if (decodeCaseArray[index].result)
testFailed("The " + decodeCaseArray[index].url + " test: errorCallback was called incorrectly.");
else
testPassed("The " + decodeCaseArray[index].url + " test: errorCallback has been called correctly.");
runDecodeTest(++index);
}
}
request.send();
}
Turn off the legacy prefixed WebAudio API https://bugs.webkit.org/show_bug.cgi?id=216886 Reviewed by Sam Weinig. LayoutTests/imported/w3c: * web-platform-tests/webaudio/historical-expected.txt: Rebaseline test that is now passing. Source/WebCore: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. No new tests, rebaselined existing tests. * Modules/webaudio/AudioBufferSourceNode.idl: Make sure legacy constants get unexposed if the PrefixedWebAudio setting is disabled. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): (GetRuntimeEnabledStaticProperties): * bindings/scripts/test/JS/JSTestConditionalIncludes.cpp: (WebCore::JSTestConditionalIncludesConstructor::initializeProperties): (WebCore::JSTestConditionalIncludesPrototype::finishCreation): * bindings/scripts/test/JS/JSTestEnabledBySetting.cpp: (WebCore::JSTestEnabledBySettingConstructor::prototypeForStructure): (WebCore::JSTestEnabledBySettingConstructor::initializeProperties): (WebCore::JSTestEnabledBySettingPrototype::finishCreation): * bindings/scripts/test/TestEnabledBySetting.idl: Add support for using [EnabledBySetting=X] on constants. Source/WebKit: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. * Shared/WebPreferencesInternal.yaml: Source/WebKitLegacy/mac: Turn off the legacy prefixed WebAudio API, now that the modern unprefixed API has been enabled in r267488. * WebView/WebView.mm: (-[WebView _preferencesChanged:]): LayoutTests: Port existing layout tests from the prefixed WebAudio API to the new unprefixed version. * fast/history/page-cache-closed-audiocontext.html: * fast/history/page-cache-running-audiocontext.html: * fast/history/page-cache-suspended-audiocontext.html: * fast/mediastream/getUserMedia-webaudio.html: * fast/mediastream/media-devices-enumerate-devices.html: * fast/mediastream/mediastreamtrack-audio-clone.html: * fast/mediastream/mock-media-source-webaudio.html: * http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html: * http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html: * http/wpt/mediarecorder/MediaRecorder-onremovetrack.html: * http/wpt/webaudio/resources/audiocontext-stopped-iframe.html: * platform/ios/webaudio/realtimeanalyser-fft-sizing-expected.txt: * resources/testharnessreport.js: * webaudio/analyser-exception.html: * webaudio/audiobuffer-crash-expected.txt: * webaudio/audiobuffer-crash.html: * webaudio/audiobuffer-expected.txt: * webaudio/audiobuffer-neuter.html: * webaudio/audiobuffer.html: * webaudio/audiobuffersource-channels-expected.txt: * webaudio/audiobuffersource-channels.html: * webaudio/audiobuffersource-ended.html: * webaudio/audiobuffersource-multi-channels.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated-loop.html: * webaudio/audiobuffersource-negative-playbackrate-interpolated.html: * webaudio/audiobuffersource-negative-playbackrate-loop.html: * webaudio/audiobuffersource-negative-playbackrate.html: * webaudio/audiobuffersource-not-gced-until-ended.html: * webaudio/audiobuffersource-playbackState-expected.txt: Removed. * webaudio/audiobuffersource-playbackState.html: Removed. * webaudio/audiobuffersource-playbackrate.html: * webaudio/audiobuffersource-start.html: * webaudio/audiobuffersource.html: * webaudio/audiobuffersourcenode-legacy-api-expected.txt: * webaudio/audiobuffersourcenode-legacy-api.html: * webaudio/audiochannelmerger-basic.html: * webaudio/audiochannelmerger-stereo.html: * webaudio/audiochannelsplitter.html: * webaudio/audiocontext-promise-throwing-expected.txt: * webaudio/audiocontext-promise-throwing.html: * webaudio/audiocontext-promise.html: * webaudio/audiocontext-restriction-audiobuffersourcenode-start.html: * webaudio/audiocontext-restriction.html: * webaudio/audiocontext-state-interrupted.html: * webaudio/audiocontext-state.html: * webaudio/audionode-connect-order.html: * webaudio/audionode.html: * webaudio/audioparam-connect-audioratesignal.html: * webaudio/audioparam-summingjunction.html: * webaudio/audioprocessingevent.html: * webaudio/automatic-pull-node.html: * webaudio/convolution-mono-mono.html: * webaudio/convolver-channels.html: * webaudio/convolver-setBuffer-different-samplerate.html: * webaudio/convolver-setBuffer-null.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/decode-audio-data-too-short.html: * webaudio/delaynode-max-default-delay.html: * webaudio/delaynode-max-nondefault-delay.html: * webaudio/delaynode-maxdelay.html: * webaudio/delaynode-maxdelaylimit.html: * webaudio/delaynode-scheduling.html: * webaudio/delaynode.html: * webaudio/distance-exponential.html: * webaudio/distance-inverse.html: * webaudio/distance-linear.html: * webaudio/dynamicscompressor-basic.html: * webaudio/finished-audio-buffer-source-nodes-should-be-collectable.html: * webaudio/gain-basic.html: * webaudio/gain.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode-gc.html: * webaudio/mediaelementaudiosourcenode.html: * webaudio/mixing.html: * webaudio/offlineaudiocontext-gc.html: * webaudio/offlineaudiocontext-restriction.html: * webaudio/oscillatornode-legacy-api-expected.txt: * webaudio/oscillatornode-legacy-api.html: * webaudio/page-canstartmedia.html: * webaudio/panner-equalpower-stereo.html: * webaudio/panner-equalpower.html: * webaudio/prefixed-pannernode-basic-expected.txt: Removed. * webaudio/prefixed-pannernode-basic.html: Removed. * webaudio/realtimeanalyser-fft-sizing-expected.txt: * webaudio/realtimeanalyser-fft-sizing.html: * webaudio/resources/audio-codec-test.js: (runDecodingTest): * webaudio/resources/audiobuffersource-ended-detached-frame-iframe.html: * webaudio/resources/audioparam-testing-legacy.js: (createAudioGraphAndTest): * webaudio/resources/compatibility.js: Removed. * webaudio/resources/javascriptaudionode-testing.js: (runJSNodeTest): * webaudio/resources/oscillator-testing-legacy.js: (generateExponentialOscillatorSweep): * webaudio/sample-accurate-scheduling.html: * webaudio/silence-after-playback.html: * webaudio/silent-audio-interrupted-in-background.html: * webaudio/stereo2mono-down-mixing.html: * webaudio/test-basic.html: * webaudio/up-mixing-mono-51.html: * webaudio/up-mixing-mono-stereo.html: * webaudio/up-mixing-stereo-51.html: * webaudio/waveshaper.html: * webaudio/web-audio-is-playing.html: * webaudio/webaudio-gc.html: * webaudio/webkitofflineaudiocontext-startRendering-crash-expected.txt: * webaudio/webkitofflineaudiocontext-startRendering-crash.html: * webrtc/audio-peer-connection-g722.html: * webrtc/audio-peer-connection-webaudio.html: * webrtc/clone-audio-track.html: * webrtc/getUserMedia-webaudio-autoplay.html: * webrtc/peer-connection-audio-mute.html: * webrtc/peer-connection-audio-mute2.html: * webrtc/peer-connection-createMediaStreamDestination.html: * webrtc/peer-connection-remote-audio-mute.html: * webrtc/peer-connection-remote-audio-mute2.html: * webrtc/routines.js: Canonical link: https://commits.webkit.org/229688@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267504 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-23 22:48:05 +00:00
setTimeout(() => {
runDecodeTest(0);
}, 0);
</script>
</body>
</html>