Replaced eglbase_jni with with holding a EglBase in PeerConnectionFactory.

Review URL: https://codereview.webrtc.org/1695763002

Cr-Commit-Position: refs/heads/master@{#11627}
This commit is contained in:
perkj
2016-02-15 06:28:36 -08:00
committed by Commit bot
parent 8259c2de02
commit 461121c67b
9 changed files with 48 additions and 152 deletions

View File

@ -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;