package com.foxx.androidcast.diagnostics;

/*********************************************************************
 * CastDiagnosticsLabels.java
 * Created at: Sat 16 May 2026 13:35:48 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class CastDiagnosticsLabels
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (6 commits, 159 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	1c6f25ad871cb71788ed6fd1817d4d59d22d5ef6638704c9483937a2a9c15977
**********************************************************************/
import com.foxx.androidcast.CastSettings;
import com.foxx.androidcast.media.codec.jni.NativeCodecBridge;

/** Human-readable names for diagnostics (no bare AUTO enum tokens). */
public final class CastDiagnosticsLabels {
    private CastDiagnosticsLabels() {}

    public static String congestionController() {
        return "PassThroughNetworkControlPlane (heartbeat stats)";
    }

    public static String bitrateMode(CastSettings.BitrateMode mode) {
        if (mode == null) {
            return "CastTuningEngine (default)";
        }
        switch (mode) {
            case NONE:
                return "Uncapped encoder bitrate";
            case QUALITY:
                return "Quality bias (+25% bitrate)";
            case SPEED:
                return "Speed bias (−35% bitrate, ≤24 fps)";
            case BALANCED:
                return "Balanced preset";
            case ROBUST_LESS:
                return "RobustLess (UDP, −45% bitrate)";
            case ESTIMATED:
                return "CastTuningEngine bandwidth estimate";
            case AUTO:
            default:
                return "CastTuningEngine (preset + peer stats)";
        }
    }

    public static String networkAdoption(CastSettings.NetworkAdoption mode) {
        if (mode == null) {
            return "No extra network scaling";
        }
        switch (mode) {
            case QUALITY:
                return "Quality bias (+10% bitrate)";
            case SPEED:
                return "Speed bias (−30% bitrate)";
            case ESTIMATED:
                return "CastTuningEngine recv-bitrate cap";
            case AUTO:
            default:
                return "No extra network scaling";
        }
    }

    public static String adjustmentPreset(CastSettings.AdjustmentPreset preset) {
        if (preset == null) {
            return "CastTuningEngine default";
        }
        switch (preset) {
            case NONE:
                return "No preset adjustments";
            case QUALITY:
                return "Quality (+15% bitrate, +2 fps)";
            case SPEED:
                return "Speed (−15% bitrate)";
            case PERFORMANCE:
                return "Performance (−15% bitrate, stable fps)";
            case AUTO:
            default:
                return "CastTuningEngine adaptive preset";
        }
    }

    public static String resolution(CastSettings.Resolution res) {
        if (res == null) {
            return "Device default";
        }
        switch (res) {
            case FULL:
                return "Full display";
            case THREE_QUARTERS:
                return "75% display scale";
            case HALF:
                return "50% display scale";
            case HD_720P:
                return "720p long-edge cap";
            case SD_480P:
                return "480p long-edge cap";
            case FIXED_1080P:
                return "Fixed 1080p box";
            case FIXED_720P:
                return "Fixed 720p box";
            case ADAPTIVE:
                return "Adaptive (CastTuningEngine + peer)";
            default:
                return res.name();
        }
    }

    public static String videoCodec(CastSettings.VideoCodec codec) {
        if (codec == null) {
            return "CodecNegotiator preference list";
        }
        switch (codec) {
            case H264:
                return "H.264 (forced)";
            case H265:
                return "H.265 (forced)";
            case PASSTHROUGH:
                return "Passthrough (debug, unimplemented)";
            case LIBVPX_VP8:
                return com.foxx.androidcast.media.codec.jni.NativeCodecBridge.isLibvpxAvailable()
                        ? "libvpx VP8" : "libvpx VP8 (HW fallback)";
            case LIBVPX_VP9:
                return com.foxx.androidcast.media.codec.jni.NativeCodecBridge.isLibvpxAvailable()
                        ? "libvpx VP9" : "libvpx VP9 (HW fallback)";
            case AUTO:
            default:
                return "AUTO (lowest priority score wins)";
        }
    }

    public static String audioCodec(CastSettings.AudioCodec codec) {
        if (codec == null) {
            return "AUTO (AAC via MediaCodec)";
        }
        switch (codec) {
            case AAC:
                return "AAC-LC (forced)";
            case SPEEX:
                return NativeCodecBridge.isSpeexAvailable()
                        ? "Speex (native)" : "Speex (fallback AAC)";
            case OPUS:
                return NativeCodecBridge.isOpusAvailable()
                        ? "Opus + in-band FEC (native)" : "Opus (fallback AAC)";
            case PASSTHROUGH_DEBUG:
                return "Passthrough AAC (debug)";
            case AUTO:
            default:
                return "AUTO (AAC via MediaCodec)";
        }
    }

    public static String captureMode(CastSettings.CaptureMode mode) {
        if (mode == null) {
            return "Entire screen";
        }
        switch (mode) {
            case USER_CHOICE:
                return "Choose app or screen (Android 14+)";
            case CALIBRATION_TEST:
                return "Calibration test pattern";
            case CAMERA:
                return "Camera (Camera2, planned)";
            case FULL_SCREEN:
            default:
                return "Entire screen";
        }
    }
}
