mirror of
https://github.com/samsonjs/media.git
synced 2026-04-20 13:45:47 +00:00
Widen setOutputSurface workaround
This commit is contained in:
parent
7d4ac516e7
commit
50c8197004
1 changed files with 167 additions and 37 deletions
|
|
@ -84,6 +84,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
// pending output streams that have fewer frames than the codec latency.
|
||||
private static final int MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT = 10;
|
||||
|
||||
private static boolean evaluatedDeviceNeedsSetOutputSurfaceWorkaround;
|
||||
private static boolean deviceNeedsSetOutputSurfaceWorkaround;
|
||||
|
||||
private final Context context;
|
||||
private final VideoFrameReleaseTimeHelper frameReleaseTimeHelper;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
|
@ -825,11 +828,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
private boolean shouldUseDummySurface(MediaCodecInfo codecInfo) {
|
||||
return Util.SDK_INT >= 23
|
||||
&& !tunneling
|
||||
&& !codecNeedsDummySurfaceWorkaround(codecInfo.name)
|
||||
&& !codecNeedsSetOutputSurfaceWorkaround(codecInfo.name)
|
||||
&& (!codecInfo.secure || DummySurface.isSecureSupported(context));
|
||||
}
|
||||
|
||||
|
||||
private void setJoiningDeadlineMs() {
|
||||
joiningDeadlineMs = allowedJoiningTimeMs > 0
|
||||
? (SystemClock.elapsedRealtime() + allowedJoiningTimeMs) : C.TIME_UNSET;
|
||||
|
|
@ -1172,20 +1174,36 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
return Util.SDK_INT <= 22 && "foster".equals(Util.DEVICE) && "NVIDIA".equals(Util.MANUFACTURER);
|
||||
}
|
||||
|
||||
private static boolean codecNeedsDummySurfaceWorkaround(String name) {
|
||||
// Work around https://github.com/google/ExoPlayer/issues/4419.
|
||||
return (("needle".equals(Util.DEVICE)) // FireTV 4K
|
||||
&& "OMX.amlogic.avc.decoder.awesome".equals(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the device is known to implement {@link MediaCodec#setOutputSurface(Surface)}
|
||||
* incorrectly.
|
||||
* <p>
|
||||
* If true is returned then we fall back to releasing and re-instantiating the codec instead.
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* 1. Validate that Android device certification now ensures correct behavior, and add a
|
||||
* corresponding SDK_INT upper bound for applying the workaround (probably SDK_INT < 26).
|
||||
* 2. Determine a complete list of affected devices.
|
||||
* 3. Some of the devices in this list only fail to support setOutputSurface when switching from
|
||||
* a SurfaceView provided Surface to a Surface of another type (e.g. TextureView/DummySurface),
|
||||
* and vice versa. One hypothesis is that setOutputSurface fails when the surfaces have
|
||||
* different pixel formats. If we can find a way to query the Surface instances to determine
|
||||
* whether this case applies, then we'll be able to provide a more targeted workaround.
|
||||
*/
|
||||
private static boolean codecNeedsSetOutputSurfaceWorkaround(String name) {
|
||||
// Work around https://github.com/google/ExoPlayer/issues/3236,
|
||||
/**
|
||||
* Returns whether the codec is known to implement {@link MediaCodec#setOutputSurface(Surface)}
|
||||
* incorrectly.
|
||||
*
|
||||
* <p>If true is returned then we fall back to releasing and re-instantiating the codec instead.
|
||||
*
|
||||
* @param name The name of the codec.
|
||||
* @return True if the device is known to implement {@link MediaCodec#setOutputSurface(Surface)}
|
||||
* incorrectly.
|
||||
*/
|
||||
protected boolean codecNeedsSetOutputSurfaceWorkaround(String name) {
|
||||
if (Util.SDK_INT >= 27 || name.startsWith("OMX.google")) {
|
||||
// Devices running API level 27 or later should also be unaffected. Google OMX decoders are
|
||||
// not known to have this issue on any API level.
|
||||
return false;
|
||||
}
|
||||
// Work around:
|
||||
// https://github.com/google/ExoPlayer/issues/3236,
|
||||
// https://github.com/google/ExoPlayer/issues/3355,
|
||||
// https://github.com/google/ExoPlayer/issues/3439,
|
||||
// https://github.com/google/ExoPlayer/issues/3724,
|
||||
|
|
@ -1194,28 +1212,140 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
// https://github.com/google/ExoPlayer/issues/4084,
|
||||
// https://github.com/google/ExoPlayer/issues/4104,
|
||||
// https://github.com/google/ExoPlayer/issues/4134,
|
||||
// https://github.com/google/ExoPlayer/issues/4315.
|
||||
return (("deb".equals(Util.DEVICE) // Nexus 7 (2013)
|
||||
|| "flo".equals(Util.DEVICE) // Nexus 7 (2013)
|
||||
|| "mido".equals(Util.DEVICE) // Redmi Note 4
|
||||
|| "santoni".equals(Util.DEVICE)) // Redmi 4X
|
||||
&& "OMX.qcom.video.decoder.avc".equals(name))
|
||||
|| (("tcl_eu".equals(Util.DEVICE) // TCL Percee TV
|
||||
|| "SVP-DTV15".equals(Util.DEVICE) // Sony Bravia 4K 2015
|
||||
|| "BRAVIA_ATV2".equals(Util.DEVICE) // Sony Bravia 4K GB
|
||||
|| Util.DEVICE.startsWith("panell_") // Motorola Moto C Plus
|
||||
|| "F3311".equals(Util.DEVICE) // Sony Xperia E5
|
||||
|| "M5c".equals(Util.DEVICE) // Meizu M5C
|
||||
|| "QM16XE_U".equals(Util.DEVICE) // Philips QM163E
|
||||
|| "A7010a48".equals(Util.DEVICE) // Lenovo K4 Note
|
||||
|| "woods_f".equals(Util.MODEL) // Moto E (4)
|
||||
|| "watson".equals(Util.DEVICE)) // Moto C
|
||||
&& "OMX.MTK.VIDEO.DECODER.AVC".equals(name))
|
||||
|| (("ALE-L21".equals(Util.MODEL) // Huawei P8 Lite
|
||||
|| "CAM-L21".equals(Util.MODEL)) // Huawei Y6II
|
||||
&& "OMX.k3.video.decoder.avc".equals(name))
|
||||
|| (("HUAWEI VNS-L21".equals(Util.MODEL)) // Huawei P9 Lite
|
||||
&& "OMX.IMG.MSVDX.Decoder.AVC".equals(name));
|
||||
// https://github.com/google/ExoPlayer/issues/4315,
|
||||
// https://github.com/google/ExoPlayer/issues/4419,
|
||||
// https://github.com/google/ExoPlayer/issues/4460,
|
||||
// https://github.com/google/ExoPlayer/issues/4468.
|
||||
synchronized (MediaCodecVideoRenderer.class) {
|
||||
if (!evaluatedDeviceNeedsSetOutputSurfaceWorkaround) {
|
||||
switch (Util.DEVICE) {
|
||||
case "1601":
|
||||
case "1713":
|
||||
case "1714":
|
||||
case "A10-70F":
|
||||
case "A1601":
|
||||
case "A2016a40":
|
||||
case "A7000-a":
|
||||
case "A7000plus":
|
||||
case "A7010a48":
|
||||
case "A7020a48":
|
||||
case "AquaPowerM":
|
||||
case "Aura_Note_2":
|
||||
case "BLACK-1X":
|
||||
case "BRAVIA_ATV2":
|
||||
case "C1":
|
||||
case "ComioS1":
|
||||
case "CP8676_I02":
|
||||
case "CPH1609":
|
||||
case "CPY83_I00":
|
||||
case "cv1":
|
||||
case "cv3":
|
||||
case "deb":
|
||||
case "E5643":
|
||||
case "ELUGA_A3_Pro":
|
||||
case "ELUGA_Note":
|
||||
case "ELUGA_Prim":
|
||||
case "ELUGA_Ray_X":
|
||||
case "EverStar_S":
|
||||
case "F3111":
|
||||
case "F3113":
|
||||
case "F3116":
|
||||
case "F3211":
|
||||
case "F3213":
|
||||
case "F3215":
|
||||
case "F3311":
|
||||
case "flo":
|
||||
case "GiONEE_CBL7513":
|
||||
case "GiONEE_GBL7319":
|
||||
case "GIONEE_GBL7360":
|
||||
case "GIONEE_SWW1609":
|
||||
case "GIONEE_SWW1627":
|
||||
case "GIONEE_SWW1631":
|
||||
case "GIONEE_WBL5708":
|
||||
case "GIONEE_WBL7365":
|
||||
case "GIONEE_WBL7519":
|
||||
case "griffin":
|
||||
case "htc_e56ml_dtul":
|
||||
case "hwALE-H":
|
||||
case "HWBLN-H":
|
||||
case "HWCAM-H":
|
||||
case "HWVNS-H":
|
||||
case "iball8735_9806":
|
||||
case "Infinix-X572":
|
||||
case "iris60":
|
||||
case "itel_S41":
|
||||
case "j2xlteins":
|
||||
case "JGZ":
|
||||
case "K50a40":
|
||||
case "le_x6":
|
||||
case "LS-5017":
|
||||
case "M5c":
|
||||
case "manning":
|
||||
case "marino_f":
|
||||
case "MEIZU_M5":
|
||||
case "mh":
|
||||
case "mido":
|
||||
case "MX6":
|
||||
case "namath":
|
||||
case "nicklaus_f":
|
||||
case "NX541J":
|
||||
case "NX573J":
|
||||
case "OnePlus5T":
|
||||
case "p212":
|
||||
case "P681":
|
||||
case "P85":
|
||||
case "panell_d":
|
||||
case "panell_dl":
|
||||
case "panell_ds":
|
||||
case "panell_dt":
|
||||
case "PB2-670M":
|
||||
case "PGN528":
|
||||
case "PGN610":
|
||||
case "PGN611":
|
||||
case "Phantom6":
|
||||
case "Pixi4-7_3G":
|
||||
case "Pixi5-10_4G":
|
||||
case "PLE":
|
||||
case "Q350":
|
||||
case "Q4260":
|
||||
case "Q427":
|
||||
case "Q4310":
|
||||
case "Q5":
|
||||
case "QM16XE_U":
|
||||
case "QX1":
|
||||
case "santoni":
|
||||
case "Slate_Pro":
|
||||
case "SVP-DTV15":
|
||||
case "s905x018":
|
||||
case "taido_row":
|
||||
case "TB3-730F":
|
||||
case "TB3-730X":
|
||||
case "TB3-850F":
|
||||
case "TB3-850M":
|
||||
case "tcl_eu":
|
||||
case "V1":
|
||||
case "V23GB":
|
||||
case "V5":
|
||||
case "vernee_M5":
|
||||
case "watson":
|
||||
case "whyred":
|
||||
case "woods_f":
|
||||
case "woods_fn":
|
||||
case "X3_HK":
|
||||
case "XE2X":
|
||||
case "XT1663":
|
||||
case "Z12_PRO":
|
||||
case "Z80":
|
||||
deviceNeedsSetOutputSurfaceWorkaround = true;
|
||||
break;
|
||||
default:
|
||||
// Workaround not required.
|
||||
break;
|
||||
}
|
||||
evaluatedDeviceNeedsSetOutputSurfaceWorkaround = true;
|
||||
}
|
||||
}
|
||||
return deviceNeedsSetOutputSurfaceWorkaround;
|
||||
}
|
||||
|
||||
protected static final class CodecMaxValues {
|
||||
|
|
|
|||
Loading…
Reference in a new issue