Search in sources :

Example 6 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.

the class FlacMetadataReaderTest method readMetadataBlock_blockToSkip_updatesReadPosition.

@Test
public void readMetadataBlock_blockToSkip_updatesReadPosition() throws Exception {
    ExtractorInput input = buildExtractorInput("media/flac/bear.flac");
    // Skip to padding block.
    input.skipFully(640);
    FlacStreamMetadataHolder metadataHolder = new FlacStreamMetadataHolder(buildStreamMetadata());
    FlacMetadataReader.readMetadataBlock(input, metadataHolder);
    assertThat(input.getPosition()).isGreaterThan(640);
    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 7 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.

the class FlacFrameReaderTest method checkAndReadFrameHeader_validData_isTrue.

@Test
public void checkAndReadFrameHeader_validData_isTrue() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    int frameStartMarker = FlacMetadataReader.getFrameStartMarker(input);
    ParsableByteArray scratch = new ParsableByteArray(FlacConstants.MAX_FRAME_HEADER_SIZE);
    input.read(scratch.getData(), 0, FlacConstants.MAX_FRAME_HEADER_SIZE);
    boolean result = FlacFrameReader.checkAndReadFrameHeader(scratch, streamMetadataHolder.flacStreamMetadata, frameStartMarker, new SampleNumberHolder());
    assertThat(result).isTrue();
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) SampleNumberHolder(com.google.android.exoplayer2.extractor.FlacFrameReader.SampleNumberHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 8 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.

the class FlacFrameReaderTest method checkFrameHeaderFromPeek_validData_isTrue.

@Test
public void checkFrameHeaderFromPeek_validData_isTrue() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    int frameStartMarker = FlacMetadataReader.getFrameStartMarker(input);
    boolean result = FlacFrameReader.checkFrameHeaderFromPeek(input, streamMetadataHolder.flacStreamMetadata, frameStartMarker, new SampleNumberHolder());
    assertThat(result).isTrue();
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) SampleNumberHolder(com.google.android.exoplayer2.extractor.FlacFrameReader.SampleNumberHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 9 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.

the class FlacFrameReaderTest method checkAndReadFrameHeader_invalidData_isFalse.

@Test
public void checkAndReadFrameHeader_invalidData_isFalse() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    ParsableByteArray scratch = new ParsableByteArray(FlacConstants.MAX_FRAME_HEADER_SIZE);
    input.read(scratch.getData(), 0, FlacConstants.MAX_FRAME_HEADER_SIZE);
    // The first bytes of the frame are not equal to the frame start marker.
    boolean result = FlacFrameReader.checkAndReadFrameHeader(scratch, streamMetadataHolder.flacStreamMetadata, /* frameStartMarker= */
    -1, new SampleNumberHolder());
    assertThat(result).isFalse();
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) SampleNumberHolder(com.google.android.exoplayer2.extractor.FlacFrameReader.SampleNumberHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 10 with FlacStreamMetadataHolder

use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.

the class FlacFrameReaderTest method checkAndReadFrameHeader_validData_updatesPosition.

@Test
public void checkAndReadFrameHeader_validData_updatesPosition() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    int frameStartMarker = FlacMetadataReader.getFrameStartMarker(input);
    ParsableByteArray scratch = new ParsableByteArray(FlacConstants.MAX_FRAME_HEADER_SIZE);
    input.read(scratch.getData(), 0, FlacConstants.MAX_FRAME_HEADER_SIZE);
    FlacFrameReader.checkAndReadFrameHeader(scratch, streamMetadataHolder.flacStreamMetadata, frameStartMarker, new SampleNumberHolder());
    assertThat(scratch.getPosition()).isEqualTo(FlacConstants.MIN_FRAME_HEADER_SIZE);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) SampleNumberHolder(com.google.android.exoplayer2.extractor.FlacFrameReader.SampleNumberHolder) 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