Merge AudioDecoderException and VideoDecoderException

This is a necessary step for Decoder implementations to support
audio and video. MediaCodecRenderer.DecoderException is renamed
MediaCodecDecoderException and extends the new DecoderException

Issue: #2159
PiperOrigin-RevId: 301698238
This commit is contained in:
olly 2020-03-18 23:56:24 +00:00 committed by Oliver Woodman
parent 395a7031ac
commit ee6afe5eb9
17 changed files with 157 additions and 164 deletions

View file

@ -15,10 +15,10 @@
*/
package com.google.android.exoplayer2.ext.av1;
import com.google.android.exoplayer2.video.VideoDecoderException;
import com.google.android.exoplayer2.decoder.DecoderException;
/** Thrown when a libgav1 decoder error occurs. */
public final class Gav1DecoderException extends VideoDecoderException {
public final class Gav1DecoderException extends DecoderException {
/* package */ Gav1DecoderException(String message) {
super(message);

View file

@ -26,13 +26,13 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.TraceUtil;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.DecoderVideoRenderer;
import com.google.android.exoplayer2.video.VideoDecoderException;
import com.google.android.exoplayer2.video.VideoDecoderInputBuffer;
import com.google.android.exoplayer2.video.VideoDecoderOutputBuffer;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
@ -141,11 +141,8 @@ public class Libgav1VideoRenderer extends DecoderVideoRenderer {
@Override
protected SimpleDecoder<
VideoDecoderInputBuffer,
? extends VideoDecoderOutputBuffer,
? extends VideoDecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
throws VideoDecoderException {
VideoDecoderInputBuffer, ? extends VideoDecoderOutputBuffer, ? extends DecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto) throws DecoderException {
TraceUtil.beginSection("createGav1Decoder");
int initialInputBufferSize =
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;

View file

@ -15,12 +15,10 @@
*/
package com.google.android.exoplayer2.ext.ffmpeg;
import com.google.android.exoplayer2.audio.AudioDecoderException;
import com.google.android.exoplayer2.decoder.DecoderException;
/**
* Thrown when an FFmpeg decoder error occurs.
*/
public final class FfmpegDecoderException extends AudioDecoderException {
/** Thrown when an FFmpeg decoder error occurs. */
public final class FfmpegDecoderException extends DecoderException {
/* package */ FfmpegDecoderException(String message) {
super(message);

View file

@ -15,12 +15,10 @@
*/
package com.google.android.exoplayer2.ext.flac;
import com.google.android.exoplayer2.audio.AudioDecoderException;
import com.google.android.exoplayer2.decoder.DecoderException;
/**
* Thrown when an Flac decoder error occurs.
*/
public final class FlacDecoderException extends AudioDecoderException {
/** Thrown when an Flac decoder error occurs. */
public final class FlacDecoderException extends DecoderException {
/* package */ FlacDecoderException(String message) {
super(message);

View file

@ -15,12 +15,10 @@
*/
package com.google.android.exoplayer2.ext.opus;
import com.google.android.exoplayer2.audio.AudioDecoderException;
import com.google.android.exoplayer2.decoder.DecoderException;
/**
* Thrown when an Opus decoder error occurs.
*/
public final class OpusDecoderException extends AudioDecoderException {
/** Thrown when an Opus decoder error occurs. */
public final class OpusDecoderException extends DecoderException {
/* package */ OpusDecoderException(String message) {
super(message);

View file

@ -26,12 +26,12 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.TraceUtil;
import com.google.android.exoplayer2.video.DecoderVideoRenderer;
import com.google.android.exoplayer2.video.VideoDecoderException;
import com.google.android.exoplayer2.video.VideoDecoderInputBuffer;
import com.google.android.exoplayer2.video.VideoDecoderOutputBuffer;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
@ -148,11 +148,8 @@ public class LibvpxVideoRenderer extends DecoderVideoRenderer {
@Override
protected SimpleDecoder<
VideoDecoderInputBuffer,
? extends VideoDecoderOutputBuffer,
? extends VideoDecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
throws VideoDecoderException {
VideoDecoderInputBuffer, ? extends VideoDecoderOutputBuffer, ? extends DecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto) throws DecoderException {
TraceUtil.beginSection("createVpxDecoder");
int initialInputBufferSize =
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
@ -167,7 +164,7 @@ public class LibvpxVideoRenderer extends DecoderVideoRenderer {
@Override
protected void renderOutputBuffer(
VideoDecoderOutputBuffer outputBuffer, long presentationTimeUs, Format outputFormat)
throws VideoDecoderException {
throws DecoderException {
if (frameMetadataListener != null) {
frameMetadataListener.onVideoFrameAboutToBeRendered(
presentationTimeUs, System.nanoTime(), outputFormat, /* mediaFormat= */ null);

View file

@ -15,10 +15,10 @@
*/
package com.google.android.exoplayer2.ext.vp9;
import com.google.android.exoplayer2.video.VideoDecoderException;
import com.google.android.exoplayer2.decoder.DecoderException;
/** Thrown when a libvpx decoder error occurs. */
public final class VpxDecoderException extends VideoDecoderException {
public final class VpxDecoderException extends DecoderException {
/* package */ VpxDecoderException(String message) {
super(message);

View file

@ -31,6 +31,7 @@ import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.audio.AudioRendererEventListener.EventDispatcher;
import com.google.android.exoplayer2.decoder.Decoder;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.decoder.SimpleOutputBuffer;
import com.google.android.exoplayer2.drm.DrmSession;
@ -105,7 +106,7 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
private int encoderPadding;
@Nullable
private Decoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
private Decoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends DecoderException>
decoder;
@Nullable private DecoderInputBuffer inputBuffer;
@ -260,8 +261,10 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
while (drainOutputBuffer()) {}
while (feedInputBuffer()) {}
TraceUtil.endSection();
} catch (AudioDecoderException | AudioSink.ConfigurationException
| AudioSink.InitializationException | AudioSink.WriteException e) {
} catch (DecoderException
| AudioSink.ConfigurationException
| AudioSink.InitializationException
| AudioSink.WriteException e) {
throw createRendererException(e, inputFormat);
}
decoderCounters.ensureUpdated();
@ -303,12 +306,11 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
* @param mediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted content.
* Maybe null and can be ignored if decoder does not handle encrypted content.
* @return The decoder.
* @throws AudioDecoderException If an error occurred creating a suitable decoder.
* @throws DecoderException If an error occurred creating a suitable decoder.
*/
protected abstract Decoder<
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
throws AudioDecoderException;
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends DecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto) throws DecoderException;
/**
* Returns the format of audio buffers output by the decoder. Will not be called until the first
@ -327,9 +329,9 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
return false;
}
private boolean drainOutputBuffer() throws ExoPlaybackException, AudioDecoderException,
AudioSink.ConfigurationException, AudioSink.InitializationException,
AudioSink.WriteException {
private boolean drainOutputBuffer()
throws ExoPlaybackException, DecoderException, AudioSink.ConfigurationException,
AudioSink.InitializationException, AudioSink.WriteException {
if (outputBuffer == null) {
outputBuffer = decoder.dequeueOutputBuffer();
if (outputBuffer == null) {
@ -374,7 +376,7 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
return false;
}
private boolean feedInputBuffer() throws AudioDecoderException, ExoPlaybackException {
private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException {
if (decoder == null || decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
|| inputStreamEnded) {
// We need to reinitialize the decoder or the input stream has ended.
@ -607,7 +609,7 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
codecInitializedTimestamp - codecInitializingTimestamp);
decoderCounters.decoderInitCount++;
} catch (AudioDecoderException e) {
} catch (DecoderException e) {
throw createRendererException(e, inputFormat);
}
}

View file

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.audio;
package com.google.android.exoplayer2.decoder;
/** Thrown when an audio decoder error occurs. */
public class AudioDecoderException extends Exception {
/** Thrown when a {@link Decoder} error occurs. */
public class DecoderException extends Exception {
/** @param message The detail message for this exception. */
public AudioDecoderException(String message) {
public DecoderException(String message) {
super(message);
}
@ -28,8 +28,7 @@ public class AudioDecoderException extends Exception {
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
* A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.
*/
public AudioDecoderException(String message, Throwable cause) {
public DecoderException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.mediacodec;
import android.media.MediaCodec;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.util.Util;
/** Thrown when a failure occurs in a {@link MediaCodec} decoder. */
public class MediaCodecDecoderException extends DecoderException {
/** The {@link MediaCodecInfo} of the decoder that failed. Null if unknown. */
@Nullable public final MediaCodecInfo codecInfo;
/** An optional developer-readable diagnostic information string. May be null. */
@Nullable public final String diagnosticInfo;
public MediaCodecDecoderException(Throwable cause, @Nullable MediaCodecInfo codecInfo) {
super("Decoder failed: " + (codecInfo == null ? null : codecInfo.name), cause);
this.codecInfo = codecInfo;
diagnosticInfo = Util.SDK_INT >= 21 ? getDiagnosticInfoV21(cause) : null;
}
@RequiresApi(21)
@Nullable
private static String getDiagnosticInfoV21(Throwable cause) {
if (cause instanceof MediaCodec.CodecException) {
return ((MediaCodec.CodecException) cause).getDiagnosticInfo();
}
return null;
}
}

View file

@ -224,30 +224,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
}
/** Thrown when a failure occurs in the decoder. */
public static class DecoderException extends Exception {
/** The {@link MediaCodecInfo} of the decoder that failed. Null if unknown. */
@Nullable public final MediaCodecInfo codecInfo;
/** An optional developer-readable diagnostic information string. May be null. */
@Nullable public final String diagnosticInfo;
public DecoderException(Throwable cause, @Nullable MediaCodecInfo codecInfo) {
super("Decoder failed: " + (codecInfo == null ? null : codecInfo.name), cause);
this.codecInfo = codecInfo;
diagnosticInfo = Util.SDK_INT >= 21 ? getDiagnosticInfoV21(cause) : null;
}
@RequiresApi(21)
private static String getDiagnosticInfoV21(Throwable cause) {
if (cause instanceof CodecException) {
return ((CodecException) cause).getDiagnosticInfo();
}
return null;
}
}
/** Indicates no codec operating rate should be set. */
protected static final float CODEC_OPERATING_RATE_UNSET = -1;
@ -926,9 +902,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
mediaCryptoRequiresSecureDecoder = false;
}
protected DecoderException createDecoderException(
protected MediaCodecDecoderException createDecoderException(
Throwable cause, @Nullable MediaCodecInfo codecInfo) {
return new DecoderException(cause, codecInfo);
return new MediaCodecDecoderException(cause, codecInfo);
}
/** Reads into {@link #flagsOnlyBuffer} and returns whether a {@link Format} was read. */

View file

@ -28,6 +28,7 @@ import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.decoder.Decoder;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.drm.DrmSession;
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
@ -77,9 +78,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
private Format inputFormat;
private Format outputFormat;
private Decoder<
VideoDecoderInputBuffer,
? extends VideoDecoderOutputBuffer,
? extends VideoDecoderException>
VideoDecoderInputBuffer, ? extends VideoDecoderOutputBuffer, ? extends DecoderException>
decoder;
private VideoDecoderInputBuffer inputBuffer;
private VideoDecoderOutputBuffer outputBuffer;
@ -179,7 +178,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
while (feedInputBuffer()) {}
TraceUtil.endSection();
} catch (VideoDecoderException e) {
} catch (DecoderException e) {
throw createRendererException(e, inputFormat);
}
decoderCounters.ensureUpdated();
@ -488,14 +487,11 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
* @param mediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted content.
* May be null and can be ignored if decoder does not handle encrypted content.
* @return The decoder.
* @throws VideoDecoderException If an error occurred creating a suitable decoder.
* @throws DecoderException If an error occurred creating a suitable decoder.
*/
protected abstract Decoder<
VideoDecoderInputBuffer,
? extends VideoDecoderOutputBuffer,
? extends VideoDecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
throws VideoDecoderException;
VideoDecoderInputBuffer, ? extends VideoDecoderOutputBuffer, ? extends DecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto) throws DecoderException;
/**
* Renders the specified output buffer.
@ -506,11 +502,11 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
* @param outputBuffer {@link VideoDecoderOutputBuffer} to render.
* @param presentationTimeUs Presentation time in microseconds.
* @param outputFormat Output {@link Format}.
* @throws VideoDecoderException If an error occurs when rendering the output buffer.
* @throws DecoderException If an error occurs when rendering the output buffer.
*/
protected void renderOutputBuffer(
VideoDecoderOutputBuffer outputBuffer, long presentationTimeUs, Format outputFormat)
throws VideoDecoderException {
throws DecoderException {
lastRenderTimeUs = C.msToUs(SystemClock.elapsedRealtime() * 1000);
int bufferMode = outputBuffer.mode;
boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && surface != null;
@ -538,10 +534,10 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
*
* @param outputBuffer {@link VideoDecoderOutputBuffer} to render.
* @param surface Output {@link Surface}.
* @throws VideoDecoderException If an error occurs when rendering the output buffer.
* @throws DecoderException If an error occurs when rendering the output buffer.
*/
protected abstract void renderOutputBufferToSurface(
VideoDecoderOutputBuffer outputBuffer, Surface surface) throws VideoDecoderException;
VideoDecoderOutputBuffer outputBuffer, Surface surface) throws DecoderException;
/**
* Sets output surface.
@ -651,12 +647,12 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
decoderInitializedTimestamp,
decoderInitializedTimestamp - decoderInitializingTimestamp);
decoderCounters.decoderInitCount++;
} catch (VideoDecoderException e) {
} catch (DecoderException e) {
throw createRendererException(e, inputFormat);
}
}
private boolean feedInputBuffer() throws VideoDecoderException, ExoPlaybackException {
private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException {
if (decoder == null
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
|| inputStreamEnded) {
@ -732,7 +728,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
* @throws ExoPlaybackException If an error occurs draining the output buffer.
*/
private boolean drainOutputBuffer(long positionUs, long elapsedRealtimeUs)
throws ExoPlaybackException, VideoDecoderException {
throws ExoPlaybackException, DecoderException {
if (outputBuffer == null) {
outputBuffer = decoder.dequeueOutputBuffer();
if (outputBuffer == null) {
@ -774,7 +770,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
* @throws ExoPlaybackException If an error occurs processing the output buffer.
*/
private boolean processOutputBuffer(long positionUs, long elapsedRealtimeUs)
throws ExoPlaybackException, VideoDecoderException {
throws ExoPlaybackException, DecoderException {
if (initialPositionUs == C.TIME_UNSET) {
initialPositionUs = positionUs;
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.video;
import android.media.MediaCodec;
import android.view.Surface;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.mediacodec.MediaCodecDecoderException;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
/** Thrown when a failure occurs in a {@link MediaCodec} video decoder. */
public class MediaCodecVideoDecoderException extends MediaCodecDecoderException {
/** The {@link System#identityHashCode(Object)} of the surface when the exception occurred. */
public final int surfaceIdentityHashCode;
/** Whether the surface was valid when the exception occurred. */
public final boolean isSurfaceValid;
public MediaCodecVideoDecoderException(
Throwable cause, @Nullable MediaCodecInfo codecInfo, @Nullable Surface surface) {
super(cause, codecInfo);
surfaceIdentityHashCode = System.identityHashCode(surface);
isSurfaceValid = surface == null || surface.isValid();
}
}

View file

@ -43,6 +43,7 @@ import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.mediacodec.MediaCodecDecoderException;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
@ -95,23 +96,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/** Magic frame render timestamp that indicates the EOS in tunneling mode. */
private static final long TUNNELING_EOS_PRESENTATION_TIME_US = Long.MAX_VALUE;
/** A {@link DecoderException} with additional surface information. */
public static final class VideoDecoderException extends DecoderException {
/** The {@link System#identityHashCode(Object)} of the surface when the exception occurred. */
public final int surfaceIdentityHashCode;
/** Whether the surface was valid when the exception occurred. */
public final boolean isSurfaceValid;
public VideoDecoderException(
Throwable cause, @Nullable MediaCodecInfo codecInfo, @Nullable Surface surface) {
super(cause, codecInfo);
surfaceIdentityHashCode = System.identityHashCode(surface);
isSurfaceValid = surface == null || surface.isValid();
}
}
private static boolean evaluatedDeviceNeedsSetOutputSurfaceWorkaround;
private static boolean deviceNeedsSetOutputSurfaceWorkaround;
@ -1303,9 +1287,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
@Override
protected DecoderException createDecoderException(
protected MediaCodecDecoderException createDecoderException(
Throwable cause, @Nullable MediaCodecInfo codecInfo) {
return new VideoDecoderException(cause, codecInfo, surface);
return new MediaCodecVideoDecoderException(cause, codecInfo, surface);
}
/**

View file

@ -1,40 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.video;
/** Thrown when a video decoder error occurs. */
public class VideoDecoderException extends Exception {
/**
* Creates an instance with the given message.
*
* @param message The detail message for this exception.
*/
public VideoDecoderException(String message) {
super(message);
}
/**
* Creates an instance with the given message and cause.
*
* @param message The detail message for this exception.
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
* A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.
*/
public VideoDecoderException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -29,6 +29,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.decoder.SimpleOutputBuffer;
@ -65,7 +66,7 @@ public class DecoderAudioRendererTest {
@Override
protected SimpleDecoder<
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends DecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto) {
return new FakeDecoder();
}
@ -114,7 +115,7 @@ public class DecoderAudioRendererTest {
}
private static final class FakeDecoder
extends SimpleDecoder<DecoderInputBuffer, SimpleOutputBuffer, AudioDecoderException> {
extends SimpleDecoder<DecoderInputBuffer, SimpleOutputBuffer, DecoderException> {
public FakeDecoder() {
super(new DecoderInputBuffer[1], new SimpleOutputBuffer[1]);
@ -136,13 +137,13 @@ public class DecoderAudioRendererTest {
}
@Override
protected AudioDecoderException createUnexpectedDecodeException(Throwable error) {
return new AudioDecoderException("Unexpected decode error", error);
protected DecoderException createUnexpectedDecodeException(Throwable error) {
return new DecoderException("Unexpected decode error", error);
}
@Override
protected AudioDecoderException decode(DecoderInputBuffer inputBuffer,
SimpleOutputBuffer outputBuffer, boolean reset) {
protected DecoderException decode(
DecoderInputBuffer inputBuffer, SimpleOutputBuffer outputBuffer, boolean reset) {
if (inputBuffer.isEndOfStream()) {
outputBuffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
}

View file

@ -31,6 +31,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.testutil.FakeSampleStream;
@ -128,10 +129,10 @@ public final class DecoderVideoRendererTest {
protected SimpleDecoder<
VideoDecoderInputBuffer,
? extends VideoDecoderOutputBuffer,
? extends VideoDecoderException>
? extends DecoderException>
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto) {
return new SimpleDecoder<
VideoDecoderInputBuffer, VideoDecoderOutputBuffer, VideoDecoderException>(
VideoDecoderInputBuffer, VideoDecoderOutputBuffer, DecoderException>(
new VideoDecoderInputBuffer[10], new VideoDecoderOutputBuffer[10]) {
@Override
protected VideoDecoderInputBuffer createInputBuffer() {
@ -144,13 +145,13 @@ public final class DecoderVideoRendererTest {
}
@Override
protected VideoDecoderException createUnexpectedDecodeException(Throwable error) {
return new VideoDecoderException("error", error);
protected DecoderException createUnexpectedDecodeException(Throwable error) {
return new DecoderException("error", error);
}
@Nullable
@Override
protected VideoDecoderException decode(
protected DecoderException decode(
VideoDecoderInputBuffer inputBuffer,
VideoDecoderOutputBuffer outputBuffer,
boolean reset) {