/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/
#![feature(exit_status_error)]

use serde::{Deserialize, Serialize};
use std::sync::{LazyLock, Mutex};

pub mod fragment;
pub mod image;
pub mod subtitles;
pub mod thumbnail;

#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct Config {
    #[serde(default)] pub enable_rkmpp: bool,
    #[serde(default)] pub enable_rkrga: bool,
    #[serde(default)] pub use_svtav1: bool,
    #[serde(default)] pub use_rav1e: bool,
    pub svtav1_preset: Option<u8>, // 0..=13, high is fast
    pub rav1e_preset: Option<u8>,  // 0..=10
    pub aom_preset: Option<u8>,    // 0..=8, high is fast
    pub x264_preset: Option<String>,
}

pub static CONF_PRELOAD: Mutex<Option<Config>> = Mutex::new(None);
static CONF: LazyLock<Config> = LazyLock::new(|| {
    CONF_PRELOAD
        .lock()
        .unwrap()
        .take()
        .expect("transcoder config not preloaded. logic error")
});

static LOCAL_VIDEO_TRANSCODING_TASKS: Mutex<()> = Mutex::new(());
