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:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user