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