FreeSWITCH API Documentation  1.7.0
switch_loadable_module.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_loadable_module.h -- Loadable Modules
30  *
31  */
32 /*! \file switch_loadable_module.h
33  \brief Loadable Module Routines
34 
35  This module is the gateway between external modules and the core of the application.
36  it contains all the access points to the various pluggable interfaces including the codecs
37  and API modules.
38 
39 */
40 
41 #ifndef SWITCH_LOADABLE_MODULE_H
42 #define SWITCH_LOADABLE_MODULE_H
43 
44 #include <switch_log.h>
45 #include <switch.h>
47 
49 /*!
50  \defgroup mods Loadable Module Functions
51  \ingroup core1
52  \{
53 */
54 /*! \brief The abstraction of a loadable module */
56  /*! the name of the module */
57  const char *module_name;
58  /*! the table of endpoints the module has implemented */
60  /*! the table of timers the module has implemented */
62  /*! the table of dialplans the module has implemented */
64  /*! the table of codecs the module has implemented */
66  /*! the table of applications the module has implemented */
68  /*! the table of chat applications the module has implemented */
70  /*! the table of api functions the module has implemented */
72  /*! the table of json api functions the module has implemented */
74  /*! the table of file formats the module has implemented */
76  /*! the table of speech interfaces the module has implemented */
78  /*! the table of directory interfaces the module has implemented */
80  /*! the table of chat interfaces the module has implemented */
82  /*! the table of say interfaces the module has implemented */
84  /*! the table of asr interfaces the module has implemented */
86  /*! the table of management interfaces the module has implemented */
88  /*! the table of limit interfaces the module has implemented */
91  int refs;
93 };
94 
95 /*!
96  \brief Initilize the module backend and load all the modules
97  \return SWITCH_STATUS_SUCCESS when complete
98  */
100 
101 /*!
102  \brief Shutdown the module backend and call the shutdown routine in all loaded modules
103  */
105 
106 /*!
107  \brief Retrieve the endpoint interface by it's registered name
108  \param name the name of the endpoint
109  \return the desired endpoint interface
110  */
112 
113 /*!
114  \brief Retrieve the codec interface by it's registered name
115  \param name the name of the codec
116  \return the desired codec interface
117  */
119 
120 SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname);
121 
122 /*!
123  \brief Retrieve the dialplan interface by it's registered name
124  \param name the name of the dialplan
125  \return the desired dialplan interface
126  */
128 
129 /*!
130  \brief Enumerates a list of all modules discovered in a directory
131  \param the directory to look for modules in
132  \param memory pool
133  \param callback function to call for each module found
134  \param user data argument to pass to the callback function
135  \return the resulting status
136  */
138 
139 
140 /*!
141  \brief Enumerates a list of all currently loaded modules
142  \param callback function to call for each module found
143  \param user data argument to pass to the callback function
144  \return the resulting status
145  */
147 
148 /*!
149  \brief build a dynamic module object and register it (for use in double embeded modules)
150  \param filename the name of the modules source file
151  \param switch_module_load the function to call when the module is loaded
152  \param switch_module_runtime a function requested to be started in it's own thread once loaded
153  \param switch_module_shutdown the function to call when the system is shutdown
154  \param runtime start the runtime thread or not
155  \return the resulting status
156  \note only use this function if you are making a module that in turn gateways module loading to another technology
157  */
159  switch_module_load_t switch_module_load,
160  switch_module_runtime_t switch_module_runtime,
161  switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime);
162 
163 
164 /*!
165  \brief Retrieve the timer interface by it's registered name
166  \param name the name of the timer
167  \return the desired timer interface
168  */
170 
171 /*!
172  \brief Retrieve the application interface by it's registered name
173  \param name the name of the application
174  \return the desired application interface
175  */
177 
178 /*!
179  \brief Retrieve the chat application interface by it's registered name
180  \param name the name of the chat application
181  \return the desired chat application interface
182  */
184 
185 SWITCH_DECLARE(switch_status_t) switch_core_execute_chat_app(switch_event_t *message, const char *app, const char *data);
186 
187 /*!
188  \brief Retrieve the API interface by it's registered name
189  \param name the name of the API
190  \return the desired API interface
191  */
193 
194 /*!
195  \brief Retrieve the JSON API interface by it's registered name
196  \param name the name of the API
197  \return the desired API interface
198  */
200 
201 /*!
202  \brief Retrieve the file format interface by it's registered name
203  \param name the name of the file format
204  \return the desired file format interface
205  */
207 
208 /*!
209  \brief Retrieve the speech interface by it's registered name
210  \param name the name of the speech interface
211  \return the desired speech interface
212  */
214 
215 /*!
216  \brief Retrieve the asr interface by it's registered name
217  \param name the name of the asr interface
218  \return the desired asr interface
219  */
221 
222 /*!
223  \brief Retrieve the directory interface by it's registered name
224  \param name the name of the directory interface
225  \return the desired directory interface
226  */
228 
229 /*!
230  \brief Retrieve the chat interface by it's registered name
231  \param name the name of the chat interface
232  \return the desired chat interface
233  */
235 
236 /*!
237  \brief Retrieve the say interface by it's registered name
238  \param name the name of the say interface
239  \return the desired say interface
240  */
242 
243 /*!
244  \brief Retrieve the management interface by it's registered name
245  \param relative_oid the relative oid of the management interface
246  \return the desired management interface
247  */
249 
250 /*!
251  \brief Retrieve the limit interface by it's registered name
252  \param name the name of the limit interface
253  \return the desired limit interface
254  */
256 
257 /*!
258  \brief Retrieve the list of loaded codecs into an array
259  \param array the array to populate
260  \param arraylen the max size in elements of the array
261  \return the number of elements added to the array
262  */
264 
265 
266 /*!
267  \brief Retrieve the list of loaded codecs into an array based on another array showing the sorted order
268  \param array the array to populate
269  \param arraylen the max size in elements of the array
270  \param prefs the array of preferred codec names
271  \param preflen the size in elements of the prefs
272  \return the number of elements added to the array
273  \note this function only considers codecs that are listed in the "prefs" array and ignores the rest.
274 */
275 SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen);
276 
277 /*!
278  \brief Execute a registered API command
279  \param cmd the name of the API command to execute
280  \param arg the optional arguement to the command
281  \param session an optional session
282  \param stream stream for output
283  \return the status returned by the API call
284 */
285 SWITCH_DECLARE(switch_status_t) switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
286 
287 /*!
288  \brief Execute a registered JSON API command
289  \param json the name of the JSON API command to execute
290  \param arg the optional arguement to the command
291  \param session an optional session
292  \param stream stream for output
293  \return the status returned by the API call
294 */
296 
297 /*!
298  \brief Load a module
299  \param dir the directory where the module resides
300  \param fname the file name of the module
301  \param runtime option to start the runtime thread if it exists
302  \param err pointer to error message
303  \return the status
304 */
305 SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname, switch_bool_t runtime, const char **err);
306 
307 /*!
308  \brief Check if a module is loaded
309  \param mod the module name
310  \return the status
311 */
313 
314 /*!
315  \brief Unoad a module
316  \param dir the directory where the module resides
317  \param fname the file name of the module
318  \param err pointer to error message
319  \return the status
320 */
321 SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir, char *fname, switch_bool_t force, const char **err);
322 
323 /* Prototypes of module interface functions */
324 
325 /*!
326  \brief Load a module
327  \param module_interface a pointer to a pointer to aim at your module's local interface
328  \param filename the path to the module's dll or so file
329  \return SWITCH_STATUS_SUCCESS on a successful load
330 */
331 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t ** module_interface, char *filename);
332 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void);
333 
334 /*!
335  \brief Shutdown a module
336  \return SWITCH_STATUS_SUCCESS on a successful shutdown
337 */
338 SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
339 
340 #define SWITCH_ADD_API(api_int, int_name, descript, funcptr, syntax_string) \
341  for (;;) { \
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; \
347  break; \
348  }
349 
350 #define SWITCH_ADD_JSON_API(json_api_int, int_name, descript, funcptr, syntax_string) \
351  for (;;) { \
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; \
357  break; \
358  }
359 
360 #define SWITCH_ADD_CHAT(chat_int, int_name, funcptr) \
361  for (;;) { \
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; \
365  break; \
366  }
367 
368 #define SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \
369  for (;;) { \
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; \
377  break; \
378  }
379 
380 #define SWITCH_ADD_CHAT_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \
381  for (;;) { \
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; \
389  break; \
390  }
391 
392 #define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) \
393  for (;;) { \
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; \
397  break; \
398  }
399 
400 #define SWITCH_ADD_LIMIT(limit_int, int_name, incrptr, releaseptr, usageptr, resetptr, statusptr, interval_resetptr) \
401  for (;;) { \
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; \
410  break; \
411  }
412 
414 
415 #define SWITCH_ADD_CODEC(codec_int, int_name) \
416  for (;;) { \
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(); \
421  break; \
422  }
423 
424  static inline int switch_check_interval(uint32_t rate, uint32_t ptime)
425 {
426  uint32_t max_ms = 0, ptime_div = 0;
427 
428  switch (rate) {
429  case 22050:
430  case 11025:
431  if (ptime < 120)
432  return 1;
433  break;
434  case 48000:
435  max_ms = 40;
436  ptime_div = 2;
437  break;
438  case 44100:
439  max_ms = 40;
440  ptime_div = 2;
441  break;
442  case 32000:
443  case 24000:
444  case 16000:
445  max_ms = 60;
446  ptime_div = 2;
447  break;
448  case 12000:
449  max_ms = 100;
450  ptime_div = 2;
451  break;
452  case 8000:
453  max_ms = 120;
454  ptime_div = 2;
455  break;
456  }
457 
458  if (max_ms && ptime_div && (ptime <= max_ms && (ptime % ptime_div) == 0) && ((rate / 1000) * ptime) < SWITCH_RECOMMENDED_BUFFER_SIZE) {
459  return 1;
460  }
461 
462  return 0;
463 }
464 
466  /*! enumeration defining the type of the codec */
467  const switch_codec_type_t codec_type,
468  /*! the IANA code number */
469  switch_payload_t ianacode,
470  /*! the IANA code name */
471  const char *iananame,
472  /*! default fmtp to send (can be overridden by the init function) */
473  char *fmtp,
474  /*! samples transferred per second */
475  uint32_t samples_per_second,
476  /*! actual samples transferred per second for those who are not moron g722 RFC writers */
477  uint32_t actual_samples_per_second,
478  /*! bits transferred per second */
479  int bits_per_second,
480  /*! number of microseconds that denote one frame */
481  int microseconds_per_packet,
482  /*! number of samples that denote one frame */
483  uint32_t samples_per_packet,
484  /*! number of bytes that denote one frame decompressed */
485  uint32_t decoded_bytes_per_packet,
486  /*! number of bytes that denote one frame compressed */
487  uint32_t encoded_bytes_per_packet,
488  /*! number of channels represented */
489  uint8_t number_of_channels,
490  /*! number of frames to send in one network packet */
491  int codec_frames_per_packet,
492  /*! function to initialize a codec handle using this implementation */
494  /*! function to encode raw data into encoded data */
496  /*! function to decode encoded data into raw data */
498  /*! deinitalize a codec handle using this implementation */
500 {
501 
502  if (decoded_bytes_per_packet > SWITCH_RECOMMENDED_BUFFER_SIZE) {
503  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %d channels %d not enough buffer space %u > %d\n",
504  iananame, actual_samples_per_second, microseconds_per_packet / 1000, number_of_channels, decoded_bytes_per_packet, SWITCH_RECOMMENDED_BUFFER_SIZE);
505  } else if (codec_type == SWITCH_CODEC_TYPE_VIDEO || switch_check_interval(actual_samples_per_second, microseconds_per_packet / 1000)) {
507  impl->codec_type = codec_type;
508  impl->ianacode = ianacode;
509  impl->iananame = switch_core_strdup(pool, iananame);
510  impl->fmtp = switch_core_strdup(pool, fmtp);
511  impl->samples_per_second = samples_per_second;
512  impl->actual_samples_per_second = actual_samples_per_second;
513  impl->bits_per_second = bits_per_second;
514  impl->microseconds_per_packet = microseconds_per_packet;
515  impl->samples_per_packet = samples_per_packet;
516  impl->decoded_bytes_per_packet = decoded_bytes_per_packet;
517  impl->encoded_bytes_per_packet = encoded_bytes_per_packet;
518  impl->number_of_channels = number_of_channels;
519  impl->codec_frames_per_packet = codec_frames_per_packet;
520  impl->init = init;
521  impl->encode = encode;
522  impl->decode = decode;
523  impl->destroy = destroy;
524  impl->codec_id = codec_interface->codec_id;
525  impl->next = codec_interface->implementations;
527  impl->modname = codec_interface->modname;
528  codec_interface->implementations = impl;
529  } else {
530  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %d channels: %d\n",
531  iananame, actual_samples_per_second, microseconds_per_packet / 1000, number_of_channels);
532  }
533 }
534 
535 ///\}
536 
538  /*! the IANA code number */
539  switch_payload_t ianacode,
540  /*! the IANA code name */
541  const char *iananame,
542  /*! default fmtp to send (can be overridden by the init function) */
543  char *fmtp,
545  /*! function to encode raw data into encoded data */
547  /*! function to decode encoded data into raw data */
549  /*! function to send control messages to the codec */
551  /*! deinitalize a codec handle using this implementation */
553 {
554 
556  memset(impl, 0, sizeof(*impl));
558  impl->ianacode = ianacode;
559  impl->iananame = switch_core_strdup(pool, iananame);
560  impl->fmtp = switch_core_strdup(pool, fmtp);
561  impl->samples_per_second = 90000;
562  impl->actual_samples_per_second = 90000;
563  impl->bits_per_second = 0;
564  impl->microseconds_per_packet = 0;
565  impl->samples_per_packet = 0;
566  impl->number_of_channels = 1;
567  impl->codec_frames_per_packet = 1;
568  impl->init = init;
569  impl->encode_video = encode;
570  impl->decode_video = decode;
571  impl->codec_control = control;
572  impl->destroy = destroy;
573  impl->codec_id = codec_interface->codec_id;
574  impl->next = codec_interface->implementations;
576  impl->modname = codec_interface->modname;
577  codec_interface->implementations = impl;
578 }
579 
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); \
582  }
583 
584 
586 {
587  return (codec && (codec->flags & SWITCH_CODEC_FLAG_READY) && codec->mutex && codec->codec_interface && codec->implementation) ? SWITCH_TRUE : SWITCH_FALSE;
588 }
589 
590 
594 
596 #endif
597 /* For Emacs:
598  * Local Variables:
599  * mode:c
600  * indent-tabs-mode:t
601  * tab-width:4
602  * c-basic-offset:4
603  * End:
604  * For VIM:
605  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
606  */
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
Definition: switch.h:43
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
Definition: switch_types.h:557
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) ...
switch_bool_t
Definition: switch_types.h:405
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
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
switch_memory_pool_t * pool
Representation of an event.
Definition: switch_event.h:80
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
Definition: switch_core.c:64
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_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.
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
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
Definition: switch_apr.h:436
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)
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
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...
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)
switch_json_api_interface_t * json_api_interface
Module Interface Definitions.
Main Library Header.
#define SWITCH_DECLARE(type)
Simple Log.
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
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_mutex_t * mutex
switch_api_interface_t * api_interface
switch_core_codec_video_encode_func_t encode_video
char * filename
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)
memset(buf, 0, buflen)
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.
uint8_t switch_payload_t
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
Definition: switch.h:42