Avoid using EGLContext class for Android 4.1 and below.

Support for this class was added in Android 4.2, so
disable surface decoding for lower Android versions.

BUG=3901
R=tkchin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/31669004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7478 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
glaznev@webrtc.org 2014-10-20 19:08:05 +00:00
parent b69ea9a35a
commit a8c0edd29f
3 changed files with 27 additions and 3 deletions

View File

@ -80,6 +80,11 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
// aspect ratio is changed if necessary.
public static enum ScalingType
{ SCALE_ASPECT_FIT, SCALE_ASPECT_FILL, SCALE_FILL };
private static final int EGL14_SDK_VERSION =
android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
// Current SDK version.
private static final int CURRENT_SDK_VERSION =
android.os.Build.VERSION.SDK_INT;
private final String VERTEX_SHADER_STRING =
"varying vec2 interp_tc;\n" +
@ -666,8 +671,10 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
Log.d(TAG, "VideoRendererGui.onSurfaceCreated");
// Store render EGL context
eglContext = EGL14.eglGetCurrentContext();
Log.d(TAG, "VideoRendererGui EGL Context: " + eglContext);
if (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION) {
eglContext = EGL14.eglGetCurrentContext();
Log.d(TAG, "VideoRendererGui EGL Context: " + eglContext);
}
// Create YUV and OES programs.
yuvProgram = createProgram(VERTEX_SHADER_STRING,

View File

@ -273,11 +273,19 @@ class ClassReferenceHolder {
LoadClass(jni, "org/webrtc/IceCandidate");
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
LoadClass(jni, "android/graphics/SurfaceTexture");
LoadClass(jni, "android/opengl/EGLContext");
LoadClass(jni, "org/webrtc/MediaCodecVideoEncoder");
LoadClass(jni, "org/webrtc/MediaCodecVideoEncoder$OutputBufferInfo");
LoadClass(jni, "org/webrtc/MediaCodecVideoDecoder");
LoadClass(jni, "org/webrtc/MediaCodecVideoDecoder$DecoderOutputBufferInfo");
jclass j_decoder_class = GetClass("org/webrtc/MediaCodecVideoDecoder");
jmethodID j_is_egl14_supported_method = jni->GetStaticMethodID(
j_decoder_class, "isEGL14Supported", "()Z");
bool is_egl14_supported = jni->CallStaticBooleanMethod(
j_decoder_class, j_is_egl14_supported_method);
CHECK_EXCEPTION(jni);
if (is_egl14_supported) {
LoadClass(jni, "android/opengl/EGLContext");
}
#endif
LoadClass(jni, "org/webrtc/MediaSource$State");
LoadClass(jni, "org/webrtc/MediaStream");

View File

@ -95,6 +95,10 @@ class MediaCodecVideoDecoder {
private EGLDisplay eglDisplay = EGL14.EGL_NO_DISPLAY;
private EGLContext eglContext = EGL14.EGL_NO_CONTEXT;
private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE;
private static final int EGL14_SDK_VERSION =
android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
private static final int CURRENT_SDK_VERSION =
android.os.Build.VERSION.SDK_INT;
private MediaCodecVideoDecoder() { }
@ -166,6 +170,11 @@ class MediaCodecVideoDecoder {
return null; // No HW VP8 decoder.
}
private static boolean isEGL14Supported() {
Log.d(TAG, "SDK version: " + CURRENT_SDK_VERSION);
return (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION);
}
private static boolean isPlatformSupported() {
return findVp8Decoder(false) != null;
}