kplayer_rust_wrap/kplayer/plugin/
mod.rs

1#[derive(Copy, Clone)]
2#[allow(dead_code)]
3pub enum MediaType {
4    MediaTypeNone,
5    MediaTypeVideo,
6    MediaTypeAudio,
7}
8
9pub enum InstanceType {
10    InstanceTypeSide,
11    InstanceTypeLink,
12}
13
14#[derive(Copy, Clone)]
15#[allow(dead_code)]
16pub struct Timer {
17    tid: i32,
18    milliseconds: i32,
19}
20impl Timer {
21    pub fn get_tid(&self) -> i32 {
22        self.tid
23    }
24    pub fn get_milliseconds(&self) -> i32 {
25        self.milliseconds
26    }
27    pub fn new(_tid: i32, _milliseconds: i32) -> Self {
28        Timer {
29            tid: _tid,
30            milliseconds: _milliseconds,
31        }
32    }
33}
34
35pub trait BasePlugin {
36    // get plugin name
37    fn get_name(&self) -> String;
38
39    // get plugin author
40    fn get_author(&self) -> String;
41
42    // get plugin args
43    fn get_args(&mut self, args: std::collections::HashMap<String, String>) -> Vec<String>;
44
45    // get plugin allow custom args
46    fn get_allow_custom_args(&self) -> Vec<&'static str> {
47        let vec: Vec<&'static str> = Vec::new();
48        vec
49    }
50
51    // get plugin filter name
52    fn get_filter_name(&self) -> String;
53
54    // get plugin media type
55    fn get_media_type(&self) -> MediaType;
56
57    // validate args
58    fn validate_user_args(
59        &mut self,
60        args: std::collections::HashMap<String, String>,
61    ) -> Result<bool, &'static str>;
62
63    // print plugin log
64    fn print_log(&self, level: super::util::os::PrintLogLevel, log: &str) {
65        super::util::os::print_log(level, &format!("[{}] {}", self.get_name(), log).to_string())
66    }
67
68    // get timer
69    fn register_task(&self) -> Vec<Timer> {
70        let empty: Vec<Timer> = Vec::new();
71        empty
72    }
73
74    // get subscribe key
75    fn register_message_keys(&self) -> Vec<super::proto::keys::EventMessageAction> {
76        let empty: Vec<super::proto::keys::EventMessageAction> = Vec::new();
77        empty
78    }
79
80    // execute timer
81    #[warn(unused_variables)]
82    fn execute_task(&mut self, _tid: u32) {}
83
84    // execute message
85    #[allow(unused_variables)]
86    fn execute_message(&mut self, action: i32, body: String) {}
87
88    // get instance type
89    #[allow(unused_variables)]
90    fn get_instance_type(&mut self) -> InstanceType {
91        InstanceType::InstanceTypeLink
92    }
93
94    // hook created
95    #[allow(unused_variables)]
96    fn hook_created(&mut self) -> i32 {
97        0
98    }
99}