use of androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.
the class FlacMetadataReaderTest method readMetadataBlock_streamInfoBlock_setsStreamMetadata.
@Test
public void readMetadataBlock_streamInfoBlock_setsStreamMetadata() throws Exception {
ExtractorInput input = buildExtractorInput("media/flac/bear.flac");
input.skipFully(FlacConstants.STREAM_MARKER_SIZE);
FlacStreamMetadataHolder metadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
null);
FlacMetadataReader.readMetadataBlock(input, metadataHolder);
assertThat(metadataHolder.flacStreamMetadata).isNotNull();
assertThat(metadataHolder.flacStreamMetadata.sampleRate).isEqualTo(48000);
}
use of androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.
the class FlacMetadataReaderTest method readMetadataBlock_updatesReadPositionAndAlignsPeekPosition.
@Test
public void readMetadataBlock_updatesReadPositionAndAlignsPeekPosition() throws Exception {
ExtractorInput input = buildExtractorInput("media/flac/bear.flac");
input.skipFully(FlacConstants.STREAM_MARKER_SIZE);
// Advance peek position after metadata block.
input.advancePeekPosition(FlacConstants.STREAM_INFO_BLOCK_SIZE + 1);
FlacMetadataReader.readMetadataBlock(input, new FlacStreamMetadataHolder(/* flacStreamMetadata= */
null));
assertThat(input.getPosition()).isNotEqualTo(0);
assertThat(input.getPeekPosition()).isEqualTo(input.getPosition());
}
use of androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.
the class FlacMetadataReaderTest method readMetadataBlock_nonStreamInfoBlockWithNullStreamMetadata_throwsException.
@Test
public void readMetadataBlock_nonStreamInfoBlockWithNullStreamMetadata_throwsException() throws Exception {
ExtractorInput input = buildExtractorInput("media/flac/bear.flac");
// Skip to seek table block.
input.skipFully(FlacConstants.STREAM_MARKER_SIZE + FlacConstants.STREAM_INFO_BLOCK_SIZE);
assertThrows(IllegalArgumentException.class, () -> FlacMetadataReader.readMetadataBlock(input, new FlacStreamMetadataHolder(/* flacStreamMetadata= */
null)));
}
use of androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.
the class FlacMetadataReaderTest method readMetadataBlock_lastMetadataBlock_isTrue.
@Test
public void readMetadataBlock_lastMetadataBlock_isTrue() throws Exception {
ExtractorInput input = buildExtractorInput("media/flac/bear_one_metadata_block.flac");
input.skipFully(FlacConstants.STREAM_MARKER_SIZE);
boolean result = FlacMetadataReader.readMetadataBlock(input, new FlacStreamMetadataHolder(/* flacStreamMetadata= */
null));
assertThat(result).isTrue();
}
use of androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.
the class FlacMetadataReaderTest method readMetadataBlock_seekTableBlock_updatesStreamMetadata.
@Test
public void readMetadataBlock_seekTableBlock_updatesStreamMetadata() throws Exception {
ExtractorInput input = buildExtractorInput("media/flac/bear.flac");
// Skip to seek table block.
input.skipFully(FlacConstants.STREAM_MARKER_SIZE + FlacConstants.STREAM_INFO_BLOCK_SIZE);
FlacStreamMetadataHolder metadataHolder = new FlacStreamMetadataHolder(buildStreamMetadata());
long originalSampleRate = metadataHolder.flacStreamMetadata.sampleRate;
FlacMetadataReader.readMetadataBlock(input, metadataHolder);
assertThat(metadataHolder.flacStreamMetadata).isNotNull();
// Check that metadata passed has not been erased.
assertThat(metadataHolder.flacStreamMetadata.sampleRate).isEqualTo(originalSampleRate);
assertThat(metadataHolder.flacStreamMetadata.seekTable).isNotNull();
assertThat(metadataHolder.flacStreamMetadata.seekTable.pointSampleNumbers.length).isEqualTo(32);
}
Aggregations