mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add WAV playback tests.
The output dumps are intentionally empty because the playback is using bypass modes. Still adding a AUDIO_RAW decoder to the ShadowMediaCodecConfig to ensure that we would output samples if bypass mode were disabled. PiperOrigin-RevId: 352794959
This commit is contained in:
parent
26ea43d21f
commit
737630740c
5 changed files with 79 additions and 0 deletions
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.e2etest;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
|
import com.google.android.exoplayer2.Player;
|
||||||
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
|
import com.google.android.exoplayer2.robolectric.PlaybackOutput;
|
||||||
|
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
|
||||||
|
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
|
||||||
|
import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock;
|
||||||
|
import com.google.android.exoplayer2.testutil.CapturingRenderersFactory;
|
||||||
|
import com.google.android.exoplayer2.testutil.DumpFileAsserts;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.ParameterizedRobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
/** End-to-end tests using WAV samples. */
|
||||||
|
// TODO(b/143232359): Remove once https://issuetracker.google.com/143232359 is resolved.
|
||||||
|
@Config(sdk = 29)
|
||||||
|
@RunWith(ParameterizedRobolectricTestRunner.class)
|
||||||
|
public final class WavPlaybackTest {
|
||||||
|
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}")
|
||||||
|
public static ImmutableList<String> mediaSamples() {
|
||||||
|
return ImmutableList.of("sample.wav", "sample_ima_adpcm.wav", "sample_with_trailing_bytes.wav");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedRobolectricTestRunner.Parameter public String inputFile;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ShadowMediaCodecConfig mediaCodecConfig =
|
||||||
|
ShadowMediaCodecConfig.forAllSupportedMimeTypes();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
Context applicationContext = ApplicationProvider.getApplicationContext();
|
||||||
|
CapturingRenderersFactory capturingRenderersFactory =
|
||||||
|
new CapturingRenderersFactory(applicationContext);
|
||||||
|
SimpleExoPlayer player =
|
||||||
|
new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory)
|
||||||
|
.setClock(new AutoAdvancingFakeClock())
|
||||||
|
.build();
|
||||||
|
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
|
||||||
|
|
||||||
|
player.setMediaItem(MediaItem.fromUri("asset:///media/wav/" + inputFile));
|
||||||
|
player.prepare();
|
||||||
|
player.play();
|
||||||
|
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
|
||||||
|
player.release();
|
||||||
|
|
||||||
|
DumpFileAsserts.assertOutput(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
playbackOutput,
|
||||||
|
"playbackdumps/wav/" + inputFile + ".dump");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -78,6 +78,11 @@ public final class ShadowMediaCodecConfig extends ExternalResource {
|
||||||
configureCodec("exotest.audio.mpegl2", MimeTypes.AUDIO_MPEG_L2);
|
configureCodec("exotest.audio.mpegl2", MimeTypes.AUDIO_MPEG_L2);
|
||||||
configureCodec("exotest.audio.opus", MimeTypes.AUDIO_OPUS);
|
configureCodec("exotest.audio.opus", MimeTypes.AUDIO_OPUS);
|
||||||
configureCodec("exotest.audio.vorbis", MimeTypes.AUDIO_VORBIS);
|
configureCodec("exotest.audio.vorbis", MimeTypes.AUDIO_VORBIS);
|
||||||
|
|
||||||
|
// Raw audio should use a bypass mode and never need this codec. However, to easily assert
|
||||||
|
// failures of the bypass mode we want to detect when the raw audio is decoded by this class and
|
||||||
|
// thus we need a codec to output samples.
|
||||||
|
configureCodec("exotest.audio.raw", MimeTypes.AUDIO_RAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
0
testdata/src/test/assets/playbackdumps/wav/sample.wav.dump
vendored
Normal file
0
testdata/src/test/assets/playbackdumps/wav/sample.wav.dump
vendored
Normal file
0
testdata/src/test/assets/playbackdumps/wav/sample_ima_adpcm.wav.dump
vendored
Normal file
0
testdata/src/test/assets/playbackdumps/wav/sample_ima_adpcm.wav.dump
vendored
Normal file
0
testdata/src/test/assets/playbackdumps/wav/sample_with_trailing_bytes.wav.dump
vendored
Normal file
0
testdata/src/test/assets/playbackdumps/wav/sample_with_trailing_bytes.wav.dump
vendored
Normal file
Loading…
Reference in a new issue