use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder 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.FlacMetadataReader.FlacStreamMetadataHolder in project ExoPlayer by google.
the class FlacFrameReaderTest method buildExtractorInputReadingFromFirstFrame.
private ExtractorInput buildExtractorInputReadingFromFirstFrame(String file, FlacStreamMetadataHolder streamMetadataHolder) throws IOException {
ExtractorInput input = buildExtractorInput(file);
input.skipFully(FlacConstants.STREAM_MARKER_SIZE);
boolean lastMetadataBlock = false;
while (!lastMetadataBlock) {
lastMetadataBlock = FlacMetadataReader.readMetadataBlock(input, streamMetadataHolder);
}
return input;
}
use of com.google.android.exoplayer2.extractor.FlacMetadataReader.FlacStreamMetadataHolder 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.FlacMetadataReader.FlacStreamMetadataHolder 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.FlacMetadataReader.FlacStreamMetadataHolder 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