RTS API Documentation  1.10.11
Data Structures | Macros | Enumerations | Functions | Variables
switch_loadable_module.h File Reference

Loadable Module Routines. More...

#include <switch_log.h>
#include <switch.h>
#include <switch_module_interfaces.h>
+ Include dependency graph for switch_loadable_module.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  switch_loadable_module_interface
 The abstraction of a loadable module. More...
 

Macros

#define SWITCH_ADD_API(api_int, int_name, descript, funcptr, syntax_string)
 
#define SWITCH_ADD_JSON_API(json_api_int, int_name, descript, funcptr, syntax_string)
 
#define SWITCH_ADD_CHAT(chat_int, int_name, funcptr)
 
#define SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags)
 
#define SWITCH_ADD_CHAT_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags)
 
#define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr)
 
#define SWITCH_ADD_LIMIT(limit_int, int_name, incrptr, releaseptr, usageptr, resetptr, statusptr, interval_resetptr)
 
#define SWITCH_ADD_CODEC(codec_int, int_name)
 
#define SWITCH_DECLARE_STATIC_MODULE(init, load, run, shut)
 

Enumerations

enum  switch_loadable_module_type_t { SWITCH_LOADABLE_MODULE_TYPE_PRELOAD, SWITCH_LOADABLE_MODULE_TYPE_COMMON, SWITCH_LOADABLE_MODULE_TYPE_POSTLOAD }
 List of loadable module types. More...
 

Functions

switch_status_t switch_loadable_module_init (switch_bool_t autoload)
 Initilize the module backend and load all the modules. More...
 
void switch_loadable_module_shutdown (void)
 Shutdown the module backend and call the shutdown routine in all loaded modules. More...
 
switch_endpoint_interface_tswitch_loadable_module_get_endpoint_interface (const char *name)
 Retrieve the endpoint interface by it's registered name. More...
 
switch_codec_interface_tswitch_loadable_module_get_codec_interface (const char *name, const char *modname)
 Retrieve the codec interface by it's registered name. More...
 
char * switch_parse_codec_buf (char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname, char **fmtp)
 
switch_dialplan_interface_tswitch_loadable_module_get_dialplan_interface (const char *name)
 Retrieve the dialplan interface by it's registered name. More...
 
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. More...
 
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. More...
 
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) More...
 
switch_timer_interface_tswitch_loadable_module_get_timer_interface (const char *name)
 Retrieve the timer interface by it's registered name. More...
 
switch_application_interface_tswitch_loadable_module_get_application_interface (const char *name)
 Retrieve the application interface by it's registered name. More...
 
switch_chat_application_interface_tswitch_loadable_module_get_chat_application_interface (const char *name)
 Retrieve the chat application interface by it's registered name. More...
 
switch_status_t switch_core_execute_chat_app (switch_event_t *message, const char *app, const char *data)
 
switch_api_interface_tswitch_loadable_module_get_api_interface (const char *name)
 Retrieve the API interface by it's registered name. More...
 
switch_json_api_interface_tswitch_loadable_module_get_json_api_interface (const char *name)
 Retrieve the JSON API interface by it's registered name. More...
 
switch_file_interface_tswitch_loadable_module_get_file_interface (const char *name, const char *modname)
 Retrieve the file format interface by it's registered name. More...
 
switch_database_interface_tswitch_loadable_module_get_database_interface (const char *name, const char *modname)
 Retrieve the database interface by it's registered name. More...
 
switch_speech_interface_tswitch_loadable_module_get_speech_interface (const char *name)
 Retrieve the speech interface by it's registered name. More...
 
switch_asr_interface_tswitch_loadable_module_get_asr_interface (const char *name)
 Retrieve the asr interface by it's registered name. More...
 
switch_directory_interface_tswitch_loadable_module_get_directory_interface (const char *name)
 Retrieve the directory interface by it's registered name. More...
 
switch_chat_interface_tswitch_loadable_module_get_chat_interface (const char *name)
 Retrieve the chat interface by it's registered name. More...
 
switch_say_interface_tswitch_loadable_module_get_say_interface (const char *name)
 Retrieve the say interface by it's registered name. More...
 
switch_management_interface_tswitch_loadable_module_get_management_interface (const char *relative_oid)
 Retrieve the management interface by it's registered name. More...
 
switch_limit_interface_tswitch_loadable_module_get_limit_interface (const char *name)
 Retrieve the limit interface by it's registered name. More...
 
