Mark toI420 as Nullable

Bug: webrtc:12877
Change-Id: I1b52b46bc9208d20f1887bdc87497e4eb227ecaf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232330
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Fabian Bergmark <fabianbergmark@google.com>
Cr-Commit-Position: refs/heads/main@{#35050}
diff --git a/api/video/video_frame_buffer.h b/api/video/video_frame_buffer.h
index 3e12c75..7b0782f 100644
--- a/api/video/video_frame_buffer.h
+++ b/api/video/video_frame_buffer.h
@@ -69,6 +69,8 @@
   // 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<I420BufferInterface> 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 0066354..e9f3b52 100644
--- a/sdk/android/api/org/webrtc/VideoFrame.java
+++ b/sdk/android/api/org/webrtc/VideoFrame.java
@@ -13,6 +13,7 @@
 import android.graphics.Matrix;
 import android.opengl.GLES11Ext;
 import android.opengl.GLES20;
+import androidx.annotation.Nullable;
 import java.nio.ByteBuffer;
 
 /**
@@ -53,8 +54,11 @@
      * 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.
+     *
+     * <p> 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();