Search in sources :

Example 1 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.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);
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 2 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.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());
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 3 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.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)));
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 4 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.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();
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 5 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.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);
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Aggregations

FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)21 FlacStreamMetadataHolder (com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder)20 Test (org.junit.Test)20 SampleNumberHolder (com.google.android.exoplayer2.extractor.FlacFrameReader.SampleNumberHolder)9 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)5 Metadata (com.google.android.exoplayer2.metadata.Metadata)2 PictureFrame (com.google.android.exoplayer2.metadata.flac.PictureFrame)2 Nullable (androidx.annotation.Nullable)1 VorbisComment (com.google.android.exoplayer2.metadata.vorbis.VorbisComment)1 ParsableBitArray (com.google.android.exoplayer2.util.ParsableBitArray)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1