in amazon-chime-sdk/src/main/java/com/amazonaws/services/chime/sdk/meetings/internal/video/gl/DefaultEglRenderer.kt [101:129]
override fun createEglSurface(inputSurface: Any) {
check(inputSurface is SurfaceTexture || inputSurface is Surface) { "Surface must be SurfaceTexture or Surface" }
surface = inputSurface
renderHandler?.post {
logger.info(TAG, "Request on handler thread to create EGL surface from input surface $surface")
if (eglCore != null && eglCore?.eglSurface == EGL14.EGL_NO_SURFACE && surface != null) {
val surfaceAttributess = intArrayOf(EGL14.EGL_NONE)
eglCore?.eglSurface = EGL14.eglCreateWindowSurface(
eglCore?.eglDisplay, eglCore?.eglConfig, surface,
surfaceAttributess, 0
)
EGL14.eglMakeCurrent(
eglCore?.eglDisplay,
eglCore?.eglSurface,
eglCore?.eglSurface,
eglCore?.eglContext
)
// Necessary for YUV frames with odd width.
GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1)
}
// Discard any old frame
synchronized(ShareEglLock.Lock) {
pendingFrame?.release()
pendingFrame = null
}
}
}