Search in sources :

Example 96 with ParsableByteArray

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);
}
Also used : ParsableByteArray(androidx.media3.common.util.ParsableByteArray)

Example 97 with ParsableByteArray

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);
}
Also used : ParsableByteArray(androidx.media3.common.util.ParsableByteArray) Test(org.junit.Test)

Example 98 with ParsableByteArray

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);
}
Also used : ParsableByteArray(androidx.media3.common.util.ParsableByteArray) Test(org.junit.Test)

Example 99 with ParsableByteArray

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();
}
Also used : ParsableByteArray(androidx.media3.common.util.ParsableByteArray) FlacStreamMetadataHolder(androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder) SampleNumberHolder(androidx.media3.extractor.FlacFrameReader.SampleNumberHolder) FakeExtractorInput(androidx.media3.test.utils.FakeExtractorInput) Test(org.junit.Test)

Example 100 with ParsableByteArray

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();
}
Also used : ParsableByteArray(androidx.media3.common.util.ParsableByteArray) FlacStreamMetadataHolder(androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder) SampleNumberHolder(androidx.media3.extractor.FlacFrameReader.SampleNumberHolder) FakeExtractorInput(androidx.media3.test.utils.FakeExtractorInput) Test(org.junit.Test)

Aggregations

ParsableByteArray (androidx.media3.common.util.ParsableByteArray)96 Test (org.junit.Test)38 Nullable (androidx.annotation.Nullable)34 Format (androidx.media3.common.Format)9 ArrayList (java.util.ArrayList)9 Metadata (androidx.media3.common.Metadata)7 FakeExtractorInput (androidx.media3.test.utils.FakeExtractorInput)7 SeekPoint (androidx.media3.extractor.SeekPoint)5 Cue (androidx.media3.common.text.Cue)4 SampleNumberHolder (androidx.media3.extractor.FlacFrameReader.SampleNumberHolder)4 FlacStreamMetadataHolder (androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder)4 ByteBuffer (java.nio.ByteBuffer)4 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)4 ParsableBitArray (androidx.media3.common.util.ParsableBitArray)3 Mesh (androidx.media3.exoplayer.video.spherical.Projection.Mesh)3 SubMesh (androidx.media3.exoplayer.video.spherical.Projection.SubMesh)3 TrackOutput (androidx.media3.extractor.TrackOutput)3 SmtaMetadataEntry (androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry)3 LeafAtom (androidx.media3.extractor.mp4.Atom.LeafAtom)3 EnsuresNonNullIf (org.checkerframework.checker.nullness.qual.EnsuresNonNullIf)3