Bug 1669503 - Add various test cases for mp3 trimming. r=jya

Differential Revision: https://phabricator.services.mozilla.com/D94470
This commit is contained in:
Paul Adenot 2020-11-04 23:20:05 +00:00
Родитель f8210c4ae7
Коммит f4d10e9a1d
4 изменённых файлов: 22 добавлений и 5 удалений

Двоичные данные
dom/media/webaudio/test/cropped_8000hz_8kbs_mono_lame3.100.abr.mp3 Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -33,6 +33,8 @@ support-files =
sine-440-10s.opus
half-a-second-8000.mp3
half-a-second-48000.mp3
cropped_8000hz_8kbs_mono_lame3.100.abr.mp3
v3.mp3
webaudio.js
../../webrtc/tests/mochitests/mediaStreamPlayback.js
../../webrtc/tests/mochitests/head.js

Просмотреть файл

@ -12,18 +12,33 @@
SimpleTest.waitForExplicitFinish();
var tests = [
"half-a-second-8000.mp3",
"half-a-second-48000.mp3",
{
name: "half-a-second-8000.mp3",
duration: 0.5
},
{
name: "half-a-second-48000.mp3",
duration: 0.5
},
{
name: "v3.mp3",
duration: 3
},
{
// Weird file that has the end padding larger than a packet size.
name: "cropped_8000hz_8kbs_mono_lame3.100.abr.mp3",
duration: 28.65675
}
];
async function doit(t) {
var count = 0;
var context = new OfflineAudioContext(1, 128, 48000);
tests.forEach(async testfile => {
var response = await fetch(testfile);
tests.forEach(async testcase => {
var response = await fetch(testcase.name);
var buffer = await response.arrayBuffer();
var decoded = await context.decodeAudioData(buffer);
is(decoded.duration, 0.5, "The file is half a second.");
is(decoded.duration, testcase.duration, "The file has the correct duration.");
if (++count == tests.length) {
SimpleTest.finish();
}

Двоичные данные
dom/media/webaudio/test/v3.mp3 Normal file

Двоичный файл не отображается.