From f7a7698aaff417b4c7751d9fee638b2ff1ba5084 Mon Sep 17 00:00:00 2001 From: Fabian Bergmark Date: Mon, 20 Sep 2021 14:09:53 +0200 Subject: [PATCH] Mark toI420 as Nullable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:12877 Change-Id: I1b52b46bc9208d20f1887bdc87497e4eb227ecaf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232330 Reviewed-by: Niels Moller Reviewed-by: Xavier Lepaul‎ Reviewed-by: Henrik Boström Commit-Queue: Fabian Bergmark Cr-Commit-Position: refs/heads/main@{#35050} --- api/video/video_frame_buffer.h | 2 ++ sdk/android/api/org/webrtc/VideoFrame.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api/video/video_frame_buffer.h b/api/video/video_frame_buffer.h index 3e12c75a45..7b0782f9c4 100644 --- a/api/video/video_frame_buffer.h +++ b/api/video/video_frame_buffer.h @@ -69,6 +69,8 @@ class RTC_EXPORT VideoFrameBuffer : public rtc::RefCountInterface { // in another format, a conversion will take place. All implementations must // provide a fallback to I420 for compatibility with e.g. the internal WebRTC // software encoders. + // Conversion may fail, for example if reading the pixel data from a texture + // fails. If the conversion fails, nullptr is returned. virtual rtc::scoped_refptr ToI420() = 0; // GetI420() methods should return I420 buffer if conversion is trivial, i.e diff --git a/sdk/android/api/org/webrtc/VideoFrame.java b/sdk/android/api/org/webrtc/VideoFrame.java index 006635459e..e9f3b52455 100644 --- a/sdk/android/api/org/webrtc/VideoFrame.java +++ b/sdk/android/api/org/webrtc/VideoFrame.java @@ -13,6 +13,7 @@ package org.webrtc; import android.graphics.Matrix; import android.opengl.GLES11Ext; import android.opengl.GLES20; +import androidx.annotation.Nullable; import java.nio.ByteBuffer; /** @@ -53,8 +54,11 @@ public class VideoFrame implements RefCounted { * Returns a memory-backed frame in I420 format. If the pixel data is in another format, a * conversion will take place. All implementations must provide a fallback to I420 for * compatibility with e.g. the internal WebRTC software encoders. + * + *

Conversion may fail, for example if reading the pixel data from a texture fails. If the + * conversion fails, null is returned. */ - @CalledByNative("Buffer") I420Buffer toI420(); + @Nullable @CalledByNative("Buffer") I420Buffer toI420(); @Override @CalledByNative("Buffer") void retain(); @Override @CalledByNative("Buffer") void release();