| Index: talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
|
| diff --git a/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc b/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
|
| index 7f558c0551b07e657d2163df58167a4734ecf06d..89246cf311779e73bd7881fba9a5b7b8b359ae1a 100644
|
| --- a/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
|
| +++ b/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
|
| @@ -127,7 +127,7 @@ class MediaCodecVideoEncoder : public webrtc::VideoEncoder,
|
|
|
| int GetTargetFramerate() override;
|
|
|
| - bool SupportsNativeHandle() const override { return true; }
|
| + bool SupportsNativeHandle() const override { return egl_context_ != nullptr; }
|
| const char* ImplementationName() const override;
|
|
|
| private:
|
| @@ -520,7 +520,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread(
|
| gof_idx_ = 0;
|
|
|
| // We enforce no extra stride/padding in the format creation step.
|
| - jobject j_video_codec_enum = JavaEnumFromIndex(
|
| + jobject j_video_codec_enum = JavaEnumFromIndexAndClassName(
|
| jni, "MediaCodecVideoEncoder$VideoCodecType", codecType_);
|
| const bool encode_status = jni->CallBooleanMethod(
|
| *j_media_codec_video_encoder_, j_init_encode_method_,
|
| @@ -1114,8 +1114,7 @@ const char* MediaCodecVideoEncoder::ImplementationName() const {
|
| return "MediaCodec";
|
| }
|
|
|
| -MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory()
|
| - : egl_context_(nullptr) {
|
| +MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory() {
|
| JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
| ScopedLocalRefFrame local_ref_frame(jni);
|
| jclass j_encoder_class = FindClass(jni, "org/webrtc/MediaCodecVideoEncoder");
|
| @@ -1152,32 +1151,15 @@ MediaCodecVideoEncoderFactory::MediaCodecVideoEncoderFactory()
|
| }
|
| }
|
|
|
| -MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() {}
|
| +MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() {
|
| + ALOGD << "MediaCodecVideoEncoderFactory dtor";
|
| +}
|
|
|
| void MediaCodecVideoEncoderFactory::SetEGLContext(
|
| JNIEnv* jni, jobject render_egl_context) {
|
| ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext";
|
| - if (egl_context_) {
|
| - jni->DeleteGlobalRef(egl_context_);
|
| - egl_context_ = NULL;
|
| - }
|
| - if (!IsNull(jni, render_egl_context)) {
|
| - egl_context_ = jni->NewGlobalRef(render_egl_context);
|
| - if (CheckException(jni)) {
|
| - ALOGE << "error calling NewGlobalRef for EGL Context.";
|
| - egl_context_ = NULL;
|
| - } else {
|
| - jclass j_egl_context_class =
|
| - FindClass(jni, "org/webrtc/EglBase14$Context");
|
| - if (!jni->IsInstanceOf(egl_context_, j_egl_context_class)) {
|
| - ALOGE << "Wrong EGL Context.";
|
| - jni->DeleteGlobalRef(egl_context_);
|
| - egl_context_ = NULL;
|
| - }
|
| - }
|
| - }
|
| - if (egl_context_ == NULL) {
|
| - ALOGW << "NULL VideoDecoder EGL context - HW surface encoding is disabled.";
|
| + if (!egl_base_.CreateEglBase(jni, render_egl_context)) {
|
| + ALOGW << "Invalid EGL context - HW surface encoding is disabled.";
|
| }
|
| }
|
|
|
| @@ -1185,7 +1167,7 @@ webrtc::VideoEncoder* MediaCodecVideoEncoderFactory::CreateVideoEncoder(
|
| VideoCodecType type) {
|
| if (supported_codecs_.empty()) {
|
| ALOGW << "No HW video encoder for type " << (int)type;
|
| - return NULL;
|
| + return nullptr;
|
| }
|
| for (std::vector<VideoCodec>::const_iterator it = supported_codecs_.begin();
|
| it != supported_codecs_.end(); ++it) {
|
| @@ -1193,11 +1175,11 @@ webrtc::VideoEncoder* MediaCodecVideoEncoderFactory::CreateVideoEncoder(
|
| ALOGD << "Create HW video encoder for type " << (int)type <<
|
| " (" << it->name << ").";
|
| return new MediaCodecVideoEncoder(AttachCurrentThreadIfNeeded(), type,
|
| - egl_context_);
|
| + egl_base_.egl_base_context());
|
| }
|
| }
|
| ALOGW << "Can not find HW video encoder for type " << (int)type;
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| const std::vector<MediaCodecVideoEncoderFactory::VideoCodec>&
|
|
|