From 1bb36d2c776dbd17cbbe1a4fdd69ccc7e2190183 Mon Sep 17 00:00:00 2001 From: Fabian Bergmark Date: Thu, 17 Jun 2021 11:53:24 +0200 Subject: [PATCH] Change YuvConverter.convert to catch GLExceptions and return null. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With https://webrtc-review.googlesource.com/c/src/+/222582, I420 conversion is allowed to fail. Bug: webrtc:12877 Change-Id: Iadae21ad889f084b8027206af4478223d7733d3e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/222653 Reviewed-by: Xavier Lepaul‎ Commit-Queue: Fabian Bergmark Cr-Commit-Position: refs/heads/master@{#34320} --- sdk/android/api/org/webrtc/YuvConverter.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sdk/android/api/org/webrtc/YuvConverter.java b/sdk/android/api/org/webrtc/YuvConverter.java index 0e2d5055f7..9c00678900 100644 --- a/sdk/android/api/org/webrtc/YuvConverter.java +++ b/sdk/android/api/org/webrtc/YuvConverter.java @@ -12,6 +12,8 @@ package org.webrtc; import android.graphics.Matrix; import android.opengl.GLES20; +import android.opengl.GLException; +import android.support.annotation.Nullable; import java.nio.ByteBuffer; import org.webrtc.VideoFrame.I420Buffer; import org.webrtc.VideoFrame.TextureBuffer; @@ -20,7 +22,9 @@ import org.webrtc.VideoFrame.TextureBuffer; * Class for converting OES textures to a YUV ByteBuffer. It can be constructed on any thread, but * should only be operated from a single thread with an active EGL context. */ -public class YuvConverter { +public final class YuvConverter { + private static final String TAG = "YuvConverter"; + private static final String FRAGMENT_SHADER = // Difference in texture coordinate corresponding to one // sub-pixel in the x direction. @@ -122,9 +126,17 @@ public class YuvConverter { } /** Converts the texture buffer to I420. */ + @Nullable public I420Buffer convert(TextureBuffer inputTextureBuffer) { - threadChecker.checkIsOnValidThread(); + try { + return convertInternal(inputTextureBuffer); + } catch (GLException e) { + Logging.w(TAG, "Failed to convert TextureBuffer", e); + } + return null; + } + private I420Buffer convertInternal(TextureBuffer inputTextureBuffer) { TextureBuffer preparedBuffer = (TextureBuffer) videoFrameDrawer.prepareBufferForViewportSize( inputTextureBuffer, inputTextureBuffer.getWidth(), inputTextureBuffer.getHeight());