Add a way to force a frame to be sent from SurfaceTextureHelper
This allows forcing a minimum frame rate if the producer doesn’t update
the SurfaceTexture often.
This needs to be done in SurfaceTextureHelper to keep the
synchronization of the texture access consistent.
Bug: b/149383039
Change-Id: I0e3c82dd51d486b931bd8dda0fd9d5cdb1a90901
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177001
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Xavier Lepaul <xalep@google.com>
Cr-Commit-Position: refs/heads/master@{#31504}
diff --git a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
index 3522a87..b7b028f 100644
--- a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
+++ b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
@@ -263,6 +263,17 @@
});
}
+ /**
+ * Forces a frame to be produced. If no new frame is available, the last frame is sent to the
+ * listener again.
+ */
+ public void forceFrame() {
+ handler.post(() -> {
+ hasPendingTexture = true;
+ tryDeliverTextureFrame();
+ });
+ }
+
/** Set the rotation of the delivered frames. */
public void setFrameRotation(int rotation) {
handler.post(() -> this.frameRotation = rotation);