@Override public void consume(ParsableByteArray data, boolean payloadUnitStartIndicator, ExtractorOutput output) { // Skip pointer. if (payloadUnitStartIndicator) { int pointerField = data.readUnsignedByte(); data.skipBytes(pointerField); } data.readBytes(patScratch, 3); patScratch.skipBits(12); // table_id (8), section_syntax_indicator (1), '0' (1), reserved (2) int sectionLength = patScratch.readBits(12); // transport_stream_id (16), reserved (2), version_number (5), current_next_indicator (1), // section_number (8), last_section_number (8) data.skipBytes(5); int programCount = (sectionLength - 9) / 4; for (int i = 0; i < programCount; i++) { data.readBytes(patScratch, 4); patScratch.skipBits(19); // program_number (16), reserved (3) int pid = patScratch.readBits(13); tsPayloadReaders.put(pid, new PmtReader()); } // Skip CRC_32. }
@Override public void init(ExtractorOutput output) { this.output = output; this.trackOutput = output.track(0); output.endTracks(); try { decoder = new FlacJni(); } catch (FlacDecoderException e) { throw new RuntimeException(e); } }
@Override public void consume(ParsableByteArray data, boolean payloadUnitStartIndicator, ExtractorOutput output) { // Skip pointer. if (payloadUnitStartIndicator) { int pointerField = data.readUnsignedByte(); data.skipBytes(pointerField); } data.readBytes(patScratch, 3); patScratch.skipBits(12); // table_id (8), section_syntax_indicator (1), '0' (1), reserved (2) int sectionLength = patScratch.readBits(12); // transport_stream_id (16), reserved (2), version_number (5), current_next_indicator (1), // section_number (8), last_section_number (8) data.skipBytes(5); int programCount = (sectionLength - 9) / 4; for (int i = 0; i < programCount; i++) { data.readBytes(patScratch, 4); int programNumber = patScratch.readBits(16); patScratch.skipBits(3); // reserved (3) if (programNumber == 0) { patScratch.skipBits(13); // network_PID (13) } else { int pid = patScratch.readBits(13); tsPayloadReaders.put(pid, new PmtReader()); } } // Skip CRC_32. }
/** * Consumes the payload of a PS packet. * * @param data The PES packet. The position will be set to the start of the payload. * @param output The output to which parsed data should be written. */ public void consume(ParsableByteArray data, ExtractorOutput output) { data.readBytes(pesScratch.data, 0, 3); pesScratch.setPosition(0); parseHeader(); data.readBytes(pesScratch.data, 0, extendedHeaderLength); pesScratch.setPosition(0); parseHeaderExtension(); pesPayloadReader.packetStarted(timeUs, true); pesPayloadReader.consume(data); // We always have complete PES packets with program stream. pesPayloadReader.packetFinished(); }
@Override public void init(ExtractorOutput output) { extractorOutput = output; trackOutput = output.track(0); wavHeader = null; output.endTracks(); }
@Override public final void init(ExtractorOutput output) { extractorOutput = output; if (sideloadedTrack != null) { TrackBundle bundle = new TrackBundle(output.track(0)); bundle.init(sideloadedTrack, new DefaultSampleValues(0, 0, 0, 0)); trackBundles.put(0, bundle); extractorOutput.endTracks(); } }
@Override public void init(ExtractorOutput output) { adtsReader = new AdtsReader(output.track(0)); output.endTracks(); output.seekMap(SeekMap.UNSEEKABLE); }
@Override public void init(ExtractorOutput output) { this.output = output; output.seekMap(SeekMap.UNSEEKABLE); }
@Override public void consume(ParsableByteArray data, boolean payloadUnitStartIndicator, ExtractorOutput output) { if (payloadUnitStartIndicator) { switch (state) { case STATE_FINDING_HEADER: case STATE_READING_HEADER: // Expected. break; case STATE_READING_HEADER_EXTENSION: Log.w(TAG, "Unexpected start indicator reading extended header"); break; case STATE_READING_BODY: // If payloadSize == -1 then the length of the previous packet was unspecified, and so // we only know that it's finished now that we've seen the start of the next one. This // is expected. If payloadSize != -1, then the length of the previous packet was known, // but we didn't receive that amount of data. This is not expected. if (payloadSize != -1) { Log.w(TAG, "Unexpected start indicator: expected " + payloadSize + " more bytes"); } // Either way, if the body was started, notify the reader that it has now finished. if (bodyStarted) { pesPayloadReader.packetFinished(); } break; } setState(STATE_READING_HEADER); } while (data.bytesLeft() > 0) { switch (state) { case STATE_FINDING_HEADER: data.skipBytes(data.bytesLeft()); break; case STATE_READING_HEADER: if (continueRead(data, pesScratch.data, HEADER_SIZE)) { setState(parseHeader() ? STATE_READING_HEADER_EXTENSION : STATE_FINDING_HEADER); } break; case STATE_READING_HEADER_EXTENSION: int readLength = Math.min(MAX_HEADER_EXTENSION_SIZE, extendedHeaderLength); // Read as much of the extended header as we're interested in, and skip the rest. if (continueRead(data, pesScratch.data, readLength) && continueRead(data, null, extendedHeaderLength)) { parseHeaderExtension(); bodyStarted = false; setState(STATE_READING_BODY); } break; case STATE_READING_BODY: readLength = data.bytesLeft(); int padding = payloadSize == -1 ? 0 : readLength - payloadSize; if (padding > 0) { readLength -= padding; data.setLimit(data.getPosition() + readLength); } pesPayloadReader.consume(data, timeUs, !bodyStarted); bodyStarted = true; if (payloadSize != -1) { payloadSize -= readLength; if (payloadSize == 0) { pesPayloadReader.packetFinished(); setState(STATE_READING_HEADER); } } break; } } }
@Override public void init(ExtractorOutput output) { extractorOutput = output; }
@Override public void init(ExtractorOutput output) { extractorOutput = output; trackOutput = output.track(0); extractorOutput.endTracks(); }
@Override public void init(ExtractorOutput extractorOutput) { this.extractorOutput = extractorOutput; trackOutput = extractorOutput.track(0); extractorOutput.endTracks(); }
@Override public void init(ExtractorOutput output) { adtsReader = new AdtsReader(output.track(0), output.track(1)); output.endTracks(); output.seekMap(SeekMap.UNSEEKABLE); }
@Override public void consume(ParsableByteArray data, boolean payloadUnitStartIndicator, ExtractorOutput output) { if (payloadUnitStartIndicator) { switch (state) { case STATE_FINDING_HEADER: case STATE_READING_HEADER: // Expected. break; case STATE_READING_HEADER_EXTENSION: Log.w(TAG, "Unexpected start indicator reading extended header"); break; case STATE_READING_BODY: // If payloadSize == -1 then the length of the previous packet was unspecified, and so // we only know that it's finished now that we've seen the start of the next one. This // is expected. If payloadSize != -1, then the length of the previous packet was known, // but we didn't receive that amount of data. This is not expected. if (payloadSize != -1) { Log.w(TAG, "Unexpected start indicator: expected " + payloadSize + " more bytes"); } // Either way, notify the reader that it has now finished. pesPayloadReader.packetFinished(); break; } setState(STATE_READING_HEADER); } while (data.bytesLeft() > 0) { switch (state) { case STATE_FINDING_HEADER: data.skipBytes(data.bytesLeft()); break; case STATE_READING_HEADER: if (continueRead(data, pesScratch.data, HEADER_SIZE)) { setState(parseHeader() ? STATE_READING_HEADER_EXTENSION : STATE_FINDING_HEADER); } break; case STATE_READING_HEADER_EXTENSION: int readLength = Math.min(MAX_HEADER_EXTENSION_SIZE, extendedHeaderLength); // Read as much of the extended header as we're interested in, and skip the rest. if (continueRead(data, pesScratch.data, readLength) && continueRead(data, null, extendedHeaderLength)) { parseHeaderExtension(); pesPayloadReader.packetStarted(timeUs, dataAlignmentIndicator); setState(STATE_READING_BODY); } break; case STATE_READING_BODY: readLength = data.bytesLeft(); int padding = payloadSize == -1 ? 0 : readLength - payloadSize; if (padding > 0) { readLength -= padding; data.setLimit(data.getPosition() + readLength); } pesPayloadReader.consume(data); if (payloadSize != -1) { payloadSize -= readLength; if (payloadSize == 0) { pesPayloadReader.packetFinished(); setState(STATE_READING_HEADER); } } break; } } }
@Override public void init(ExtractorOutput output) { TrackOutput trackOutput = output.track(0); output.endTracks(); streamReader.init(output, trackOutput); }
void init(ExtractorOutput output, TrackOutput trackOutput) { this.extractorOutput = output; this.trackOutput = trackOutput; }
@Override public void init(ExtractorOutput output) { this.extractorOutput = output; }
/** * Consumes the payload of a TS packet. * * @param data The TS packet. The position will be set to the start of the payload. * @param payloadUnitStartIndicator Whether payloadUnitStartIndicator was set on the TS packet. * @param output The output to which parsed data should be written. */ public abstract void consume(ParsableByteArray data, boolean payloadUnitStartIndicator, ExtractorOutput output);