You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add AudioEncoderCocoa class, an AudioToolbox implementation of WebCodec's AudioEncoder
https://bugs.webkit.org/show_bug.cgi?id=284019
rdar://140889671
Reviewed by NOBODY (OOPS!).
We add AudioEncoderCocoa, AudioToolbox implementation of WebCodec's AudioEncoder. We only support
encoding to Opus and AAC as the framework doesn't provide encoder for Flac, mp3 and vorbis (decoder only)
Enabled WPT tests.
* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/webcodecs/audio-encoder-codec-specific.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/webcodecs/audio-encoder-config.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/webcodecs/audio-encoder-config.https.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/webcodecs/audio-encoder.https.any-expected.txt:
* LayoutTests/platform/glib/TestExpectations: Remove passing expectations, add the remaining ones that do fail.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/webcodecs/audio-encoder-config.https.any-expected.txt: Removed.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/webcodecs/audio-encoder-config.https.any.worker-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/webcodecs/audio-encoder-codec-specific.https.any-expected.txt: Added. The
only failure remaining is related to different default for Opus encoding which yield slightly different values to what expected.
The test performs very rough float comparisons.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/webcodecs/audio-encoder.https.any-expected.txt: Added.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/webcodecs/audio-encoder-codec-specific.https.any-expected.txt: Added.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/webcodecs/audio-encoder.https.any-expected.txt: Added.
* Source/WebCore/Modules/webcodecs/OpusEncoderConfig.h:
* Source/WebCore/Modules/webcodecs/WebCodecsAudioEncoder.cpp:
(WebCore::isSupportedEncoderCodec): Add additional checks to ensure that the values provided in the Opus config are sane.
While this isn't probably the best place to do so, as this is common for both GStreamer and Cocoa AudioEncoder, it's the simplest.
(WebCore::isValidEncoderConfig): Make sure sampleRate and numberOfChannels aren't 0.
(WebCore::createAudioEncoderConfig): Increase code readability by using struct's named member initialisation.
(WebCore::WebCodecsAudioEncoder::configure):
(WebCore::WebCodecsAudioEncoder::encode): Both Firefox and Chromes rejects AudioData that has a different sampleRate or numberOfChannels.
While we did the same, we didn't process the errors as per spec which requires that we also change the state to Closed just before
queueing the error.
(WebCore::WebCodecsAudioEncoder::isConfigSupported):
* Source/WebCore/PlatformMac.cmake:
* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/AudioEncoder.cpp:
(WebCore::AudioEncoder::create): Plumb AudioEncoderCocoa.
* Source/WebCore/platform/AudioEncoder.h:
* Source/WebCore/platform/AudioEncoderActiveConfiguration.h: Add default initialiser to comply with more recent clang version.
It allows to make the struct member initialisation optional.
* Source/WebCore/platform/audio/cocoa/AudioDecoderCocoa.cpp:
(WebCore::InternalAudioDecoderCocoa::initialize): Change default AudioData creation to use interleaved frames instead of planar. A few
tests has this expectations, even though this isn't mandated by the specs.
* Source/WebCore/platform/audio/cocoa/AudioEncoderCocoa.cpp: Added.
(WebCore::InternalAudioEncoderCocoa::create):
(WebCore::InternalAudioEncoderCocoa::reset):
(WebCore::InternalAudioEncoderCocoa::converter):
(WebCore::InternalAudioEncoderCocoa::queueSingleton):
(WebCore::AudioEncoderCocoa::create):
(WebCore::AudioEncoderCocoa::AudioEncoderCocoa):
(WebCore::AudioEncoderCocoa::~AudioEncoderCocoa):
(WebCore::AudioEncoderCocoa::encode):
(WebCore::AudioEncoderCocoa::flush):
(WebCore::AudioEncoderCocoa::reset):
(WebCore::AudioEncoderCocoa::close):
(WebCore::InternalAudioEncoderCocoa::InternalAudioEncoderCocoa):
(WebCore::InternalAudioEncoderCocoa::initialize):
(WebCore::InternalAudioEncoderCocoa::compressedAudioOutputBufferCallback):
(WebCore::InternalAudioEncoderCocoa::generateDecoderDescriptionFromSample const):
(WebCore::InternalAudioEncoderCocoa::activeConfiguration const):
(WebCore::InternalAudioEncoderCocoa::processEncodedOutputs):
(WebCore::InternalAudioEncoderCocoa::encode):
(WebCore::InternalAudioEncoderCocoa::flush):
(WebCore::InternalAudioEncoderCocoa::close):
* Source/WebCore/platform/audio/cocoa/AudioEncoderCocoa.h: Copied from Source/WebCore/platform/AudioEncoderActiveConfiguration.h.
Copy file name to clipboardexpand all lines: LayoutTests/imported/w3c/web-platform-tests/webcodecs/audio-encoder-config.https.any-expected.txt
+13-19
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Missing
3
3
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Empty codec
4
4
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Missing sampleRate
5
5
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Missing numberOfChannels
6
-
FAIL Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero sampleRate assert_unreached: Should have rejected: undefined Reached unreachable code
7
-
FAIL Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero channels assert_unreached: Should have rejected: undefined Reached unreachable code
8
-
FAIL Test that AudioEncoder.isConfigSupported() rejects invalid config: Bit rate too big assert_unreached: Should have rejected: undefined Reached unreachable code
6
+
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero sampleRate
7
+
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero channels
8
+
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Bit rate too big
9
9
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Opus complexity too big
10
10
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Opus packetlossperc too big
11
11
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Opus frame duration too small
@@ -15,15 +15,9 @@ PASS Test that AudioEncoder.configure() rejects invalid config: Missing codec
15
15
PASS Test that AudioEncoder.configure() rejects invalid config: Empty codec
16
16
PASS Test that AudioEncoder.configure() rejects invalid config: Missing sampleRate
17
17
PASS Test that AudioEncoder.configure() rejects invalid config: Missing numberOfChannels
18
-
FAIL Test that AudioEncoder.configure() rejects invalid config: Zero sampleRate assert_throws_js: function "() => {
19
-
codec.configure(entry.config);
20
-
}" did not throw
21
-
FAIL Test that AudioEncoder.configure() rejects invalid config: Zero channels assert_throws_js: function "() => {
22
-
codec.configure(entry.config);
23
-
}" did not throw
24
-
FAIL Test that AudioEncoder.configure() rejects invalid config: Bit rate too big assert_throws_js: function "() => {
25
-
codec.configure(entry.config);
26
-
}" did not throw
18
+
PASS Test that AudioEncoder.configure() rejects invalid config: Zero sampleRate
19
+
PASS Test that AudioEncoder.configure() rejects invalid config: Zero channels
20
+
PASS Test that AudioEncoder.configure() rejects invalid config: Bit rate too big
27
21
PASS Test that AudioEncoder.configure() rejects invalid config: Opus complexity too big
28
22
PASS Test that AudioEncoder.configure() rejects invalid config: Opus packetlossperc too big
29
23
PASS Test that AudioEncoder.configure() rejects invalid config: Opus frame duration too small
@@ -43,11 +37,11 @@ PASS Test that AudioEncoder.configure() doesn't support config: Sample rate is t
43
37
PASS Test that AudioEncoder.configure() doesn't support config: Way too many channels
44
38
PASS Test that AudioEncoder.configure() doesn't support config: Possible future opus codec string
45
39
PASS Test that AudioEncoder.configure() doesn't support config: Possible future aac codec string
Copy file name to clipboardexpand all lines: LayoutTests/imported/w3c/web-platform-tests/webcodecs/audio-encoder-config.https.any.worker-expected.txt
+13-19
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Missing
3
3
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Empty codec
4
4
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Missing sampleRate
5
5
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Missing numberOfChannels
6
-
FAIL Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero sampleRate assert_unreached: Should have rejected: undefined Reached unreachable code
7
-
FAIL Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero channels assert_unreached: Should have rejected: undefined Reached unreachable code
8
-
FAIL Test that AudioEncoder.isConfigSupported() rejects invalid config: Bit rate too big assert_unreached: Should have rejected: undefined Reached unreachable code
6
+
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero sampleRate
7
+
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Zero channels
8
+
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Bit rate too big
9
9
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Opus complexity too big
10
10
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Opus packetlossperc too big
11
11
PASS Test that AudioEncoder.isConfigSupported() rejects invalid config: Opus frame duration too small
@@ -15,15 +15,9 @@ PASS Test that AudioEncoder.configure() rejects invalid config: Missing codec
15
15
PASS Test that AudioEncoder.configure() rejects invalid config: Empty codec
16
16
PASS Test that AudioEncoder.configure() rejects invalid config: Missing sampleRate
17
17
PASS Test that AudioEncoder.configure() rejects invalid config: Missing numberOfChannels
18
-
FAIL Test that AudioEncoder.configure() rejects invalid config: Zero sampleRate assert_throws_js: function "() => {
19
-
codec.configure(entry.config);
20
-
}" did not throw
21
-
FAIL Test that AudioEncoder.configure() rejects invalid config: Zero channels assert_throws_js: function "() => {
22
-
codec.configure(entry.config);
23
-
}" did not throw
24
-
FAIL Test that AudioEncoder.configure() rejects invalid config: Bit rate too big assert_throws_js: function "() => {
25
-
codec.configure(entry.config);
26
-
}" did not throw
18
+
PASS Test that AudioEncoder.configure() rejects invalid config: Zero sampleRate
19
+
PASS Test that AudioEncoder.configure() rejects invalid config: Zero channels
20
+
PASS Test that AudioEncoder.configure() rejects invalid config: Bit rate too big
27
21
PASS Test that AudioEncoder.configure() rejects invalid config: Opus complexity too big
28
22
PASS Test that AudioEncoder.configure() rejects invalid config: Opus packetlossperc too big
29
23
PASS Test that AudioEncoder.configure() rejects invalid config: Opus frame duration too small
@@ -43,11 +37,11 @@ PASS Test that AudioEncoder.configure() doesn't support config: Sample rate is t
43
37
PASS Test that AudioEncoder.configure() doesn't support config: Way too many channels
44
38
PASS Test that AudioEncoder.configure() doesn't support config: Possible future opus codec string
45
39
PASS Test that AudioEncoder.configure() doesn't support config: Possible future aac codec string
0 commit comments