int switch_loadable_module_get_codecs (const switch_codec_implementation_t **array, int arraylen)
 Retrieve the list of loaded codecs into an array. More...
 
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. More...
 
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. More...
 
switch_status_t switch_json_api_execute (cJSON *json, switch_core_session_t *session, cJSON **retval)
 Execute a registered JSON API command. More...
 
switch_status_t switch_loadable_module_load_module (const char *dir, const char *fname, switch_bool_t runtime, const char **err)
 Load a module. More...
 
switch_status_t switch_loadable_module_exists (const char *mod)
 Check if a module is loaded. More...
 
switch_status_t switch_loadable_module_protect (const char *mod)
 Protect module from beeing unloaded. More...
 
switch_status_t switch_loadable_module_unload_module (const char *dir, const char *fname, switch_bool_t force, const char **err)
 Unoad a module. More...
 
 SWITCH_MOD_DECLARE (switch_status_t) switch_module_load(switch_loadable_module_interface_t **module_interface
 Load a module. More...
 
uint32_t switch_core_codec_next_id (void)
 
static int switch_check_interval (uint32_t rate, uint32_t ptime)
 
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)
 
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)
 
static switch_bool_t switch_core_codec_ready (switch_codec_t *codec)
 
switch_core_recover_callback_t switch_core_get_secondary_recover_callback (const char *key)
 
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)
 

Variables

const char * filename
 

Detailed Description

Loadable Module Routines.

This module is the gateway between external modules and the core of the application. it contains all the access points to the various pluggable interfaces including the codecs and API modules.

Definition in file switch_loadable_module.h.

Macro Definition Documentation

◆ SWITCH_DECLARE_STATIC_MODULE

#define SWITCH_DECLARE_STATIC_MODULE (   init,
  load,
  run,
  shut 
)
Value:
void init(void) { \
switch_loadable_module_build_dynamic(__FILE__, load, run, shut, SWITCH_FALSE); \
}

Definition at line 602 of file switch_loadable_module.h.

Function Documentation

◆ switch_core_codec_add_video_implementation()

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 
)
inlinestatic
Parameters
ianacodethe IANA code number
iananamethe IANA code name
fmtpdefault fmtp to send (can be overridden by the init function)
encodefunction to encode raw data into encoded data
decodefunction to decode encoded data into raw data
controlfunction to send control messages to the codec
destroydeinitalize a codec handle using this implementation

Definition at line 559 of file switch_loadable_module.h.

References switch_codec_implementation::actual_samples_per_second, switch_codec_implementation::bits_per_second, switch_codec_implementation::codec_control, switch_codec_implementation::codec_frames_per_packet, switch_codec_implementation::codec_id, switch_codec_interface::codec_id, switch_codec_implementation::codec_type, switch_codec_implementation::decode_video, switch_codec_implementation::destroy, switch_codec_implementation::encode_video, switch_codec_implementation::fmtp, switch_codec_implementation::ianacode, switch_codec_implementation::iananame, switch_codec_implementation::impl_id, switch_codec_interface::implementations, switch_codec_implementation::init, memset(), switch_codec_implementation::microseconds_per_packet, switch_codec_implementation::modname, switch_codec_interface::modname, switch_codec_implementation::next, switch_codec_implementation::number_of_channels, switch_codec_implementation::samples_per_packet, switch_codec_implementation::samples_per_second, SWITCH_CODEC_TYPE_VIDEO, switch_core_alloc, switch_core_codec_next_id(), and switch_core_strdup.

575 {
576 
578  memset(impl, 0, sizeof(*impl));
580  impl->ianacode = ianacode;
581  impl->iananame = switch_core_strdup(pool, iananame);
582  impl->fmtp = switch_core_strdup(pool, fmtp);
583  impl->samples_per_second = 90000;
584  impl->actual_samples_per_second = 90000;
585  impl->bits_per_second = 0;
586  impl->microseconds_per_packet = 0;
587  impl->samples_per_packet = 0;
588  impl->number_of_channels = 1;
589  impl->codec_frames_per_packet = 1;
590  impl->init = init;
591  impl->encode_video = encode;
592  impl->decode_video = decode;
593  impl->codec_control = control;
594  impl->destroy = destroy;
595  impl->codec_id = codec_interface->codec_id;
596  impl->next = codec_interface->implementations;
598  impl->modname = codec_interface->modname;
599  codec_interface->implementations = impl;
600 }
switch_core_codec_destroy_func_t destroy
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
switch_memory_pool_t * pool
switch_codec_implementation_t * implementations
switch_core_codec_video_decode_func_t decode_video
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
uint32_t switch_core_codec_next_id(void)
switch_core_codec_init_func_t init
struct switch_codec_implementation * next
A table of settings and callbacks that define a paticular implementation of a codec.
switch_core_codec_video_encode_func_t encode_video
memset(buf, 0, buflen)
switch_core_codec_control_func_t codec_control

