package com.example.godeye.models

/**
 * Модель данных для статистики видео трансляции
 */
data class VideoStatistics(
    val fps: Int = 0,
    val width: Int = 0,
    val height: Int = 0,
    val bitrate: Long = 0,
    val bytesSent: Long = 0,
    val packetsLost: Int = 0,
    val jitter: Double = 0.0,
    val rtt: Long = 0,
    val framerate: Int = 0 // ДОБАВЛЕНО: для совместимости
) {
    val resolution: String
        get() = "${width}x${height}"

    val qualityLevel: VideoQuality
        get() = when {
            width >= 1920 -> VideoQuality.FULL_HD
            width >= 1280 -> VideoQuality.HD
            width >= 854 -> VideoQuality.SD
            else -> VideoQuality.LOW
        }
}

enum class VideoQuality {
    LOW, SD, HD, FULL_HD
}

/**
 * Состояние трансляции
 */
data class StreamingState(
    val isStreaming: Boolean = false,
    val sessionId: String? = null,
    val operatorId: String? = null,
    val startTime: Long = 0,
    val cameraType: String = "back",
    val statistics: VideoStatistics = VideoStatistics()
) {
    val duration: Long
        get() = if (isStreaming) System.currentTimeMillis() - startTime else 0
}
