| Index: webrtc/api/java/jni/androidmediaencoder_jni.cc
|
| diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
|
| index 7acb73bbd20ade3b0906ad9abceaef05fd4d8e8a..ddfa85affaea178ac9a5a5e52d30cc315deba8ab 100644
|
| --- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
|
| +++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
|
| @@ -1164,7 +1164,8 @@ const char* MediaCodecVideoEncoder::ImplementationName() const {
|
| return "MediaCodec";
|
| }
|
|
|
| -MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory() {
|
| +MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory()
|
| + : egl_context_(nullptr) {
|
| JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
| ScopedLocalRefFrame local_ref_frame(jni);
|
| jclass j_encoder_class = FindClass(jni, "org/webrtc/MediaCodecVideoEncoder");
|
| @@ -1203,13 +1204,19 @@ MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory() {
|
|
|
| MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() {
|
| ALOGD << "MediaCodecVideoEncoderFactory dtor";
|
| + if (egl_context_) {
|
| + JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
| + jni->DeleteGlobalRef(egl_context_);
|
| + }
|
| }
|
|
|
| void MediaCodecVideoEncoderFactory::SetEGLContext(
|
| - JNIEnv* jni, jobject render_egl_context) {
|
| + JNIEnv* jni, jobject egl_context) {
|
| ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext";
|
| - if (!egl_base_.CreateEglBase(jni, render_egl_context)) {
|
| - ALOGW << "Invalid EGL context - HW surface encoding is disabled.";
|
| + RTC_DCHECK(!egl_context_);
|
| + egl_context_ = jni->NewGlobalRef(egl_context);
|
| + if (CheckException(jni)) {
|
| + ALOGE << "error calling NewGlobalRef for EGL Context.";
|
| }
|
| }
|
|
|
| @@ -1225,7 +1232,7 @@ webrtc::VideoEncoder* MediaCodecVideoEncoderFactory::CreateVideoEncoder(
|
| ALOGD << "Create HW video encoder for type " << (int)type <<
|
| " (" << it->name << ").";
|
| return new MediaCodecVideoEncoder(AttachCurrentThreadIfNeeded(), type,
|
| - egl_base_.egl_base_context());
|
| + egl_context_);
|
| }
|
| }
|
| ALOGW << "Can not find HW video encoder for type " << (int)type;
|
|
|