Search in sources :

Example 11 with ParserException

use of com.google.android.exoplayer2.ParserException in project ExoPlayer by google.

the class MatroskaExtractor method endMasterElement.

/* package */
void endMasterElement(int id) throws ParserException {
    switch(id) {
        case ID_SEGMENT_INFO:
            if (timecodeScale == C.TIME_UNSET) {
                // timecodeScale was omitted. Use the default value.
                timecodeScale = 1000000;
            }
            if (durationTimecode != C.TIME_UNSET) {
                durationUs = scaleTimecodeToUs(durationTimecode);
            }
            break;
        case ID_SEEK:
            if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.POSITION_UNSET) {
                throw new ParserException("Mandatory element SeekID or SeekPosition not found");
            }
            if (seekEntryId == ID_CUES) {
                cuesContentPosition = seekEntryPosition;
            }
            break;
        case ID_CUES:
            if (!sentSeekMap) {
                extractorOutput.seekMap(buildSeekMap());
                sentSeekMap = true;
            } else {
            // We have already built the cues. Ignore.
            }
            break;
        case ID_BLOCK_GROUP:
            if (blockState != BLOCK_STATE_DATA) {
                // We've skipped this block (due to incompatible track number).
                return;
            }
            // If the ReferenceBlock element was not found for this sample, then it is a keyframe.
            if (!sampleSeenReferenceBlock) {
                blockFlags |= C.BUFFER_FLAG_KEY_FRAME;
            }
            commitSampleToOutput(tracks.get(blockTrackNumber), blockTimeUs);
            blockState = BLOCK_STATE_START;
            break;
        case ID_CONTENT_ENCODING:
            if (currentTrack.hasContentEncryption) {
                if (currentTrack.encryptionKeyId == null) {
                    throw new ParserException("Encrypted Track found but ContentEncKeyID was not found");
                }
                currentTrack.drmInitData = new DrmInitData(new SchemeData(C.UUID_NIL, MimeTypes.VIDEO_WEBM, currentTrack.encryptionKeyId));
            }
            break;
        case ID_CONTENT_ENCODINGS:
            if (currentTrack.hasContentEncryption && currentTrack.sampleStrippedBytes != null) {
                throw new ParserException("Combining encryption and compression is not supported");
            }
            break;
        case ID_TRACK_ENTRY:
            if (isCodecSupported(currentTrack.codecId)) {
                currentTrack.initializeOutput(extractorOutput, currentTrack.number);
                tracks.put(currentTrack.number, currentTrack);
            }
            currentTrack = null;
            break;
        case ID_TRACKS:
            if (tracks.size() == 0) {
                throw new ParserException("No valid tracks were found");
            }
            extractorOutput.endTracks();
            break;
        default:
            break;
    }
}
Also used : ParserException(com.google.android.exoplayer2.ParserException) DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) SchemeData(com.google.android.exoplayer2.drm.DrmInitData.SchemeData)

Example 12 with ParserException

use of com.google.android.exoplayer2.ParserException in project ExoPlayer by google.

the class VorbisUtilTest method testVerifyVorbisHeaderCapturePatternQuiteInvalidPatternQuite.

public void testVerifyVorbisHeaderCapturePatternQuiteInvalidPatternQuite() throws ParserException {
    ParsableByteArray header = new ParsableByteArray(new byte[] { 0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's' });
    assertFalse(VorbisUtil.verifyVorbisHeaderCapturePattern(0x01, header, true));
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 13 with ParserException

use of com.google.android.exoplayer2.ParserException in project ExoPlayer by google.

the class VorbisUtilTest method testVerifyVorbisHeaderCapturePatternInvalidHeader.

public void testVerifyVorbisHeaderCapturePatternInvalidHeader() {
    ParsableByteArray header = new ParsableByteArray(new byte[] { 0x01, 'v', 'o', 'r', 'b', 'i', 's' });
    try {
        VorbisUtil.verifyVorbisHeaderCapturePattern(0x99, header, false);
        fail();
    } catch (ParserException e) {
        assertEquals("expected header type 99", e.getMessage());
    }
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) ParserException(com.google.android.exoplayer2.ParserException)

Example 14 with ParserException

use of com.google.android.exoplayer2.ParserException in project ExoPlayer by google.

the class VorbisUtilTest method testVerifyVorbisHeaderCapturePattern.

public void testVerifyVorbisHeaderCapturePattern() throws ParserException {
    ParsableByteArray header = new ParsableByteArray(new byte[] { 0x01, 'v', 'o', 'r', 'b', 'i', 's' });
    assertEquals(true, VorbisUtil.verifyVorbisHeaderCapturePattern(0x01, header, false));
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 15 with ParserException

use of com.google.android.exoplayer2.ParserException in project ExoPlayer by google.

the class VorbisUtilTest method testReadVorbisModes.

public void testReadVorbisModes() throws ParserException {
    byte[] data = TestData.getSetupHeaderData();
    ParsableByteArray headerData = new ParsableByteArray(data, data.length);
    VorbisUtil.Mode[] modes = VorbisUtil.readVorbisModes(headerData, 2);
    assertEquals(2, modes.length);
    assertEquals(false, modes[0].blockFlag);
    assertEquals(0, modes[0].mapping);
    assertEquals(0, modes[0].transformType);
    assertEquals(0, modes[0].windowType);
    assertEquals(true, modes[1].blockFlag);
    assertEquals(1, modes[1].mapping);
    assertEquals(0, modes[1].transformType);
    assertEquals(0, modes[1].windowType);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Aggregations

ParserException (com.google.android.exoplayer2.ParserException)23 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)14 ContainerAtom (com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom)4 ArrayList (java.util.ArrayList)4 Format (com.google.android.exoplayer2.Format)3 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)3 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)3 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)3 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)2 LeafAtom (com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom)2 AvcConfig (com.google.android.exoplayer2.video.AvcConfig)2 Matcher (java.util.regex.Matcher)2 XmlPullParser (org.xmlpull.v1.XmlPullParser)2 Point (android.graphics.Point)1 Uri (android.net.Uri)1 Pair (android.util.Pair)1 SparseArray (android.util.SparseArray)1 SchemeData (com.google.android.exoplayer2.drm.DrmInitData.SchemeData)1 ChunkIndex (com.google.android.exoplayer2.extractor.ChunkIndex)1 GaplessInfoHolder (com.google.android.exoplayer2.extractor.GaplessInfoHolder)1