mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Update web-platform-tests to revision b'099ab08227717e000b444ff560e93f96b49e05d7'
This commit is contained in:
parent
53570ffe55
commit
a1db4c746d
172 changed files with 12261 additions and 2279 deletions
|
@ -472,3 +472,101 @@ promise_test(async t => {
|
|||
encoder.reset();
|
||||
assert_equals(encoder.encodeQueueSize, 0);
|
||||
}, 'encodeQueueSize test');
|
||||
|
||||
const testOpusEncoderConfigs = [
|
||||
{
|
||||
comment: 'Empty Opus config',
|
||||
opus: {},
|
||||
},
|
||||
{
|
||||
comment: 'Opus with frameDuration',
|
||||
opus: {frameDuration: 2500},
|
||||
},
|
||||
{
|
||||
comment: 'Opus with complexity',
|
||||
opus: {complexity: 10},
|
||||
},
|
||||
{
|
||||
comment: 'Opus with useinbandfec',
|
||||
opus: {
|
||||
packetlossperc: 15,
|
||||
useinbandfec: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
comment: 'Opus with usedtx',
|
||||
opus: {usedtx: true},
|
||||
},
|
||||
{
|
||||
comment: 'Opus mixed parameters',
|
||||
opus: {
|
||||
frameDuration: 40000,
|
||||
complexity: 0,
|
||||
packetlossperc: 10,
|
||||
useinbandfec: true,
|
||||
usedtx: true,
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
testOpusEncoderConfigs.forEach(entry => {
|
||||
promise_test(async t => {
|
||||
let sample_rate = 48000;
|
||||
let total_duration_s = 0.5;
|
||||
let data_count = 10;
|
||||
let outputs = [];
|
||||
let init = {
|
||||
error: e => {
|
||||
assert_unreached('error: ' + e);
|
||||
},
|
||||
output: chunk => {
|
||||
outputs.push(chunk);
|
||||
}
|
||||
};
|
||||
|
||||
let encoder = new AudioEncoder(init);
|
||||
|
||||
assert_equals(encoder.state, 'unconfigured');
|
||||
let config = {
|
||||
codec: 'opus',
|
||||
sampleRate: sample_rate,
|
||||
numberOfChannels: 2,
|
||||
bitrate: 256000, // 256kbit
|
||||
opus: entry.opus,
|
||||
};
|
||||
|
||||
encoder.configure(config);
|
||||
|
||||
let timestamp_us = 0;
|
||||
let data_duration_s = total_duration_s / data_count;
|
||||
let data_length = data_duration_s * config.sampleRate;
|
||||
for (let i = 0; i < data_count; i++) {
|
||||
let data = make_audio_data(
|
||||
timestamp_us, config.numberOfChannels, config.sampleRate,
|
||||
data_length);
|
||||
encoder.encode(data);
|
||||
data.close();
|
||||
timestamp_us += data_duration_s * 1_000_000;
|
||||
}
|
||||
|
||||
// Encoders might output an extra buffer of silent padding.
|
||||
let padding_us = data_duration_s * 1_000_000;
|
||||
|
||||
await encoder.flush();
|
||||
encoder.close();
|
||||
assert_greater_than_equal(outputs.length, data_count);
|
||||
assert_equals(outputs[0].timestamp, 0, 'first chunk timestamp');
|
||||
let total_encoded_duration = 0
|
||||
for (chunk of outputs) {
|
||||
assert_greater_than(chunk.byteLength, 0, 'chunk byteLength');
|
||||
assert_greater_than_equal(
|
||||
timestamp_us + padding_us, chunk.timestamp, 'chunk timestamp');
|
||||
assert_greater_than(chunk.duration, 0, 'chunk duration');
|
||||
total_encoded_duration += chunk.duration;
|
||||
}
|
||||
|
||||
// The total duration might be padded with silence.
|
||||
assert_greater_than_equal(
|
||||
total_encoded_duration, total_duration_s * 1_000_000);
|
||||
}, 'Test encoding Opus with additional parameters: ' + entry.comment);
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue