Commit 922b8a2c by ibaker Committed by Oliver Woodman

Add option to FakeTrackOutput to de-duplicate repeated formats

Expose this through ExtractorAsserts via a new AssertionConfig object

PiperOrigin-RevId: 308980701
parent 625c7347
Showing with 180 additions and 131 deletions
......@@ -38,18 +38,18 @@ public final class AmrExtractorParameterizedTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void extractingNarrowBandSamples() throws Exception {
ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_nb.amr", assertionConfig);
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_nb.amr", simulationConfig);
}
@Test
public void extractingWideBandSamples() throws Exception {
ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_wb.amr", assertionConfig);
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_wb.amr", simulationConfig);
}
@Test
......@@ -57,7 +57,7 @@ public final class AmrExtractorParameterizedTest {
ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ true),
"amr/sample_nb_cbr.amr",
assertionConfig);
simulationConfig);
}
@Test
......@@ -65,7 +65,7 @@ public final class AmrExtractorParameterizedTest {
ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ true),
"amr/sample_wb_cbr.amr",
assertionConfig);
simulationConfig);
}
......
......@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.flac;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -33,95 +34,107 @@ public class FlacExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sample() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_flac");
"flac/bear.flac",
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_flac").build(),
simulationConfig);
}
@Test
public void sampleWithId3HeaderAndId3Enabled() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_with_id3.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_with_id3_enabled_flac");
"flac/bear_with_id3.flac",
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_with_id3_enabled_flac").build(),
simulationConfig);
}
@Test
public void sampleWithId3HeaderAndId3Disabled() throws Exception {
ExtractorAsserts.assertBehavior(
() -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA),
/* file= */ "flac/bear_with_id3.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_with_id3_disabled_flac");
"flac/bear_with_id3.flac",
new AssertionConfig.Builder()
.setDumpFilesPrefix("flac/bear_with_id3_disabled_flac")
.build(),
simulationConfig);
}
@Test
public void sampleUnseekable() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_no_seek_table_no_num_samples.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_no_seek_table_no_num_samples_flac");
"flac/bear_no_seek_table_no_num_samples.flac",
new AssertionConfig.Builder()
.setDumpFilesPrefix("flac/bear_no_seek_table_no_num_samples_flac")
.build(),
simulationConfig);
}
@Test
public void sampleWithVorbisComments() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_with_vorbis_comments.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_with_vorbis_comments_flac");
"flac/bear_with_vorbis_comments.flac",
new AssertionConfig.Builder()
.setDumpFilesPrefix("flac/bear_with_vorbis_comments_flac")
.build(),
simulationConfig);
}
@Test
public void sampleWithPicture() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_with_picture.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_with_picture_flac");
"flac/bear_with_picture.flac",
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_with_picture_flac").build(),
simulationConfig);
}
@Test
public void oneMetadataBlock() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_one_metadata_block.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_one_metadata_block_flac");
"flac/bear_one_metadata_block.flac",
new AssertionConfig.Builder()
.setDumpFilesPrefix("flac/bear_one_metadata_block_flac")
.build(),
simulationConfig);
}
@Test
public void noMinMaxFrameSize() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_no_min_max_frame_size.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_no_min_max_frame_size_flac");
"flac/bear_no_min_max_frame_size.flac",
new AssertionConfig.Builder()
.setDumpFilesPrefix("flac/bear_no_min_max_frame_size_flac")
.build(),
simulationConfig);
}
@Test
public void noNumSamples() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_no_num_samples.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_no_num_samples_flac");
"flac/bear_no_num_samples.flac",
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_no_num_samples_flac").build(),
simulationConfig);
}
@Test
public void uncommonSampleRate() throws Exception {
ExtractorAsserts.assertBehavior(
FlacExtractor::new,
/* file= */ "flac/bear_uncommon_sample_rate.flac",
assertionConfig,
/* dumpFilesPrefix= */ "flac/bear_uncommon_sample_rate_flac");
"flac/bear_uncommon_sample_rate.flac",
new AssertionConfig.Builder()
.setDumpFilesPrefix("flac/bear_uncommon_sample_rate_flac")
.build(),
simulationConfig);
}
}
......@@ -33,10 +33,10 @@ public final class FlvExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sample() throws Exception {
ExtractorAsserts.assertBehavior(FlvExtractor::new, "flv/sample.flv", assertionConfig);
ExtractorAsserts.assertBehavior(FlvExtractor::new, "flv/sample.flv", simulationConfig);
}
}
......@@ -33,39 +33,40 @@ public final class MatroskaExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void mkvSample() throws Exception {
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/sample.mkv", assertionConfig);
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/sample.mkv", simulationConfig);
}
@Test
public void mkvSample_withSubripSubtitles() throws Exception {
ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/sample_with_srt.mkv", assertionConfig);
MatroskaExtractor::new, "mkv/sample_with_srt.mkv", simulationConfig);
}
@Test
public void mkvSample_withHtcRotationInfoInTrackName() throws Exception {
ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/sample_with_htc_rotation_track_name.mkv", assertionConfig);
MatroskaExtractor::new, "mkv/sample_with_htc_rotation_track_name.mkv", simulationConfig);
}
@Test
public void mkvFullBlocksSample() throws Exception {
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/full_blocks.mkv", assertionConfig);
ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/full_blocks.mkv", simulationConfig);
}
@Test
public void webmSubsampleEncryption() throws Exception {
ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/subsample_encrypted_noaltref.webm", assertionConfig);
MatroskaExtractor::new, "mkv/subsample_encrypted_noaltref.webm", simulationConfig);
}
@Test
public void webmSubsampleEncryptionWithAltrefFrames() throws Exception {
ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/subsample_encrypted_altref.webm", assertionConfig);
MatroskaExtractor::new, "mkv/subsample_encrypted_altref.webm", simulationConfig);
}
}
......@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.mp3;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -33,18 +34,18 @@ public final class Mp3ExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void mp3SampleWithXingHeader() throws Exception {
ExtractorAsserts.assertBehavior(
Mp3Extractor::new, "mp3/bear-vbr-xing-header.mp3", assertionConfig);
Mp3Extractor::new, "mp3/bear-vbr-xing-header.mp3", simulationConfig);
}
@Test
public void mp3SampleWithCbrSeeker() throws Exception {
ExtractorAsserts.assertBehavior(
Mp3Extractor::new, "mp3/bear-cbr-variable-frame-size-no-seek-table.mp3", assertionConfig);
Mp3Extractor::new, "mp3/bear-cbr-variable-frame-size-no-seek-table.mp3", simulationConfig);
}
@Test
......@@ -52,29 +53,29 @@ public final class Mp3ExtractorTest {
ExtractorAsserts.assertBehavior(
() -> new Mp3Extractor(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING),
"mp3/bear-vbr-no-seek-table.mp3",
assertionConfig);
simulationConfig);
}
@Test
public void trimmedMp3Sample() throws Exception {
ExtractorAsserts.assertBehavior(Mp3Extractor::new, "mp3/play-trimmed.mp3", assertionConfig);
ExtractorAsserts.assertBehavior(Mp3Extractor::new, "mp3/play-trimmed.mp3", simulationConfig);
}
@Test
public void mp3SampleWithId3Enabled() throws Exception {
ExtractorAsserts.assertBehavior(
Mp3Extractor::new,
/* file= */ "mp3/bear-id3.mp3",
assertionConfig,
/* dumpFilesPrefix= */ "mp3/bear-id3-enabled");
"mp3/bear-id3.mp3",
new AssertionConfig.Builder().setDumpFilesPrefix("mp3/bear-id3-enabled").build(),
simulationConfig);
}
@Test
public void mp3SampleWithId3Disabled() throws Exception {
ExtractorAsserts.assertBehavior(
() -> new Mp3Extractor(Mp3Extractor.FLAG_DISABLE_ID3_METADATA),
/* file= */ "mp3/bear-id3.mp3",
assertionConfig,
/* dumpFilesPrefix= */ "mp3/bear-id3-disabled");
"mp3/bear-id3.mp3",
new AssertionConfig.Builder().setDumpFilesPrefix("mp3/bear-id3-disabled").build(),
simulationConfig);
}
}
......@@ -38,12 +38,12 @@ public final class FragmentedMp4ExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sample() throws Exception {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_fragmented.mp4", assertionConfig);
getExtractorFactory(ImmutableList.of()), "mp4/sample_fragmented.mp4", simulationConfig);
}
@Test
......@@ -51,7 +51,7 @@ public final class FragmentedMp4ExtractorTest {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()),
"mp4/sample_fragmented_seekable.mp4",
assertionConfig);
simulationConfig);
}
@Test
......@@ -62,31 +62,33 @@ public final class FragmentedMp4ExtractorTest {
Collections.singletonList(
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build()));
ExtractorAsserts.assertBehavior(
extractorFactory, "mp4/sample_fragmented_sei.mp4", assertionConfig);
extractorFactory, "mp4/sample_fragmented_sei.mp4", simulationConfig);
}
@Test
public void sampleWithAc3Track() throws Exception {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac3_fragmented.mp4", assertionConfig);
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac3_fragmented.mp4", simulationConfig);
}
@Test
public void sampleWithAc4Track() throws Exception {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_fragmented.mp4", assertionConfig);
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_fragmented.mp4", simulationConfig);
}
@Test
public void sampleWithProtectedAc4Track() throws Exception {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_protected.mp4", assertionConfig);
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_protected.mp4", simulationConfig);
}
@Test
public void sampleWithEac3Track() throws Exception {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_eac3_fragmented.mp4", assertionConfig);
getExtractorFactory(ImmutableList.of()),
"mp4/sample_eac3_fragmented.mp4",
simulationConfig);
}
@Test
......@@ -94,7 +96,7 @@ public final class FragmentedMp4ExtractorTest {
ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()),
"mp4/sample_eac3joc_fragmented.mp4",
assertionConfig);
simulationConfig);
}
private static ExtractorFactory getExtractorFactory(final List<Format> closedCaptionFormats) {
......
......@@ -33,17 +33,17 @@ public final class Mp4ExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void mp4Sample() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample.mp4", assertionConfig);
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample.mp4", simulationConfig);
}
@Test
public void mp4SampleWithSlowMotionMetadata() throws Exception {
ExtractorAsserts.assertBehavior(
Mp4Extractor::new, "mp4/sample_android_slow_motion.mp4", assertionConfig);
Mp4Extractor::new, "mp4/sample_android_slow_motion.mp4", simulationConfig);
}
/**
......@@ -53,26 +53,26 @@ public final class Mp4ExtractorTest {
@Test
public void mp4SampleWithMdatTooLong() throws Exception {
ExtractorAsserts.assertBehavior(
Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4", assertionConfig);
Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4", simulationConfig);
}
@Test
public void mp4SampleWithAc3Track() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac3.mp4", assertionConfig);
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac3.mp4", simulationConfig);
}
@Test
public void mp4SampleWithAc4Track() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4", assertionConfig);
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4", simulationConfig);
}
@Test
public void mp4SampleWithEac3Track() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3.mp4", assertionConfig);
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3.mp4", simulationConfig);
}
@Test
public void mp4SampleWithEac3jocTrack() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3joc.mp4", assertionConfig);
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3joc.mp4", simulationConfig);
}
}
......@@ -37,26 +37,26 @@ public final class OggExtractorParameterizedTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void opus() throws Exception {
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear.opus", assertionConfig);
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear.opus", simulationConfig);
}
@Test
public void flac() throws Exception {
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_flac.ogg", assertionConfig);
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_flac.ogg", simulationConfig);
}
@Test
public void flacNoSeektable() throws Exception {
ExtractorAsserts.assertBehavior(
OggExtractor::new, "ogg/bear_flac_noseektable.ogg", assertionConfig);
OggExtractor::new, "ogg/bear_flac_noseektable.ogg", simulationConfig);
}
@Test
public void vorbis() throws Exception {
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_vorbis.ogg", assertionConfig);
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_vorbis.ogg", simulationConfig);
}
}
......@@ -33,7 +33,7 @@ public final class RawCcExtractorTest {
}
@ParameterizedRobolectricTestRunner.Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void rawCcSample() throws Exception {
......@@ -44,6 +44,6 @@ public final class RawCcExtractorTest {
.setAccessibilityChannel(1)
.build();
ExtractorAsserts.assertBehavior(
() -> new RawCcExtractor(format), "rawcc/sample.rawcc", assertionConfig);
() -> new RawCcExtractor(format), "rawcc/sample.rawcc", simulationConfig);
}
}
......@@ -33,20 +33,20 @@ public final class Ac3ExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void ac3Sample() throws Exception {
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.ac3", assertionConfig);
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.ac3", simulationConfig);
}
@Test
public void eAc3Sample() throws Exception {
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.eac3", assertionConfig);
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.eac3", simulationConfig);
}
@Test
public void eAc3jocSample() throws Exception {
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample_eac3joc.ec3", assertionConfig);
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample_eac3joc.ec3", simulationConfig);
}
}
......@@ -33,10 +33,10 @@ public final class Ac4ExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void ac4Sample() throws Exception {
ExtractorAsserts.assertBehavior(Ac4Extractor::new, "ts/sample.ac4", assertionConfig);
ExtractorAsserts.assertBehavior(Ac4Extractor::new, "ts/sample.ac4", simulationConfig);
}
}
......@@ -33,16 +33,17 @@ public final class AdtsExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sample() throws Exception {
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample.adts", assertionConfig);
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample.adts", simulationConfig);
}
@Test
public void sample_with_id3() throws Exception {
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample_with_id3.adts", assertionConfig);
ExtractorAsserts.assertBehavior(
AdtsExtractor::new, "ts/sample_with_id3.adts", simulationConfig);
}
@Test
......@@ -50,7 +51,7 @@ public final class AdtsExtractorTest {
ExtractorAsserts.assertBehavior(
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
"ts/sample_cbs.adts",
assertionConfig);
simulationConfig);
}
// https://github.com/google/ExoPlayer/issues/6700
......@@ -59,6 +60,6 @@ public final class AdtsExtractorTest {
ExtractorAsserts.assertBehavior(
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
"ts/sample_cbs_truncated.adts",
assertionConfig);
simulationConfig);
}
}
......@@ -33,16 +33,16 @@ public final class PsExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sampleWithH262AndMpegAudio() throws Exception {
ExtractorAsserts.assertBehavior(
PsExtractor::new, "ts/sample_h262_mpeg_audio.ps", assertionConfig);
PsExtractor::new, "ts/sample_h262_mpeg_audio.ps", simulationConfig);
}
@Test
public void sampleWithAc3() throws Exception {
ExtractorAsserts.assertBehavior(PsExtractor::new, "ts/sample_ac3.ps", assertionConfig);
ExtractorAsserts.assertBehavior(PsExtractor::new, "ts/sample_ac3.ps", simulationConfig);
}
}
......@@ -37,7 +37,6 @@ import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.TimestampAdjuster;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.ParameterizedRobolectricTestRunner;
......@@ -54,18 +53,18 @@ public final class TsExtractorTest {
}
@Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sampleWithH262AndMpegAudio() throws Exception {
ExtractorAsserts.assertBehavior(
TsExtractor::new, "ts/sample_h262_mpeg_audio.ts", assertionConfig);
TsExtractor::new, "ts/sample_h262_mpeg_audio.ts", simulationConfig);
}
@Test
public void sampleWithH264AndMpegAudio() throws Exception {
ExtractorAsserts.assertBehavior(
TsExtractor::new, "ts/sample_h264_mpeg_audio.ts", assertionConfig);
TsExtractor::new, "ts/sample_h264_mpeg_audio.ts", simulationConfig);
}
@Test
......@@ -73,7 +72,7 @@ public final class TsExtractorTest {
ExtractorAsserts.assertBehavior(
() -> new TsExtractor(FLAG_DETECT_ACCESS_UNITS),
"ts/sample_h264_no_access_unit_delimiters.ts",
assertionConfig);
simulationConfig);
}
@Test
......@@ -81,58 +80,64 @@ public final class TsExtractorTest {
ExtractorAsserts.assertBehavior(
() -> new TsExtractor(DefaultTsPayloadReaderFactory.FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS),
"ts/sample_h264_dts_audio.ts",
assertionConfig);
simulationConfig);
}
@Test
public void sampleWithH265() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_h265.ts", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_h265.ts", simulationConfig);
}
@Test
@Ignore
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
// formats and seeking.
public void sampleWithScte35() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_scte35.ts", assertionConfig);
ExtractorAsserts.assertBehavior(
TsExtractor::new,
"ts/sample_scte35.ts",
new ExtractorAsserts.AssertionConfig.Builder()
.setDeduplicateConsecutiveFormats(true)
.build(),
simulationConfig);
}
@Test
@Ignore
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
// formats and seeking.
public void sampleWithAit() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ait.ts", assertionConfig);
ExtractorAsserts.assertBehavior(
TsExtractor::new,
"ts/sample_ait.ts",
new ExtractorAsserts.AssertionConfig.Builder()
.setDeduplicateConsecutiveFormats(true)
.build(),
simulationConfig);
}
@Test
public void sampleWithAc3() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac3.ts", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac3.ts", simulationConfig);
}
@Test
public void sampleWithAc4() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac4.ts", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac4.ts", simulationConfig);
}
@Test
public void sampleWithEac3() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3.ts", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3.ts", simulationConfig);
}
@Test
public void sampleWithEac3joc() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3joc.ts", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3joc.ts", simulationConfig);
}
@Test
public void sampleWithLatm() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_latm.ts", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_latm.ts", simulationConfig);
}
@Test
public void streamWithJunkData() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_with_junk", assertionConfig);
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_with_junk", simulationConfig);
}
@Test
......
......@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.wav;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -31,11 +32,11 @@ public final class WavExtractorTest {
}
@ParameterizedRobolectricTestRunner.Parameter(0)
public ExtractorAsserts.Config assertionConfig;
public ExtractorAsserts.SimulationConfig simulationConfig;
@Test
public void sample() throws Exception {
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample.wav", assertionConfig);
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample.wav", simulationConfig);
}
@Test
......@@ -43,12 +44,13 @@ public final class WavExtractorTest {
ExtractorAsserts.assertBehavior(
WavExtractor::new,
"wav/sample_with_trailing_bytes.wav",
assertionConfig,
/* dumpFilesPrefix= */ "wav/sample.wav");
new AssertionConfig.Builder().setDumpFilesPrefix("wav/sample.wav").build(),
simulationConfig);
}
@Test
public void sample_imaAdpcm() throws Exception {
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample_ima_adpcm.wav", assertionConfig);
ExtractorAsserts.assertBehavior(
WavExtractor::new, "wav/sample_ima_adpcm.wav", simulationConfig);
}
}
......@@ -55,7 +55,7 @@ track 600:
sample count = 3
format 0:
sampleMimeType = application/x-scte35
subsampleOffsetUs = -1400000
subsampleOffsetUs = -1377756
sample 0:
time = 55610
flags = 1
......
......@@ -55,7 +55,7 @@ track 600:
sample count = 3
format 0:
sampleMimeType = application/x-scte35
subsampleOffsetUs = -1400000
subsampleOffsetUs = -1355512
sample 0:
time = 77854
flags = 1
......
......@@ -39,7 +39,7 @@ track 600:
sample count = 0
format 0:
sampleMimeType = application/x-scte35
subsampleOffsetUs = -1400000
subsampleOffsetUs = -1355512
track 8448:
total output bytes = 0
sample count = 0
......
......@@ -68,12 +68,18 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
@DumpFilesAction private static final int DUMP_FILE_ACTION = COMPARE_WITH_EXISTING;
public final SparseArray<FakeTrackOutput> trackOutputs;
private final FakeTrackOutput.Factory trackOutputFactory;
public int numberOfTracks;
public boolean tracksEnded;
public @MonotonicNonNull SeekMap seekMap;
public FakeExtractorOutput() {
this(FakeTrackOutput.DEFAULT_FACTORY);
}
public FakeExtractorOutput(FakeTrackOutput.Factory trackOutputFactory) {
this.trackOutputFactory = trackOutputFactory;
trackOutputs = new SparseArray<>();
}
......@@ -83,7 +89,7 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
if (output == null) {
assertThat(tracksEnded).isFalse();
numberOfTracks++;
output = new FakeTrackOutput();
output = trackOutputFactory.create(id, type);
trackOutputs.put(id, output);
}
return output;
......
......@@ -35,11 +35,18 @@ import java.util.Collections;
import java.util.List;
import org.checkerframework.checker.nullness.compatqual.NullableType;
/**
* A fake {@link TrackOutput}.
*/
/** A fake {@link TrackOutput}. */
public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
public static final Factory DEFAULT_FACTORY =
(id, type) -> new FakeTrackOutput(/* deduplicateConsecutiveFormats= */ false);
/** Factory for {@link FakeTrackOutput} instances. */
public interface Factory {
FakeTrackOutput create(int id, int type);
}
private final boolean deduplicateConsecutiveFormats;
private final ArrayList<DumpableSampleInfo> sampleInfos;
private final ArrayList<Dumpable> dumpables;
......@@ -49,7 +56,8 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
@Nullable public Format lastFormat;
public FakeTrackOutput() {
public FakeTrackOutput(boolean deduplicateConsecutiveFormats) {
this.deduplicateConsecutiveFormats = deduplicateConsecutiveFormats;
sampleInfos = new ArrayList<>();
dumpables = new ArrayList<>();
sampleData = Util.EMPTY_BYTE_ARRAY;
......@@ -67,9 +75,19 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
@Override
public void format(Format format) {
Assertions.checkState(
receivedSampleInFormat,
"TrackOutput must receive at least one sampleMetadata() call between format() calls.");
if (!deduplicateConsecutiveFormats) {
Assertions.checkState(
receivedSampleInFormat,
"deduplicateConsecutiveFormats=false so TrackOutput must receive at least one"
+ " sampleMetadata() call between format() calls.");
} else if (!receivedSampleInFormat) {
Dumpable dumpable = dumpables.remove(dumpables.size() - 1);
formatCount--;
Assertions.checkState(
dumpable instanceof DumpableFormat,
"receivedSampleInFormat=false so expected last dumpable to be a DumpableFormat. Found: "
+ dumpable.getClass().getCanonicalName());
}
receivedSampleInFormat = false;
addFormat(format);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment