2025-12-03 19:36:56 +00:00
|
|
|
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),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-08 18:57:54 +00:00
|
|
|
/// 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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 17:16:37 +00:00
|
|
|
/// 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> {
|
2026-04-14 13:30:32 +00:00
|
|
|
vec![
|
|
|
|
|
Self::streaming_high(),
|
|
|
|
|
Self::streaming_medium(),
|
|
|
|
|
Self::streaming_low(),
|
|
|
|
|
]
|
2026-02-22 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-03 19:36:56 +00:00
|
|
|
/// Retourne tous les profils standards
|
|
|
|
|
pub fn all_defaults() -> Vec<Self> {
|
2026-04-14 13:30:32 +00:00
|
|
|
vec![
|
|
|
|
|
Self::hi_res(),
|
|
|
|
|
Self::high(),
|
|
|
|
|
Self::medium(),
|
|
|
|
|
Self::low(),
|
|
|
|
|
Self::mobile(),
|
|
|
|
|
]
|
2025-12-03 19:36:56 +00:00
|
|
|
}
|
|
|
|
|
}
|