Search in sources :

Example 11 with ParsableBitArray

use of com.google.android.exoplayer2.util.ParsableBitArray in project ExoPlayer by google.

the class LatmReader method parseStreamMuxConfig.

/**
 * Parses a StreamMuxConfig as defined in ISO/IEC 14496-3:2009 Section 1.7.3.1, Table 1.42.
 */
@RequiresNonNull("output")
private void parseStreamMuxConfig(ParsableBitArray data) throws ParserException {
    int audioMuxVersion = data.readBits(1);
    audioMuxVersionA = audioMuxVersion == 1 ? data.readBits(1) : 0;
    if (audioMuxVersionA == 0) {
        if (audioMuxVersion == 1) {
            // Skip taraBufferFullness.
            latmGetValue(data);
        }
        if (!data.readBit()) {
            throw ParserException.createForMalformedContainer(/* message= */
            null, /* cause= */
            null);
        }
        numSubframes = data.readBits(6);
        int numProgram = data.readBits(4);
        int numLayer = data.readBits(3);
        if (numProgram != 0 || numLayer != 0) {
            throw ParserException.createForMalformedContainer(/* message= */
            null, /* cause= */
            null);
        }
        if (audioMuxVersion == 0) {
            int startPosition = data.getPosition();
            int readBits = parseAudioSpecificConfig(data);
            data.setPosition(startPosition);
            byte[] initData = new byte[(readBits + 7) / 8];
            data.readBits(initData, 0, readBits);
            Format format = new Format.Builder().setId(formatId).setSampleMimeType(MimeTypes.AUDIO_AAC).setCodecs(codecs).setChannelCount(channelCount).setSampleRate(sampleRateHz).setInitializationData(Collections.singletonList(initData)).setLanguage(language).build();
            if (!format.equals(this.format)) {
                this.format = format;
                sampleDurationUs = (C.MICROS_PER_SECOND * 1024) / format.sampleRate;
                output.format(format);
            }
        } else {
            int ascLen = (int) latmGetValue(data);
            int bitsRead = parseAudioSpecificConfig(data);
            // fillBits.
            data.skipBits(ascLen - bitsRead);
        }
        parseFrameLength(data);
        otherDataPresent = data.readBit();
        otherDataLenBits = 0;
        if (otherDataPresent) {
            if (audioMuxVersion == 1) {
                otherDataLenBits = latmGetValue(data);
            } else {
                boolean otherDataLenEsc;
                do {
                    otherDataLenEsc = data.readBit();
                    otherDataLenBits = (otherDataLenBits << 8) + data.readBits(8);
                } while (otherDataLenEsc);
            }
        }
        boolean crcCheckPresent = data.readBit();
        if (crcCheckPresent) {
            // crcCheckSum.
            data.skipBits(8);
        }
    } else {
        // This is not defined by ISO/IEC 14496-3:2009.
        throw ParserException.createForMalformedContainer(/* message= */
        null, /* cause= */
        null);
    }
}
Also used : Format(com.google.android.exoplayer2.Format) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Aggregations

ParsableBitArray (com.google.android.exoplayer2.util.ParsableBitArray)9 Nullable (androidx.annotation.Nullable)5 Paint (android.graphics.Paint)2 Format (com.google.android.exoplayer2.Format)2 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)2 ArrayList (java.util.ArrayList)2 Metadata (com.google.android.exoplayer2.metadata.Metadata)1 PictureFrame (com.google.android.exoplayer2.metadata.flac.PictureFrame)1 Cue (com.google.android.exoplayer2.text.Cue)1 Mesh (com.google.android.exoplayer2.video.spherical.Projection.Mesh)1 SubMesh (com.google.android.exoplayer2.video.spherical.Projection.SubMesh)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)1