diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java index e0542edada..a393774412 100644 --- a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java +++ b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java @@ -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, diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index d2b163974d..d82a54f4e5 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -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"); diff --git a/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java b/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java index 96d8b1baa6..f93f02a7aa 100644 --- a/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java +++ b/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoDecoder.java @@ -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; }