Skip to content

Commit

Permalink
Reject opus decoding without description when there's more than 2 cha…
Browse files Browse the repository at this point in the history
…nnels.

Differential Revision: https://phabricator.services.mozilla.com/D220431

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1915143
gecko-commit: 5e3767e9fcca6448d4c1161db2623405369f7f7f
gecko-reviewers: chunmin
  • Loading branch information
padenot authored and moz-wptsync-bot committed Sep 19, 2024
1 parent a154a3a commit a13b4c6
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions webcodecs/audio-decoder.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,41 +67,7 @@ const invalidConfigs = [
codec: 'opus',
sampleRate: 8000,
numberOfChannels: 1,
description: detachedArrayBuffer
},
},
{
comment: 'Vorbis without description',
config: {
codec: 'vorbis',
sampleRate: 48000,
numberOfChannels: 2,
},
},
{
comment: 'Vorbis with empty description',
config: {
codec: 'vorbis',
sampleRate: 48000,
numberOfChannels: 2,
description: emptyArrayBuffer,
},
},
{
comment: 'Flac without description',
config: {
codec: 'flac',
sampleRate: 48000,
numberOfChannels: 2,
},
},
{
comment: 'Flac with empty description',
config: {
codec: 'flac',
sampleRate: 48000,
numberOfChannels: 2,
description: emptyArrayBuffer,
description: detachedArrayBuffer,
},
},
];
Expand Down Expand Up @@ -180,6 +146,27 @@ const validButUnsupportedConfigs = [
},
];

// Those configurations are supported, but attempting to configure an
// AudioDecoder will fail, because `description` is invalid for this particular
// codec
var supportedButErrorOnConfiguration = [
{
comment: 'Opus with more than two channels and without description',
config: {
codec: 'opus',
sampleRate: '48000',
numberOfChannels: 3,
},
},
{
comment: 'Opus with more than two channels and with a description that is too short',
config: {
codec: 'opus',
sampleRate: '48000',
numberOfChannels: 3,
description: new Uint8Array(9), // at least 10 bytes are required for multichannel
},
},
validButUnsupportedConfigs.forEach(entry => {
promise_test(
t => {
Expand All @@ -191,10 +178,14 @@ validButUnsupportedConfigs.forEach(entry => {
entry.comment);
});

validButUnsupportedConfigs.forEach(entry => {
var shouldError = validButUnsupportedConfigs.concat(supportedButErrorOnConfiguration);

shouldError.forEach(entry => {
promise_test(
t => {
let isErrorCallbackCalled = false;
let supported = AudioDecoder.isConfigSupported(entry.config);
assert_implements_optional(supported, entry.config.codec + ' unsupported');
let codec = new AudioDecoder({
output: t.unreached_func('unexpected output'),
error: t.step_func_done(e => {
Expand Down

0 comments on commit a13b4c6

Please sign in to comment.