aboutsummaryrefslogtreecommitdiff
path: root/common/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/config.rs')
-rw-r--r--common/src/config.rs119
1 files changed, 44 insertions, 75 deletions
diff --git a/common/src/config.rs b/common/src/config.rs
index d7682df..df16ef0 100644
--- a/common/src/config.rs
+++ b/common/src/config.rs
@@ -4,27 +4,53 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use crate::{jhls::EncodingProfile, user::PermissionSet};
+use crate::user::PermissionSet;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf};
-#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct GlobalConfig {
pub hostname: String,
pub brand: String,
pub slogan: String,
- #[serde(default = "return_true" )] pub tls: bool,
- #[serde(default = "default::asset_path")] pub asset_path: PathBuf,
- #[serde(default = "default::database_path")] pub database_path: PathBuf,
- #[serde(default = "default::cache_path")] pub cache_path: PathBuf,
- #[serde(default = "default::media_path")] pub media_path: PathBuf,
- #[serde(default = "default::secrets_path")] pub secrets_path: PathBuf,
- #[serde(default = "default::transcoding_profiles")] pub transcoding_profiles: Vec<EncodingProfile>,
- #[serde(default = "default::max_in_memory_cache_size")] pub max_in_memory_cache_size: usize,
- #[serde(default)] pub admin_username: Option<String>,
- #[serde(default = "default::login_expire")] pub login_expire: i64,
- #[serde(default)] pub default_permission_set: PermissionSet,
+ #[serde(default = "return_true")]
+ pub tls: bool,
+ pub asset_path: PathBuf,
+ pub database_path: PathBuf,
+ pub cache_path: PathBuf,
+ pub media_path: PathBuf,
+ pub secrets_path: PathBuf,
+ #[serde(default = "max_in_memory_cache_size")]
+ pub max_in_memory_cache_size: usize,
+ #[serde(default)]
+ pub admin_username: Option<String>,
+ #[serde(default = "login_expire")]
+ pub login_expire: i64,
+ #[serde(default)]
+ pub default_permission_set: PermissionSet,
+ #[serde(default)]
+ pub encoders: EncoderArgs,
+}
+
+#[derive(Debug, Deserialize, Serialize, Default)]
+pub struct EncoderArgs {
+ pub avc: Option<String>,
+ pub hevc: Option<String>,
+ pub vp8: Option<String>,
+ pub vp9: Option<String>,
+ pub av1: Option<String>,
+ pub generic: Option<String>,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone, Copy)]
+#[serde(rename_all = "snake_case")]
+pub enum EncoderClass {
+ Aom,
+ Svt,
+ X26n,
+ Vpx,
+ Vaapi,
+ Rkmpp,
}
#[derive(Serialize, Deserialize, Debug, Default)]
@@ -58,68 +84,11 @@ pub struct ApiSecrets {
pub trakt: Option<String>,
}
-mod default {
- use crate::jhls::EncodingProfile;
- use std::path::PathBuf;
-
- pub fn login_expire() -> i64 {
- 60 * 60 * 24
- }
- pub fn asset_path() -> PathBuf {
- "data/assets".into()
- }
- pub fn database_path() -> PathBuf {
- "data/database".into()
- }
- pub fn cache_path() -> PathBuf {
- "data/cache".into()
- }
- pub fn media_path() -> PathBuf {
- "data/media".into()
- }
- pub fn secrets_path() -> PathBuf {
- "data/secrets.yaml".into()
- }
- pub fn max_in_memory_cache_size() -> usize {
- 50_000_000
- }
- pub fn transcoding_profiles() -> Vec<EncodingProfile> {
- vec![
- EncodingProfile::Video {
- codec: "libsvtav1".to_string(),
- preset: Some(8),
- bitrate: 2_000_000,
- width: Some(1920),
- },
- EncodingProfile::Video {
- codec: "libsvtav1".to_string(),
- preset: Some(8),
- bitrate: 1_200_000,
- width: Some(1280),
- },
- EncodingProfile::Video {
- codec: "libsvtav1".to_string(),
- preset: Some(8),
- bitrate: 300_000,
- width: Some(640),
- },
- EncodingProfile::Audio {
- codec: "libopus".to_string(),
- bitrate: 128_000,
- sample_rate: None,
- channels: Some(2),
- },
- EncodingProfile::Audio {
- codec: "libopus".to_string(),
- bitrate: 64_000,
- sample_rate: None,
- channels: Some(2),
- },
- EncodingProfile::Subtitles {
- codec: "webvtt".to_string(),
- },
- ]
- }
+fn login_expire() -> i64 {
+ 60 * 60 * 24
+}
+fn max_in_memory_cache_size() -> usize {
+ 50_000_000
}
fn return_true() -> bool {