Add logging for exceptions thrown while configuring MediaCodec.
PiperOrigin-RevId: 427728320
This commit is contained in:
parent
12ce9f7c0f
commit
b9cb87153f
@ -108,7 +108,7 @@ public final class DefaultCodec implements Codec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw createInitializationTransformationException(
|
throw createInitializationTransformationException(
|
||||||
e, configurationFormat, isVideo, isDecoder, mediaCodecName);
|
e, mediaFormat, configurationFormat, isVideo, isDecoder, mediaCodecName);
|
||||||
}
|
}
|
||||||
this.mediaCodec = mediaCodec;
|
this.mediaCodec = mediaCodec;
|
||||||
this.inputSurface = inputSurface;
|
this.inputSurface = inputSurface;
|
||||||
@ -299,6 +299,7 @@ public final class DefaultCodec implements Codec {
|
|||||||
|
|
||||||
private static TransformationException createInitializationTransformationException(
|
private static TransformationException createInitializationTransformationException(
|
||||||
Exception cause,
|
Exception cause,
|
||||||
|
MediaFormat mediaFormat,
|
||||||
Format format,
|
Format format,
|
||||||
boolean isVideo,
|
boolean isVideo,
|
||||||
boolean isDecoder,
|
boolean isDecoder,
|
||||||
@ -306,6 +307,7 @@ public final class DefaultCodec implements Codec {
|
|||||||
if (cause instanceof IOException || cause instanceof MediaCodec.CodecException) {
|
if (cause instanceof IOException || cause instanceof MediaCodec.CodecException) {
|
||||||
return TransformationException.createForCodec(
|
return TransformationException.createForCodec(
|
||||||
cause,
|
cause,
|
||||||
|
mediaFormat,
|
||||||
format,
|
format,
|
||||||
isVideo,
|
isVideo,
|
||||||
isDecoder,
|
isDecoder,
|
||||||
@ -317,6 +319,7 @@ public final class DefaultCodec implements Codec {
|
|||||||
if (cause instanceof IllegalArgumentException) {
|
if (cause instanceof IllegalArgumentException) {
|
||||||
return TransformationException.createForCodec(
|
return TransformationException.createForCodec(
|
||||||
cause,
|
cause,
|
||||||
|
mediaFormat,
|
||||||
format,
|
format,
|
||||||
isVideo,
|
isVideo,
|
||||||
isDecoder,
|
isDecoder,
|
||||||
|
@ -18,6 +18,7 @@ package androidx.media3.transformer;
|
|||||||
import static java.lang.annotation.ElementType.TYPE_USE;
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||||
|
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
|
import android.media.MediaFormat;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -207,7 +208,40 @@ public final class TransformationException extends Exception {
|
|||||||
* Creates an instance for a decoder or encoder related exception.
|
* Creates an instance for a decoder or encoder related exception.
|
||||||
*
|
*
|
||||||
* @param cause The cause of the failure.
|
* @param cause The cause of the failure.
|
||||||
* @param format The {@link Format} used for configuring the decoder/encoder.
|
* @param mediaFormat The {@link MediaFormat} used for configuring the underlying {@link
|
||||||
|
* MediaCodec}, if known.
|
||||||
|
* @param format The {@link Format} used for configuring the {@link Codec}.
|
||||||
|
* @param isVideo Whether the decoder or encoder is configured for video.
|
||||||
|
* @param isDecoder Whether the exception is created for a decoder.
|
||||||
|
* @param mediaCodecName The name of the {@link MediaCodec} used, if known.
|
||||||
|
* @param errorCode See {@link #errorCode}.
|
||||||
|
* @return The created instance.
|
||||||
|
*/
|
||||||
|
public static TransformationException createForCodec(
|
||||||
|
Throwable cause,
|
||||||
|
@Nullable MediaFormat mediaFormat,
|
||||||
|
Format format,
|
||||||
|
boolean isVideo,
|
||||||
|
boolean isDecoder,
|
||||||
|
@Nullable String mediaCodecName,
|
||||||
|
int errorCode) {
|
||||||
|
String componentName = (isVideo ? "Video" : "Audio") + (isDecoder ? "Decoder" : "Encoder");
|
||||||
|
String errorMessage =
|
||||||
|
componentName
|
||||||
|
+ " error, format="
|
||||||
|
+ format
|
||||||
|
+ ", mediaCodecName="
|
||||||
|
+ mediaCodecName
|
||||||
|
+ ", mediaFormat="
|
||||||
|
+ (mediaFormat == null ? "no configured MediaFormat" : mediaFormat.toString());
|
||||||
|
return new TransformationException(errorMessage, cause, errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance for a decoder or encoder related exception.
|
||||||
|
*
|
||||||
|
* @param cause The cause of the failure.
|
||||||
|
* @param format The {@link Format} used for configuring the {@link Codec}.
|
||||||
* @param isVideo Whether the decoder or encoder is configured for video.
|
* @param isVideo Whether the decoder or encoder is configured for video.
|
||||||
* @param isDecoder Whether the exception is created for a decoder.
|
* @param isDecoder Whether the exception is created for a decoder.
|
||||||
* @param mediaCodecName The name of the {@link MediaCodec} used, if known.
|
* @param mediaCodecName The name of the {@link MediaCodec} used, if known.
|
||||||
@ -221,11 +255,8 @@ public final class TransformationException extends Exception {
|
|||||||
boolean isDecoder,
|
boolean isDecoder,
|
||||||
@Nullable String mediaCodecName,
|
@Nullable String mediaCodecName,
|
||||||
int errorCode) {
|
int errorCode) {
|
||||||
String componentName = (isVideo ? "Video" : "Audio") + (isDecoder ? "Decoder" : "Encoder");
|
return createForCodec(
|
||||||
return new TransformationException(
|
cause, /* mediaFormat= */ null, format, isVideo, isDecoder, mediaCodecName, errorCode);
|
||||||
componentName + " error, format = " + format + ", mediaCodecName=" + mediaCodecName,
|
|
||||||
cause,
|
|
||||||
errorCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user