use std::time::Duration;
use rskit_errors::AppResult;
use rskit_storage::FileSource;
use crate::spatial::Resolution;
use crate::time::Timestamp;
use super::{Chapter, KeyframeInfo, MediaMetadata, SilenceInterval};
#[async_trait::async_trait]
pub trait MediaProbe: Send + Sync {
async fn probe(&self, source: &FileSource) -> AppResult<MediaMetadata>;
async fn thumbnail(
&self,
source: &FileSource,
at: Timestamp,
resolution: Option<Resolution>,
) -> AppResult<FileSource>;
async fn thumbnails(
&self,
source: &FileSource,
interval: Duration,
resolution: Option<Resolution>,
) -> AppResult<Vec<FileSource>>;
async fn sprite_sheet(
&self,
_source: &FileSource,
_interval: Duration,
_thumb_resolution: Resolution,
_columns: u32,
) -> AppResult<FileSource> {
Err(rskit_errors::AppError::new(
rskit_errors::ErrorCode::InvalidInput,
"sprite_sheet not supported by this backend",
))
}
async fn scene_detect(
&self,
_source: &FileSource,
_threshold: f64,
) -> AppResult<Vec<Timestamp>> {
Err(rskit_errors::AppError::new(
rskit_errors::ErrorCode::InvalidInput,
"scene_detect not supported by this backend",
))
}
async fn waveform(
&self,
_source: &FileSource,
_resolution: Resolution,
) -> AppResult<FileSource> {
Err(rskit_errors::AppError::new(
rskit_errors::ErrorCode::InvalidInput,
"waveform not supported by this backend",
))
}
async fn keyframes(&self, _source: &FileSource) -> AppResult<Vec<KeyframeInfo>> {
Err(rskit_errors::AppError::new(
rskit_errors::ErrorCode::InvalidInput,
"keyframes not supported by this backend",
))
}
async fn silence_detect(
&self,
_source: &FileSource,
_min_duration: Duration,
_noise_threshold_db: f64,
) -> AppResult<Vec<SilenceInterval>> {
Err(rskit_errors::AppError::new(
rskit_errors::ErrorCode::InvalidInput,
"silence_detect not supported by this backend",
))
}
async fn chapters(&self, _source: &FileSource) -> AppResult<Vec<Chapter>> {
Err(rskit_errors::AppError::new(
rskit_errors::ErrorCode::InvalidInput,
"chapters not supported by this backend",
))
}
}