use of androidx.media3.common.util.ParsableByteArray in project media by androidx.
the class SampleQueueTest method writeSample.
/**
* Writes a single sample to {@code sampleQueue}.
*/
private void writeSample(byte[] data, long timestampUs, int sampleFlags) {
sampleQueue.sampleData(new ParsableByteArray(data), data.length);
sampleQueue.sampleMetadata(timestampUs, sampleFlags, data.length, /* offset= */
0, (sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null);
}
use of androidx.media3.common.util.ParsableByteArray in project media by androidx.
the class FlacFrameReaderTest method readFrameBlockSizeSamplesFromKey_keyBetween8and15_returnsCorrectBlockSize.
@Test
public void readFrameBlockSizeSamplesFromKey_keyBetween8and15_returnsCorrectBlockSize() {
int result = FlacFrameReader.readFrameBlockSizeSamplesFromKey(new ParsableByteArray(/* limit= */
0), /* blockSizeKey= */
11);
assertThat(result).isEqualTo(2048);
}
use of androidx.media3.common.util.ParsableByteArray in project media by androidx.
the class FlacFrameReaderTest method readFrameBlockSizeSamplesFromKey_keyBetween2and5_returnsCorrectBlockSize.
@Test
public void readFrameBlockSizeSamplesFromKey_keyBetween2and5_returnsCorrectBlockSize() {
int result = FlacFrameReader.readFrameBlockSizeSamplesFromKey(new ParsableByteArray(/* limit= */
0), /* blockSizeKey= */
3);
assertThat(result).isEqualTo(1152);
}
use of androidx.media3.common.util.ParsableByteArray in project media by androidx.
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();
}
use of androidx.media3.common.util.ParsableByteArray in project media by androidx.
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();
}
Aggregations