package com.performancecoachlab.posedetection.recording

import kotlinx.coroutines.flow.Flow

/**
 * Pixel-coordinate crop rectangle applied after decode + rotation.
 * [x] and [y] are the top-left corner; [width] and [height] are the crop size.
 */
data class CropRect(val x: Int, val y: Int, val width: Int, val height: Int)

expect suspend fun extractFrame(
    videoPath: String, frameTimestamp: Long
): InputFrame?

/**
 * Batch sequential frame extraction as a Flow. More efficient than repeated
 * [extractFrame] calls for processing many frames from the same video.
 * Frames are emitted in the order of [frameTimestamps] (must be ascending).
 *
 * If [cropRect] is provided, each frame is cropped to those pixel coordinates
 * after decode and rotation. This avoids processing full-resolution pixels
 * downstream.
 */
expect fun extractFrames(
    videoPath: String,
    frameTimestamps: List<Long>,
    cropRect: CropRect? = null,
): Flow<InputFrame>

expect suspend fun listVideoFrameTimestamps(
    videoPath: String,
): List<Long>

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect object VideoExtractionContext
