Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a35ff2e7 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Fix some javadoc issues." into rvc-dev am: ae5a3ee6

Change-Id: I1e7a9028d1188efaf143a2cbabe0a66c26a720a4
parents b8d22266 ae5a3ee6
Loading
Loading
Loading
Loading
+56 −25
Original line number Original line Diff line number Diff line
@@ -94,61 +94,84 @@ import java.util.Map;
 * which extracts and publishes all video samples:
 * which extracts and publishes all video samples:
 *
 *
 * <pre>
 * <pre>
 *
 * class VideoOutputConsumer implements MediaParser.OutputConsumer {
 * class VideoOutputConsumer implements MediaParser.OutputConsumer {
 *
 *
 *     private static final int MAXIMUM_SAMPLE_SIZE = ...;
 *     private byte[] sampleDataBuffer = new byte[4096];
 *     private byte[] sampleDataBuffer = new byte[MAXIMUM_SAMPLE_SIZE];
 *     private byte[] discardedDataBuffer = new byte[4096];
 *     private int videoTrackIndex = -1;
 *     private int videoTrackIndex = -1;
 *     private int bytesWrittenCount = 0;
 *     private int bytesWrittenCount = 0;
 *
 *
 *     \@Override
 *     &#64;Override
 *     public void onSeekMap(int i, @NonNull MediaFormat mediaFormat) { \/* Do nothing. *\/ }
 *     public void onSeekMap(int i, &#64;NonNull MediaFormat mediaFormat) {
 *       // Do nothing.
 *     }
 *
 *
 *     \@Override
 *     &#64;Override
 *     public void onTrackData(int i, @NonNull TrackData trackData) {
 *     public void onTrackData(int i, &#64;NonNull TrackData trackData) {
 *       MediaFormat mediaFormat = trackData.mediaFormat;
 *       MediaFormat mediaFormat = trackData.mediaFormat;
 *       if (videoTrackIndex == -1 && mediaFormat
 *       if (videoTrackIndex == -1 &&
 *           .getString(MediaFormat.KEY_MIME, \/* defaultValue= *\/ "").startsWith("video/")) {
 *           mediaFormat
 *               .getString(MediaFormat.KEY_MIME, &#47;* defaultValue= *&#47; "")
 *               .startsWith("video/")) {
 *         videoTrackIndex = i;
 *         videoTrackIndex = i;
 *       }
 *       }
 *     }
 *     }
 *
 *
 *     \@Override
 *     &#64;Override
 *     public void onSampleData(int trackIndex, @NonNull InputReader inputReader)
 *     public void onSampleData(int trackIndex, &#64;NonNull InputReader inputReader)
 *         throws IOException, InterruptedException {
 *         throws IOException, InterruptedException {
 *       int numberOfBytesToRead = (int) inputReader.getLength();
 *       int numberOfBytesToRead = (int) inputReader.getLength();
 *       if (videoTrackIndex != trackIndex) {
 *       if (videoTrackIndex != trackIndex) {
 *         // Discard contents.
 *         // Discard contents.
 *         inputReader.read(\/* bytes= *\/ null, \/* offset= *\/ 0, numberOfBytesToRead);
 *         inputReader.read(
 *       }
 *             discardedDataBuffer,
 *       int bytesRead = inputReader.read(sampleDataBuffer, bytesWrittenCount, numberOfBytesToRead);
 *             &#47;* offset= *&#47; 0,
 *             Math.min(discardDataBuffer.length, numberOfBytesToRead));
 *       } else {
 *         ensureSpaceInBuffer(numberOfBytesToRead);
 *         int bytesRead = inputReader.read(
 *             sampleDataBuffer, bytesWrittenCount, numberOfBytesToRead);
 *         bytesWrittenCount += bytesRead;
 *         bytesWrittenCount += bytesRead;
 *       }
 *       }
 *     }
 *
 *
 *     \@Override
 *     &#64;Override
 *     public void onSampleCompleted(
 *     public void onSampleCompleted(
 *         int trackIndex,
 *         int trackIndex,
 *         long timeUs,
 *         long timeUs,
 *         int flags,
 *         int flags,
 *         int size,
 *         int size,
 *         int offset,
 *         int offset,
 *         \@Nullable CryptoInfo cryptoData) {
 *         &#64;Nullable CryptoInfo cryptoData) {
 *       if (videoTrackIndex != trackIndex) {
 *       if (videoTrackIndex != trackIndex) {
 *         return; // It's not the video track. Ignore.
 *         return; // It's not the video track. Ignore.
 *       }
 *       }
 *       byte[] sampleData = new byte[size];
 *       byte[] sampleData = new byte[size];
 *       System.arraycopy(sampleDataBuffer, bytesWrittenCount - size - offset, sampleData, \/*
 *       int sampleStartOffset = bytesWrittenCount - size - offset;
 *       destPos= *\/ 0, size);
 *       System.arraycopy(
 *           sampleDataBuffer,
 *           sampleStartOffset,
 *           sampleData,
 *           &#47;* destPos= *&#47; 0,
 *           size);
 *       // Place trailing bytes at the start of the buffer.
 *       // Place trailing bytes at the start of the buffer.
 *       System.arraycopy(
 *       System.arraycopy(
 *           sampleDataBuffer,
 *           sampleDataBuffer,
 *           bytesWrittenCount - offset,
 *           bytesWrittenCount - offset,
 *           sampleDataBuffer,
 *           sampleDataBuffer,
 *           \/* destPos= *\/ 0,
 *           &#47;* destPos= *&#47; 0,
 *           \/* size= *\/ offset);
 *           &#47;* size= *&#47; offset);
 *       bytesWrittenCount = bytesWrittenCount - offset;
 *       publishSample(sampleData, timeUs, flags);
 *       publishSample(sampleData, timeUs, flags);
 *     }
 *     }
 *
 *    private void ensureSpaceInBuffer(int numberOfBytesToRead) {
 *      int requiredLength = bytesWrittenCount + numberOfBytesToRead;
 *      if (requiredLength > sampleDataBuffer.length) {
 *        sampleDataBuffer = Arrays.copyOf(sampleDataBuffer, requiredLength);
 *      }
 *    }
 *
 *   }
 *   }
 *
 *
 * </pre>
 * </pre>
@@ -342,11 +365,16 @@ public final class MediaParser {
        /**
        /**
         * Called to write sample data to the output.
         * Called to write sample data to the output.
         *
         *
         * <p>Implementers must attempt to consume the entirety of the input, but should surface any
         * <p>If the invocation of this method returns before the entire {@code inputReader} {@link
         * thrown {@link IOException} caused by reading from {@code input}.
         * InputReader#getLength() length} is consumed, the method will be called again for the
         * implementer to read the remaining data. Implementers should surface any thrown {@link
         * IOException} caused by reading from {@code input}.
         *
         *
         * @param trackIndex The index of the track to which the sample data corresponds.
         * @param trackIndex The index of the track to which the sample data corresponds.
         * @param inputReader The {@link InputReader} from which to read the data.
         * @param inputReader The {@link InputReader} from which to read the data.
         * @throws IOException If an exception occurs while reading from {@code inputReader}.
         * @throws InterruptedException If an interruption occurs while reading from {@code
         *     inputReader}.
         */
         */
        void onSampleData(int trackIndex, @NonNull InputReader inputReader)
        void onSampleData(int trackIndex, @NonNull InputReader inputReader)
                throws IOException, InterruptedException;
                throws IOException, InterruptedException;
@@ -361,8 +389,9 @@ public final class MediaParser {
         * @param flags Flags associated with the sample. See {@link MediaCodec
         * @param flags Flags associated with the sample. See {@link MediaCodec
         *     MediaCodec.BUFFER_FLAG_*}.
         *     MediaCodec.BUFFER_FLAG_*}.
         * @param size The size of the sample data, in bytes.
         * @param size The size of the sample data, in bytes.
         * @param offset The number of bytes that have been passed to {@link #onSampleData} since
         * @param offset The number of bytes that have been consumed by {@code onSampleData(int,
         *     the last byte belonging to the sample whose metadata is being passed.
         *     MediaParser.InputReader)} for the specified track, since the last byte belonging to
         *     the sample whose metadata is being passed.
         * @param cryptoData Encryption data required to decrypt the sample. May be null for
         * @param cryptoData Encryption data required to decrypt the sample. May be null for
         *     unencrypted samples.
         *     unencrypted samples.
         */
         */
@@ -684,7 +713,9 @@ public final class MediaParser {
     *     container data.
     *     container data.
     * @return Whether there is any data left to extract. Returns false if the end of input has been
     * @return Whether there is any data left to extract. Returns false if the end of input has been
     *     reached.
     *     reached.
     * @throws UnrecognizedInputFormatException
     * @throws IOException If an error occurs while reading from the {@link SeekableInputReader}.
     * @throws UnrecognizedInputFormatException If the format cannot be recognized by any of the
     *     underlying parser implementations.
     */
     */
    public boolean advance(@NonNull SeekableInputReader seekableInputReader)
    public boolean advance(@NonNull SeekableInputReader seekableInputReader)
            throws IOException, InterruptedException {
            throws IOException, InterruptedException {