use std::path::{Path, PathBuf};
use crate::error::PlatformError;
use super::media_interaction::MediaKind;
#[derive(Debug, Clone)]
pub struct ImageInfo {
pub width: u32,
pub height: u32,
pub mime_type: Option<String>,
}
#[derive(Debug, Clone)]
pub struct CompressImageRequest {
pub source_uri: String,
pub quality: u8,
pub max_width: Option<u32>,
pub max_height: Option<u32>,
pub output_path: PathBuf,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum VideoCompressQuality {
Low,
Medium,
High,
}
#[derive(Debug, Clone)]
pub struct CompressVideoRequest {
pub source_uri: String,
pub quality: Option<VideoCompressQuality>,
pub bitrate_kbps: Option<u32>,
pub fps: Option<u32>,
pub resolution_ratio: Option<f32>,
pub output_path: PathBuf,
}
#[derive(Debug, Clone)]
pub struct CompressedVideo {
pub path: PathBuf,
pub width: u32,
pub height: u32,
pub duration_ms: u64,
pub size: u64,
pub mime_type: Option<String>,
}
#[derive(Debug, Clone)]
pub struct VideoInfo {
pub width: u32,
pub height: u32,
pub duration_ms: u64,
pub rotation: Option<u16>,
pub bitrate: Option<u64>,
pub fps: Option<f32>,
pub mime_type: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ExtractVideoThumbnailRequest {
pub source_uri: String,
pub output_path: PathBuf,
pub max_width: Option<u32>,
pub max_height: Option<u32>,
pub time_ms: Option<u64>,
pub quality: u8,
}
#[derive(Debug, Clone)]
pub struct VideoThumbnail {
pub path: PathBuf,
pub width: u32,
pub height: u32,
pub mime_type: Option<String>,
}
pub trait MediaRuntime: Send + Sync + 'static {
fn copy_album_media_to_file(
&self,
uri: &str,
dest_path: &Path,
kind: MediaKind,
) -> Result<(), PlatformError>;
fn get_image_info(&self, uri: &str) -> Result<ImageInfo, PlatformError>;
fn compress_image(&self, request: &CompressImageRequest) -> Result<PathBuf, PlatformError>;
fn compress_video(
&self,
request: &CompressVideoRequest,
) -> Result<CompressedVideo, PlatformError>;
fn get_video_info(&self, uri: &str) -> Result<VideoInfo, PlatformError>;
fn extract_video_thumbnail(
&self,
request: &ExtractVideoThumbnailRequest,
) -> Result<VideoThumbnail, PlatformError>;
}