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