veza/veza-stream-server/src/transcoding/codecs/profiles.rs
senke 7af9c98a73 style(stream-server): apply rustfmt and fix golangci-lint v2 install
Two fixes surfaced by run #55:

1. veza-stream-server (47 files): cargo fmt had been run locally but
   never committed — the working tree was clean locally while HEAD
   had unformatted code. CI's `cargo fmt -- --check` caught the drift.
   This commit lands the formatting that was already staged.

2. ci.yml Install Go tools: `go install .../cmd/golangci-lint@latest`
   resolves to v1.64.8 (the old /cmd/ module path). The repo's
   .golangci.yml is v2-format, so v1 refuses with:
     "you are using a configuration file for golangci-lint v2
      with golangci-lint v1: please use golangci-lint v2"
   Switch to the /v2/cmd/ path so @latest actually gets v2.x.
2026-04-14 15:30:32 +02:00

139 lines
4 KiB
Rust

use super::{AudioCodec, ContainerFormat};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QualityProfile {
pub name: String,
pub bitrate: u32, // en bps (ex: 320000)
pub codec: AudioCodec,
pub sample_rate: u32,
pub channels: u8,
pub container: ContainerFormat,
pub hls_segment_time: Option<u32>, // Durée segment en secondes si HLS
}
impl QualityProfile {
/// Profil Hi-Res : 320kbps, 48kHz, Stereo, AAC
pub fn hi_res() -> Self {
Self {
name: "hi_res".to_string(),
bitrate: 320_000,
codec: AudioCodec::AAC,
sample_rate: 48_000,
channels: 2,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Profil High : 192kbps, 44.1kHz, Stereo, AAC
pub fn high() -> Self {
Self {
name: "high".to_string(),
bitrate: 192_000,
codec: AudioCodec::AAC,
sample_rate: 44_100,
channels: 2,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Profil Medium : 128kbps, 44.1kHz, Stereo, AAC
pub fn medium() -> Self {
Self {
name: "medium".to_string(),
bitrate: 128_000,
codec: AudioCodec::AAC,
sample_rate: 44_100,
channels: 2,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Profil Low : 64kbps, 22.05kHz, Mono, HE-AAC (simulé par AAC pour compatibilité max)
pub fn low() -> Self {
Self {
name: "low".to_string(),
bitrate: 64_000,
codec: AudioCodec::AAC,
sample_rate: 22_050,
channels: 1,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Profil Mobile : 32kbps, 22.05kHz, Mono, Optimisé pour réseaux faibles
pub fn mobile() -> Self {
Self {
name: "mobile".to_string(),
bitrate: 32_000,
codec: AudioCodec::AAC,
sample_rate: 22_050,
channels: 1,
container: ContainerFormat::HLS,
hls_segment_time: Some(4), // Plus court pour adaptation rapide
}
}
/// Profil Streaming High : 320kbps, 48kHz, Stereo, AAC (v0.501)
pub fn streaming_high() -> Self {
Self {
name: "streaming_high".to_string(),
bitrate: 320_000,
codec: AudioCodec::AAC,
sample_rate: 48_000,
channels: 2,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Profil Streaming Medium : 256kbps, 44.1kHz, Stereo, AAC (v0.501)
pub fn streaming_medium() -> Self {
Self {
name: "streaming_medium".to_string(),
bitrate: 256_000,
codec: AudioCodec::AAC,
sample_rate: 44_100,
channels: 2,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Profil Streaming Low : 128kbps, 44.1kHz, Stereo, AAC (v0.501)
pub fn streaming_low() -> Self {
Self {
name: "streaming_low".to_string(),
bitrate: 128_000,
codec: AudioCodec::AAC,
sample_rate: 44_100,
channels: 2,
container: ContainerFormat::HLS,
hls_segment_time: Some(6),
}
}
/// Returns the 3 streaming profiles for multi-bitrate HLS (v0.501)
pub fn streaming_profiles() -> Vec<Self> {
vec![
Self::streaming_high(),
Self::streaming_medium(),
Self::streaming_low(),
]
}
/// Retourne tous les profils standards
pub fn all_defaults() -> Vec<Self> {
vec![
Self::hi_res(),
Self::high(),
Self::medium(),
Self::low(),
Self::mobile(),
]
}
}