42 #ifndef SWITCH_LOADABLE_MODULE_H 43 #define SWITCH_LOADABLE_MODULE_H 170 switch_module_load_t switch_module_load,
171 switch_module_runtime_t switch_module_runtime,
365 #define SWITCH_ADD_API(api_int, int_name, descript, funcptr, syntax_string) \ 367 api_int = (switch_api_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_API_INTERFACE); \ 368 api_int->interface_name = int_name; \ 369 api_int->desc = descript; \ 370 api_int->function = funcptr; \ 371 api_int->syntax = syntax_string; \ 375 #define SWITCH_ADD_JSON_API(json_api_int, int_name, descript, funcptr, syntax_string) \ 377 json_api_int = (switch_json_api_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_JSON_API_INTERFACE); \ 378 json_api_int->interface_name = int_name; \ 379 json_api_int->desc = descript; \ 380 json_api_int->function = funcptr; \ 381 json_api_int->syntax = syntax_string; \ 385 #define SWITCH_ADD_CHAT(chat_int, int_name, funcptr) \ 387 chat_int = (switch_chat_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_INTERFACE); \ 388 chat_int->chat_send = funcptr; \ 389 chat_int->interface_name = int_name; \ 393 #define SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \ 395 app_int = (switch_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE); \ 396 app_int->interface_name = int_name; \ 397 app_int->application_function = funcptr; \ 398 app_int->short_desc = short_descript; \ 399 app_int->long_desc = long_descript; \ 400 app_int->syntax = syntax_string; \ 401 app_int->flags = app_flags; \ 405 #define SWITCH_ADD_CHAT_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \ 407 app_int = (switch_chat_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_APPLICATION_INTERFACE); \ 408 app_int->interface_name = int_name; \ 409 app_int->chat_application_function = funcptr; \ 410 app_int->short_desc = short_descript; \ 411 app_int->long_desc = long_descript; \ 412 app_int->syntax = syntax_string; \ 413 app_int->flags = app_flags; \ 417 #define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) \ 419 dp_int = (switch_dialplan_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \ 420 dp_int->hunt_function = funcptr; \ 421 dp_int->interface_name = int_name; \ 425 #define SWITCH_ADD_LIMIT(limit_int, int_name, incrptr, releaseptr, usageptr, resetptr, statusptr, interval_resetptr) \ 427 limit_int = (switch_limit_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_LIMIT_INTERFACE); \ 428 limit_int->incr = incrptr; \ 429 limit_int->release = releaseptr; \ 430 limit_int->usage = usageptr; \ 431 limit_int->reset = resetptr; \ 432 limit_int->interval_reset = interval_resetptr; \ 433 limit_int->status = statusptr; \ 434 limit_int->interface_name = int_name; \ 440 #define SWITCH_ADD_CODEC(codec_int, int_name) \ 442 codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \ 443 codec_int->modname = switch_core_strdup(pool, (*module_interface)->module_name); \ 444 codec_int->interface_name = switch_core_strdup(pool, int_name); \ 445 codec_int->codec_id = switch_core_codec_next_id(); \ 451 uint32_t max_ms = 0, ptime_div = 0;
493 const char *iananame,
497 uint32_t samples_per_second,
499 uint32_t actual_samples_per_second,
503 int microseconds_per_packet,
505 uint32_t samples_per_packet,
507 uint32_t decoded_bytes_per_packet,
509 uint32_t encoded_bytes_per_packet,
511 uint8_t number_of_channels,
513 int codec_frames_per_packet,
526 iananame, actual_samples_per_second, microseconds_per_packet / 1000, number_of_channels, decoded_bytes_per_packet,
SWITCH_RECOMMENDED_BUFFER_SIZE);
553 iananame, actual_samples_per_second, microseconds_per_packet / 1000, number_of_channels);
563 const char *iananame,
578 memset(impl, 0,
sizeof(*impl));
602 #define SWITCH_DECLARE_STATIC_MODULE(init, load, run, shut) void init(void) { \ 603 switch_loadable_module_build_dynamic(__FILE__, load, run, shut, SWITCH_FALSE); \ switch_timer_interface_t * switch_loadable_module_get_timer_interface(const char *name)
Retrieve the timer interface by it's registered name.
#define SWITCH_MAX_CODECS
switch_loadable_module_type_t
List of loadable module types.
A module interface to implement an application.
static int switch_check_interval(uint32_t rate, uint32_t ptime)
Abstract interface to a limit module.
#define SWITCH_CHANNEL_LOG
switch_codec_type_t
Codec types.
switch_dialplan_interface_t * dialplan_interface
switch_core_codec_destroy_func_t destroy
switch_json_api_interface_t * switch_loadable_module_get_json_api_interface(const char *name)
Retrieve the JSON API interface by it's registered name.
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
switch_directory_interface_t * directory_interface
switch_directory_interface_t * switch_loadable_module_get_directory_interface(const char *name)
Retrieve the directory interface by it's registered name.
#define SWITCH_END_EXTERN_C
int switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, char fmtp_array[SWITCH_MAX_CODECS][MAX_FMTP_LEN], int arraylen, char **prefs, int preflen)
Retrieve the list of loaded codecs into an array based on another array showing the sorted order...
switch_status_t switch_loadable_module_enumerate_available(const char *dir_path, switch_modulename_callback_func_t callback, void *user_data)
Enumerates a list of all modules discovered in a directory.
#define SWITCH_RECOMMENDED_BUFFER_SIZE
switch_status_t switch_loadable_module_build_dynamic(char *filename, switch_module_load_t switch_module_load, switch_module_runtime_t switch_module_runtime, switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime)
build a dynamic module object and register it (for use in double embeded modules) ...
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
switch_status_t switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
Execute a registered API command.
switch_codec_interface_t * codec_interface
uint32_t decoded_bytes_per_packet
Representation of an event.
switch_codec_implementation_t * implementations
A module interface to implement a chat application.
switch_management_interface_t * switch_loadable_module_get_management_interface(const char *relative_oid)
Retrieve the management interface by it's registered name.
Abstract interface to a chat module.
static void switch_core_codec_add_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface, const switch_codec_type_t codec_type, switch_payload_t ianacode, const char *iananame, char *fmtp, uint32_t samples_per_second, uint32_t actual_samples_per_second, int bits_per_second, int microseconds_per_packet, uint32_t samples_per_packet, uint32_t decoded_bytes_per_packet, uint32_t encoded_bytes_per_packet, uint8_t number_of_channels, int codec_frames_per_packet, switch_core_codec_init_func_t init, switch_core_codec_encode_func_t encode, switch_core_codec_decode_func_t decode, switch_core_codec_destroy_func_t destroy)
switch_core_codec_video_decode_func_t decode_video
Abstract interface to a dialplan module.
switch_status_t(* switch_core_codec_init_func_t)(switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings)
switch_status_t switch_json_api_execute(cJSON *json, switch_core_session_t *session, cJSON **retval)
Execute a registered JSON API command.
A table of functions that a timer module implements.
switch_database_interface_t * database_interface
struct switch_runtime runtime
char * switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname, char **fmtp)
switch_status_t switch_loadable_module_protect(const char *mod)
Protect module from beeing unloaded.
Abstract interface to an asr module.
void switch_loadable_module_shutdown(void)
Shutdown the module backend and call the shutdown routine in all loaded modules.
switch_api_interface_t * switch_loadable_module_get_api_interface(const char *name)
Retrieve the API interface by it's registered name.
Abstract interface to a file format module.
switch_thread_rwlock_t * rwlock
switch_timer_interface_t * timer_interface
switch_status_t switch_loadable_module_unload_module(const char *dir, const char *fname, switch_bool_t force, const char **err)
Unoad a module.
const switch_codec_implementation_t * implementation
switch_chat_interface_t * switch_loadable_module_get_chat_interface(const char *name)
Retrieve the chat interface by it's registered name.
Abstract interface to a speech module.
switch_database_interface_t * switch_loadable_module_get_database_interface(const char *name, const char *modname)
Retrieve the database interface by it's registered name.
switch_byte_t switch_byte_t * buf
A module interface to implement an api function.
switch_core_codec_decode_func_t decode
switch_codec_interface_t * codec_interface
switch_application_interface_t * switch_loadable_module_get_application_interface(const char *name)
Retrieve the application interface by it's registered name.
switch_status_t(* switch_core_codec_video_decode_func_t)(switch_codec_t *codec, switch_frame_t *frame)
Abstract interface to a say module.
switch_codec_type_t codec_type
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
uint32_t actual_samples_per_second
Abstract interface to a management module.
switch_chat_interface_t * chat_interface
switch_speech_interface_t * speech_interface
switch_file_interface_t * switch_loadable_module_get_file_interface(const char *name, const char *modname)
Retrieve the file format interface by it's registered name.
Top level module interface to implement a series of codec implementations.
switch_endpoint_interface_t * endpoint_interface
int switch_loadable_module_get_codecs(const switch_codec_implementation_t **array, int arraylen)
Retrieve the list of loaded codecs into an array.
switch_status_t switch_loadable_module_exists(const char *mod)
Check if a module is loaded.
uint32_t switch_core_codec_next_id(void)
int microseconds_per_packet
int(* switch_modulename_callback_func_t)(void *user_data, const char *module_name)
switch_file_interface_t * file_interface
switch_application_interface_t * application_interface
switch_codec_interface_t * switch_loadable_module_get_codec_interface(const char *name, const char *modname)
Retrieve the codec interface by it's registered name.
switch_asr_interface_t * switch_loadable_module_get_asr_interface(const char *name)
Retrieve the asr interface by it's registered name.
switch_limit_interface_t * limit_interface
switch_management_interface_t * management_interface
switch_status_t switch_loadable_module_load_module(const char *dir, const char *fname, switch_bool_t runtime, const char **err)
Load a module.
switch_status_t(* switch_core_codec_video_encode_func_t)(switch_codec_t *codec, switch_frame_t *frame)
uint32_t samples_per_packet
uint8_t number_of_channels
uint32_t samples_per_second
switch_status_t
Common return values.
switch_chat_application_interface_t * switch_loadable_module_get_chat_application_interface(const char *name)
Retrieve the chat application interface by it's registered name.
static void switch_core_codec_add_video_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface, switch_payload_t ianacode, const char *iananame, char *fmtp, switch_core_codec_init_func_t init, switch_core_codec_video_encode_func_t encode, switch_core_codec_video_decode_func_t decode, switch_core_codec_control_func_t control, switch_core_codec_destroy_func_t destroy)
switch_dialplan_interface_t * switch_loadable_module_get_dialplan_interface(const char *name)
Retrieve the dialplan interface by it's registered name.
switch_endpoint_interface_t * switch_loadable_module_get_endpoint_interface(const char *name)
Retrieve the endpoint interface by it's registered name.
switch_say_interface_t * switch_loadable_module_get_say_interface(const char *name)
Retrieve the say interface by it's registered name.
switch_status_t switch_core_register_secondary_recover_callback(const char *key, switch_core_recover_callback_t cb)
void switch_core_unregister_secondary_recover_callback(const char *key)
int codec_frames_per_packet
switch_json_api_interface_t * json_api_interface
switch_payload_t ianacode
Module Interface Definitions.
switch_status_t(* switch_core_codec_control_func_t)(switch_codec_t *codec, switch_codec_control_command_t cmd, switch_codec_control_type_t ctype, void *cmd_data, switch_codec_control_type_t atype, void *cmd_arg, switch_codec_control_type_t *rtype, void **ret_data)
uint32_t encoded_bytes_per_packet
int(* switch_core_recover_callback_t)(switch_core_session_t *session)
switch_status_t switch_loadable_module_enumerate_loaded(switch_modulename_callback_func_t callback, void *user_data)
Enumerates a list of all currently loaded modules.
switch_status_t(* switch_core_codec_decode_func_t)(switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data, uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
switch_status_t switch_core_execute_chat_app(switch_event_t *message, const char *app, const char *data)
switch_core_codec_init_func_t init
struct switch_codec_implementation * next
switch_core_codec_encode_func_t encode
switch_core_recover_callback_t switch_core_get_secondary_recover_callback(const char *key)
switch_status_t switch_loadable_module_init(switch_bool_t autoload)
Initilize the module backend and load all the modules.
switch_memory_pool_t * pool
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
A table of settings and callbacks that define a paticular implementation of a codec.
A module interface to implement a json api function.
struct fspr_pool_t switch_memory_pool_t
switch_api_interface_t * api_interface
switch_core_codec_video_encode_func_t encode_video
switch_asr_interface_t * asr_interface
switch_limit_interface_t * switch_loadable_module_get_limit_interface(const char *name)
Retrieve the limit interface by it's registered name.
switch_say_interface_t * say_interface
switch_status_t(* switch_core_codec_encode_func_t)(switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data, uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
switch_chat_application_interface_t * chat_application_interface
struct fspr_thread_rwlock_t switch_thread_rwlock_t
Abstract interface to a database module.
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t **module_interface
Load a module.
The abstraction of a loadable module.
switch_core_codec_control_func_t codec_control
switch_speech_interface_t * switch_loadable_module_get_speech_interface(const char *name)
Retrieve the speech interface by it's registered name.
Abstract interface to a directory module.
#define SWITCH_BEGIN_EXTERN_C
switch_status_t(* switch_core_codec_destroy_func_t)(switch_codec_t *)