package com.dronex.rec.recording

import android.content.Context
import androidx.lifecycle.LifecycleService

object RecordingSession {
    private var cameraController: RecordingCameraController? = null

    fun controller(context: Context): RecordingCameraController {
        return cameraController
                ?: RecordingCameraController(context.applicationContext).also {
                    cameraController = it
                }
    }

    fun release() {
        cameraController?.unbind()
        cameraController = null
    }

    fun startForeground(context: Context) {
        RecordingForegroundService.start(context)
    }

    fun stopForeground(context: Context) {
        RecordingForegroundService.stop(context)
    }

    fun recordingLifecycleOwner(): LifecycleService? = RecordingForegroundService.instance
}
