1use fission_core::ui::VideoAudioOptions;
2use fission_ir::WidgetId;
3use fission_render::LayoutRect;
4use serde::{Deserialize, Serialize};
5
6pub mod async_host;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub enum Platform {
10 Desktop,
11 Web,
12 Mobile,
13 Test,
14}
15
16#[derive(Debug, Clone, Copy, PartialEq)]
17pub struct VideoSurfaceFrame {
18 pub widget_id: WidgetId,
19 pub surface_id: u64,
20 pub rect: LayoutRect,
21}
22
23pub trait VideoBackend: Send + Sync {
24 fn create_player(&self, source: &str, audio: &VideoAudioOptions) -> Box<dyn VideoPlayer>;
25 fn present_surfaces(&self, frames: &[VideoSurfaceFrame]);
26}
27
28pub trait VideoPlayer: Send + Sync {
29 fn play(&mut self);
30 fn pause(&mut self);
31 fn stop(&mut self);
32 fn position(&self) -> u64;
33 fn duration(&self) -> Option<u64>;
34 fn surface_id(&self) -> u64;
35 fn poll_events(&mut self) -> Vec<VideoEvent>;
36 fn seek_to(&mut self, position_ms: u64);
37 fn set_rate(&mut self, rate: f32);
38 fn set_volume(&mut self, volume: f32);
39 fn set_muted(&mut self, muted: bool);
40}
41
42#[derive(Debug, Clone, PartialEq)]
43pub enum VideoEvent {
44 Ready { duration: u64 },
45 Ended,
46 Error(String),
47}