ffgl_core/
info.rs

1//! Use these to configure what the host expects from your plugin
2
3use std::ffi::c_void;
4
5use std::ffi::CStr;
6
7use num_derive::FromPrimitive;
8use num_derive::ToPrimitive;
9use num_traits::ToPrimitive;
10
11use crate::ffi::ffgl2::*;
12
13#[repr(u32)]
14#[derive(FromPrimitive, ToPrimitive, Debug, Clone, Copy, PartialEq, Default)]
15pub enum PluginType {
16    Effect = FF_EFFECT,
17    #[default]
18    Source = FF_SOURCE,
19    Mixer = FF_MIXER,
20}
21
22#[derive(PartialEq)]
23pub enum FFGLVersion {
24    // V1_5,
25    V2_1,
26}
27
28impl FFGLVersion {
29    pub const fn major(&self) -> u32 {
30        match self {
31            // FFGLVersion::V1_5 => 1,
32            FFGLVersion::V2_1 => 2,
33        }
34    }
35
36    pub const fn minor(&self) -> u32 {
37        match self {
38            // FFGLVersion::V1_5 => 5,
39            FFGLVersion::V2_1 => 1,
40        }
41    }
42}
43
44pub(crate) const FFGL_VERSION_RESOLUME: FFGLVersion = FFGLVersion::V2_1;
45
46#[derive(Debug, Clone, Default)]
47pub struct PluginInfo {
48    pub unique_id: [u8; 4],
49    pub name: [u8; 16],
50    pub ty: PluginType,
51    pub about: String,
52    pub description: String,
53}
54
55pub fn plugin_info(
56    unique_id: &[i8; 4],
57    name: &[i8; 16],
58    plugin_type: PluginType,
59) -> PluginInfoStruct {
60    PluginInfoStruct {
61        APIMajorVersion: FFGL_VERSION_RESOLUME.major(),
62        APIMinorVersion: FFGL_VERSION_RESOLUME.minor(),
63        PluginUniqueID: *unique_id,
64        PluginName: *name,
65        PluginType: plugin_type.to_u32().unwrap(),
66    }
67}
68
69pub const fn plugin_info_extended(
70    about: &'static CStr,
71    description: &'static CStr,
72) -> PluginExtendedInfoStruct {
73    PluginExtendedInfoStruct {
74        PluginMajorVersion: 0,
75        PluginMinorVersion: 0,
76        Description: about.as_ptr().cast_mut().cast(),
77        About: description.as_ptr().cast_mut().cast(),
78        FreeFrameExtendedDataSize: 0,
79        FreeFrameExtendedDataBlock: std::ptr::null::<c_void>() as *mut c_void,
80    }
81}