private void onQueueInputBuffer(DecoderInputBuffer buffer) { if (allowFirstBufferPositionDiscontinuity && !buffer.isDecodeOnly()) { // TODO: Remove this hack once we have a proper fix for [Internal: b/71876314]. // Allow the position to jump if the first presentable input buffer has a timestamp that // differs significantly from what was expected. if (Math.abs(buffer.timeUs - currentPositionUs) > 500000) { currentPositionUs = buffer.timeUs; } allowFirstBufferPositionDiscontinuity = false; } }
@Override protected void onQueueInputBuffer(DecoderInputBuffer buffer) { if (allowFirstBufferPositionDiscontinuity && !buffer.isDecodeOnly()) { // TODO: Remove this hack once we have a proper fix for [Internal: b/71876314]. // Allow the position to jump if the first presentable input buffer has a timestamp that // differs significantly from what was expected. if (Math.abs(buffer.timeUs - currentPositionUs) > 500000) { currentPositionUs = buffer.timeUs; } allowFirstBufferPositionDiscontinuity = false; } lastInputTimeUs = Math.max(buffer.timeUs, lastInputTimeUs); }
private void assertInputBufferHasNoDefaultFlagsSet() { assertThat(inputBuffer.isEndOfStream()).isFalse(); assertThat(inputBuffer.isDecodeOnly()).isFalse(); assertThat(inputBuffer.isEncrypted()).isFalse(); }
/** * Asserts {@link SampleQueue#read} returns {@link C#RESULT_BUFFER_READ} and that the * {@link DecoderInputBuffer#isEndOfStream()} is set. * * @param formatRequired The value of {@code formatRequired} passed to readData. */ private void assertReadEndOfStream(boolean formatRequired) { clearFormatHolderAndInputBuffer(); int result = sampleQueue.read(formatHolder, inputBuffer, formatRequired, true, 0); assertThat(result).isEqualTo(RESULT_BUFFER_READ); // formatHolder should not be populated. assertThat(formatHolder.format).isNull(); // inputBuffer should not contain sample data, but end of stream flag should be set. assertInputBufferContainsNoSampleData(); assertThat(inputBuffer.isEndOfStream()).isTrue(); assertThat(inputBuffer.isDecodeOnly()).isFalse(); assertThat(inputBuffer.isEncrypted()).isFalse(); }
/** * Asserts {@link SampleQueue#read} returns {@link C#RESULT_BUFFER_READ} and that the buffer is * filled with the specified sample data. * * @param timeUs The expected buffer timestamp. * @param isKeyframe The expected keyframe flag. * @param sampleData An array containing the expected sample data. * @param offset The offset in {@code sampleData} of the expected sample data. * @param length The length of the expected sample data. */ private void assertReadSample( long timeUs, boolean isKeyframe, byte[] sampleData, int offset, int length) { clearFormatHolderAndInputBuffer(); int result = sampleQueue.read(formatHolder, inputBuffer, false, false, 0); assertThat(result).isEqualTo(RESULT_BUFFER_READ); // formatHolder should not be populated. assertThat(formatHolder.format).isNull(); // inputBuffer should be populated. assertThat(inputBuffer.timeUs).isEqualTo(timeUs); assertThat(inputBuffer.isKeyFrame()).isEqualTo(isKeyframe); assertThat(inputBuffer.isDecodeOnly()).isFalse(); assertThat(inputBuffer.isEncrypted()).isFalse(); inputBuffer.flip(); assertThat(inputBuffer.data.limit()).isEqualTo(length); byte[] readData = new byte[length]; inputBuffer.data.get(readData); assertThat(readData).isEqualTo(copyOfRange(sampleData, offset, offset + length)); }
outputBuffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM); } else { if (inputBuffer.isDecodeOnly()) { outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
if (buffer.isDecodeOnly()) { decodeOnlyPresentationTimestamps.add(presentationTimeUs);