From ab8779086b037468db3e6e07d294c70c76e85cde Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 17 Dec 2015 03:35:39 -0800 Subject: [PATCH] Fix broken video on Galaxy S5 and Note III --- app/src/main/java/com/limelight/Game.java | 4 +++ .../binding/video/MediaCodecHelper.java | 25 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 8308741f..169ab998 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -10,6 +10,7 @@ import com.limelight.binding.input.evdev.EvdevListener; import com.limelight.binding.input.evdev.EvdevWatcher; import com.limelight.binding.video.EnhancedDecoderRenderer; import com.limelight.binding.video.MediaCodecDecoderRenderer; +import com.limelight.binding.video.MediaCodecHelper; import com.limelight.nvstream.NvConnection; import com.limelight.nvstream.NvConnectionListener; import com.limelight.nvstream.StreamConfiguration; @@ -198,6 +199,9 @@ public class Game extends Activity implements SurfaceHolder.Callback, return; } + // Initialize the MediaCodec helper before creating the decoder + MediaCodecHelper.initializeWithContext(this); + decoderRenderer = new MediaCodecDecoderRenderer(prefConfig.videoFormat); // Display a message to the user if H.265 was forced on but we still didn't find a decoder diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecHelper.java b/app/src/main/java/com/limelight/binding/video/MediaCodecHelper.java index 353e97a2..8f30973e 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecHelper.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecHelper.java @@ -10,6 +10,9 @@ import java.util.Locale; import android.annotation.SuppressLint; import android.annotation.TargetApi; +import android.app.ActivityManager; +import android.content.Context; +import android.content.pm.ConfigurationInfo; import android.media.MediaCodecInfo; import android.media.MediaCodecList; import android.media.MediaCodecInfo.CodecCapabilities; @@ -76,11 +79,31 @@ public class MediaCodecHelper { whitelistedHevcDecoders = new LinkedList<>(); whitelistedHevcDecoders.add("omx.exynos"); - whitelistedHevcDecoders.add("omx.qcom"); whitelistedHevcDecoders.add("omx.nvidia"); whitelistedHevcDecoders.add("omx.mtk"); whitelistedHevcDecoders.add("omx.amlogic"); whitelistedHevcDecoders.add("omx.rk"); + // omx.qcom added conditionally during initialization + } + + public static void initializeWithContext(Context context) { + ActivityManager activityManager = + (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo(); + if (configInfo.reqGlEsVersion != ConfigurationInfo.GL_ES_VERSION_UNDEFINED) { + // Qualcomm's early HEVC decoders break hard on our HEVC stream. The best check to + // tell the good from the bad decoders are the generation of Adreno GPU included: + // 3xx - bad + // 4xx - good + // + // Unfortunately, it's not that easy to get that information here, so I'll use an + // approximation by checking the GLES level (<= 3.0 is bad). + LimeLog.info("OpenGL ES version: "+configInfo.reqGlEsVersion); + if (configInfo.reqGlEsVersion > 0x30000) { + LimeLog.info("Added omx.qcom to supported decoders based on GLES 3.1+ support"); + whitelistedHevcDecoders.add("omx.qcom"); + } + } } private static boolean isDecoderInList(List decoderList, String decoderName) {