package com.humand.demo.modules.CallService

import android.content.Context
import android.graphics.SurfaceTexture
import io.getstream.webrtc.android.ui.VideoTextureViewRenderer

class CallVideoTextureViewRenderer(context: Context) : VideoTextureViewRenderer(context) {

    private var surfaceReadyListener: (() -> Unit)? = null

    fun setSurfaceReadyListener(listener: (() -> Unit)?) {
        surfaceReadyListener = listener
        if (listener != null && isAvailable) {
            listener.invoke()
        }
    }

    override fun onSurfaceTextureAvailable(
        surfaceTexture: SurfaceTexture,
        width: Int,
        height: Int
    ) {
        super.onSurfaceTextureAvailable(surfaceTexture, width, height)
        surfaceReadyListener?.invoke()
    }

}
