Skip to content

Commit ffc83d5

Browse files
committed
Implement audio decoding supports to MediaSamplesDecoder
https://bugs.webkit.org/show_bug.cgi?id=327758 rdar://190173646 Reviewed by NOBODY (OOPS!). MediaSamplesDecoder was a skeleton whose methods were placeholders. It now decodes audio in the content process by wrapping AudioDecoder, for every codec AudioDecoder accepts: Opus, Vorbis, FLAC, MP3, AAC (LC, HE, HE v2), A-law, u-law and PCM. The decoded output is one MediaSamplesBlock of interleaved 32-bit float samples per call, backed by shared memory when UseSharedMemory is set. The AAC cookie of a track built from a format description is an ES_Descriptor, which is unwrapped to the AudioSpecificConfig AudioDecoder expects. Encrypted tracks, and blocks holding encrypted samples, are rejected. Only Cocoa is supported for now; other platforms and video report that they cannot decode. MediaSamplesBlock gains isolatedCopy() as NativePromise copies its resolve value across threads. * Source/WebCore/platform/MediaSamplesBlock.h: (WebCore::MediaSamplesBlock::isolatedCopy): * Source/WebCore/platform/MediaSamplesDecoder.cpp: (WebCore::nextDescriptor): Added. (WebCore::audioSpecificConfigFromESDescriptor): Added. (WebCore::audioDecoderConfiguration): Added. (WebCore::MediaSamplesDecoder::MediaSamplesDecoder): (WebCore::MediaSamplesDecoder::~MediaSamplesDecoder): (WebCore::MediaSamplesDecoder::canDecode): (WebCore::MediaSamplesDecoder::create): (WebCore::MediaSamplesDecoder::canContinueWith): (WebCore::MediaSamplesDecoder::decode): (WebCore::MediaSamplesDecoder::drain): (WebCore::MediaSamplesDecoder::flush): (WebCore::MediaSamplesDecoder::decodeOnQueue): Added. (WebCore::MediaSamplesDecoder::drainOnQueue): Added. (WebCore::MediaSamplesDecoder::flushOnQueue): Added. (WebCore::MediaSamplesDecoder::finishFlush): Added. (WebCore::MediaSamplesDecoder::settleWithPendingOutput): Added. (WebCore::MediaSamplesDecoder::setAudioDecoder): Added. (WebCore::MediaSamplesDecoder::didFailDecoding): Added. (WebCore::MediaSamplesDecoder::didDecodeAudio): Added. * Source/WebCore/platform/MediaSamplesDecoder.h: * Tools/TestWebKitAPI/PlatformCocoa.cmake: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WebCore/cocoa/MediaSamplesDecoderTests.mm: Added.
1 parent 5a73a28 commit ffc83d5

6 files changed

Lines changed: 860 additions & 27 deletions

File tree

‎Source/WebCore/platform/MediaSamplesBlock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class MediaSamplesBlock {
9191
bool isEmpty() const { return m_samples.isEmpty(); }
9292
void clear() { m_samples.clear(); }
9393
SamplesVector takeSamples() { return std::exchange(m_samples, { }); }
94+
MediaSamplesBlock isolatedCopy() && { return WTF::move(*this); }
9495

9596
// Indicate that this MediaSampleBlock follows a discontinuity from the previous block.
9697
std::optional<bool> discontinuity() const { return m_discontinuity; }

0 commit comments

Comments
 (0)