Search in sources :

Example 21 with FlacStreamMetadata

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

the class FlacMetadataReaderTest method readMetadataBlock_notLastMetadataBlock_isFalse.

@Test
public void readMetadataBlock_notLastMetadataBlock_isFalse() throws Exception {
    ExtractorInput input = buildExtractorInput("media/flac/bear.flac");
    input.skipFully(FlacConstants.STREAM_MARKER_SIZE);
    boolean result = FlacMetadataReader.readMetadataBlock(input, new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null));
    assertThat(result).isFalse();
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 22 with FlacStreamMetadata

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

the class FlacFrameReaderTest method getFirstSampleNumber_returnsSampleNumber.

@Test
public void getFirstSampleNumber_returnsSampleNumber() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    // Skip first frame.
    input.skip(5030);
    long result = FlacFrameReader.getFirstSampleNumber(input, streamMetadataHolder.flacStreamMetadata);
    assertThat(result).isEqualTo(4096);
}
Also used : FlacStreamMetadataHolder(com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 23 with FlacStreamMetadata

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

the class FlacFrameReaderTest method checkFrameHeaderFromPeek_validData_writesSampleNumber.

@Test
public void checkFrameHeaderFromPeek_validData_writesSampleNumber() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    int frameStartMarker = FlacMetadataReader.getFrameStartMarker(input);
    // Skip first frame.
    input.skip(5030);
    SampleNumberHolder sampleNumberHolder = new SampleNumberHolder();
    FlacFrameReader.checkFrameHeaderFromPeek(input, streamMetadataHolder.flacStreamMetadata, frameStartMarker, sampleNumberHolder);
    assertThat(sampleNumberHolder.sampleNumber).isEqualTo(4096);
}
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 24 with FlacStreamMetadata

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

the class FlacFrameReaderTest method checkFrameHeaderFromPeek_invalidData_doesNotUpdatePositions.

@Test
public void checkFrameHeaderFromPeek_invalidData_doesNotUpdatePositions() throws Exception {
    String file = "media/flac/bear_one_metadata_block.flac";
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame(file, streamMetadataHolder);
    long peekPosition = input.getPosition();
    // Set read position to 0.
    input = buildExtractorInput(file);
    input.advancePeekPosition((int) peekPosition);
    // The first bytes of the frame are not equal to the frame start marker.
    FlacFrameReader.checkFrameHeaderFromPeek(input, streamMetadataHolder.flacStreamMetadata, /* frameStartMarker= */
    -1, new SampleNumberHolder());
    assertThat(input.getPosition()).isEqualTo(0);
    assertThat(input.getPeekPosition()).isEqualTo(peekPosition);
}
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 25 with FlacStreamMetadata

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

the class FlacFrameReaderTest method getFirstSampleNumber_doesNotUpdateReadPositionAndAlignsPeekPosition.

@Test
public void getFirstSampleNumber_doesNotUpdateReadPositionAndAlignsPeekPosition() throws Exception {
    FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
    null);
    ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
    long initialReadPosition = input.getPosition();
    // Advance peek position after block size bits.
    input.advancePeekPosition(FlacConstants.MAX_FRAME_HEADER_SIZE);
    FlacFrameReader.getFirstSampleNumber(input, streamMetadataHolder.flacStreamMetadata);
    assertThat(input.getPosition()).isEqualTo(initialReadPosition);
    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)

Aggregations

Test (org.junit.Test)20 FlacStreamMetadataHolder (com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder)16 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)16 SampleNumberHolder (com.google.android.exoplayer2.extractor.FlacFrameReader.SampleNumberHolder)9 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)7 Metadata (com.google.android.exoplayer2.metadata.Metadata)5 Nullable (androidx.annotation.Nullable)4 ArrayList (java.util.ArrayList)4 FlacStreamMetadata (com.google.android.exoplayer2.extractor.FlacStreamMetadata)3 VorbisComment (com.google.android.exoplayer2.metadata.vorbis.VorbisComment)3 Format (com.google.android.exoplayer2.Format)2 OutputFrameHolder (com.google.android.exoplayer2.ext.flac.FlacBinarySearchSeeker.OutputFrameHolder)1 SeekTable (com.google.android.exoplayer2.extractor.FlacStreamMetadata.SeekTable)1 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)1 PictureFrame (com.google.android.exoplayer2.metadata.flac.PictureFrame)1 ParsableBitArray (com.google.android.exoplayer2.util.ParsableBitArray)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 List (java.util.List)1 EnsuresNonNull (org.checkerframework.checker.nullness.qual.EnsuresNonNull)1