1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use makepad_shader_compiler::makepad_live_tokenizer::LiveId;

#[derive(Clone, Debug)]
pub struct VideoStreamEvent {
    pub video_id: LiveId,
    pub frame_group: Vec<u8>,
}

#[derive(Clone, Debug)]
pub struct VideoDecodingInitializedEvent {
    pub video_id: LiveId,
    pub frame_rate: usize,
    pub video_width: u32,
    pub video_height: u32,
    pub color_format: VideoColorFormat,
    pub duration: u128,
}

#[derive(Clone, Debug)]
pub struct VideoDecodingErrorEvent {
    pub video_id: LiveId,
    pub error: String,
}

#[derive(Default, Clone, Copy, Debug)]
pub enum VideoColorFormat {
    YUV420Planar,
    YUV420SemiPlanar,
    YUV420Flexible,
    #[default]
    Unknown,
}

impl VideoColorFormat {
    pub fn from_str(s: &str) -> Self {
        match s {
            "YUV420Flexible" => VideoColorFormat::YUV420Flexible,
            "YUV420Planar" => VideoColorFormat::YUV420Planar,
            "YUV420SemiPlanar" => VideoColorFormat::YUV420SemiPlanar,
            _ => VideoColorFormat::Unknown,
        }
    }
}