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