41 #ifndef SWITCH_LOADABLE_MODULE_H
42 #define SWITCH_LOADABLE_MODULE_H
159 switch_module_load_t switch_module_load,
160 switch_module_runtime_t switch_module_runtime,
340 #define SWITCH_ADD_API(api_int, int_name, descript, funcptr, syntax_string) \
342 api_int = (switch_api_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_API_INTERFACE); \
343 api_int->interface_name = int_name; \
344 api_int->desc = descript; \
345 api_int->function = funcptr; \
346 api_int->syntax = syntax_string; \
350 #define SWITCH_ADD_JSON_API(json_api_int, int_name, descript, funcptr, syntax_string) \
352 json_api_int = (switch_json_api_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_JSON_API_INTERFACE); \
353 json_api_int->interface_name = int_name; \
354 json_api_int->desc = descript; \
355 json_api_int->function = funcptr; \
356 json_api_int->syntax = syntax_string; \
360 #define SWITCH_ADD_CHAT(chat_int, int_name, funcptr) \
362 chat_int = (switch_chat_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_INTERFACE); \
363 chat_int->chat_send = funcptr; \
364 chat_int->interface_name = int_name; \
368 #define SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \
370 app_int = (switch_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE); \
371 app_int->interface_name = int_name; \
372 app_int->application_function = funcptr; \
373 app_int->short_desc = short_descript; \
374 app_int->long_desc = long_descript; \
375 app_int->syntax = syntax_string; \
376 app_int->flags = app_flags; \
380 #define SWITCH_ADD_CHAT_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \
382 app_int = (switch_chat_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_APPLICATION_INTERFACE); \
383 app_int->interface_name = int_name; \
384 app_int->chat_application_function = funcptr; \
385 app_int->short_desc = short_descript; \
386 app_int->long_desc = long_descript; \
387 app_int->syntax = syntax_string; \
388 app_int->flags = app_flags; \
392 #define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) \
394 dp_int = (switch_dialplan_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \
395 dp_int->hunt_function = funcptr; \
396 dp_int->interface_name = int_name; \
400 #define SWITCH_ADD_LIMIT(limit_int, int_name, incrptr, releaseptr, usageptr, resetptr, statusptr, interval_resetptr) \
402 limit_int = (switch_limit_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_LIMIT_INTERFACE); \
403 limit_int->incr = incrptr; \
404 limit_int->release = releaseptr; \
405 limit_int->usage = usageptr; \
406 limit_int->reset = resetptr; \
407 limit_int->interval_reset = interval_resetptr; \
408 limit_int->status = statusptr; \
409 limit_int->interface_name = int_name; \
415 #define SWITCH_ADD_CODEC(codec_int, int_name) \
417 codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \
418 codec_int->modname = switch_core_strdup(pool, (*module_interface)->module_name); \
419 codec_int->interface_name = switch_core_strdup(pool, int_name); \
420 codec_int->codec_id = switch_core_codec_next_id(); \
426 uint32_t max_ms = 0, ptime_div = 0;
471 const char *iananame,
475 uint32_t samples_per_second,
477 uint32_t actual_samples_per_second,
481 int microseconds_per_packet,
483 uint32_t samples_per_packet,
485 uint32_t decoded_bytes_per_packet,
487 uint32_t encoded_bytes_per_packet,
489 uint8_t number_of_channels,
491 int codec_frames_per_packet,
504 iananame, actual_samples_per_second, microseconds_per_packet / 1000, number_of_channels, decoded_bytes_per_packet,
SWITCH_RECOMMENDED_BUFFER_SIZE);
531 iananame, actual_samples_per_second, microseconds_per_packet / 1000, number_of_channels);
541 const char *iananame,
556 memset(impl, 0,
sizeof(*impl));
580 #define SWITCH_DECLARE_STATIC_MODULE(init, load, run, shut) void init(void) { \
581 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.
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_status_t switch_loadable_module_load_module(char *dir, char *fname, switch_bool_t runtime, const char **err)
Load a module.
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
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
switch_memory_pool_t * pool
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_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.
struct switch_runtime runtime
switch_status_t(* switch_core_codec_video_encode_func_t)(switch_codec_t *codec, switch_frame_t *frame)
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.
int(* switch_modulename_callback_func_t)(void *user_data, const char *module_name)
switch_thread_rwlock_t * rwlock
switch_timer_interface_t * timer_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)
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_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.
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.
struct apr_thread_rwlock_t switch_thread_rwlock_t
Top level module interface to implement a series of codec implementations.
switch_endpoint_interface_t * endpoint_interface
switch_status_t(* switch_core_codec_destroy_func_t)(switch_codec_t *)
switch_status_t(* switch_core_codec_init_func_t)(switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings)
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.
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 switch_core_codec_next_id(void)
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)
int microseconds_per_packet
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
uint32_t samples_per_packet
uint8_t number_of_channels
int switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen)
Retrieve the list of loaded codecs into an array based on another array showing the sorted order...
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.
switch_status_t switch_loadable_module_unload_module(char *dir, char *fname, switch_bool_t force, const char **err)
Unoad a module.
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.
uint32_t encoded_bytes_per_packet
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_execute_chat_app(switch_event_t *message, const char *app, const char *data)
switch_core_codec_init_func_t init
int(* switch_core_recover_callback_t)(switch_core_session_t *session)
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.
struct apr_pool_t switch_memory_pool_t
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.
switch_api_interface_t * api_interface
switch_core_codec_video_encode_func_t encode_video
switch_asr_interface_t * asr_interface
switch_status_t(* switch_core_codec_video_decode_func_t)(switch_codec_t *codec, switch_frame_t *frame)
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_chat_application_interface_t * chat_application_interface
char * switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname)
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