[Android 6+] Add ability to always use ExoPlayer's MediaVideoCodecRenderer setOutputSurface workaround

As some devices not present in ExoPlayer's list may not implement
MediaCodec.setOutputSurface(Surface) properly, this workaround could be useful
on these devices.

It forces ExoPlayer to fall back on releasing and re-instantiating video codec
instances, which is always used on Android 5 and lower due to addition of this
method in Android 6.

To do so, a CustomMediaCodecVideoRenderer, based on ExoPlayer's
MediaVideoCodecRenderer which always return true for the
codecNeedsSetOutputSurfaceWorkaround method has been added, which is used in
CustomRenderersFactory, a class based on DefaultRenderersFactory which always
returns our CustomMediaCodecVideoRenderer as the video renderers.

CustomRenderersFactory replaces DefaultRenderersFactory in the player, in the
case this setting is enabled.
This commit is contained in:
AudricV 2023-02-26 19:39:17 +01:00 committed by Stypox
parent a02b92fd59
commit 787758a436
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
6 changed files with 121 additions and 6 deletions

View file

@ -777,4 +777,6 @@
<string name="settings_category_exoplayer_summary">Manage some ExoPlayer settings. These changes require a player restart to take effect</string>
<string name="use_exoplayer_decoder_fallback_title">Use ExoPlayer\'s decoder fallback feature</string>
<string name="use_exoplayer_decoder_fallback_summary">Enable this option if you have decoder initialization issues, which falls back to lower-priority decoders if primary decoders initialization fail. This may result in poor playback performance than when using primary decoders</string>
<string name="always_use_exoplayer_set_output_surface_workaround_title">Always use ExoPlayer\'s video output surface setting workaround</string>
<string name="always_use_exoplayer_set_output_surface_workaround_summary">This workaround releases and re-instantiates video codecs when a surface change occurs, instead of setting the surface to the codec directly. Already used by ExoPlayer on some devices with this issue, this setting has only an effect on Android 6 and higher\n\nEnabling this option may prevent playback errors when switching the current video player or switching to fullscreen</string>
</resources>