Commit 73d4b67e by samrobinson Committed by microkatz

Expand createNoSupportedMimeTypeException for HDR ColorInfo case.

PiperOrigin-RevId: 506900817
parent 90de454e
...@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.C; ...@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.video.ColorInfo;
/** /**
* Pipeline for processing media data. * Pipeline for processing media data.
...@@ -44,14 +45,22 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -44,14 +45,22 @@ import com.google.android.exoplayer2.util.MimeTypes;
trackType = MimeTypes.getTrackType(firstInputFormat.sampleMimeType); trackType = MimeTypes.getTrackType(firstInputFormat.sampleMimeType);
} }
protected static TransformationException createNoSupportedMimeTypeException( protected static TransformationException createNoSupportedMimeTypeException(Format format) {
Format requestedEncoderFormat) { String errorMessage = "No MIME type is supported by both encoder and muxer.";
int errorCode = TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED;
boolean isVideo = MimeTypes.isVideo(format.sampleMimeType);
if (isVideo && ColorInfo.isTransferHdr(format.colorInfo)) {
errorMessage += " Requested HDR colorInfo: " + format.colorInfo;
errorCode = TransformationException.ERROR_CODE_HDR_ENCODING_UNSUPPORTED;
}
return TransformationException.createForCodec( return TransformationException.createForCodec(
new IllegalArgumentException("No MIME type is supported by both encoder and muxer."), new IllegalArgumentException(errorMessage),
TransformationException.ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED, errorCode,
MimeTypes.isVideo(requestedEncoderFormat.sampleMimeType), isVideo,
/* isDecoder= */ false, /* isDecoder= */ false,
requestedEncoderFormat); format);
} }
@Override @Override
......
...@@ -441,19 +441,8 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -441,19 +441,8 @@ import org.checkerframework.dataflow.qual.Pure;
findSupportedMimeTypeForEncoderAndMuxer( findSupportedMimeTypeForEncoderAndMuxer(
requestedOutputMimeType, muxerSupportedMimeTypes, requestedEncoderFormat.colorInfo); requestedOutputMimeType, muxerSupportedMimeTypes, requestedEncoderFormat.colorInfo);
if (supportedMimeType == null) { if (supportedMimeType == null) {
if (ColorInfo.isTransferHdr(requestedEncoderFormat.colorInfo)) {
throw TransformationException.createForCodec(
new IllegalStateException(
"No MIME type supported by both encoder and muxer for requested HDR colorInfo: "
+ requestedEncoderFormat.colorInfo),
TransformationException.ERROR_CODE_HDR_ENCODING_UNSUPPORTED,
/* isVideo= */ true,
/* isDecoder= */ false,
requestedEncoderFormat);
} else {
throw createNoSupportedMimeTypeException(requestedEncoderFormat); throw createNoSupportedMimeTypeException(requestedEncoderFormat);
} }
}
encoder = encoder =
encoderFactory.createForVideoEncoding( encoderFactory.createForVideoEncoding(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment