package com.example.livingai.data.repository.media

import android.graphics.Bitmap
import com.example.livingai.domain.ml.AIModel
import com.example.livingai.domain.repository.VideoRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class VideoRepositoryImpl(private val aiModel: AIModel) : VideoRepository {

    private var isRecording = false

    override fun startRecording(onRecordingStarted: () -> Unit) {
        isRecording = true
        // Logic to start recording video if needed
        onRecordingStarted()
    }

    override fun stopRecording() {
        isRecording = false
        // Logic to stop recording
    }

    override suspend fun processFrame(bitmap: Bitmap): String = withContext(Dispatchers.Default) {
        if (isRecording) {
            aiModel.deriveInference(bitmap)
        } else {
            ""
        }
    }
}