◆ switch_core_codec_ready()

static switch_bool_t switch_core_codec_ready ( switch_codec_t codec)
inlinestatic

Definition at line 607 of file switch_loadable_module.h.

References switch_codec::codec_interface, switch_codec::flags, switch_codec::implementation, key, switch_codec::mutex, SWITCH_CODEC_FLAG_READY, switch_core_get_secondary_recover_callback(), switch_core_register_secondary_recover_callback(), switch_core_unregister_secondary_recover_callback(), SWITCH_DECLARE, SWITCH_END_EXTERN_C, SWITCH_FALSE, and SWITCH_TRUE.

Referenced by early_thread_run(), switch_core_codec_control(), switch_core_codec_decode(), switch_core_codec_decode_video(), switch_core_codec_destroy(), switch_core_codec_encode(), switch_core_codec_encode_video(), switch_core_media_bug_prune(), switch_core_media_bug_remove(), switch_core_media_bug_remove_all_function(), switch_core_media_bug_remove_callback(), switch_core_media_bug_transfer_callback(), switch_core_media_codec_control(), switch_core_media_codec_get_cap(), switch_core_media_negotiate_sdp(), switch_core_media_read_frame(), switch_core_media_read_lock_unlock(), switch_core_media_set_codec(), switch_core_media_set_outgoing_bitrate(), switch_core_media_set_video_codec(), switch_core_media_write_frame(), switch_core_session_outgoing_channel(), switch_core_session_raw_read(), switch_core_session_read_frame(), switch_core_session_reset(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_session_stop_media(), switch_core_session_write_frame(), switch_ivr_deactivate_unicast(), switch_ivr_originate(), switch_ivr_play_file(), switch_ivr_speak_text_handle(), switch_ivr_wait_for_answer(), and switch_media_handle_destroy().

608 {
609  return (codec && (codec->flags & SWITCH_CODEC_FLAG_READY) && codec->mutex && codec->codec_interface && codec->implementation) ? SWITCH_TRUE : SWITCH_FALSE;
610 }
const switch_codec_implementation_t * implementation
switch_codec_interface_t * codec_interface
switch_mutex_t * mutex

◆ switch_core_get_secondary_recover_callback()

switch_core_recover_callback_t switch_core_get_secondary_recover_callback ( const char *  key)

Definition at line 3216 of file switch_loadable_module.c.

References loadable_modules, switch_loadable_module_container::mutex, switch_loadable_module_container::secondary_recover_hash, switch_core_hash_find(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by recover_callback(), and switch_core_codec_ready().

3217 {
3219 
3223 
3224  return cb;
3225 }
static struct switch_loadable_module_container loadable_modules
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
int(* switch_core_recover_callback_t)(switch_core_session_t *session)
char * key
Definition: switch_msrp.c:64

◆ switch_core_register_secondary_recover_callback()

switch_status_t switch_core_register_secondary_recover_callback ( const char *  key,
switch_core_recover_callback_t  cb 
)

Definition at line 3228 of file switch_loadable_module.c.

References loadable_modules, switch_loadable_module_container::mutex, switch_loadable_module_container::secondary_recover_hash, switch_assert, switch_core_hash_find(), switch_core_hash_insert, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_codec_ready().

3229 {
3231 
3232  switch_assert(cb);
3233 
3236  status = SWITCH_STATUS_FALSE;
3237  } else {
3239  }
3241 
3242  return status;
3243 }
static struct switch_loadable_module_container loadable_modules
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_status_t
Common return values.
#define switch_core_hash_insert(_h, _k, _d)
Definition: switch_core.h:1479
char * key
Definition: switch_msrp.c:64
#define switch_assert(expr)

◆ switch_core_unregister_secondary_recover_callback()

void switch_core_unregister_secondary_recover_callback ( const char *  key)

Definition at line 3246 of file switch_loadable_module.c.

References loadable_modules, switch_loadable_module_container::mutex, switch_loadable_module_container::secondary_recover_hash, switch_core_hash_delete(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_codec_ready().

3247 {
3251 }
static struct switch_loadable_module_container loadable_modules
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
void * switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key)
Delete data from a hash based on desired key.
char * key
Definition: switch_msrp.c:64