From f0ab6a0169c6617ea5054b801f331aebe9b93bd2 Mon Sep 17 00:00:00 2001 From: Xavier Lepaul Date: Thu, 11 Jun 2020 14:03:56 +0200 Subject: [PATCH] Add a way to force a frame to be sent from SurfaceTextureHelper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Xavier Lepaul Cr-Commit-Position: refs/heads/master@{#31504} --- sdk/android/api/org/webrtc/SurfaceTextureHelper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java index 3522a87487..b7b028f5ae 100644 --- a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java +++ b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java @@ -263,6 +263,17 @@ public class SurfaceTextureHelper { }); } + /** + * 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);