use of com.google.android.exoplayer2.extractor.FlacStreamMetadata in project ExoPlayer by google.
the class FlacFrameReaderTest method checkFrameHeaderFromPeek_invalidData_isFalse.
@Test
public void checkFrameHeaderFromPeek_invalidData_isFalse() throws Exception {
FlacStreamMetadataHolder streamMetadataHolder = new FlacStreamMetadataHolder(/* flacStreamMetadata= */
null);
ExtractorInput input = buildExtractorInputReadingFromFirstFrame("media/flac/bear_one_metadata_block.flac", streamMetadataHolder);
// The first bytes of the frame are not equal to the frame start marker.
boolean result = FlacFrameReader.checkFrameHeaderFromPeek(input, streamMetadataHolder.flacStreamMetadata, /* frameStartMarker= */
-1, new SampleNumberHolder());
assertThat(result).isFalse();
}
use of com.google.android.exoplayer2.extractor.FlacStreamMetadata in project ExoPlayer by google.
the class FlacFrameReaderTest method checkAndReadFrameHeader_validData_writesSampleNumber.
@Test
public void checkAndReadFrameHeader_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);
ParsableByteArray scratch = new ParsableByteArray(FlacConstants.MAX_FRAME_HEADER_SIZE);
input.read(scratch.getData(), 0, FlacConstants.MAX_FRAME_HEADER_SIZE);
SampleNumberHolder sampleNumberHolder = new SampleNumberHolder();
FlacFrameReader.checkAndReadFrameHeader(scratch, streamMetadataHolder.flacStreamMetadata, frameStartMarker, sampleNumberHolder);
assertThat(sampleNumberHolder.sampleNumber).isEqualTo(4096);
}
use of com.google.android.exoplayer2.extractor.FlacStreamMetadata in project ExoPlayer by google.
the class FlacReader method readHeaders.
@Override
@EnsuresNonNullIf(expression = "#3.format", result = false)
protected boolean readHeaders(ParsableByteArray packet, long position, SetupData setupData) {
byte[] data = packet.getData();
@Nullable FlacStreamMetadata streamMetadata = this.streamMetadata;
if (streamMetadata == null) {
streamMetadata = new FlacStreamMetadata(data, 17);
this.streamMetadata = streamMetadata;
byte[] metadata = Arrays.copyOfRange(data, 9, packet.limit());
setupData.format = streamMetadata.getFormat(metadata, /* id3Metadata= */
null);
return true;
}
if ((data[0] & 0x7F) == FlacConstants.METADATA_TYPE_SEEK_TABLE) {
SeekTable seekTable = FlacMetadataReader.readSeekTableMetadataBlock(packet);
streamMetadata = streamMetadata.copyWithSeekTable(seekTable);
this.streamMetadata = streamMetadata;
flacOggSeeker = new FlacOggSeeker(streamMetadata, seekTable);
return true;
}
if (isAudioPacket(data)) {
if (flacOggSeeker != null) {
flacOggSeeker.setFirstFrameOffset(position);
setupData.oggSeeker = flacOggSeeker;
}
checkNotNull(setupData.format);
return false;
}
return true;
}
Aggregations