fix: pair front camera analysis with a local drained preview surface

This commit is contained in:
zenord
2026-10-13 18:54:59 +08:00
parent 4010675f8c
commit 688bb7d6b3
20 changed files with 453 additions and 24 deletions
+12
View File
@@ -1,4 +1,16 @@
package android.graphics
class SurfaceTexture(val texture: Int) {
fun interface OnFrameAvailableListener {fun onFrameAvailable(surface: SurfaceTexture)}
var released=false;var updates=0;var throwUpdate=false
var width=0;var height=0
private var listener: OnFrameAvailableListener?=null;private var handler: android.os.Handler?=null
init {check(texture in android.opengl.GLES20.liveTextures)}
fun setDefaultBufferSize(w: Int,h: Int) {width=w;height=h}
fun setOnFrameAvailableListener(l: OnFrameAvailableListener?,h: android.os.Handler?=null) {listener=l;handler=h}
fun frame() {val cb=listener ?: return;handler!!.post {cb.onFrameAvailable(this)}}
fun updateTexImage() {check(!released);if(throwUpdate) error("synthetic_update_failure");updates++}
fun release() {check(!released);released=true}
}
object ImageFormat {const val YUV_420_888=35}
class Matrix {fun postRotate(f: Float) {}}
class Rect(val left: Int,val top: Int,val right: Int,val bottom: Int) {fun width()=right-left;fun height()=bottom-top}