Change PeerConnectionFactory.setVideoHwAccelerationOptions to be able to replace Egl context.

BUG=b/27222102
R=glaznev@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#11666}
This commit is contained in:
Per
2016-02-18 11:35:48 +01:00
parent 74db777d64
commit fd22e6cf2d
3 changed files with 15 additions and 4 deletions

View File

@ -896,7 +896,10 @@ MediaCodecVideoDecoderFactory::~MediaCodecVideoDecoderFactory() {
void MediaCodecVideoDecoderFactory::SetEGLContext( void MediaCodecVideoDecoderFactory::SetEGLContext(
JNIEnv* jni, jobject egl_context) { JNIEnv* jni, jobject egl_context) {
ALOGD << "MediaCodecVideoDecoderFactory::SetEGLContext"; ALOGD << "MediaCodecVideoDecoderFactory::SetEGLContext";
RTC_DCHECK(!egl_context_); if (egl_context_) {
jni->DeleteGlobalRef(egl_context_);
egl_context_ = nullptr;
}
egl_context_ = jni->NewGlobalRef(egl_context); egl_context_ = jni->NewGlobalRef(egl_context);
if (CheckException(jni)) { if (CheckException(jni)) {
ALOGE << "error calling NewGlobalRef for EGL Context."; ALOGE << "error calling NewGlobalRef for EGL Context.";

View File

@ -1213,7 +1213,10 @@ MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() {
void MediaCodecVideoEncoderFactory::SetEGLContext( void MediaCodecVideoEncoderFactory::SetEGLContext(
JNIEnv* jni, jobject egl_context) { JNIEnv* jni, jobject egl_context) {
ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext"; ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext";
RTC_DCHECK(!egl_context_); if (egl_context_) {
jni->DeleteGlobalRef(egl_context_);
egl_context_ = nullptr;
}
egl_context_ = jni->NewGlobalRef(egl_context); egl_context_ = jni->NewGlobalRef(egl_context);
if (CheckException(jni)) { if (CheckException(jni)) {
ALOGE << "error calling NewGlobalRef for EGL Context."; ALOGE << "error calling NewGlobalRef for EGL Context.";

View File

@ -171,8 +171,13 @@ public class PeerConnectionFactory {
*/ */
public void setVideoHwAccelerationOptions(EglBase.Context localEglContext, public void setVideoHwAccelerationOptions(EglBase.Context localEglContext,
EglBase.Context remoteEglContext) { EglBase.Context remoteEglContext) {
if (localEglbase != null || remoteEglbase != null) { if (localEglbase != null) {
throw new IllegalStateException("Egl context already set."); Logging.w(TAG, "Egl context already set.");
localEglbase.release();
}
if (remoteEglbase != null) {
Logging.w(TAG, "Egl context already set.");
remoteEglbase.release();
} }
localEglbase = EglBase.create(localEglContext); localEglbase = EglBase.create(localEglContext);
remoteEglbase = EglBase.create(remoteEglContext); remoteEglbase = EglBase.create(remoteEglContext);