Add option to FakeTrackOutput to de-duplicate repeated formats
Expose this through ExtractorAsserts via a new AssertionConfig object PiperOrigin-RevId: 308980701
This commit is contained in:
parent
625c734726
commit
922b8a2c15
@ -38,18 +38,18 @@ public final class AmrExtractorParameterizedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void extractingNarrowBandSamples() throws Exception {
|
public void extractingNarrowBandSamples() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_nb.amr", assertionConfig);
|
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_nb.amr", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void extractingWideBandSamples() throws Exception {
|
public void extractingWideBandSamples() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_wb.amr", assertionConfig);
|
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_wb.amr", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -57,7 +57,7 @@ public final class AmrExtractorParameterizedTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
createAmrExtractorFactory(/* withSeeking= */ true),
|
createAmrExtractorFactory(/* withSeeking= */ true),
|
||||||
"amr/sample_nb_cbr.amr",
|
"amr/sample_nb_cbr.amr",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -65,7 +65,7 @@ public final class AmrExtractorParameterizedTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
createAmrExtractorFactory(/* withSeeking= */ true),
|
createAmrExtractorFactory(/* withSeeking= */ true),
|
||||||
"amr/sample_wb_cbr.amr",
|
"amr/sample_wb_cbr.amr",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.google.android.exoplayer2.extractor.flac;
|
package com.google.android.exoplayer2.extractor.flac;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
||||||
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -33,95 +34,107 @@ public class FlacExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample() throws Exception {
|
public void sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear.flac",
|
"flac/bear.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_flac").build(),
|
||||||
/* dumpFilesPrefix= */ "flac/bear_flac");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithId3HeaderAndId3Enabled() throws Exception {
|
public void sampleWithId3HeaderAndId3Enabled() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_with_id3.flac",
|
"flac/bear_with_id3.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_with_id3_enabled_flac").build(),
|
||||||
/* dumpFilesPrefix= */ "flac/bear_with_id3_enabled_flac");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithId3HeaderAndId3Disabled() throws Exception {
|
public void sampleWithId3HeaderAndId3Disabled() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA),
|
() -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA),
|
||||||
/* file= */ "flac/bear_with_id3.flac",
|
"flac/bear_with_id3.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder()
|
||||||
/* dumpFilesPrefix= */ "flac/bear_with_id3_disabled_flac");
|
.setDumpFilesPrefix("flac/bear_with_id3_disabled_flac")
|
||||||
|
.build(),
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleUnseekable() throws Exception {
|
public void sampleUnseekable() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_no_seek_table_no_num_samples.flac",
|
"flac/bear_no_seek_table_no_num_samples.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder()
|
||||||
/* dumpFilesPrefix= */ "flac/bear_no_seek_table_no_num_samples_flac");
|
.setDumpFilesPrefix("flac/bear_no_seek_table_no_num_samples_flac")
|
||||||
|
.build(),
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithVorbisComments() throws Exception {
|
public void sampleWithVorbisComments() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_with_vorbis_comments.flac",
|
"flac/bear_with_vorbis_comments.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder()
|
||||||
/* dumpFilesPrefix= */ "flac/bear_with_vorbis_comments_flac");
|
.setDumpFilesPrefix("flac/bear_with_vorbis_comments_flac")
|
||||||
|
.build(),
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithPicture() throws Exception {
|
public void sampleWithPicture() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_with_picture.flac",
|
"flac/bear_with_picture.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_with_picture_flac").build(),
|
||||||
/* dumpFilesPrefix= */ "flac/bear_with_picture_flac");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void oneMetadataBlock() throws Exception {
|
public void oneMetadataBlock() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_one_metadata_block.flac",
|
"flac/bear_one_metadata_block.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder()
|
||||||
/* dumpFilesPrefix= */ "flac/bear_one_metadata_block_flac");
|
.setDumpFilesPrefix("flac/bear_one_metadata_block_flac")
|
||||||
|
.build(),
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noMinMaxFrameSize() throws Exception {
|
public void noMinMaxFrameSize() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_no_min_max_frame_size.flac",
|
"flac/bear_no_min_max_frame_size.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder()
|
||||||
/* dumpFilesPrefix= */ "flac/bear_no_min_max_frame_size_flac");
|
.setDumpFilesPrefix("flac/bear_no_min_max_frame_size_flac")
|
||||||
|
.build(),
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noNumSamples() throws Exception {
|
public void noNumSamples() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_no_num_samples.flac",
|
"flac/bear_no_num_samples.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_no_num_samples_flac").build(),
|
||||||
/* dumpFilesPrefix= */ "flac/bear_no_num_samples_flac");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uncommonSampleRate() throws Exception {
|
public void uncommonSampleRate() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
FlacExtractor::new,
|
FlacExtractor::new,
|
||||||
/* file= */ "flac/bear_uncommon_sample_rate.flac",
|
"flac/bear_uncommon_sample_rate.flac",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder()
|
||||||
/* dumpFilesPrefix= */ "flac/bear_uncommon_sample_rate_flac");
|
.setDumpFilesPrefix("flac/bear_uncommon_sample_rate_flac")
|
||||||
|
.build(),
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,10 @@ public final class FlvExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample() throws Exception {
|
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)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mkvSample() throws Exception {
|
public void mkvSample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/sample.mkv", assertionConfig);
|
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/sample.mkv", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mkvSample_withSubripSubtitles() throws Exception {
|
public void mkvSample_withSubripSubtitles() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
MatroskaExtractor::new, "mkv/sample_with_srt.mkv", assertionConfig);
|
MatroskaExtractor::new, "mkv/sample_with_srt.mkv", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mkvSample_withHtcRotationInfoInTrackName() throws Exception {
|
public void mkvSample_withHtcRotationInfoInTrackName() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
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
|
@Test
|
||||||
public void mkvFullBlocksSample() throws Exception {
|
public void mkvFullBlocksSample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/full_blocks.mkv", assertionConfig);
|
ExtractorAsserts.assertBehavior(
|
||||||
|
MatroskaExtractor::new, "mkv/full_blocks.mkv", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void webmSubsampleEncryption() throws Exception {
|
public void webmSubsampleEncryption() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
MatroskaExtractor::new, "mkv/subsample_encrypted_noaltref.webm", assertionConfig);
|
MatroskaExtractor::new, "mkv/subsample_encrypted_noaltref.webm", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void webmSubsampleEncryptionWithAltrefFrames() throws Exception {
|
public void webmSubsampleEncryptionWithAltrefFrames() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
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;
|
package com.google.android.exoplayer2.extractor.mp3;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
||||||
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -33,18 +34,18 @@ public final class Mp3ExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp3SampleWithXingHeader() throws Exception {
|
public void mp3SampleWithXingHeader() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
Mp3Extractor::new, "mp3/bear-vbr-xing-header.mp3", assertionConfig);
|
Mp3Extractor::new, "mp3/bear-vbr-xing-header.mp3", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp3SampleWithCbrSeeker() throws Exception {
|
public void mp3SampleWithCbrSeeker() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
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
|
@Test
|
||||||
@ -52,29 +53,29 @@ public final class Mp3ExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new Mp3Extractor(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING),
|
() -> new Mp3Extractor(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING),
|
||||||
"mp3/bear-vbr-no-seek-table.mp3",
|
"mp3/bear-vbr-no-seek-table.mp3",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void trimmedMp3Sample() throws Exception {
|
public void trimmedMp3Sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Mp3Extractor::new, "mp3/play-trimmed.mp3", assertionConfig);
|
ExtractorAsserts.assertBehavior(Mp3Extractor::new, "mp3/play-trimmed.mp3", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp3SampleWithId3Enabled() throws Exception {
|
public void mp3SampleWithId3Enabled() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
Mp3Extractor::new,
|
Mp3Extractor::new,
|
||||||
/* file= */ "mp3/bear-id3.mp3",
|
"mp3/bear-id3.mp3",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("mp3/bear-id3-enabled").build(),
|
||||||
/* dumpFilesPrefix= */ "mp3/bear-id3-enabled");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp3SampleWithId3Disabled() throws Exception {
|
public void mp3SampleWithId3Disabled() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new Mp3Extractor(Mp3Extractor.FLAG_DISABLE_ID3_METADATA),
|
() -> new Mp3Extractor(Mp3Extractor.FLAG_DISABLE_ID3_METADATA),
|
||||||
/* file= */ "mp3/bear-id3.mp3",
|
"mp3/bear-id3.mp3",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("mp3/bear-id3-disabled").build(),
|
||||||
/* dumpFilesPrefix= */ "mp3/bear-id3-disabled");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,12 @@ public final class FragmentedMp4ExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample() throws Exception {
|
public void sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()), "mp4/sample_fragmented.mp4", assertionConfig);
|
getExtractorFactory(ImmutableList.of()), "mp4/sample_fragmented.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -51,7 +51,7 @@ public final class FragmentedMp4ExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()),
|
getExtractorFactory(ImmutableList.of()),
|
||||||
"mp4/sample_fragmented_seekable.mp4",
|
"mp4/sample_fragmented_seekable.mp4",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -62,31 +62,33 @@ public final class FragmentedMp4ExtractorTest {
|
|||||||
Collections.singletonList(
|
Collections.singletonList(
|
||||||
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build()));
|
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build()));
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
extractorFactory, "mp4/sample_fragmented_sei.mp4", assertionConfig);
|
extractorFactory, "mp4/sample_fragmented_sei.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithAc3Track() throws Exception {
|
public void sampleWithAc3Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac3_fragmented.mp4", assertionConfig);
|
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac3_fragmented.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithAc4Track() throws Exception {
|
public void sampleWithAc4Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_fragmented.mp4", assertionConfig);
|
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_fragmented.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithProtectedAc4Track() throws Exception {
|
public void sampleWithProtectedAc4Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_protected.mp4", assertionConfig);
|
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_protected.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithEac3Track() throws Exception {
|
public void sampleWithEac3Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()), "mp4/sample_eac3_fragmented.mp4", assertionConfig);
|
getExtractorFactory(ImmutableList.of()),
|
||||||
|
"mp4/sample_eac3_fragmented.mp4",
|
||||||
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -94,7 +96,7 @@ public final class FragmentedMp4ExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
getExtractorFactory(ImmutableList.of()),
|
getExtractorFactory(ImmutableList.of()),
|
||||||
"mp4/sample_eac3joc_fragmented.mp4",
|
"mp4/sample_eac3joc_fragmented.mp4",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ExtractorFactory getExtractorFactory(final List<Format> closedCaptionFormats) {
|
private static ExtractorFactory getExtractorFactory(final List<Format> closedCaptionFormats) {
|
||||||
|
@ -33,17 +33,17 @@ public final class Mp4ExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp4Sample() throws Exception {
|
public void mp4Sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample.mp4", assertionConfig);
|
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp4SampleWithSlowMotionMetadata() throws Exception {
|
public void mp4SampleWithSlowMotionMetadata() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
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
|
@Test
|
||||||
public void mp4SampleWithMdatTooLong() throws Exception {
|
public void mp4SampleWithMdatTooLong() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4", assertionConfig);
|
Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp4SampleWithAc3Track() throws Exception {
|
public void mp4SampleWithAc3Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac3.mp4", assertionConfig);
|
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac3.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp4SampleWithAc4Track() throws Exception {
|
public void mp4SampleWithAc4Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4", assertionConfig);
|
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp4SampleWithEac3Track() throws Exception {
|
public void mp4SampleWithEac3Track() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3.mp4", assertionConfig);
|
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3.mp4", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mp4SampleWithEac3jocTrack() throws Exception {
|
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)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void opus() throws Exception {
|
public void opus() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear.opus", assertionConfig);
|
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear.opus", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void flac() throws Exception {
|
public void flac() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_flac.ogg", assertionConfig);
|
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_flac.ogg", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void flacNoSeektable() throws Exception {
|
public void flacNoSeektable() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
OggExtractor::new, "ogg/bear_flac_noseektable.ogg", assertionConfig);
|
OggExtractor::new, "ogg/bear_flac_noseektable.ogg", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void vorbis() throws Exception {
|
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)
|
@ParameterizedRobolectricTestRunner.Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rawCcSample() throws Exception {
|
public void rawCcSample() throws Exception {
|
||||||
@ -44,6 +44,6 @@ public final class RawCcExtractorTest {
|
|||||||
.setAccessibilityChannel(1)
|
.setAccessibilityChannel(1)
|
||||||
.build();
|
.build();
|
||||||
ExtractorAsserts.assertBehavior(
|
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)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ac3Sample() throws Exception {
|
public void ac3Sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.ac3", assertionConfig);
|
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.ac3", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void eAc3Sample() throws Exception {
|
public void eAc3Sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.eac3", assertionConfig);
|
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.eac3", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void eAc3jocSample() throws Exception {
|
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)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ac4Sample() throws Exception {
|
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)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample() throws Exception {
|
public void sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample.adts", assertionConfig);
|
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample.adts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample_with_id3() throws Exception {
|
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
|
@Test
|
||||||
@ -50,7 +51,7 @@ public final class AdtsExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
|
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
|
||||||
"ts/sample_cbs.adts",
|
"ts/sample_cbs.adts",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/google/ExoPlayer/issues/6700
|
// https://github.com/google/ExoPlayer/issues/6700
|
||||||
@ -59,6 +60,6 @@ public final class AdtsExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
|
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
|
||||||
"ts/sample_cbs_truncated.adts",
|
"ts/sample_cbs_truncated.adts",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,16 @@ public final class PsExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithH262AndMpegAudio() throws Exception {
|
public void sampleWithH262AndMpegAudio() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
PsExtractor::new, "ts/sample_h262_mpeg_audio.ps", assertionConfig);
|
PsExtractor::new, "ts/sample_h262_mpeg_audio.ps", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithAc3() throws Exception {
|
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.ParsableByteArray;
|
||||||
import com.google.android.exoplayer2.util.TimestampAdjuster;
|
import com.google.android.exoplayer2.util.TimestampAdjuster;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.ParameterizedRobolectricTestRunner;
|
import org.robolectric.ParameterizedRobolectricTestRunner;
|
||||||
@ -54,18 +53,18 @@ public final class TsExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parameter(0)
|
@Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithH262AndMpegAudio() throws Exception {
|
public void sampleWithH262AndMpegAudio() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
TsExtractor::new, "ts/sample_h262_mpeg_audio.ts", assertionConfig);
|
TsExtractor::new, "ts/sample_h262_mpeg_audio.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithH264AndMpegAudio() throws Exception {
|
public void sampleWithH264AndMpegAudio() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
TsExtractor::new, "ts/sample_h264_mpeg_audio.ts", assertionConfig);
|
TsExtractor::new, "ts/sample_h264_mpeg_audio.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -73,7 +72,7 @@ public final class TsExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new TsExtractor(FLAG_DETECT_ACCESS_UNITS),
|
() -> new TsExtractor(FLAG_DETECT_ACCESS_UNITS),
|
||||||
"ts/sample_h264_no_access_unit_delimiters.ts",
|
"ts/sample_h264_no_access_unit_delimiters.ts",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -81,58 +80,64 @@ public final class TsExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
() -> new TsExtractor(DefaultTsPayloadReaderFactory.FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS),
|
() -> new TsExtractor(DefaultTsPayloadReaderFactory.FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS),
|
||||||
"ts/sample_h264_dts_audio.ts",
|
"ts/sample_h264_dts_audio.ts",
|
||||||
assertionConfig);
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithH265() throws Exception {
|
public void sampleWithH265() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_h265.ts", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_h265.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
|
|
||||||
// formats and seeking.
|
|
||||||
public void sampleWithScte35() throws Exception {
|
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
|
@Test
|
||||||
@Ignore
|
|
||||||
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
|
|
||||||
// formats and seeking.
|
|
||||||
public void sampleWithAit() throws Exception {
|
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
|
@Test
|
||||||
public void sampleWithAc3() throws Exception {
|
public void sampleWithAc3() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac3.ts", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac3.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithAc4() throws Exception {
|
public void sampleWithAc4() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac4.ts", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac4.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithEac3() throws Exception {
|
public void sampleWithEac3() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3.ts", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithEac3joc() throws Exception {
|
public void sampleWithEac3joc() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3joc.ts", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3joc.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sampleWithLatm() throws Exception {
|
public void sampleWithLatm() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_latm.ts", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_latm.ts", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void streamWithJunkData() throws Exception {
|
public void streamWithJunkData() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_with_junk", assertionConfig);
|
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_with_junk", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.google.android.exoplayer2.extractor.wav;
|
package com.google.android.exoplayer2.extractor.wav;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
||||||
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -31,11 +32,11 @@ public final class WavExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedRobolectricTestRunner.Parameter(0)
|
@ParameterizedRobolectricTestRunner.Parameter(0)
|
||||||
public ExtractorAsserts.Config assertionConfig;
|
public ExtractorAsserts.SimulationConfig simulationConfig;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample() throws Exception {
|
public void sample() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample.wav", assertionConfig);
|
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample.wav", simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -43,12 +44,13 @@ public final class WavExtractorTest {
|
|||||||
ExtractorAsserts.assertBehavior(
|
ExtractorAsserts.assertBehavior(
|
||||||
WavExtractor::new,
|
WavExtractor::new,
|
||||||
"wav/sample_with_trailing_bytes.wav",
|
"wav/sample_with_trailing_bytes.wav",
|
||||||
assertionConfig,
|
new AssertionConfig.Builder().setDumpFilesPrefix("wav/sample.wav").build(),
|
||||||
/* dumpFilesPrefix= */ "wav/sample.wav");
|
simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sample_imaAdpcm() throws Exception {
|
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
|
sample count = 3
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = application/x-scte35
|
sampleMimeType = application/x-scte35
|
||||||
subsampleOffsetUs = -1400000
|
subsampleOffsetUs = -1377756
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 55610
|
time = 55610
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -55,7 +55,7 @@ track 600:
|
|||||||
sample count = 3
|
sample count = 3
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = application/x-scte35
|
sampleMimeType = application/x-scte35
|
||||||
subsampleOffsetUs = -1400000
|
subsampleOffsetUs = -1355512
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 77854
|
time = 77854
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -39,7 +39,7 @@ track 600:
|
|||||||
sample count = 0
|
sample count = 0
|
||||||
format 0:
|
format 0:
|
||||||
sampleMimeType = application/x-scte35
|
sampleMimeType = application/x-scte35
|
||||||
subsampleOffsetUs = -1400000
|
subsampleOffsetUs = -1355512
|
||||||
track 8448:
|
track 8448:
|
||||||
total output bytes = 0
|
total output bytes = 0
|
||||||
sample count = 0
|
sample count = 0
|
||||||
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.testutil;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
@ -31,6 +32,7 @@ import com.google.android.exoplayer2.util.Util;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assertion methods for {@link Extractor}.
|
* Assertion methods for {@link Extractor}.
|
||||||
@ -38,27 +40,27 @@ import java.util.List;
|
|||||||
public final class ExtractorAsserts {
|
public final class ExtractorAsserts {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of arrays containing {@link Config} objects to exercise different extractor
|
* Returns a list of arrays containing {@link SimulationConfig} objects to exercise different
|
||||||
* paths.
|
* extractor paths.
|
||||||
*
|
*
|
||||||
* <p>This is intended to be used from tests using {@code ParameterizedRobolectricTestRunner} or
|
* <p>This is intended to be used from tests using {@code ParameterizedRobolectricTestRunner} or
|
||||||
* {@code org.junit.runners.Parameterized}.
|
* {@code org.junit.runners.Parameterized}.
|
||||||
*/
|
*/
|
||||||
public static List<Object[]> configs() {
|
public static List<Object[]> configs() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[] {new Config(true, false, false, false)},
|
new Object[] {new SimulationConfig(true, false, false, false)},
|
||||||
new Object[] {new Config(true, false, false, true)},
|
new Object[] {new SimulationConfig(true, false, false, true)},
|
||||||
new Object[] {new Config(true, false, true, false)},
|
new Object[] {new SimulationConfig(true, false, true, false)},
|
||||||
new Object[] {new Config(true, false, true, true)},
|
new Object[] {new SimulationConfig(true, false, true, true)},
|
||||||
new Object[] {new Config(true, true, false, false)},
|
new Object[] {new SimulationConfig(true, true, false, false)},
|
||||||
new Object[] {new Config(true, true, false, true)},
|
new Object[] {new SimulationConfig(true, true, false, true)},
|
||||||
new Object[] {new Config(true, true, true, false)},
|
new Object[] {new SimulationConfig(true, true, true, false)},
|
||||||
new Object[] {new Config(true, true, true, true)},
|
new Object[] {new SimulationConfig(true, true, true, true)},
|
||||||
new Object[] {new Config(false, false, false, false)});
|
new Object[] {new SimulationConfig(false, false, false, false)});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A config of different environments to simulate and extractor behaviour to test. */
|
/** A config of different environments to simulate and extractor behaviours to test. */
|
||||||
public static class Config {
|
public static class SimulationConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to sniff the data by calling {@link Extractor#sniff(ExtractorInput)} prior to
|
* Whether to sniff the data by calling {@link Extractor#sniff(ExtractorInput)} prior to
|
||||||
@ -72,7 +74,7 @@ public final class ExtractorAsserts {
|
|||||||
/** Whether to simulate partial reads. */
|
/** Whether to simulate partial reads. */
|
||||||
public final boolean simulatePartialReads;
|
public final boolean simulatePartialReads;
|
||||||
|
|
||||||
private Config(
|
private SimulationConfig(
|
||||||
boolean sniffFirst,
|
boolean sniffFirst,
|
||||||
boolean simulateIOErrors,
|
boolean simulateIOErrors,
|
||||||
boolean simulateUnknownLength,
|
boolean simulateUnknownLength,
|
||||||
@ -91,6 +93,49 @@ public final class ExtractorAsserts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A config for the assertions made (e.g. dump file location). */
|
||||||
|
public static class AssertionConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The prefix prepended to the dump files path. If not set, the path to the source data will be
|
||||||
|
* used.
|
||||||
|
*/
|
||||||
|
@Nullable public final String dumpFilesPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls how consecutive formats with no intervening samples are handled. If true, only the
|
||||||
|
* last format received is retained. If false, consecutive formats with no samples cause the
|
||||||
|
* test to fail.
|
||||||
|
*/
|
||||||
|
public final boolean deduplicateConsecutiveFormats;
|
||||||
|
|
||||||
|
private AssertionConfig(
|
||||||
|
@Nullable String dumpFilesPrefix, boolean deduplicateConsecutiveFormats) {
|
||||||
|
this.dumpFilesPrefix = dumpFilesPrefix;
|
||||||
|
this.deduplicateConsecutiveFormats = deduplicateConsecutiveFormats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for {@link AssertionConfig} instances. */
|
||||||
|
public static class Builder {
|
||||||
|
private @MonotonicNonNull String dumpFilesPrefix;
|
||||||
|
private boolean deduplicateConsecutiveFormats;
|
||||||
|
|
||||||
|
public Builder setDumpFilesPrefix(String dumpFilesPrefix) {
|
||||||
|
this.dumpFilesPrefix = dumpFilesPrefix;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDeduplicateConsecutiveFormats(boolean deduplicateConsecutiveFormats) {
|
||||||
|
this.deduplicateConsecutiveFormats = deduplicateConsecutiveFormats;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssertionConfig build() {
|
||||||
|
return new AssertionConfig(dumpFilesPrefix, deduplicateConsecutiveFormats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** A factory for {@link Extractor} instances. */
|
/** A factory for {@link Extractor} instances. */
|
||||||
public interface ExtractorFactory {
|
public interface ExtractorFactory {
|
||||||
Extractor create();
|
Extractor create();
|
||||||
@ -127,7 +172,7 @@ public final class ExtractorAsserts {
|
|||||||
* <li>Calls {@link Extractor#seek(long, long)} and {@link Extractor#release()} without calling
|
* <li>Calls {@link Extractor#seek(long, long)} and {@link Extractor#release()} without calling
|
||||||
* {@link Extractor#init(ExtractorOutput)} to check these calls do not fail.
|
* {@link Extractor#init(ExtractorOutput)} to check these calls do not fail.
|
||||||
* <li>Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
|
* <li>Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
|
||||||
* boolean)} with all possible combinations of "simulate" parameters.
|
* boolean, boolean)} with all possible combinations of "simulate" parameters.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
||||||
@ -146,7 +191,7 @@ public final class ExtractorAsserts {
|
|||||||
* <li>Calls {@link Extractor#seek(long, long)} and {@link Extractor#release()} without calling
|
* <li>Calls {@link Extractor#seek(long, long)} and {@link Extractor#release()} without calling
|
||||||
* {@link Extractor#init(ExtractorOutput)} to check these calls do not fail.
|
* {@link Extractor#init(ExtractorOutput)} to check these calls do not fail.
|
||||||
* <li>Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
|
* <li>Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
|
||||||
* boolean)} with all possible combinations of "simulate" parameters.
|
* boolean, boolean)} with all possible combinations of "simulate" parameters.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
||||||
@ -169,7 +214,7 @@ public final class ExtractorAsserts {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that an extractor consumes valid input data successfully under the conditions specified
|
* Asserts that an extractor consumes valid input data successfully under the conditions specified
|
||||||
* by {@code config}.
|
* by {@code simulationConfig}.
|
||||||
*
|
*
|
||||||
* <p>The output of the extractor is compared against prerecorded dump files whose names are
|
* <p>The output of the extractor is compared against prerecorded dump files whose names are
|
||||||
* derived from the {@code file} parameter.
|
* derived from the {@code file} parameter.
|
||||||
@ -177,29 +222,29 @@ public final class ExtractorAsserts {
|
|||||||
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
||||||
* class which is to be tested.
|
* class which is to be tested.
|
||||||
* @param file The path to the input sample.
|
* @param file The path to the input sample.
|
||||||
* @param config Details on the environment to simulate and behaviours to assert.
|
* @param simulationConfig Details on the environment to simulate and behaviours to assert.
|
||||||
* @throws IOException If reading from the input fails.
|
* @throws IOException If reading from the input fails.
|
||||||
*/
|
*/
|
||||||
public static void assertBehavior(ExtractorFactory factory, String file, Config config)
|
public static void assertBehavior(
|
||||||
throws IOException {
|
ExtractorFactory factory, String file, SimulationConfig simulationConfig) throws IOException {
|
||||||
assertBehavior(factory, file, config, file);
|
assertBehavior(factory, file, new AssertionConfig.Builder().build(), simulationConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that an extractor consumes valid input data successfully successfully under the
|
* Asserts that an extractor consumes valid input data successfully successfully under the
|
||||||
* conditions specified by {@code config}.
|
* conditions specified by {@code simulationConfig}.
|
||||||
*
|
*
|
||||||
* <p>The output of the extractor is compared against prerecorded dump files.
|
* <p>The output of the extractor is compared against prerecorded dump files.
|
||||||
*
|
*
|
||||||
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
* @param assertionConfig Details of how to read and process the source and dump files.
|
||||||
* class which is to be tested.
|
* @param simulationConfig Details on the environment to simulate and behaviours to assert.
|
||||||
* @param file The path to the input sample.
|
|
||||||
* @param config Details on the environment to simulate and behaviours to assert.
|
|
||||||
* @param dumpFilesPrefix The dump files prefix prepended to the dump files path.
|
|
||||||
* @throws IOException If reading from the input fails.
|
* @throws IOException If reading from the input fails.
|
||||||
*/
|
*/
|
||||||
public static void assertBehavior(
|
public static void assertBehavior(
|
||||||
ExtractorFactory factory, String file, Config config, String dumpFilesPrefix)
|
ExtractorFactory factory,
|
||||||
|
String file,
|
||||||
|
AssertionConfig assertionConfig,
|
||||||
|
SimulationConfig simulationConfig)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// Check behavior prior to initialization.
|
// Check behavior prior to initialization.
|
||||||
Extractor extractor = factory.create();
|
Extractor extractor = factory.create();
|
||||||
@ -208,22 +253,25 @@ public final class ExtractorAsserts {
|
|||||||
// Assert output.
|
// Assert output.
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
byte[] fileData = TestUtil.getByteArray(context, file);
|
byte[] fileData = TestUtil.getByteArray(context, file);
|
||||||
|
String dumpFilesPrefix =
|
||||||
|
assertionConfig.dumpFilesPrefix != null ? assertionConfig.dumpFilesPrefix : file;
|
||||||
assertOutput(
|
assertOutput(
|
||||||
factory.create(),
|
factory.create(),
|
||||||
dumpFilesPrefix,
|
dumpFilesPrefix,
|
||||||
fileData,
|
fileData,
|
||||||
context,
|
context,
|
||||||
config.sniffFirst,
|
assertionConfig.deduplicateConsecutiveFormats,
|
||||||
config.simulateIOErrors,
|
simulationConfig.sniffFirst,
|
||||||
config.simulateUnknownLength,
|
simulationConfig.simulateIOErrors,
|
||||||
config.simulatePartialReads);
|
simulationConfig.simulateUnknownLength,
|
||||||
|
simulationConfig.simulatePartialReads);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
|
* Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
|
||||||
* boolean)} with all possible combinations of "simulate" parameters with {@code sniffFirst} set
|
* boolean, boolean)} with all possible combinations of "simulate" parameters with {@code
|
||||||
* to true, and makes one additional call with the "simulate" and {@code sniffFirst} parameters
|
* sniffFirst} set to true, and makes one additional call with the "simulate" and {@code
|
||||||
* all set to false.
|
* sniffFirst} parameters all set to false.
|
||||||
*
|
*
|
||||||
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
||||||
* class which is to be tested.
|
* class which is to be tested.
|
||||||
@ -235,15 +283,17 @@ public final class ExtractorAsserts {
|
|||||||
private static void assertOutput(
|
private static void assertOutput(
|
||||||
ExtractorFactory factory, String dumpFilesPrefix, byte[] data, Context context)
|
ExtractorFactory factory, String dumpFilesPrefix, byte[] data, Context context)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, false, false, false);
|
assertOutput(
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, false, false, true);
|
factory.create(), dumpFilesPrefix, data, context, false, true, false, false, false);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, false, true, false);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, false, false, true);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, false, true, true);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, false, true, false);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, true, false, false);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, false, true, true);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, true, false, true);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, true, false, false);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, true, true, false);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, true, false, true);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, true, true, true, true);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, true, true, false);
|
||||||
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, false, false, false);
|
assertOutput(factory.create(), dumpFilesPrefix, data, context, false, true, true, true, true);
|
||||||
|
assertOutput(
|
||||||
|
factory.create(), dumpFilesPrefix, data, context, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,6 +317,7 @@ public final class ExtractorAsserts {
|
|||||||
String dumpFilesPrefix,
|
String dumpFilesPrefix,
|
||||||
byte[] data,
|
byte[] data,
|
||||||
Context context,
|
Context context,
|
||||||
|
boolean deduplicateConsecutiveFormats,
|
||||||
boolean sniffFirst,
|
boolean sniffFirst,
|
||||||
boolean simulateIOErrors,
|
boolean simulateIOErrors,
|
||||||
boolean simulateUnknownLength,
|
boolean simulateUnknownLength,
|
||||||
@ -282,7 +333,8 @@ public final class ExtractorAsserts {
|
|||||||
input.resetPeekPosition();
|
input.resetPeekPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeExtractorOutput extractorOutput = consumeTestData(extractor, input, 0, true);
|
FakeExtractorOutput extractorOutput =
|
||||||
|
consumeTestData(extractor, input, 0, true, deduplicateConsecutiveFormats);
|
||||||
if (simulateUnknownLength) {
|
if (simulateUnknownLength) {
|
||||||
extractorOutput.assertOutput(context, dumpFilesPrefix + UNKNOWN_LENGTH_EXTENSION);
|
extractorOutput.assertOutput(context, dumpFilesPrefix + UNKNOWN_LENGTH_EXTENSION);
|
||||||
} else {
|
} else {
|
||||||
@ -323,9 +375,14 @@ public final class ExtractorAsserts {
|
|||||||
private ExtractorAsserts() {}
|
private ExtractorAsserts() {}
|
||||||
|
|
||||||
private static FakeExtractorOutput consumeTestData(
|
private static FakeExtractorOutput consumeTestData(
|
||||||
Extractor extractor, FakeExtractorInput input, long timeUs, boolean retryFromStartIfLive)
|
Extractor extractor,
|
||||||
|
FakeExtractorInput input,
|
||||||
|
long timeUs,
|
||||||
|
boolean retryFromStartIfLive,
|
||||||
|
boolean deduplicateConsecutiveFormats)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
FakeExtractorOutput output = new FakeExtractorOutput();
|
FakeExtractorOutput output =
|
||||||
|
new FakeExtractorOutput((id, type) -> new FakeTrackOutput(deduplicateConsecutiveFormats));
|
||||||
extractor.init(output);
|
extractor.init(output);
|
||||||
consumeTestData(extractor, input, timeUs, output, retryFromStartIfLive);
|
consumeTestData(extractor, input, timeUs, output, retryFromStartIfLive);
|
||||||
return output;
|
return output;
|
||||||
|
@ -68,12 +68,18 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
|
|||||||
@DumpFilesAction private static final int DUMP_FILE_ACTION = COMPARE_WITH_EXISTING;
|
@DumpFilesAction private static final int DUMP_FILE_ACTION = COMPARE_WITH_EXISTING;
|
||||||
|
|
||||||
public final SparseArray<FakeTrackOutput> trackOutputs;
|
public final SparseArray<FakeTrackOutput> trackOutputs;
|
||||||
|
private final FakeTrackOutput.Factory trackOutputFactory;
|
||||||
|
|
||||||
public int numberOfTracks;
|
public int numberOfTracks;
|
||||||
public boolean tracksEnded;
|
public boolean tracksEnded;
|
||||||
public @MonotonicNonNull SeekMap seekMap;
|
public @MonotonicNonNull SeekMap seekMap;
|
||||||
|
|
||||||
public FakeExtractorOutput() {
|
public FakeExtractorOutput() {
|
||||||
|
this(FakeTrackOutput.DEFAULT_FACTORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeExtractorOutput(FakeTrackOutput.Factory trackOutputFactory) {
|
||||||
|
this.trackOutputFactory = trackOutputFactory;
|
||||||
trackOutputs = new SparseArray<>();
|
trackOutputs = new SparseArray<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +89,7 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
|
|||||||
if (output == null) {
|
if (output == null) {
|
||||||
assertThat(tracksEnded).isFalse();
|
assertThat(tracksEnded).isFalse();
|
||||||
numberOfTracks++;
|
numberOfTracks++;
|
||||||
output = new FakeTrackOutput();
|
output = trackOutputFactory.create(id, type);
|
||||||
trackOutputs.put(id, output);
|
trackOutputs.put(id, output);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
@ -35,11 +35,18 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||||
|
|
||||||
/**
|
/** A fake {@link TrackOutput}. */
|
||||||
* A fake {@link TrackOutput}.
|
|
||||||
*/
|
|
||||||
public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
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<DumpableSampleInfo> sampleInfos;
|
||||||
private final ArrayList<Dumpable> dumpables;
|
private final ArrayList<Dumpable> dumpables;
|
||||||
|
|
||||||
@ -49,7 +56,8 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||||||
|
|
||||||
@Nullable public Format lastFormat;
|
@Nullable public Format lastFormat;
|
||||||
|
|
||||||
public FakeTrackOutput() {
|
public FakeTrackOutput(boolean deduplicateConsecutiveFormats) {
|
||||||
|
this.deduplicateConsecutiveFormats = deduplicateConsecutiveFormats;
|
||||||
sampleInfos = new ArrayList<>();
|
sampleInfos = new ArrayList<>();
|
||||||
dumpables = new ArrayList<>();
|
dumpables = new ArrayList<>();
|
||||||
sampleData = Util.EMPTY_BYTE_ARRAY;
|
sampleData = Util.EMPTY_BYTE_ARRAY;
|
||||||
@ -67,9 +75,19 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void format(Format format) {
|
public void format(Format format) {
|
||||||
Assertions.checkState(
|
if (!deduplicateConsecutiveFormats) {
|
||||||
receivedSampleInFormat,
|
Assertions.checkState(
|
||||||
"TrackOutput must receive at least one sampleMetadata() call between format() calls.");
|
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;
|
receivedSampleInFormat = false;
|
||||||
addFormat(format);
|
addFormat(format);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user