Loading apex/media/framework/java/android/media/MediaParser.java +27 −24 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.google.android.exoplayer2.video.ColorInfo; import java.io.EOFException; import java.io.EOFException; import java.io.IOException; import java.io.IOException; import java.io.InterruptedIOException; import java.nio.ByteBuffer; import java.nio.ByteBuffer; import java.util.Collections; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; Loading Loading @@ -119,7 +120,7 @@ import java.util.Map; * * * @Override * @Override * public void onSampleData(int trackIndex, @NonNull InputReader inputReader) * public void onSampleData(int trackIndex, @NonNull InputReader inputReader) * throws IOException, InterruptedException { * throws IOException { * int numberOfBytesToRead = (int) inputReader.getLength(); * int numberOfBytesToRead = (int) inputReader.getLength(); * if (videoTrackIndex != trackIndex) { * if (videoTrackIndex != trackIndex) { * // Discard contents. * // Discard contents. Loading Loading @@ -310,8 +311,7 @@ public final class MediaParser { * of the input has been reached. * of the input has been reached. * @throws java.io.IOException If an error occurs reading from the source. * @throws java.io.IOException If an error occurs reading from the source. */ */ int read(@NonNull byte[] buffer, int offset, int readLength) int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException; throws IOException, InterruptedException; /** Returns the current read position (byte offset) in the stream. */ /** Returns the current read position (byte offset) in the stream. */ long getPosition(); long getPosition(); Loading Loading @@ -373,11 +373,8 @@ public final class MediaParser { * @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 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; throws IOException, InterruptedException; /** /** * Called once all the data of a sample has been passed to {@link #onSampleData}. * Called once all the data of a sample has been passed to {@link #onSampleData}. Loading Loading @@ -717,8 +714,7 @@ public final class MediaParser { * @throws UnrecognizedInputFormatException If the format cannot be recognized by any of the * @throws UnrecognizedInputFormatException If the format cannot be recognized by any of the * underlying parser implementations. * underlying parser implementations. */ */ public boolean advance(@NonNull SeekableInputReader seekableInputReader) public boolean advance(@NonNull SeekableInputReader seekableInputReader) throws IOException { throws IOException, InterruptedException { if (mExtractorInput == null) { if (mExtractorInput == null) { // TODO: For efficiency, the same implementation should be used, by providing a // TODO: For efficiency, the same implementation should be used, by providing a // clearBuffers() method, or similar. // clearBuffers() method, or similar. Loading Loading @@ -748,8 +744,10 @@ public final class MediaParser { } } } catch (EOFException e) { } catch (EOFException e) { // Do nothing. // Do nothing. } catch (IOException | InterruptedException e) { } catch (InterruptedException e) { throw new IllegalStateException(e); // TODO: Remove this exception replacement once we update the ExoPlayer // version. throw new InterruptedIOException(); } finally { } finally { mExtractorInput.resetPeekPosition(); mExtractorInput.resetPeekPosition(); } } Loading @@ -767,7 +765,13 @@ public final class MediaParser { } } mPositionHolder.position = seekableInputReader.getPosition(); mPositionHolder.position = seekableInputReader.getPosition(); int result = mExtractor.read(mExtractorInput, mPositionHolder); int result = 0; try { result = mExtractor.read(mExtractorInput, mPositionHolder); } catch (InterruptedException e) { // TODO: Remove this exception replacement once we update the ExoPlayer version. throw new InterruptedIOException(); } if (result == Extractor.RESULT_END_OF_INPUT) { if (result == Extractor.RESULT_END_OF_INPUT) { return false; return false; } } Loading Loading @@ -853,13 +857,7 @@ public final class MediaParser { @Override @Override public int read(byte[] buffer, int offset, int readLength) throws IOException { public int read(byte[] buffer, int offset, int readLength) throws IOException { // TODO: Reevaluate interruption in Input. try { return mInputReader.read(buffer, offset, readLength); return mInputReader.read(buffer, offset, readLength); } catch (InterruptedException e) { // TODO: Remove. throw new RuntimeException(); } } } @Override @Override Loading Loading @@ -926,7 +924,7 @@ public final class MediaParser { @Override @Override public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput) public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput) throws IOException, InterruptedException { throws IOException { mScratchExtractorInputAdapter.setExtractorInput(input, length); mScratchExtractorInputAdapter.setExtractorInput(input, length); long positionBeforeReading = mScratchExtractorInputAdapter.getPosition(); long positionBeforeReading = mScratchExtractorInputAdapter.getPosition(); mOutputConsumer.onSampleData(mTrackIndex, mScratchExtractorInputAdapter); mOutputConsumer.onSampleData(mTrackIndex, mScratchExtractorInputAdapter); Loading @@ -938,7 +936,7 @@ public final class MediaParser { mScratchParsableByteArrayAdapter.resetWithByteArray(data, length); mScratchParsableByteArrayAdapter.resetWithByteArray(data, length); try { try { mOutputConsumer.onSampleData(mTrackIndex, mScratchParsableByteArrayAdapter); mOutputConsumer.onSampleData(mTrackIndex, mScratchParsableByteArrayAdapter); } catch (IOException | InterruptedException e) { } catch (IOException e) { // Unexpected. // Unexpected. throw new RuntimeException(e); throw new RuntimeException(e); } } Loading Loading @@ -967,9 +965,14 @@ public final class MediaParser { // Input implementation. // Input implementation. @Override @Override public int read(byte[] buffer, int offset, int readLength) public int read(byte[] buffer, int offset, int readLength) throws IOException { throws IOException, InterruptedException { int readBytes = 0; int readBytes = mExtractorInput.read(buffer, offset, readLength); try { readBytes = mExtractorInput.read(buffer, offset, readLength); } catch (InterruptedException e) { // TODO: Remove this exception replacement once we update the ExoPlayer version. throw new InterruptedIOException(); } mCurrentPosition += readBytes; mCurrentPosition += readBytes; return readBytes; return readBytes; } } Loading api/current.txt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -26403,7 +26403,7 @@ package android.media { } } public final class MediaParser { public final class MediaParser { method public boolean advance(@NonNull android.media.MediaParser.SeekableInputReader) throws java.io.IOException, java.lang.InterruptedException; method public boolean advance(@NonNull android.media.MediaParser.SeekableInputReader) throws java.io.IOException; method @NonNull public static android.media.MediaParser create(@NonNull android.media.MediaParser.OutputConsumer, @NonNull java.lang.String...); method @NonNull public static android.media.MediaParser create(@NonNull android.media.MediaParser.OutputConsumer, @NonNull java.lang.String...); method @NonNull public static android.media.MediaParser createByName(@NonNull String, @NonNull android.media.MediaParser.OutputConsumer); method @NonNull public static android.media.MediaParser createByName(@NonNull String, @NonNull android.media.MediaParser.OutputConsumer); method @Nullable public String getParserName(); method @Nullable public String getParserName(); Loading Loading @@ -26435,12 +26435,12 @@ package android.media { public static interface MediaParser.InputReader { public static interface MediaParser.InputReader { method public long getLength(); method public long getLength(); method public long getPosition(); method public long getPosition(); method public int read(@NonNull byte[], int, int) throws java.io.IOException, java.lang.InterruptedException; method public int read(@NonNull byte[], int, int) throws java.io.IOException; } } public static interface MediaParser.OutputConsumer { public static interface MediaParser.OutputConsumer { method public void onSampleCompleted(int, long, int, int, int, @Nullable android.media.MediaCodec.CryptoInfo); method public void onSampleCompleted(int, long, int, int, int, @Nullable android.media.MediaCodec.CryptoInfo); method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException, java.lang.InterruptedException; method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException; method public void onSeekMap(@NonNull android.media.MediaParser.SeekMap); method public void onSeekMap(@NonNull android.media.MediaParser.SeekMap); method public void onTrackData(int, @NonNull android.media.MediaParser.TrackData); method public void onTrackData(int, @NonNull android.media.MediaParser.TrackData); method public void onTracksFound(int); method public void onTracksFound(int); Loading
apex/media/framework/java/android/media/MediaParser.java +27 −24 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.google.android.exoplayer2.video.ColorInfo; import java.io.EOFException; import java.io.EOFException; import java.io.IOException; import java.io.IOException; import java.io.InterruptedIOException; import java.nio.ByteBuffer; import java.nio.ByteBuffer; import java.util.Collections; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; Loading Loading @@ -119,7 +120,7 @@ import java.util.Map; * * * @Override * @Override * public void onSampleData(int trackIndex, @NonNull InputReader inputReader) * public void onSampleData(int trackIndex, @NonNull InputReader inputReader) * throws IOException, InterruptedException { * throws IOException { * int numberOfBytesToRead = (int) inputReader.getLength(); * int numberOfBytesToRead = (int) inputReader.getLength(); * if (videoTrackIndex != trackIndex) { * if (videoTrackIndex != trackIndex) { * // Discard contents. * // Discard contents. Loading Loading @@ -310,8 +311,7 @@ public final class MediaParser { * of the input has been reached. * of the input has been reached. * @throws java.io.IOException If an error occurs reading from the source. * @throws java.io.IOException If an error occurs reading from the source. */ */ int read(@NonNull byte[] buffer, int offset, int readLength) int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException; throws IOException, InterruptedException; /** Returns the current read position (byte offset) in the stream. */ /** Returns the current read position (byte offset) in the stream. */ long getPosition(); long getPosition(); Loading Loading @@ -373,11 +373,8 @@ public final class MediaParser { * @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 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; throws IOException, InterruptedException; /** /** * Called once all the data of a sample has been passed to {@link #onSampleData}. * Called once all the data of a sample has been passed to {@link #onSampleData}. Loading Loading @@ -717,8 +714,7 @@ public final class MediaParser { * @throws UnrecognizedInputFormatException If the format cannot be recognized by any of the * @throws UnrecognizedInputFormatException If the format cannot be recognized by any of the * underlying parser implementations. * underlying parser implementations. */ */ public boolean advance(@NonNull SeekableInputReader seekableInputReader) public boolean advance(@NonNull SeekableInputReader seekableInputReader) throws IOException { throws IOException, InterruptedException { if (mExtractorInput == null) { if (mExtractorInput == null) { // TODO: For efficiency, the same implementation should be used, by providing a // TODO: For efficiency, the same implementation should be used, by providing a // clearBuffers() method, or similar. // clearBuffers() method, or similar. Loading Loading @@ -748,8 +744,10 @@ public final class MediaParser { } } } catch (EOFException e) { } catch (EOFException e) { // Do nothing. // Do nothing. } catch (IOException | InterruptedException e) { } catch (InterruptedException e) { throw new IllegalStateException(e); // TODO: Remove this exception replacement once we update the ExoPlayer // version. throw new InterruptedIOException(); } finally { } finally { mExtractorInput.resetPeekPosition(); mExtractorInput.resetPeekPosition(); } } Loading @@ -767,7 +765,13 @@ public final class MediaParser { } } mPositionHolder.position = seekableInputReader.getPosition(); mPositionHolder.position = seekableInputReader.getPosition(); int result = mExtractor.read(mExtractorInput, mPositionHolder); int result = 0; try { result = mExtractor.read(mExtractorInput, mPositionHolder); } catch (InterruptedException e) { // TODO: Remove this exception replacement once we update the ExoPlayer version. throw new InterruptedIOException(); } if (result == Extractor.RESULT_END_OF_INPUT) { if (result == Extractor.RESULT_END_OF_INPUT) { return false; return false; } } Loading Loading @@ -853,13 +857,7 @@ public final class MediaParser { @Override @Override public int read(byte[] buffer, int offset, int readLength) throws IOException { public int read(byte[] buffer, int offset, int readLength) throws IOException { // TODO: Reevaluate interruption in Input. try { return mInputReader.read(buffer, offset, readLength); return mInputReader.read(buffer, offset, readLength); } catch (InterruptedException e) { // TODO: Remove. throw new RuntimeException(); } } } @Override @Override Loading Loading @@ -926,7 +924,7 @@ public final class MediaParser { @Override @Override public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput) public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput) throws IOException, InterruptedException { throws IOException { mScratchExtractorInputAdapter.setExtractorInput(input, length); mScratchExtractorInputAdapter.setExtractorInput(input, length); long positionBeforeReading = mScratchExtractorInputAdapter.getPosition(); long positionBeforeReading = mScratchExtractorInputAdapter.getPosition(); mOutputConsumer.onSampleData(mTrackIndex, mScratchExtractorInputAdapter); mOutputConsumer.onSampleData(mTrackIndex, mScratchExtractorInputAdapter); Loading @@ -938,7 +936,7 @@ public final class MediaParser { mScratchParsableByteArrayAdapter.resetWithByteArray(data, length); mScratchParsableByteArrayAdapter.resetWithByteArray(data, length); try { try { mOutputConsumer.onSampleData(mTrackIndex, mScratchParsableByteArrayAdapter); mOutputConsumer.onSampleData(mTrackIndex, mScratchParsableByteArrayAdapter); } catch (IOException | InterruptedException e) { } catch (IOException e) { // Unexpected. // Unexpected. throw new RuntimeException(e); throw new RuntimeException(e); } } Loading Loading @@ -967,9 +965,14 @@ public final class MediaParser { // Input implementation. // Input implementation. @Override @Override public int read(byte[] buffer, int offset, int readLength) public int read(byte[] buffer, int offset, int readLength) throws IOException { throws IOException, InterruptedException { int readBytes = 0; int readBytes = mExtractorInput.read(buffer, offset, readLength); try { readBytes = mExtractorInput.read(buffer, offset, readLength); } catch (InterruptedException e) { // TODO: Remove this exception replacement once we update the ExoPlayer version. throw new InterruptedIOException(); } mCurrentPosition += readBytes; mCurrentPosition += readBytes; return readBytes; return readBytes; } } Loading
api/current.txt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -26403,7 +26403,7 @@ package android.media { } } public final class MediaParser { public final class MediaParser { method public boolean advance(@NonNull android.media.MediaParser.SeekableInputReader) throws java.io.IOException, java.lang.InterruptedException; method public boolean advance(@NonNull android.media.MediaParser.SeekableInputReader) throws java.io.IOException; method @NonNull public static android.media.MediaParser create(@NonNull android.media.MediaParser.OutputConsumer, @NonNull java.lang.String...); method @NonNull public static android.media.MediaParser create(@NonNull android.media.MediaParser.OutputConsumer, @NonNull java.lang.String...); method @NonNull public static android.media.MediaParser createByName(@NonNull String, @NonNull android.media.MediaParser.OutputConsumer); method @NonNull public static android.media.MediaParser createByName(@NonNull String, @NonNull android.media.MediaParser.OutputConsumer); method @Nullable public String getParserName(); method @Nullable public String getParserName(); Loading Loading @@ -26435,12 +26435,12 @@ package android.media { public static interface MediaParser.InputReader { public static interface MediaParser.InputReader { method public long getLength(); method public long getLength(); method public long getPosition(); method public long getPosition(); method public int read(@NonNull byte[], int, int) throws java.io.IOException, java.lang.InterruptedException; method public int read(@NonNull byte[], int, int) throws java.io.IOException; } } public static interface MediaParser.OutputConsumer { public static interface MediaParser.OutputConsumer { method public void onSampleCompleted(int, long, int, int, int, @Nullable android.media.MediaCodec.CryptoInfo); method public void onSampleCompleted(int, long, int, int, int, @Nullable android.media.MediaCodec.CryptoInfo); method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException, java.lang.InterruptedException; method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException; method public void onSeekMap(@NonNull android.media.MediaParser.SeekMap); method public void onSeekMap(@NonNull android.media.MediaParser.SeekMap); method public void onTrackData(int, @NonNull android.media.MediaParser.TrackData); method public void onTrackData(int, @NonNull android.media.MediaParser.TrackData); method public void onTracksFound(int); method public void onTracksFound(int);