janus_plugin_sys/
plugin.rs

1use jansson_sys::json_t;
2use std::os::raw::{c_char, c_int, c_void, c_short};
3use glib_sys::gboolean;
4
5#[repr(C)]
6#[derive(Debug)]
7pub struct janus_callbacks {
8    pub push_event: extern "C" fn(
9        handle: *mut janus_plugin_session,
10        plugin: *mut janus_plugin,
11        transaction: *const c_char,
12        message: *mut json_t,
13        jsep: *mut json_t,
14    ) -> c_int,
15    pub relay_rtp: extern "C" fn(handle: *mut janus_plugin_session, packet: *mut janus_plugin_rtp),
16    pub relay_rtcp: extern "C" fn(handle: *mut janus_plugin_session, packet: *mut janus_plugin_rtcp),
17    pub relay_data: extern "C" fn(handle: *mut janus_plugin_session, packet: *mut janus_plugin_data),
18    pub send_pli: extern "C" fn(handle: *mut janus_plugin_session),
19    pub send_remb: extern "C" fn(handle: *mut janus_plugin_session, bitrate: c_int),
20    pub close_pc: extern "C" fn(handle: *mut janus_plugin_session),
21    pub end_session: extern "C" fn(handle: *mut janus_plugin_session),
22    pub events_is_enabled: extern "C" fn() -> c_int,
23    pub notify_event: extern "C" fn(plugin: *mut janus_plugin, handle: *mut janus_plugin_session, event: *mut json_t),
24    pub auth_is_signature_valid: extern "C" fn(plugin: *mut janus_plugin, token: *const c_char) -> gboolean,
25    pub auth_signature_contains: extern "C" fn(plugin: *mut janus_plugin, token: *const c_char, descriptor: *const c_char) -> gboolean,
26}
27
28#[repr(i32)]
29#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
30pub enum janus_plugin_result_type {
31    JANUS_PLUGIN_ERROR = -1,
32    JANUS_PLUGIN_OK = 0,
33    JANUS_PLUGIN_OK_WAIT = 1,
34}
35
36#[repr(C)]
37#[derive(Debug)]
38pub struct janus_plugin_session {
39    pub gateway_handle: *mut c_void,
40    pub plugin_handle: *mut c_void,
41    pub stopped: c_int,
42    pub ref_: crate::janus_refcount,
43}
44
45#[repr(C)]
46#[derive(Debug)]
47pub struct janus_plugin_result {
48    pub type_: janus_plugin_result_type,
49    pub text: *const c_char,
50    pub content: *mut json_t,
51}
52
53#[repr(C)]
54#[derive(Debug)]
55pub struct janus_plugin_rtp_extensions {
56    pub audio_level : c_char,
57    pub audio_level_vad : c_char,
58    pub video_rotation : c_short,
59    pub video_back_camera : c_char,
60    pub video_flipped : c_char,
61}
62
63#[repr(C)]
64#[derive(Debug)]
65pub struct janus_plugin_rtp {
66    pub video :  c_char,
67    pub buffer : *mut c_char,
68    pub length : c_short,
69    pub extensions : janus_plugin_rtp_extensions,
70}
71
72#[repr(C)]
73#[derive(Debug)]
74pub struct janus_plugin_rtcp {
75    pub video : c_char,
76    pub buffer : *mut c_char,
77    pub length : c_short,
78}
79
80#[repr(C)]
81#[derive(Debug)]
82pub struct janus_plugin_data {
83    pub label : *mut c_char,
84    pub protocol : *mut c_char,
85    pub binary : c_char,
86    pub buffer : *mut c_char,
87    pub length : c_short,
88}
89
90#[repr(C)]
91#[derive(Debug)]
92pub struct janus_plugin {
93    pub init: unsafe extern "C" fn(callback: *mut janus_callbacks, config_path: *const c_char) -> c_int,
94    pub destroy: unsafe extern "C" fn(),
95    pub get_api_compatibility: unsafe extern "C" fn() -> c_int,
96    pub get_version: unsafe extern "C" fn() -> c_int,
97    pub get_version_string: unsafe extern "C" fn() -> *const c_char,
98    pub get_description: unsafe extern "C" fn() -> *const c_char,
99    pub get_name: unsafe extern "C" fn() -> *const c_char,
100    pub get_author: unsafe extern "C" fn() -> *const c_char,
101    pub get_package: unsafe extern "C" fn() -> *const c_char,
102    pub create_session: unsafe extern "C" fn(handle: *mut janus_plugin_session, error: *mut c_int),
103    pub handle_message: unsafe extern "C" fn(
104        handle: *mut janus_plugin_session,
105        transaction: *mut c_char,
106        message: *mut json_t,
107        jsep: *mut json_t,
108    ) -> *mut janus_plugin_result,
109    pub handle_admin_message: unsafe extern "C" fn(message: *mut json_t) -> *mut json_t,
110    pub setup_media: unsafe extern "C" fn(handle: *mut janus_plugin_session),
111    pub incoming_rtp: unsafe extern "C" fn(handle: *mut janus_plugin_session, packet: *mut janus_plugin_rtp),
112    pub incoming_rtcp: unsafe extern "C" fn(handle: *mut janus_plugin_session, packet: *mut janus_plugin_rtcp),
113    pub incoming_data: unsafe extern "C" fn(handle: *mut janus_plugin_session, packet: *mut janus_plugin_data),
114    pub data_ready: unsafe extern "C" fn(handle: *mut janus_plugin_session),
115    pub slow_link: unsafe extern "C" fn(handle: *mut janus_plugin_session, uplink: c_int, video: c_int),
116    pub hangup_media: unsafe extern "C" fn(handle: *mut janus_plugin_session),
117    pub destroy_session: unsafe extern "C" fn(handle: *mut janus_plugin_session, error: *mut c_int),
118    pub query_session: unsafe extern "C" fn(handle: *mut janus_plugin_session) -> *mut json_t,
119}
120
121extern "C" {
122    pub fn janus_plugin_result_new(type_: janus_plugin_result_type, text: *const c_char, content: *mut json_t) -> *mut janus_plugin_result;
123    pub fn janus_plugin_result_destroy(result: *mut janus_plugin_result);
124}