The goal is to provide a safe + ergonomic pit of success for mod authors, and connect freeswitch to the wider rust ecosystem.
A simple module demonstrating the basic API pattern:
use freeswitch_rs::core::Session;
use freeswitch_rs::log::{debug, info};
use freeswitch_rs::prelude::*;
#[switch_module_define(mod_hello_world)]
struct FSModule;
impl LoadableModule for FSModule {
fn load(module: FSModuleInterface, _pool: FSModulePool) -> switch_status_t {
info!("mod hello_world loading");
module.add_api(hello_world);
switch_status_t::SWITCH_STATUS_SUCCESS
}
}
#[switch_api_define]
fn hello_world(cmd: &str, _session: Option<&Session>, mut stream: StreamHandle) -> switch_status_t {
debug!("mod hello_world cmd {}", &cmd);
let _ = writeln!(stream, "+OK Success");
switch_status_t::SWITCH_STATUS_SUCCESS
}For a more advanced example with async processing and media bugs, see mods/mod_wsfork.
- This project wouldn't be possible without the work of the FreeSWITCH project, creating and maintaining an incredible open source telephony platform.
- The previous work in the area: Freeswitchrs which helped guide the way.
- The open source mods written by Dave Horton / drachtio which really helped me understand freeswitch.