private void outputSample(int offset) { int flags = sampleIsKeyframe ? C.SAMPLE_FLAG_SYNC : 0; int size = (int) (nalUnitStartPosition - samplePosition); output.sampleMetadata(sampleTimeUs, flags, size, offset, null); }
@Override public void packetFinished() { output.sampleMetadata(sampleTimeUs, C.SAMPLE_FLAG_SYNC, sampleSize, 0, null); writingSample = false; }
private void commitSampleToOutput(Track track, long timeUs) { if (CODEC_ID_SUBRIP.equals(track.codecId)) { writeSubripSample(track); } track.output.sampleMetadata(timeUs, blockFlags, sampleBytesWritten, 0, track.encryptionKeyId); sampleRead = true; resetSample(); }
/** * Attempts to read the remainder of the frame. * <p> * If a frame is read in full then true is returned. The frame will have been output, and the * position of the source will have been advanced to the byte that immediately follows the end of * the frame. * <p> * If a frame is not read in full then the position of the source will have been advanced to the * limit, and the method should be called again with the next source to continue the read. * * @param source The source from which to read. */ private void readFrameRemainder(ParsableByteArray source) { int bytesToRead = Math.min(source.bytesLeft(), frameSize - frameBytesRead); output.sampleData(source, bytesToRead); frameBytesRead += bytesToRead; if (frameBytesRead < frameSize) { // We haven't read the whole of the frame yet. return; } output.sampleMetadata(timeUs, C.SAMPLE_FLAG_SYNC, frameSize, 0, null); timeUs += frameDurationUs; frameBytesRead = 0; state = STATE_FINDING_HEADER; }
bytesRead += bytesToRead; if (bytesRead == sampleSize) { output.sampleMetadata(timeUs, C.SAMPLE_FLAG_SYNC, sampleSize, 0, null); timeUs += frameDurationUs; bytesRead = 0;
@Override public void consume(ParsableByteArray seiBuffer, long pesTimeUs, boolean startOfPacket) { int b; while (seiBuffer.bytesLeft() > 1 /* last byte will be rbsp_trailing_bits */) { // Parse payload type. int payloadType = 0; do { b = seiBuffer.readUnsignedByte(); payloadType += b; } while (b == 0xFF); // Parse payload size. int payloadSize = 0; do { b = seiBuffer.readUnsignedByte(); payloadSize += b; } while (b == 0xFF); // Process the payload. We only support EIA-608 payloads currently. if (Eia608Parser.isSeiMessageEia608(payloadType, payloadSize, seiBuffer)) { output.sampleData(seiBuffer, payloadSize); output.sampleMetadata(pesTimeUs, C.SAMPLE_FLAG_SYNC, payloadSize, 0, null); } else { seiBuffer.skipBytes(payloadSize); } } }
bytesRead += bytesToRead; if (bytesRead == sampleSize) { output.sampleMetadata(timeUs, C.SAMPLE_FLAG_SYNC, sampleSize, 0, null); timeUs += frameDurationUs; state = STATE_FINDING_SYNC;
trackOutput.sampleMetadata(timeUs, C.SAMPLE_FLAG_SYNC, synchronizedHeader.frameSize, 0, null); samplesRead += synchronizedHeader.samplesPerFrame; sampleBytesRemaining = 0;
trackOutput.sampleMetadata(track.sampleTable.timestampsUs[sampleIndex], track.sampleTable.flags[sampleIndex], sampleSize, 0, null); track.sampleIndex++;
byte[] encryptionKey = fragmentRun.definesEncryptionData ? track.sampleDescriptionEncryptionBoxes[fragmentRun.sampleDescriptionIndex].keyId : null; trackOutput.sampleMetadata(sampleTimeUs, sampleFlags, sampleSize, 0, encryptionKey);
output.sampleMetadata(sampleTimeUs, flags, size, bytesWrittenPastNalUnit, null);