[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

@ -29,4 +29,12 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
</PreferenceScreen>
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="@string/always_use_exoplayer_set_output_surface_workaround_key"
android:summary="@string/always_use_exoplayer_set_output_surface_workaround_summary"
android:title="@string/always_use_exoplayer_set_output_surface_workaround_title"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
</PreferenceScreen>