Changeset 280416 in webkit
- Timestamp:
- Jul 28, 2021 9:18:16 PM (12 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 43 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/mac/TestExpectations (modified) (1 diff)
-
LayoutTests/webaudio/decode-audio-data-basic.html (modified) (3 diffs)
-
LayoutTests/webaudio/decode-audio-data-webm-opus-expected.txt (added)
-
LayoutTests/webaudio/decode-audio-data-webm-opus.html (added)
-
LayoutTests/webaudio/resources/media/opus.webm (added)
-
LayoutTests/webaudio/resources/media/vorbis.webm (added)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Headers.cmake (modified) (1 diff)
-
Source/WebCore/PAL/ChangeLog (modified) (1 diff)
-
Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp (modified) (4 diffs)
-
Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h (modified) (4 diffs)
-
Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h (modified) (1 diff)
-
Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm (modified) (2 diffs)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (1 diff)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (2 diffs)
-
Source/WebCore/page/RuntimeEnabledFeatures.h (modified) (2 diffs)
-
Source/WebCore/platform/MediaSample.h (modified) (1 diff)
-
Source/WebCore/platform/audio/AudioBus.cpp (modified) (1 diff)
-
Source/WebCore/platform/audio/AudioBus.h (modified) (1 diff)
-
Source/WebCore/platform/audio/AudioChannel.h (modified) (1 diff)
-
Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.cpp (modified) (8 diffs)
-
Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.h (modified) (3 diffs)
-
Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h (modified) (1 diff)
-
Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm (modified) (4 diffs)
-
Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.mm (modified) (1 diff)
-
Source/WebCore/platform/graphics/TrackPrivateBase.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h (modified) (5 diffs)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm (modified) (1 diff)
-
Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm (modified) (8 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/FeatureFlags/WebKit-appletvos.plist (modified) (1 diff)
-
Source/WebKit/FeatureFlags/WebKit-ios.plist (modified) (1 diff)
-
Source/WebKit/FeatureFlags/WebKit-macos.plist (modified) (1 diff)
-
Source/WebKit/FeatureFlags/WebKit-watchos.plist (modified) (1 diff)
-
Source/WebKit/GPUProcess/GPUProcess.cpp (modified) (1 diff)
-
Source/WebKit/GPUProcess/GPUProcess.h (modified) (2 diffs)
-
Source/WebKit/GPUProcess/GPUProcess.messages.in (modified) (1 diff)
-
Source/WebKit/Shared/WebPreferencesDefaultValues.cpp (modified) (1 diff)
-
Source/WebKit/Shared/WebPreferencesDefaultValues.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm (modified) (2 diffs)
-
Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h (modified) (1 diff)
-
Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r280415 r280416 1 2021-07-28 Jean-Yves Avenard <jya@apple.com> 2 3 [WebAudio] Add webm/opus container support 4 https://bugs.webkit.org/show_bug.cgi?id=227110 5 <rdar://problem/79437067> 6 7 Reviewed by Jer Noble. 8 9 * platform/mac/TestExpectations: Only enable test on macOS Monterey 10 * webaudio/decode-audio-data-basic.html: fix whitespace 11 * webaudio/decode-audio-data-webm-opus-expected.txt: Added. 12 * webaudio/decode-audio-data-webm-opus.html: Added. 13 * webaudio/resources/media/opus.webm: Added. 14 * webaudio/resources/media/vorbis.webm: Added. 15 1 16 2021-07-28 Sihui Liu <sihui_liu@apple.com> 2 17 -
trunk/LayoutTests/platform/mac/TestExpectations
r280408 r280416 1756 1756 [ Catalina Mojave BigSur ] media/media-source/media-webm-opus-partial.html [ Skip ] 1757 1757 [ Catalina Mojave BigSur ] media/media-source/media-webm-opus-partial-abort.html [ Skip ] 1758 [ Catalina Mojave BigSur ] webaudio/decode-audio-data-webm-opus.html [ Skip ] 1758 1759 1759 1760 webkit.org/b/214422 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html [ Pass Failure ] -
trunk/LayoutTests/webaudio/decode-audio-data-basic.html
r267504 r280416 8 8 <script> 9 9 description("Basic tests for decodeAudioData function."); 10 10 11 11 window.jsTestIsAsync = true; 12 12 … … 35 35 request.open("GET", decodeCaseArray[index].url, true); 36 36 request.responseType = "arraybuffer"; 37 37 38 38 request.onload = function() { 39 39 context.decodeAudioData(request.response, successCallback, errorCallback); 40 40 41 41 function successCallback() { 42 42 if (decodeCaseArray[index].result) … … 44 44 else 45 45 testFailed("The " + decodeCaseArray[index].url + " test: successCallback was not called."); 46 46 47 47 runDecodeTest(++index); 48 48 } 49 49 50 50 function errorCallback() { 51 51 if (decodeCaseArray[index].result) -
trunk/Source/WTF/ChangeLog
r280414 r280416 1 2021-07-28 Jean-Yves Avenard <jya@apple.com> 2 3 [WebAudio] Add webm/opus container support 4 https://bugs.webkit.org/show_bug.cgi?id=227110 5 <rdar://problem/79437067> 6 7 Reviewed by Jer Noble. 8 9 Add WebMWebAudioEnabled preference to make canPlayType return probably for mimetype: 10 "audio/webm; codecs=opus" 11 Disabled by default. 12 13 * Scripts/Preferences/WebPreferencesExperimental.yaml: 14 1 15 2021-07-28 Ryosuke Niwa <rniwa@webkit.org> 2 16 -
trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml
r280327 r280416 1262 1262 default: WebKit::defaultWebMParserEnabled() 1263 1263 1264 WebMWebAudioEnabled: 1265 type: bool 1266 webcoreBinding: RuntimeEnabledFeatures 1267 humanReadableName: "WebM Web Audio" 1268 humanReadableDescription: "Enable WebM Web Audio" 1269 condition: ENABLE(MEDIA_SOURCE) 1270 defaultValue: 1271 WebKitLegacy: 1272 default: WebKit::defaultWebMWebAudioEnabled() 1273 WebKit: 1274 default: WebKit::defaultWebMWebAudioEnabled() 1275 1264 1276 # FIXME: Is this implemented for WebKitLegacy? If not, this should be excluded from WebKitLegacy entirely. 1265 1277 WebRTCH264LowLatencyEncoderEnabled: -
trunk/Source/WebCore/ChangeLog
r280415 r280416 1 2021-07-28 Jean-Yves Avenard <jya@apple.com> 2 3 [WebAudio] Add webm/opus container support 4 https://bugs.webkit.org/show_bug.cgi?id=227110 5 <rdar://problem/79437067> 6 7 Reviewed by Jer Noble. 8 9 Add support for webm in Web Audio. 10 As decoding needs to be performed in the web content process we 11 need to ensure that the decoders are available there. For security 12 reasons, com.apple.audio.AudioComponentRegistrar mach calls are blocked 13 which prevents registering a new audio component. 14 We instead register it in the UI process so that AudioComponentFetchServerRegistrations 15 SPI can forward the registration in the web process. 16 Unfortunately, for unknown reasons, this fails for Vorbis audio codec (bug 228139). 17 18 To demux the webm content, we use the existing SourceBufferParserWebM to extract all 19 audio packets. We then iterate over all CM Samples and decode them into PCM, performing 20 resampling as needed on the fly. 21 There are things left to fix. 22 - Opus and Vorbis encoder delay isn't handled (bug 228140) which leaves audible 23 silence at the beginning of the destination buffer. 24 - We can only decode mono and stereo content. Opus and Vorbis let you define a 25 custom channel ordering, this is particularly used with ambisonic audio (with opus 255 mode). 26 CoreMedia doesn't easily deal with such re-ordering as it appears to be essentially 27 designed for audible content. With more than 2 channels, decoding will either fail 28 or produce channels in the wrong order. 29 30 Test: webaudio/decode-audio-data-webm-opus.html 31 32 * Headers.cmake: Export header so that we can register the decoder in the UI process. 33 * WebCore.xcodeproj/project.pbxproj: same as above. 34 * html/HTMLMediaElement.cpp: 35 (WebCore::HTMLMediaElement::canPlayType const): Make canPlayType(webm/audio; codecs=opus) 36 work if features is set. 37 * page/RuntimeEnabledFeatures.h: 38 (WebCore::RuntimeEnabledFeatures::setWebMWebAudioEnabled): 39 (WebCore::RuntimeEnabledFeatures::webMWebAudioEnabled const): 40 * platform/MediaSample.h: Fly-by fix: remove unnecessary WEBCORE_EXPORT 41 * platform/audio/AudioBus.cpp: 42 (WebCore::AudioBus::setLength): 43 * platform/audio/AudioBus.h: Add setLength method. Will change the reported length 44 without touching the underlying storage. 45 * platform/audio/AudioChannel.h: Add setLength method. Will change the reported 46 length without touching the underlying storage. 47 * platform/audio/cocoa/AudioFileReaderCocoa.cpp: 48 (WebCore::tryCreateAudioBufferList): Fix checkedInt use to catch potential overflow 49 (WebCore::AudioBufferListHolder::AudioBufferListHolder): Add convenience class that 50 free wrapped AudioBufferList object on exit. 51 (WebCore::AudioBufferListHolder::~AudioBufferListHolder): 52 (WebCore::AudioBufferListHolder::operator bool const): 53 (WebCore::AudioBufferListHolder::operator-> const): 54 (WebCore::AudioBufferListHolder::operator* const): 55 (WebCore::AudioBufferListHolder::isValid const): 56 (WebCore::AudioFileReader::AudioFileReader): 57 (WebCore::AudioFileReader::isMaybeWebM const): Method to check if the buffer 58 contains WebM data. 59 (WebCore::passthroughInputDataCallback): Required for AudioConverterFillComplexBuffer. 60 Will feed the decoder the data to decode, splitting the multiple packets found 61 in the CMSampleBuffer. 62 (WebCore::AudioFileReader::numberOfFrames const): Return the total number of 63 decoded frames in the packets. 64 (WebCore::AudioFileReader::fileDataFormat const): Create AudioStreamBasicDescription 65 related to the demuxed audio track. nullopt if unsupported content. 66 (WebCore::AudioFileReader::clientDataFormat const): 67 (WebCore::AudioFileReader::createBus): 68 (WebCore::AudioFileReader::logChannel const): 69 * platform/audio/cocoa/AudioFileReaderCocoa.h: 70 * platform/audio/cocoa/AudioSampleDataSource.h: Remove unused typedef. 71 * platform/audio/cocoa/AudioSampleDataSource.mm: 72 (WebCore::AudioSampleDataSource::~AudioSampleDataSource): Fly-by fix, make it use 73 PAL softlinks 74 (WebCore::AudioSampleDataSource::setupConverter): Fly-by fix, make it use PAL 75 softlinks 76 * platform/gamepad/mac/HIDGamepadProvider.mm: Fly-by fix, add missing header. 77 * platform/graphics/TrackPrivateBase.cpp: Fly-by fix, add missing header. 78 * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: 79 Fly-by fix required by webkit-prepare : don't tag the whole class as WEBCORE_EXPORT. 80 Move constructor and destructor function definitions out-of-line to prevent 81 linkage errors. 82 * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: 83 (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): Move code 84 * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Fly-by fix, add missing header. 85 * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Export some symbols, add new 86 method definitions. 87 * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: 88 (WebCore::registerDecoderFactory): Instead of attempting to register the decoder 89 by dl-opening the required library, first attempting to see if the decoder is 90 already available. Calling AudioComponentRegister in the web content process 91 when the GPU process is enabled will fail due to sandbox settings. Which would 92 incorrectly report the codec to not be available when it was. 93 (WebCore::createAudioFormatDescriptionForFormat): 94 (WebCore::isOpusDecoderAvailable): Fly-by fix, should the method be called 95 on non-mac platform it would have return the unitialized value of the available 96 static variable. 97 (WebCore::registerOpusDecoderIfNeeded): Added 98 (WebCore::isVorbisDecoderAvailable): Same as isOpusDecoderAvailable 99 (WebCore::registerVorbisDecoderIfNeeded): Added 100 1 101 2021-07-28 Sihui Liu <sihui_liu@apple.com> 2 102 -
trunk/Source/WebCore/Headers.cmake
r280415 r280416 1337 1337 platform/graphics/angle/GraphicsContextGLANGLEUtilities.h 1338 1338 1339 platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h 1340 1339 1341 platform/graphics/displaylists/DisplayList.h 1340 1342 platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h -
trunk/Source/WebCore/PAL/ChangeLog
r280384 r280416 1 2021-07-28 Jean-Yves Avenard <jya@apple.com> 2 3 [WebAudio] Add webm/opus container support 4 https://bugs.webkit.org/show_bug.cgi?id=227110 5 <rdar://problem/79437067> 6 7 Reviewed by Jer Noble. 8 9 Add various AVFoundation (AVAudioConverter) related methods and 10 CoreMedia to access required CMSampleBuffer related methods. 11 12 * pal/cf/CoreMediaSoftLink.cpp: 13 * pal/cf/CoreMediaSoftLink.h: 14 * pal/cocoa/AVFoundationSoftLink.h: 15 * pal/cocoa/AVFoundationSoftLink.mm: 16 1 17 2021-07-28 Alex Christensen <achristensen@webkit.org> 2 18 -
trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp
r279786 r280416 37 37 #endif 38 38 39 #include <CoreAudio/CoreAudioTypes.h> 40 39 41 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400) 40 42 #define CMSAMPLEBUFFERCALL_NOESCAPE CF_NOESCAPE … … 48 50 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferCopyDataBytes, OSStatus, (CMBlockBufferRef theSourceBuffer, size_t offsetToData, size_t dataLength, void* destination), (theSourceBuffer, offsetToData, dataLength, destination), PAL_EXPORT) 49 51 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferGetDataLength, size_t, (CMBlockBufferRef theBuffer), (theBuffer), PAL_EXPORT) 52 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferIsRangeContiguous, Boolean, (CMBlockBufferRef theBuffer, size_t offset, size_t length), (theBuffer, offset, length), PAL_EXPORT) 50 53 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferReplaceDataBytes, OSStatus, (const void* sourceBytes, CMBlockBufferRef destinationBuffer, size_t offsetIntoDestination, size_t dataLength), (sourceBytes, destinationBuffer, offsetIntoDestination, dataLength), PAL_EXPORT) 51 54 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMFormatDescriptionGetExtensions, CFDictionaryRef, (CMFormatDescriptionRef desc), (desc), PAL_EXPORT) … … 53 56 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferGetDataBuffer, CMBlockBufferRef, (CMSampleBufferRef sbuf), (sbuf), PAL_EXPORT) 54 57 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferGetFormatDescription, CMFormatDescriptionRef, (CMSampleBufferRef sbuf), (sbuf), PAL_EXPORT) 58 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferGetAudioStreamPacketDescriptions, OSStatus, (CMSampleBufferRef sbuf, size_t packetDescriptionsSize, AudioStreamPacketDescription* packetDescriptionsOut, size_t* packetDescriptionsSizeNeededOut), (sbuf, packetDescriptionsSize, packetDescriptionsOut, packetDescriptionsSizeNeededOut), PAL_EXPORT) 55 59 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferGetSampleTimingInfo, OSStatus, (CMSampleBufferRef sbuf, CMItemIndex sampleIndex, CMSampleTimingInfo* timingInfoOut), (sbuf, sampleIndex, timingInfoOut), PAL_EXPORT) 56 60 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferDataIsReady, Boolean, (CMSampleBufferRef sbuf), (sbuf), PAL_EXPORT) … … 109 113 110 114 #if PLATFORM(COCOA) 115 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferCreateContiguous, OSStatus, (CFAllocatorRef structureAllocator, CMBlockBufferRef sourceBuffer, CFAllocatorRef blockAllocator, const CMBlockBufferCustomBlockSource* customBlockSource, size_t offsetToData, size_t dataLength, CMBlockBufferFlags flags, CMBlockBufferRef* blockBufferOut), (structureAllocator, sourceBuffer, blockAllocator, customBlockSource, offsetToData, dataLength, flags, blockBufferOut), PAL_EXPORT) 111 116 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMFormatDescriptionGetMediaSubType, FourCharCode, (CMFormatDescriptionRef desc), (desc), PAL_EXPORT) 112 117 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMFormatDescriptionGetMediaType, CMMediaType, (CMFormatDescriptionRef desc), (desc), PAL_EXPORT) -
trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h
r279786 r280416 29 29 // FIXME: Should be USE(COREMEDIA), but this isn't currently defined on Windows. 30 30 31 #include <CoreAudio/CoreAudioTypes.h> 31 32 #include <pal/spi/cf/CoreMediaSPI.h> 32 33 #include <wtf/SoftLinking.h> … … 50 51 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMBlockBufferGetDataLength, size_t, (CMBlockBufferRef theBuffer), (theBuffer)) 51 52 #define CMBlockBufferGetDataLength softLink_CoreMedia_CMBlockBufferGetDataLength 53 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMBlockBufferIsRangeContiguous, Boolean, (CMBlockBufferRef theBuffer, size_t offset, size_t length), (theBuffer, offset, length)) 54 #define CMBlockBufferIsRangeContiguous softLink_CoreMedia_CMBlockBufferIsRangeContiguous 52 55 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMBlockBufferReplaceDataBytes, OSStatus, (const void* sourceBytes, CMBlockBufferRef destinationBuffer, size_t offsetIntoDestination, size_t dataLength), (sourceBytes, destinationBuffer, offsetIntoDestination, dataLength)) 53 56 #define CMBlockBufferReplaceDataBytes softLink_CoreMedia_CMBlockBufferReplaceDataBytes … … 60 63 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMSampleBufferGetFormatDescription, CMFormatDescriptionRef, (CMSampleBufferRef sbuf), (sbuf)) 61 64 #define CMSampleBufferGetFormatDescription softLink_CoreMedia_CMSampleBufferGetFormatDescription 65 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMSampleBufferGetAudioStreamPacketDescriptions, OSStatus, (CMSampleBufferRef sbuf, size_t packetDescriptionsSize, AudioStreamPacketDescription* packetDescriptionsOut, size_t* packetDescriptionsSizeNeededOut), (sbuf, packetDescriptionsSize, packetDescriptionsOut, packetDescriptionsSizeNeededOut)) 66 #define CMSampleBufferGetAudioStreamPacketDescriptions softLink_CoreMedia_CMSampleBufferGetAudioStreamPacketDescriptions 62 67 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMSampleBufferGetSampleTimingInfo, OSStatus, (CMSampleBufferRef sbuf, CMItemIndex sampleIndex, CMSampleTimingInfo* timingInfoOut), (sbuf, sampleIndex, timingInfoOut)) 63 68 #define CMSampleBufferGetSampleTimingInfo softLink_CoreMedia_CMSampleBufferGetSampleTimingInfo … … 169 174 #if PLATFORM(COCOA) 170 175 176 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMBlockBufferCreateContiguous, OSStatus, (CFAllocatorRef structureAllocator, CMBlockBufferRef sourceBuffer, CFAllocatorRef blockAllocator, const CMBlockBufferCustomBlockSource* customBlockSource, size_t offsetToData, size_t dataLength, CMBlockBufferFlags flags, CMBlockBufferRef* blockBufferOut), (structureAllocator, sourceBuffer, blockAllocator, customBlockSource, offsetToData, dataLength, flags, blockBufferOut)) 177 #define CMBlockBufferCreateContiguous softLink_CoreMedia_CMBlockBufferCreateContiguous 171 178 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMFormatDescriptionGetMediaSubType, FourCharCode, (CMFormatDescriptionRef desc), (desc)) 172 179 #define CMFormatDescriptionGetMediaSubType softLink_CoreMedia_CMFormatDescriptionGetMediaSubType -
trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h
r276828 r280416 325 325 #endif // HAVE(AVROUTEPICKERVIEW) 326 326 327 #if PLATFORM(COCOA) 328 SOFT_LINK_CLASS_FOR_HEADER(PAL, AVAudioConverter) 329 SOFT_LINK_CLASS_FOR_HEADER(PAL, AVAudioFormat) 330 SOFT_LINK_CLASS_FOR_HEADER(PAL, AVAudioCompressedBuffer) 331 SOFT_LINK_CLASS_FOR_HEADER(PAL, AVAudioPCMBuffer) 332 #endif // PLATFORM(COCOA) 333 327 334 #endif // USE(AVFOUNDATION) -
trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm
r276828 r280416 231 231 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetHTTPCookiesKey, NSString *, PAL_EXPORT) 232 232 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetRequiresCustomURLLoadingKey, NSString *, PAL_EXPORT) 233 #endif 233 #endif // PLATFORM(IOS_FAMILY) 234 234 235 235 #if PLATFORM(IOS_FAMILY) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) … … 245 245 #endif // HAVE(AVROUTEPICKERVIEW) 246 246 247 #if PLATFORM(COCOA) 248 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVAudioConverter, PAL_EXPORT) 249 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVAudioFormat, PAL_EXPORT) 250 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVAudioCompressedBuffer, PAL_EXPORT) 251 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVAudioPCMBuffer, PAL_EXPORT) 252 #endif 253 247 254 #endif // USE(AVFOUNDATION) -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r280415 r280416 233 233 07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */; }; 234 234 07F4E93320B3587F002E3803 /* AVAssetMIMETypeCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 07C8AD121D073D630087C5CE /* AVAssetMIMETypeCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; 235 07F5CFF52582A51D00662EF5 /* WebMAudioUtilitiesCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F5CFF42582A4F800662EF5 /* WebMAudioUtilitiesCocoa.h */; };235 07F5CFF52582A51D00662EF5 /* WebMAudioUtilitiesCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F5CFF42582A4F800662EF5 /* WebMAudioUtilitiesCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; }; 236 236 07F5CFF62582A52900662EF5 /* WebMAudioUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07F5CFF22582A4F800662EF5 /* WebMAudioUtilitiesCocoa.mm */; }; 237 237 07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r280330 r280416 1047 1047 } 1048 1048 1049 static inline bool webMWebAudioEnabled() 1050 { 1051 #if ENABLE(MEDIA_SOURCE) 1052 return RuntimeEnabledFeatures::sharedFeatures().webMWebAudioEnabled(); 1053 #else 1054 return false; 1055 #endif 1056 } 1057 1049 1058 String HTMLMediaElement::canPlayType(const String& mimeType) const 1050 1059 { … … 1060 1069 // so that sites relying on this test to determine if webaudio use of opus or vorbis won't error. 1061 1070 auto codecs = contentType.codecs(); 1062 if (support == MediaPlayer::SupportsType::IsSupported && ( codecs.contains("opus") || codecs.contains("vorbis")))1071 if (support == MediaPlayer::SupportsType::IsSupported && ((codecs.contains("opus") && !webMWebAudioEnabled()) || codecs.contains("vorbis"))) 1063 1072 support = MediaPlayer::SupportsType::IsNotSupported; 1064 1073 #endif -
trunk/Source/WebCore/page/RuntimeEnabledFeatures.h
r279974 r280416 236 236 void setWebMParserEnabled(bool isEnabled) { m_webMParserEnabled = isEnabled; } 237 237 bool webMParserEnabled() const { return m_webMParserEnabled; } 238 void setWebMWebAudioEnabled(bool isEnabled) { m_webMWebAudioEnabled = isEnabled; } 239 bool webMWebAudioEnabled() const { return m_webMWebAudioEnabled; } 238 240 #endif 239 241 … … 372 374 #if ENABLE(MEDIA_SOURCE) 373 375 bool m_webMParserEnabled { false }; 376 bool m_webMWebAudioEnabled { false }; 374 377 #endif 375 378 -
trunk/Source/WebCore/platform/MediaSample.h
r278253 r280416 58 58 }; 59 59 60 class WEBCORE_EXPORTMediaSample : public ThreadSafeRefCounted<MediaSample> {60 class MediaSample : public ThreadSafeRefCounted<MediaSample> { 61 61 public: 62 62 virtual ~MediaSample() = default; -
trunk/Source/WebCore/platform/audio/AudioBus.cpp
r278333 r280416 74 74 } 75 75 76 void AudioBus::setLength(size_t newLength) 77 { 78 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(newLength <= m_length); 79 if (newLength == m_length) 80 return; 81 for (unsigned i = 0; i < m_channels.size(); ++i) 82 m_channels[i]->setLength(newLength); 83 m_length = newLength; 84 } 85 76 86 void AudioBus::zero() 77 87 { -
trunk/Source/WebCore/platform/audio/AudioBus.h
r278333 r280416 84 84 size_t length() const { return m_length; } 85 85 86 // Reduce the number of frames available without changing the allocated memory size. 87 void setLength(size_t); 88 86 89 // Sample-rate : 0.0 if unknown or "don't care" 87 90 float sampleRate() const { return m_sampleRate; } -
trunk/Source/WebCore/platform/audio/AudioChannel.h
r278333 r280416 75 75 size_t length() const { return m_length; } 76 76 77 // Set new length. Can only be set to a value lower than the current length. 78 void setLength(size_t newLength) 79 { 80 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(newLength <= length()); 81 m_length = newLength; 82 } 83 77 84 // Direct access to PCM sample data. Non-const accessor clears silent flag. 78 85 float* mutableData() -
trunk/Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.cpp
r279335 r280416 35 35 #include "AudioBus.h" 36 36 #include "AudioFileReader.h" 37 #include "AudioSampleDataSource.h" 38 #include "AudioTrackPrivate.h" 37 39 #include "FloatConversion.h" 40 #include "InbandTextTrackPrivate.h" 38 41 #include "Logging.h" 42 #include "MediaSampleAVFObjC.h" 43 #include "VideoTrackPrivate.h" 44 #include "WebMAudioUtilitiesCocoa.h" 45 #include <AudioToolbox/AudioConverter.h> 39 46 #include <AudioToolbox/ExtendedAudioFile.h> 40 47 #include <CoreFoundation/CoreFoundation.h> 41 #include <pal/cf/AudioToolboxSoftLink.h> 48 #include <SourceBufferParserWebM.h> 49 #include <limits> 42 50 #include <wtf/CheckedArithmetic.h> 43 51 #include <wtf/FastMalloc.h> 52 #include <wtf/Function.h> 44 53 #include <wtf/RetainPtr.h> 54 #include <wtf/Scope.h> 55 #include <wtf/Vector.h> 56 #include <pal/cf/AudioToolboxSoftLink.h> 57 #include <pal/cf/CoreMediaSoftLink.h> 45 58 46 59 namespace WebCore { … … 48 61 static WARN_UNUSED_RETURN AudioBufferList* tryCreateAudioBufferList(size_t numberOfBuffers) 49 62 { 63 if (!numberOfBuffers) 64 return nullptr; 50 65 CheckedSize bufferListSize = sizeof(AudioBufferList) - sizeof(AudioBuffer); 51 bufferListSize += numberOfBuffers * sizeof(AudioBuffer);66 bufferListSize += WTF::checkedProduct<size_t>(numberOfBuffers, sizeof(AudioBuffer)); 52 67 if (bufferListSize.hasOverflowed()) 53 68 return nullptr; … … 88 103 } 89 104 105 // On stack RAII class that will free the allocated AudioBufferList* as needed. 106 class AudioBufferListHolder { 107 public: 108 explicit AudioBufferListHolder(size_t numberOfChannels) 109 : m_bufferList(tryCreateAudioBufferList(numberOfChannels)) 110 { 111 } 112 113 ~AudioBufferListHolder() 114 { 115 if (m_bufferList) 116 destroyAudioBufferList(m_bufferList); 117 } 118 119 explicit operator bool() const { return !!m_bufferList; } 120 AudioBufferList* operator->() const { return m_bufferList; } 121 operator AudioBufferList*() const { return m_bufferList; } 122 AudioBufferList& operator*() const { ASSERT(m_bufferList); return *m_bufferList; } 123 bool isValid() const { return validateAudioBufferList(m_bufferList); } 124 private: 125 AudioBufferList* m_bufferList; 126 }; 127 128 class AudioFileReaderWebMData { 129 WTF_MAKE_FAST_ALLOCATED; 130 131 public: 132 #if ENABLE(MEDIA_SOURCE) 133 SourceBufferParserWebM::InitializationSegment m_initSegment; 134 #endif 135 MediaTime m_duration; 136 Vector<Ref<MediaSampleAVFObjC>> m_samples; 137 }; 138 90 139 AudioFileReader::AudioFileReader(const void* data, size_t dataSize) 91 140 : m_data(data) 92 141 , m_dataSize(dataSize) 93 { 142 #if !RELEASE_LOG_DISABLED 143 , m_logger(Logger::create(this)) 144 , m_logIdentifier(LoggerHelper::uniqueLogIdentifier()) 145 #endif 146 { 147 #if ENABLE(MEDIA_SOURCE) 148 if (isMaybeWebM(static_cast<const uint8_t*>(data), dataSize)) { 149 m_webmData = demuxWebMData(static_cast<const uint8_t*>(data), dataSize); 150 if (m_webmData) 151 return; 152 } 153 #endif 94 154 if (PAL::AudioFileOpenWithCallbacks(this, readProc, 0, getSizeProc, 0, 0, &m_audioFileID) != noErr) 95 155 return; … … 111 171 m_audioFileID = 0; 112 172 } 173 174 #if ENABLE(MEDIA_SOURCE) 175 bool AudioFileReader::isMaybeWebM(const uint8_t* data, size_t dataSize) const 176 { 177 // From https://mimesniff.spec.whatwg.org/#signature-for-webm 178 return dataSize >= 4 && data[0] == 0x1A && data[1] == 0x45 && data[2] == 0xDF && data[3] == 0xA3; 179 } 180 181 std::unique_ptr<AudioFileReaderWebMData> AudioFileReader::demuxWebMData(const uint8_t* data, size_t dataSize) const 182 { 183 auto parser = adoptRef(new SourceBufferParserWebM()); 184 bool error = false; 185 std::optional<uint64_t> audioTrackId; 186 MediaTime duration; 187 SourceBufferParserWebM::InitializationSegment initSegment; 188 Vector<Ref<MediaSampleAVFObjC>> samples; 189 parser->setDidEncounterErrorDuringParsingCallback([&](uint64_t) { 190 error = true; 191 }); 192 parser->setDidParseInitializationDataCallback([&](SourceBufferParserWebM::InitializationSegment&& init) { 193 for (auto& audioTrack : init.audioTracks) { 194 if (audioTrack.track && audioTrack.track->trackUID()) { 195 duration = init.duration; 196 audioTrackId = audioTrack.track->trackUID(); 197 initSegment = WTFMove(init); 198 return; 199 } 200 } 201 }); 202 parser->setDidProvideMediaDataCallback([&](Ref<MediaSample>&& sample, uint64_t trackID, const String&) { 203 if (!audioTrackId || trackID != *audioTrackId) 204 return; 205 samples.append(static_reference_cast<MediaSampleAVFObjC>(WTFMove(sample))); 206 }); 207 parser->setCallOnClientThreadCallback([](auto&& function) { 208 function(); 209 }); 210 SourceBufferParser::Segment segment({ data, dataSize }); 211 parser->appendData(WTFMove(segment)); 212 if (!audioTrackId) 213 return nullptr; 214 parser->flushPendingAudioBuffers(); 215 return makeUnique<AudioFileReaderWebMData>(AudioFileReaderWebMData { WTFMove(initSegment), WTFMove(duration), WTFMove(samples) }); 216 } 217 218 struct PassthroughUserData { 219 UInt32 m_channels; 220 UInt32 m_dataSize; 221 const void* m_data; 222 UInt32 m_index; 223 Vector<AudioStreamPacketDescription>& m_packets; 224 }; 225 226 // Error value we pass through the decoder to signal that nothing 227 // has gone wrong during decoding and we're done processing the packet. 228 const uint32_t kNoMoreDataErr = 'MOAR'; 229 230 static OSStatus passthroughInputDataCallback(AudioConverterRef, UInt32* numDataPackets, AudioBufferList* data, AudioStreamPacketDescription** packetDesc, void* inUserData) 231 { 232 ASSERT(numDataPackets && data && inUserData); 233 if (!numDataPackets || !data || !inUserData) 234 return kAudioConverterErr_UnspecifiedError; 235 236 auto* userData = static_cast<PassthroughUserData*>(inUserData); 237 if (userData->m_index == userData->m_packets.size()) { 238 *numDataPackets = 0; 239 return kNoMoreDataErr; 240 } 241 242 if (packetDesc) { 243 if (userData->m_index >= userData->m_packets.size()) { 244 *numDataPackets = 0; 245 return kAudioConverterErr_RequiresPacketDescriptionsError; 246 } 247 *packetDesc = &userData->m_packets[userData->m_index]; 248 } 249 250 data->mBuffers[0].mNumberChannels = userData->m_channels; 251 data->mBuffers[0].mDataByteSize = userData->m_dataSize; 252 data->mBuffers[0].mData = const_cast<void*>(userData->m_data); 253 254 *numDataPackets = 1; 255 userData->m_index++; 256 257 return noErr; 258 } 259 260 Vector<AudioStreamPacketDescription> AudioFileReader::getPacketDescriptions(CMSampleBufferRef sampleBuffer) const 261 { 262 size_t packetDescriptionsSize; 263 if (PAL::CMSampleBufferGetAudioStreamPacketDescriptions(sampleBuffer, 0, nullptr, &packetDescriptionsSize) != noErr) { 264 RELEASE_LOG_FAULT(WebAudio, "Unable to get packet description list size"); 265 return { }; 266 } 267 size_t numDescriptions = packetDescriptionsSize / sizeof(AudioStreamPacketDescription); 268 if (!numDescriptions) { 269 RELEASE_LOG_FAULT(WebAudio, "No packet description found."); 270 return { }; 271 } 272 Vector<AudioStreamPacketDescription> descriptions(numDescriptions); 273 if (PAL::CMSampleBufferGetAudioStreamPacketDescriptions(sampleBuffer, packetDescriptionsSize, descriptions.data(), nullptr) != noErr) { 274 RELEASE_LOG_FAULT(WebAudio, "Unable to get packet description list"); 275 return { }; 276 } 277 auto numPackets = PAL::CMSampleBufferGetNumSamples(sampleBuffer); 278 if (numDescriptions != size_t(numPackets)) { 279 RELEASE_LOG_FAULT(WebAudio, "Unhandled CMSampleBuffer structure"); 280 return { }; 281 } 282 return descriptions; 283 } 284 285 std::optional<size_t> AudioFileReader::decodeWebMData(AudioBufferList& bufferList, size_t numberOfFrames, const AudioStreamBasicDescription& inFormat, const AudioStreamBasicDescription& outFormat) const 286 { 287 AudioConverterRef converter; 288 if (PAL::AudioConverterNew(&inFormat, &outFormat, &converter) != noErr) { 289 RELEASE_LOG_FAULT(WebAudio, "Unable to create decoder"); 290 return { }; 291 } 292 auto cleanup = makeScopeExit([&] { 293 PAL::AudioConverterDispose(converter); 294 }); 295 ASSERT(m_webmData && !m_webmData->m_samples.isEmpty() && m_webmData->m_samples[0]->sampleBuffer(), "Structure integrity was checked in numberOfFrames"); 296 auto formatDescription = PAL::CMSampleBufferGetFormatDescription(m_webmData->m_samples[0]->sampleBuffer()); 297 if (!formatDescription) { 298 RELEASE_LOG_FAULT(WebAudio, "Unable to retrieve format description from first sample"); 299 return { }; 300 } 301 size_t magicCookieSize = 0; 302 const void* magicCookie = PAL::CMAudioFormatDescriptionGetMagicCookie(formatDescription, &magicCookieSize); 303 if (magicCookie && magicCookieSize) 304 PAL::AudioConverterSetProperty(converter, kAudioConverterDecompressionMagicCookie, magicCookieSize, magicCookie); 305 306 AudioBufferListHolder decodedBufferList(inFormat.mChannelsPerFrame); 307 if (!decodedBufferList) { 308 RELEASE_LOG_FAULT(WebAudio, "Unable to create decoder"); 309 return { }; 310 } 311 312 size_t decodedFrames = 0; 313 OSStatus status; 314 for (auto& sample : m_webmData->m_samples) { 315 CMSampleBufferRef sampleBuffer = sample->sampleBuffer(); 316 auto buffer = PAL::CMSampleBufferGetDataBuffer(sampleBuffer); 317 ASSERT(PAL::CMBlockBufferIsRangeContiguous(buffer, 0, 0)); 318 if (!PAL::CMBlockBufferIsRangeContiguous(buffer, 0, 0)) { 319 RELEASE_LOG_FAULT(WebAudio, "Unable to read sample content (not contiguous)"); 320 return { }; 321 } 322 323 size_t srcSize = PAL::CMBlockBufferGetDataLength(buffer); 324 char* srcData = nullptr; 325 if (PAL::CMBlockBufferGetDataPointer(buffer, 0, nullptr, nullptr, &srcData) != noErr) { 326 RELEASE_LOG_FAULT(WebAudio, "Unable to retrieve data"); 327 return { }; 328 } 329 330 auto descriptions = getPacketDescriptions(sampleBuffer); 331 if (descriptions.isEmpty()) 332 return { }; 333 334 PassthroughUserData userData = { inFormat.mChannelsPerFrame, UInt32(srcSize), srcData, 0, descriptions }; 335 336 do { 337 if (numberOfFrames < decodedFrames) { 338 RELEASE_LOG_FAULT(WebAudio, "Decoded more frames than first calculated"); 339 return { }; 340 } 341 // in: the max number of packets we can handle from the decoder. 342 // out: the number of packets the decoder is actually returning. 343 UInt32 numFrames = std::min<uint32_t>(std::numeric_limits<int32_t>::max() / sizeof(float), numberOfFrames - decodedFrames); 344 345 for (UInt32 i = 0; i < inFormat.mChannelsPerFrame; i++) { 346 decodedBufferList->mBuffers[i].mNumberChannels = 1; 347 decodedBufferList->mBuffers[i].mDataByteSize = numFrames * sizeof(float); 348 decodedBufferList->mBuffers[i].mData = static_cast<float*>(bufferList.mBuffers[i].mData) + decodedFrames; 349 } 350 status = PAL::AudioConverterFillComplexBuffer(converter, passthroughInputDataCallback, &userData, &numFrames, decodedBufferList, nullptr); 351 if (status && status != kNoMoreDataErr) { 352 RELEASE_LOG_FAULT(WebAudio, "Error decoding data"); 353 return { }; 354 } 355 decodedFrames += numFrames; 356 } while (status != kNoMoreDataErr); 357 } 358 return decodedFrames; 359 } 360 #endif 113 361 114 362 OSStatus AudioFileReader::readProc(void* clientData, SInt64 position, UInt32 requestCount, void* buffer, UInt32* actualCount) … … 137 385 } 138 386 139 RefPtr<AudioBus> AudioFileReader::createBus(float sampleRate, bool mixToMono) 140 { 141 if (!m_extAudioFileRef) 142 return nullptr; 143 144 // Get file's data format 145 UInt32 size = sizeof(m_fileDataFormat); 146 if (PAL::ExtAudioFileGetProperty(m_extAudioFileRef, kExtAudioFileProperty_FileDataFormat, &size, &m_fileDataFormat) != noErr) 147 return nullptr; 148 149 size_t numberOfChannels = m_fileDataFormat.mChannelsPerFrame; 150 151 // Number of frames 152 SInt64 numberOfFrames64 = 0; 153 size = sizeof(numberOfFrames64); 154 if (PAL::ExtAudioFileGetProperty(m_extAudioFileRef, kExtAudioFileProperty_FileLengthFrames, &size, &numberOfFrames64) != noErr || numberOfFrames64 <= 0) 155 return nullptr; 156 157 double fileSampleRate = m_fileDataFormat.mSampleRate; 158 387 ssize_t AudioFileReader::numberOfFrames() const 388 { 389 SInt64 numberOfFramesIn64 = 0; 390 391 if (!m_webmData) { 392 if (!m_extAudioFileRef) 393 return -1; 394 395 UInt32 size = sizeof(numberOfFramesIn64); 396 if (PAL::ExtAudioFileGetProperty(m_extAudioFileRef, kExtAudioFileProperty_FileLengthFrames, &size, &numberOfFramesIn64) != noErr || numberOfFramesIn64 <= 0) { 397 RELEASE_LOG_FAULT(WebAudio, "Unable to retrieve number of frames in content (unsupported?"); 398 return -1; 399 } 400 401 return numberOfFramesIn64; 402 } 403 #if ENABLE(MEDIA_SOURCE) 404 if (m_webmData->m_samples.isEmpty()) { 405 RELEASE_LOG_FAULT(WebAudio, "No sample demuxed from webm container"); 406 return -1; 407 } 408 409 // Calculate the total number of decoded samples that were demuxed. 410 // This code only handle the CMSampleBuffer as generated by the SourceBufferParserWebM 411 // where a AudioStreamPacketDescriptions array is always provided even with 412 // Constant bitrate and constant frames-per-packet audio. 413 for (auto& sample : m_webmData->m_samples) { 414 auto sampleBuffer = sample->sampleBuffer(); 415 if (!sampleBuffer) { 416 RELEASE_LOG_FAULT(WebAudio, "Impossible memory corruption encountered"); 417 return -1; 418 } 419 const auto formatDescription = PAL::CMSampleBufferGetFormatDescription(sampleBuffer); 420 if (!formatDescription) { 421 RELEASE_LOG_FAULT(WebAudio, "Unable to retrieve format descriptiong from sample"); 422 return -1; 423 } 424 const AudioStreamBasicDescription* const asbd = PAL::CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription); 425 if (!asbd) { 426 RELEASE_LOG_FAULT(WebAudio, "Unable to retrieve asbd from format description"); 427 return -1; 428 } 429 430 auto descriptions = getPacketDescriptions(sampleBuffer); 431 if (descriptions.isEmpty()) 432 return -1; 433 434 for (const auto& description : descriptions) { 435 uint32_t fpp = description.mVariableFramesInPacket ? description.mVariableFramesInPacket : asbd->mFramesPerPacket; 436 numberOfFramesIn64 += fpp; 437 } 438 } 439 return numberOfFramesIn64; 440 #else 441 return 0; 442 #endif 443 } 444 445 std::optional<AudioStreamBasicDescription> AudioFileReader::fileDataFormat() const 446 { 447 if (!m_webmData) { 448 AudioStreamBasicDescription format; 449 UInt32 size = sizeof(format); 450 if (PAL::ExtAudioFileGetProperty(m_extAudioFileRef, kExtAudioFileProperty_FileDataFormat, &size, &format) != noErr) 451 return { }; 452 return format; 453 } 454 455 if (m_webmData->m_samples.isEmpty()) 456 return { }; 457 458 CMFormatDescriptionRef formatDescription = PAL::CMSampleBufferGetFormatDescription(m_webmData->m_samples[0]->sampleBuffer()); 459 if (!formatDescription) 460 return { }; 461 462 const AudioStreamBasicDescription* const asbd = PAL::CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription); 463 return *asbd; 464 } 465 466 AudioStreamBasicDescription AudioFileReader::clientDataFormat(const AudioStreamBasicDescription& inFormat, float sampleRate) const 467 { 159 468 // Make client format same number of channels as file format, but tweak a few things. 160 469 // Client format will be linear PCM (canonical), and potentially change sample-rate. 161 m_clientDataFormat = m_fileDataFormat;470 AudioStreamBasicDescription outFormat = inFormat; 162 471 163 472 const int bytesPerFloat = sizeof(Float32); 164 473 const int bitsPerByte = 8; 165 m_clientDataFormat.mFormatID = kAudioFormatLinearPCM; 166 m_clientDataFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved; 167 m_clientDataFormat.mBytesPerPacket = bytesPerFloat; 168 m_clientDataFormat.mFramesPerPacket = 1; 169 m_clientDataFormat.mBytesPerFrame = bytesPerFloat; 170 m_clientDataFormat.mChannelsPerFrame = numberOfChannels; 171 m_clientDataFormat.mBitsPerChannel = bitsPerByte * bytesPerFloat; 474 outFormat.mFormatID = kAudioFormatLinearPCM; 475 outFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved; 476 outFormat.mBytesPerPacket = outFormat.mBytesPerFrame = bytesPerFloat; 477 outFormat.mFramesPerPacket = 1; 478 outFormat.mBitsPerChannel = bitsPerByte * bytesPerFloat; 172 479 173 480 if (sampleRate) 174 m_clientDataFormat.mSampleRate = sampleRate; 175 176 if (PAL::ExtAudioFileSetProperty(m_extAudioFileRef, kExtAudioFileProperty_ClientDataFormat, sizeof(AudioStreamBasicDescription), &m_clientDataFormat) != noErr) 177 return nullptr; 178 179 // Change numberOfFrames64 to destination sample-rate 180 numberOfFrames64 = numberOfFrames64 * (m_clientDataFormat.mSampleRate / fileSampleRate); 181 size_t numberOfFrames = static_cast<size_t>(numberOfFrames64); 182 481 outFormat.mSampleRate = sampleRate; 482 483 return outFormat; 484 } 485 486 RefPtr<AudioBus> AudioFileReader::createBus(float sampleRate, bool mixToMono) 487 { 488 SInt64 numberOfFramesIn64 = numberOfFrames(); 489 if (numberOfFramesIn64 <= 0) 490 return nullptr; 491 492 auto inFormat = fileDataFormat(); 493 if (!inFormat) 494 return nullptr; 495 496 AudioStreamBasicDescription outFormat = clientDataFormat(*inFormat, sampleRate); 497 size_t numberOfChannels = inFormat->mChannelsPerFrame; 498 double fileSampleRate = inFormat->mSampleRate; 499 SInt64 numberOfFramesOut64 = numberOfFramesIn64 * (outFormat.mSampleRate / fileSampleRate); 500 size_t numberOfFrames = static_cast<size_t>(numberOfFramesOut64); 183 501 size_t busChannelCount = mixToMono ? 1 : numberOfChannels; 184 502 185 503 // Create AudioBus where we'll put the PCM audio data 186 504 auto audioBus = AudioBus::create(busChannelCount, numberOfFrames); 187 audioBus->setSampleRate(narrowPrecisionToFloat(m_clientDataFormat.mSampleRate)); // save for later 505 audioBus->setSampleRate(narrowPrecisionToFloat(outFormat.mSampleRate)); // save for later 506 507 AudioBufferListHolder bufferList(numberOfChannels); 508 if (!bufferList) { 509 RELEASE_LOG_FAULT(WebAudio, "tryCreateAudioBufferList(%ld) returned null", numberOfChannels); 510 return nullptr; 511 } 512 const size_t bufferSize = numberOfFrames * sizeof(float); 188 513 189 514 // Only allocated in the mixToMono case; deallocated on destruction. 190 515 AudioFloatArray leftChannel; 191 516 AudioFloatArray rightChannel; 192 193 AudioBufferList* bufferList = tryCreateAudioBufferList(numberOfChannels);194 if (!bufferList) {195 RELEASE_LOG_FAULT(WebAudio, "tryCreateAudioBufferList(%ld) returned null", numberOfChannels);196 return nullptr;197 }198 const size_t bufferSize = numberOfFrames * sizeof(float);199 517 200 518 RELEASE_ASSERT(bufferList->mNumberBuffers == numberOfChannels); … … 223 541 } 224 542 225 if (! validateAudioBufferList(bufferList)) {543 if (!bufferList.isValid()) { 226 544 RELEASE_LOG_FAULT(WebAudio, "Generated buffer in AudioFileReader::createBus() did not pass validation"); 227 545 ASSERT_NOT_REACHED(); 228 destroyAudioBufferList(bufferList); 229 return nullptr; 230 } 231 232 // Read from the file (or in-memory version) 233 UInt32 framesToRead = numberOfFrames; 234 if (PAL::ExtAudioFileRead(m_extAudioFileRef, &framesToRead, bufferList) != noErr) { 235 destroyAudioBufferList(bufferList); 236 return nullptr; 546 return nullptr; 547 } 548 549 if (m_webmData) { 550 #if ENABLE(MEDIA_SOURCE) 551 auto decodedFrames = decodeWebMData(*bufferList, numberOfFrames, *inFormat, outFormat); 552 if (!decodedFrames) 553 return nullptr; 554 // The actual decoded number of frames may not match the number of frames calculated 555 // while demuxing as frames can be trimmed. It will always be lower. 556 audioBus->setLength(*decodedFrames); 557 numberOfFrames = *decodedFrames; 558 #endif 559 } else { 560 if (PAL::ExtAudioFileSetProperty(m_extAudioFileRef, kExtAudioFileProperty_ClientDataFormat, sizeof(AudioStreamBasicDescription), &outFormat) != noErr) 561 return nullptr; 562 563 // Read from the file (or in-memory version) 564 UInt32 framesToRead = numberOfFrames; 565 if (PAL::ExtAudioFileRead(m_extAudioFileRef, &framesToRead, bufferList) != noErr) 566 return nullptr; 237 567 } 238 568 … … 244 574 } 245 575 246 // Cleanup247 destroyAudioBufferList(bufferList);248 249 576 return audioBus; 250 577 } … … 256 583 } 257 584 585 #if !RELEASE_LOG_DISABLED 586 WTFLogChannel& AudioFileReader::logChannel() const 587 { 588 return LogMedia; 589 } 590 #endif 591 258 592 } // WebCore 259 593 -
trunk/Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.h
r279335 r280416 33 33 34 34 #include <CoreAudio/CoreAudioTypes.h> 35 #include <optional> 36 #include <wtf/LoggerHelper.h> 35 37 #include <wtf/RefPtr.h> 36 38 37 39 using ExtAudioFileRef = struct OpaqueExtAudioFile*; 38 40 using AudioFileID = struct OpaqueAudioFileID*; 41 typedef struct opaqueCMSampleBuffer* CMSampleBufferRef; 39 42 40 43 namespace WebCore { 41 44 42 45 class AudioBus; 46 class SourceBufferParserWebM; 47 class AudioFileReaderWebMData; 43 48 44 49 // Wrapper class for AudioFile and ExtAudioFile CoreAudio APIs for reading files and in-memory versions of them... 45 50 46 class AudioFileReader { 51 class AudioFileReader 52 #if !RELEASE_LOG_DISABLED 53 : public LoggerHelper 54 #endif 55 { 47 56 public: 48 explicitAudioFileReader(const void* data, size_t dataSize);57 AudioFileReader(const void* data, size_t dataSize); 49 58 ~AudioFileReader(); 50 59 … … 54 63 size_t dataSize() const { return m_dataSize; } 55 64 65 #if !RELEASE_LOG_DISABLED 66 const Logger& logger() const final { return m_logger.get(); } 67 const void* logIdentifier() const final { return m_logIdentifier; } 68 WTFLogChannel& logChannel() const final; 69 const char* logClassName() const final { return "AudioFileReaderCocoa"; } 70 #endif 71 56 72 private: 73 #if ENABLE(MEDIA_SOURCE) 74 bool isMaybeWebM(const uint8_t* data, size_t dataSize) const; 75 std::unique_ptr<AudioFileReaderWebMData> demuxWebMData(const uint8_t* data, size_t dataSize) const; 76 Vector<AudioStreamPacketDescription> getPacketDescriptions(CMSampleBufferRef) const; 77 std::optional<size_t> decodeWebMData(AudioBufferList&, size_t numberOfFrames, const AudioStreamBasicDescription& inFormat, const AudioStreamBasicDescription& outFormat) const; 78 #endif 57 79 static OSStatus readProc(void* clientData, SInt64 position, UInt32 requestCount, void* buffer, UInt32* actualCount); 58 80 static SInt64 getSizeProc(void* clientData); 81 ssize_t numberOfFrames() const; 82 std::optional<AudioStreamBasicDescription> fileDataFormat() const; 83 AudioStreamBasicDescription clientDataFormat(const AudioStreamBasicDescription& inFormat, float sampleRate) const; 59 84 60 85 const void* m_data = { nullptr }; … … 64 89 ExtAudioFileRef m_extAudioFileRef = { nullptr }; 65 90 66 AudioStreamBasicDescription m_fileDataFormat; 67 AudioStreamBasicDescription m_clientDataFormat; 91 std::unique_ptr<AudioFileReaderWebMData> m_webmData; 92 93 #if !RELEASE_LOG_DISABLED 94 const Ref<Logger> m_logger; 95 const void* m_logIdentifier; 96 #endif 97 68 98 }; 69 99 -
trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h
r278453 r280416 34 34 #include <wtf/text/WTFString.h> 35 35 36 typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;37 36 typedef struct opaqueCMSampleBuffer *CMSampleBufferRef; 38 37 -
trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm
r279335 r280416 40 40 #import <wtf/StringPrintStream.h> 41 41 42 #import <pal/cf/AudioToolboxSoftLink.h> 42 43 #import <pal/cf/CoreMediaSoftLink.h> 43 44 … … 68 69 { 69 70 if (m_converter) 70 AudioConverterDispose(m_converter);71 PAL::AudioConverterDispose(m_converter); 71 72 } 72 73 … … 76 77 77 78 if (m_converter) { 78 AudioConverterDispose(m_converter);79 PAL::AudioConverterDispose(m_converter); 79 80 m_converter = nullptr; 80 81 } … … 83 84 return 0; 84 85 85 OSStatus err = AudioConverterNew(&m_inputDescription->streamDescription(), &m_outputDescription->streamDescription(), &m_converter);86 OSStatus err = PAL::AudioConverterNew(&m_inputDescription->streamDescription(), &m_outputDescription->streamDescription(), &m_converter); 86 87 if (err) { 87 88 RunLoop::main().dispatch([this, protectedThis = makeRefPtr(*this), err] { -
trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.mm
r279480 r280416 29 29 #if ENABLE(GAMEPAD) && PLATFORM(MAC) 30 30 31 #import "GameControllerGamepadProvider.h" 31 32 #import "GamepadProviderClient.h" 32 33 #import "Logging.h" -
trunk/Source/WebCore/platform/graphics/TrackPrivateBase.cpp
r278253 r280416 30 30 31 31 #include "Logging.h" 32 #include <wtf/LoggerHelper.h>33 32 34 33 namespace WebCore { -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h
r278253 r280416 35 35 class PixelBuffer; 36 36 37 class WEBCORE_EXPORTMediaSampleAVFObjC : public MediaSample {37 class MediaSampleAVFObjC : public MediaSample { 38 38 public: 39 39 static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, uint64_t trackID) { return adoptRef(*new MediaSampleAVFObjC(sample, trackID)); } … … 45 45 static RetainPtr<CMSampleBufferRef> cloneSampleBufferAndSetAsDisplayImmediately(CMSampleBufferRef); 46 46 47 RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const override;47 WEBCORE_EXPORT RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const override; 48 48 49 49 MediaTime presentationTime() const override; … … 60 60 PlatformSample platformSample() override; 61 61 std::optional<ByteRange> byteRange() const override; 62 void dump(PrintStream&) const override;62 WEBCORE_EXPORT void dump(PrintStream&) const override; 63 63 void offsetTimestampsBy(const MediaTime&) override; 64 64 void setTimestamps(const MediaTime&, const MediaTime&) override; 65 bool isDivisable() const override;66 std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime, UseEndTime) override;67 Ref<MediaSample> createNonDisplayingCopy() const override;65 WEBCORE_EXPORT bool isDivisable() const override; 66 WEBCORE_EXPORT std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime, UseEndTime) override; 67 WEBCORE_EXPORT Ref<MediaSample> createNonDisplayingCopy() const override; 68 68 69 69 VideoRotation videoRotation() const override { return m_rotation; } 70 70 bool videoMirrored() const override { return m_mirrored; } 71 uint32_t videoPixelFormat() const final;71 WEBCORE_EXPORT uint32_t videoPixelFormat() const final; 72 72 73 73 CMSampleBufferRef sampleBuffer() const { return m_sample.get(); } … … 79 79 80 80 protected: 81 MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&& sample) 82 : m_sample(WTFMove(sample)) 83 { 84 } 85 MediaSampleAVFObjC(CMSampleBufferRef sample) 86 : m_sample(sample) 87 { 88 } 89 MediaSampleAVFObjC(CMSampleBufferRef sample, AtomString trackID) 90 : m_sample(sample) 91 , m_id(trackID) 92 { 93 } 94 MediaSampleAVFObjC(CMSampleBufferRef sample, uint64_t trackID) 95 : m_sample(sample) 96 , m_id(AtomString::number(trackID)) 97 { 98 } 99 MediaSampleAVFObjC(CMSampleBufferRef sample, VideoRotation rotation, bool mirrored) 100 : m_sample(sample) 101 , m_rotation(rotation) 102 , m_mirrored(mirrored) 103 { 104 } 81 WEBCORE_EXPORT MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&&); 82 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef); 83 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, AtomString trackID); 84 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, uint64_t trackID); 85 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, VideoRotation, bool mirrored); 86 WEBCORE_EXPORT virtual ~MediaSampleAVFObjC(); 105 87 106 88 std::optional<MediaSample::ByteRange> byteRangeForAttachment(CFStringRef key) const; 107 89 108 virtual ~MediaSampleAVFObjC() = default;109 90 RetainPtr<CMSampleBufferRef> m_sample; 110 91 AtomString m_id; … … 114 95 115 96 } // namespace WebCore 116 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm
r279335 r280416 46 46 namespace WebCore { 47 47 48 MediaSampleAVFObjC::MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&& sample) 49 : m_sample(WTFMove(sample)) 50 { 51 } 52 MediaSampleAVFObjC::MediaSampleAVFObjC(CMSampleBufferRef sample) 53 : m_sample(sample) 54 { 55 } 56 MediaSampleAVFObjC::MediaSampleAVFObjC(CMSampleBufferRef sample, AtomString trackID) 57 : m_sample(sample) 58 , m_id(trackID) 59 { 60 } 61 MediaSampleAVFObjC::MediaSampleAVFObjC(CMSampleBufferRef sample, uint64_t trackID) 62 : m_sample(sample) 63 , m_id(AtomString::number(trackID)) 64 { 65 } 66 MediaSampleAVFObjC::MediaSampleAVFObjC(CMSampleBufferRef sample, VideoRotation rotation, bool mirrored) 67 : m_sample(sample) 68 , m_rotation(rotation) 69 , m_mirrored(mirrored) 70 { 71 } 72 73 MediaSampleAVFObjC::~MediaSampleAVFObjC() = default; 74 48 75 RefPtr<MediaSampleAVFObjC> MediaSampleAVFObjC::createImageSample(PixelBuffer&& pixelBuffer) 49 76 { -
trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm
r279335 r280416 32 32 #import <CoreMedia/CMFormatDescription.h> 33 33 #import <pal/avfoundation/MediaTimeAVFoundation.h> 34 #import <pal/cf/CoreMediaSoftLink.h>35 34 #import <wtf/MainThread.h> 36 35 #import <wtf/MediaTime.h> 37 36 #import <wtf/MonotonicTime.h> 37 #import <wtf/RunLoop.h> 38 38 #import <wtf/StringPrintStream.h> 39 39 #import <wtf/Vector.h> … … 43 43 #import "CoreVideoSoftLink.h" 44 44 #import "VideoToolboxSoftLink.h" 45 #import <pal/cf/CoreMediaSoftLink.h> 45 46 46 47 // Equivalent to WTF_DECLARE_CF_TYPE_TRAIT(CMSampleBuffer); -
trunk/Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h
r274902 r280416 35 35 namespace WebCore { 36 36 37 bool isVorbisDecoderAvailable(); 37 WEBCORE_EXPORT bool isVorbisDecoderAvailable(); 38 WEBCORE_EXPORT bool registerVorbisDecoderIfNeeded(); 38 39 RetainPtr<CMFormatDescriptionRef> createVorbisAudioFormatDescription(size_t, const void*); 39 40 … … 53 54 }; 54 55 55 bool isOpusDecoderAvailable(); 56 WEBCORE_EXPORT bool isOpusDecoderAvailable(); 57 WEBCORE_EXPORT bool registerOpusDecoderIfNeeded(); 56 58 bool parseOpusPrivateData(size_t privateDataSize, const void* privateData, size_t frameDataSize, const void* frameData, OpusCookieContents&); 57 59 RetainPtr<CMFormatDescriptionRef> createOpusAudioFormatDescription(const OpusCookieContents&); -
trunk/Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm
r274902 r280416 33 33 #import "MediaUtilities.h" 34 34 #import "PlatformMediaSessionManager.h" 35 #import <AudioToolbox/AudioCodec.h> 35 36 #import <AudioToolbox/AudioComponent.h> 36 37 #import <AudioToolbox/AudioFormat.h> … … 39 40 #import <wtf/FlipBytes.h> 40 41 #import <wtf/Seconds.h> 41 42 42 #if ENABLE(OPUS) 43 43 #import <libwebrtc/opus_defines.h> 44 44 #endif 45 #import <pal/cf/AudioToolboxSoftLink.h> 45 46 46 47 namespace WebCore { … … 49 50 static bool registerDecoderFactory(const char* decoderName, OSType decoderType) 50 51 { 52 AudioComponentDescription desc { kAudioDecoderComponentType, decoderType, 'appl', kAudioComponentFlag_SandboxSafe, 0 }; 53 AudioComponent comp = PAL::AudioComponentFindNext(0, &desc); 54 if (comp) 55 return true; // Already registered. 56 51 57 constexpr char audioComponentsDylib[] = "/System/Library/Components/AudioCodecs.component/Contents/MacOS/AudioCodecs"; 52 58 void *handle = dlopen(audioComponentsDylib, RTLD_LAZY | RTLD_LOCAL); … … 58 64 return false; 59 65 60 AudioComponentDescription desc { 'adec', decoderType, 'appl', kAudioComponentFlag_SandboxSafe, 0 };61 66 if (!AudioComponentRegister(&desc, CFSTR(""), 0, decoderFactory)) { 62 67 dlclose(handle); … … 72 77 asbd.mFormatID = formatID; 73 78 uint32_t size = sizeof(asbd); 74 auto error = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, magicCookie.size(), magicCookie.data(), &size, &asbd);79 auto error = PAL::AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, magicCookie.size(), magicCookie.data(), &size, &asbd); 75 80 if (error) { 76 81 RELEASE_LOG_ERROR(Media, "createAudioFormatDescriptionForFormat failed with error %d (%.4s)", error, (char *)&error); … … 327 332 bool isOpusDecoderAvailable() 328 333 { 329 static bool available;330 331 334 #if ENABLE(OPUS) && PLATFORM(MAC) 332 335 if (!PlatformMediaSessionManager::opusDecoderEnabled()) 333 336 return false; 334 337 338 return registerOpusDecoderIfNeeded(); 339 #else 340 return false; 341 #endif 342 } 343 344 bool registerOpusDecoderIfNeeded() 345 { 346 #if ENABLE(OPUS) && PLATFORM(MAC) 347 static bool available; 348 335 349 static dispatch_once_t onceToken; 336 350 dispatch_once(&onceToken, ^{ 337 available = registerDecoderFactory("ACOpusDecoderFactory", 'opus');351 available = registerDecoderFactory("ACOpusDecoderFactory", kAudioFormatOpus); 338 352 }); 339 #endif340 353 341 354 return available; 355 #else 356 return false; 357 #endif 342 358 } 343 359 … … 419 435 bool isVorbisDecoderAvailable() 420 436 { 421 static bool available;422 423 437 #if ENABLE(VORBIS) && PLATFORM(MAC) 424 438 if (!PlatformMediaSessionManager::vorbisDecoderEnabled()) 425 439 return false; 440 441 return registerVorbisDecoderIfNeeded(); 442 #else 443 return false; 444 #endif 445 } 446 447 bool registerVorbisDecoderIfNeeded() 448 { 449 #if ENABLE(VORBIS) && PLATFORM(MAC) 450 static bool available; 426 451 427 452 static dispatch_once_t onceToken; … … 429 454 available = registerDecoderFactory("ACVorbisDecoderFactory", 'vorb'); 430 455 }); 431 #endif432 456 433 457 return available; 458 #else 459 return false; 460 #endif 434 461 } 435 462 -
trunk/Source/WebKit/ChangeLog
r280401 r280416 1 2021-07-28 Jean-Yves Avenard <jya@apple.com> 2 3 [WebAudio] Add webm/opus container support 4 https://bugs.webkit.org/show_bug.cgi?id=227110 5 <rdar://problem/79437067> 6 7 Reviewed by Jer Noble. 8 9 Add default value for webm_webaudio feature flag for the different platforms. 10 Disabled by default on all platforms. 11 Fly-by fix: don't make webm parser dependent on VP9 support. 12 13 * FeatureFlags/WebKit-appletvos.plist: 14 * FeatureFlags/WebKit-ios.plist: 15 * FeatureFlags/WebKit-macos.plist: 16 * FeatureFlags/WebKit-watchos.plist: 17 * GPUProcess/GPUProcess.h: 18 * GPUProcess/GPUProcess.messages.in: 19 * Shared/WebPreferencesDefaultValues.cpp: 20 (WebKit::defaultWebMWebAudioEnabled): 21 * Shared/WebPreferencesDefaultValues.h: 22 * UIProcess/Cocoa/WebProcessProxyCocoa.mm: 23 (WebKit::WebProcessProxy::sendAudioComponentRegistrations): 24 1 25 2021-07-28 Myles C. Maxfield <mmaxfield@apple.com> 2 26 -
trunk/Source/WebKit/FeatureFlags/WebKit-appletvos.plist
r275239 r280416 88 88 <true/> 89 89 </dict> 90 <key>webm_webaudio</key> 91 <dict> 92 <key>Enabled</key> 93 <true/> 94 </dict> 90 95 <key>RB_full_manage_WK_jetsam</key> 91 96 <dict> -
trunk/Source/WebKit/FeatureFlags/WebKit-ios.plist
r275239 r280416 88 88 <true/> 89 89 </dict> 90 <key>webm_webaudio</key> 91 <dict> 92 <key>Enabled</key> 93 <true/> 94 </dict> 90 95 <key>RB_full_manage_WK_jetsam</key> 91 96 <dict> -
trunk/Source/WebKit/FeatureFlags/WebKit-macos.plist
r275239 r280416 88 88 <true/> 89 89 </dict> 90 <key>webm_webaudio</key> 91 <dict> 92 <key>Enabled</key> 93 <true/> 94 </dict> 90 95 <key>RB_full_manage_WK_jetsam</key> 91 96 <dict> -
trunk/Source/WebKit/FeatureFlags/WebKit-watchos.plist
r275239 r280416 88 88 <true/> 89 89 </dict> 90 <key>webm_webaudio</key> 91 <dict> 92 <key>Enabled</key> 93 <true/> 94 </dict> 90 95 <key>RB_full_manage_WK_jetsam</key> 91 96 <dict> -
trunk/Source/WebKit/GPUProcess/GPUProcess.cpp
r279926 r280416 452 452 #endif 453 453 454 #if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)454 #if ENABLE(MEDIA_SOURCE) 455 455 void GPUProcess::setWebMParserEnabled(bool enabled) 456 456 { -
trunk/Source/WebKit/GPUProcess/GPUProcess.h
r279926 r280416 142 142 #endif 143 143 144 #if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)144 #if ENABLE(MEDIA_SOURCE) 145 145 void setWebMParserEnabled(bool); 146 146 #endif … … 195 195 bool m_enableVP9SWDecoder { false }; 196 196 #endif 197 #if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)197 #if ENABLE(MEDIA_SOURCE) 198 198 bool m_webMParserEnabled { false }; 199 199 #endif -
trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in
r279912 r280416 52 52 #endif 53 53 54 #if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)54 #if ENABLE(MEDIA_SOURCE) 55 55 SetWebMParserEnabled(bool enabled); 56 56 #endif -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp
r280327 r280416 333 333 } 334 334 335 bool defaultWebMWebAudioEnabled() 336 { 337 #if HAVE(SYSTEM_FEATURE_FLAGS) 338 return isFeatureFlagEnabled("webm_webaudio"); 339 #endif 340 341 return false; 342 } 343 335 344 #endif // ENABLE(MEDIA_SOURCE) 336 345 -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h
r280327 r280416 112 112 #if ENABLE(MEDIA_SOURCE) 113 113 bool defaultWebMParserEnabled(); 114 bool defaultWebMWebAudioEnabled(); 114 115 #endif 115 116 -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm
r280258 r280416 39 39 #import "WebProcessPool.h" 40 40 #import <WebCore/RuntimeApplicationChecks.h> 41 #import <WebCore/WebMAudioUtilitiesCocoa.h> 41 42 #import <sys/sysctl.h> 42 43 #import <wtf/NeverDestroyed.h> … … 296 297 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [protectedThis = makeRef(*this)] () mutable { 297 298 CFDataRef registrations { nullptr }; 299 300 WebCore::registerOpusDecoderIfNeeded(); 301 WebCore::registerVorbisDecoderIfNeeded(); 298 302 if (noErr != AudioComponentFetchServerRegistrations(®istrations) || !registrations) 299 303 return; -
trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h
r279974 r280416 88 88 #if ENABLE(MEDIA_SOURCE) 89 89 bool defaultWebMParserEnabled(); 90 bool defaultWebMWebAudioEnabled(); 90 91 #endif 91 92 -
trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm
r279974 r280416 299 299 } 300 300 301 bool defaultWebMWebAudioEnabled() 302 { 303 #if HAVE(SYSTEM_FEATURE_FLAGS) 304 return isFeatureFlagEnabled("webm_webaudio"); 305 #endif 306 307 return false; 308 } 309 301 310 #endif // ENABLE(MEDIA_SOURCE) 302 311
Note: See TracChangeset
for help on using the changeset viewer.