androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.72k stars 413 forks source link

Make MediaCodecVideoRenderer::shouldUsePlaceholderSurface protected. #1905

Open khouzam opened 2 days ago

khouzam commented 2 days ago

This enables a derived renderer to disable the placeholder surface.

Not having a placeholder surface allows to delay instantiating the codecs until we have a surface. This allows to have more players ready without having their decoders loaded.

This follows the mode that shouldUseDetachedSurface is protected and overridable by a derived class.

Since getSurfaceForCodec must call hasSurfaceForCodec, the check for the placeholder surface in getSurfaceForCodec should not trigger if we disable the placeholder surface as hasSurfaceForCodec would have returned false.

microkatz commented 5 hours ago

@khouzam

Thanks for submitting your request! Just a curiosity, have you looked at [MediaCodecVideoRenderer::shouldInitCodec] for your use case? Its already overridable and utilized by MediaCodecRenderer to decide if the decoder should be initialized.