Add a static rendererSupportsFormat method for MCVR

This refactors the `supportsFormat` method on the MediaCodecVideoRenderer to be a static method that can be called from external components to determine if a video format is supported by the device renderers. Since `context` is the only component that is part of the MCVR, it can easily be obtained externally and passed to the method.

This can help optimize format support decisions ahead of time of a player having been instantiated, such as removing unsupported representations from a dash manifest.

This could also be done for the MCAR but would also require passing in the AudioSink and isn't required at this time.
This commit is contained in:
Gilles Khouzam 2024-08-13 12:11:59 -07:00 committed by microkatz
parent fd48dd9ce8
commit a772e1525c

View File

@ -486,6 +486,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
@Override
protected @Capabilities int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
throws DecoderQueryException {
return rendererSupportsFormat(context, mediaCodecSelector, format);
}
public static @Capabilities int rendererSupportsFormat(
Context context,
MediaCodecSelector mediaCodecSelector,
Format format)
throws DecoderQueryException {
String mimeType = format.sampleMimeType;
if (!MimeTypes.isVideo(mimeType)) {
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);