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}
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
index ddfa85a..7fa93de 100644
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
@@ -1213,7 +1213,10 @@
 void MediaCodecVideoEncoderFactory::SetEGLContext(
     JNIEnv* jni, jobject egl_context) {
   ALOGD << "MediaCodecVideoEncoderFactory::SetEGLContext";
-  RTC_DCHECK(!egl_context_);
+  if (egl_context_) {
+    jni->DeleteGlobalRef(egl_context_);
+    egl_context_ = nullptr;
+  }
   egl_context_ = jni->NewGlobalRef(egl_context);
   if (CheckException(jni)) {
     ALOGE << "error calling NewGlobalRef for EGL Context.";