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();
}
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);
}
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);
}
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);
}
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());
}
Aggregations