what's up doc
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@280 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
8a292bf0b2
commit
a4d3a30ac2
|
@ -115,6 +115,12 @@ modules: $(NAME)
|
|||
modclean:
|
||||
@cd src/mod && for i in `find . -type d -name mod_\*` ; do echo making clean $$i ; SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CC="$(CC)" MOD="$$i" $(PWD)/modmake.sh $(PWD) $$i clean || exit 1; done
|
||||
|
||||
everything: all modules
|
||||
|
||||
installall: install install_mod
|
||||
|
||||
wayclean: clean modclean
|
||||
|
||||
modwipe:
|
||||
rm -f $(PREFIX)/mod/*.so
|
||||
|
||||
|
|
|
@ -978,6 +978,12 @@ modules: $(NAME)
|
|||
modclean:
|
||||
@cd src/mod && for i in `find . -type d -name mod_\*` ; do echo making clean $$i ; SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CC="$(CC)" MOD="$$i" $(PWD)/modmake.sh $(PWD) $$i clean || exit 1; done
|
||||
|
||||
everything: all modules
|
||||
|
||||
installall: install install_mod
|
||||
|
||||
wayclean: clean modclean
|
||||
|
||||
modwipe:
|
||||
rm -f $(PREFIX)/mod/*.so
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ OPTIMIZE_OUTPUT_FOR_C = YES
|
|||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
IGNORE_PREFIX = switch_
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
@ -126,16 +128,16 @@ FILTER_SOURCE_FILES = NO
|
|||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
USE_HTAGS = NO
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
USE_HTAGS = YES
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 1
|
||||
IGNORE_PREFIX = switch_
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
@ -156,6 +158,7 @@ DISABLE_INDEX = NO
|
|||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 250
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
*/
|
||||
/*! \file switch_apr.h
|
||||
\brief APR includes header
|
||||
|
||||
The things powered by APR are renamed into the switch_ namespace to provide a cleaner
|
||||
look to things and helps me to document what parts of APR I am using I'd like to take this
|
||||
opportunity to thank APR for all the awesome stuff it does and for making my life much easier.
|
||||
|
||||
*/
|
||||
#ifndef SWITCH_APR_H
|
||||
#define SWITCH_APR_H
|
||||
|
@ -64,10 +69,16 @@ extern "C" {
|
|||
The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions
|
||||
any other apr code should be as hidden as possible.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup switch_apr Brought To You By APR
|
||||
* @ingroup FREESWITCH
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup switch_file_io File I/O Handling Functions
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -76,6 +87,7 @@ typedef apr_file_t switch_file_t;
|
|||
|
||||
/**
|
||||
* @defgroup switch_file_permissions File Permissions flags
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -102,6 +114,7 @@ typedef apr_file_t switch_file_t;
|
|||
|
||||
/**
|
||||
* @defgroup switch_file_open_flags File Open Flags/Routines
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
#define SWITCH_FOPEN_READ APR_FOPEN_READ /**< Open the file for reading */
|
||||
|
@ -209,7 +222,7 @@ DoxyDefine(apr_status_t switch_file_write(switch_file_t *thefile, const void *bu
|
|||
|
||||
/**
|
||||
* @defgroup switch_thread_cond Condition Variable Routines
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -296,7 +309,7 @@ DoxyDefine(apr_status_t switch_thread_cond_destroy(switch_thread_cond_t *cond);)
|
|||
|
||||
/**
|
||||
* @defgroup switch_thread_proc Threads and Process Functions
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -344,7 +357,7 @@ DoxyDefine(apr_status_t switch_thread_create(switch_thread_t **new_thread, switc
|
|||
|
||||
/**
|
||||
* @defgroup switch_network_io Network Routines
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -910,7 +923,7 @@ DoxyDefine(apr_status_t switch_mcast_interface(switch_socket_t *sock,
|
|||
|
||||
/**
|
||||
* @defgroup switch_memory_pool Memory Pool Functions
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
/** The fundamental pool type */
|
||||
|
@ -931,7 +944,7 @@ DoxyDefine(void switch_pool_clear(switch_memory_pool *p);)
|
|||
|
||||
/**
|
||||
* @defgroup apr_poll Poll Routines
|
||||
* @ingroup APR
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
/** Poll descriptor set. */
|
||||
|
@ -1013,7 +1026,7 @@ DoxyDefine(apr_status_t switch_poll(switch_pollfd_t *aprset, apr_int32_t numsock
|
|||
|
||||
/**
|
||||
* @defgroup switch_time Time Routines
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -1097,7 +1110,7 @@ DoxyDefine(void switch_sleep(apr_interval_time_t t);)
|
|||
|
||||
/**
|
||||
* @defgroup apr_hash Hash Tables
|
||||
* @ingroup APR
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -1147,7 +1160,7 @@ DoxyDefine(void switch_hash_this(switch_hash_index_t *hi, const void **key,
|
|||
|
||||
/**
|
||||
* @defgroup switch_StrMatch String matching routines
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -1179,7 +1192,7 @@ DoxyDefine(const char * switch_strmatch(const switch_strmatch_pattern *pattern,
|
|||
|
||||
/**
|
||||
* @defgroup switch_UUID UUID Handling
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -1218,7 +1231,7 @@ DoxyDefine(apr_status_t switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_
|
|||
|
||||
/**
|
||||
* @defgroup switch_FIFO Thread Safe FIFO bounded queue
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -1314,6 +1327,7 @@ DoxyDefine(apr_status_t switch_queue_trypop(switch_queue_t *queue, void **data);
|
|||
DoxyDefine(apr_status_t switch_queue_trypush(switch_queue_t *queue, void *data);)
|
||||
#define switch_queue_trypush apr_queue_trypush
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
*/
|
||||
/*! \file switch_buffer.h
|
||||
\brief Data Buffering Code
|
||||
|
||||
The purpose of this module is to make a plain buffering interface that can be used for read/write buffers
|
||||
throughout the application. The first implementation was done to provide the functionality and the interface
|
||||
and I think it can be optimized under the hood as we go using bucket brigades and/or ring buffering techniques.
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_BUFFER_H
|
||||
|
@ -89,13 +93,13 @@ SWITCH_DECLARE(int) switch_buffer_read(switch_buffer *buffer, void *data, size_t
|
|||
* \param buffer any buffer of type switch_buffer
|
||||
* \param data pointer to the data to be written
|
||||
* \param datalen amount of data to be written
|
||||
* \return int ammount of buffer used after the write, or 0 if no space available
|
||||
* \return int amount of buffer used after the write, or 0 if no space available
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_buffer_write(switch_buffer *buffer, void *data, size_t datalen);
|
||||
|
||||
/*! \brief Remove data from the buffer
|
||||
* \param buffer any buffer of type switch_buffer
|
||||
* \param datalen amount of data to be returned
|
||||
* \param datalen amount of data to be removed
|
||||
* \return int size of buffer, or 0 if unable to toss that much data
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_buffer_toss(switch_buffer *buffer, size_t datalen);
|
||||
|
|
|
@ -31,6 +31,16 @@
|
|||
*/
|
||||
/*! \file switch_caller.h
|
||||
\brief Caller Identification
|
||||
|
||||
This file implements a caller profile which is a group of information about a connected endpoint
|
||||
such as common caller id and other useful information such as ip address and destination number.
|
||||
A connected session's channel has up to 3 profiles: It's own, that of the session who spawned it
|
||||
and that of the session it has spawned.
|
||||
|
||||
In addition, this file implements an abstract interface for extensions and applications.
|
||||
A connected session's channel has one extension object which may have one or more applications
|
||||
linked into a stack which will be executed in order by the session's state machine when the
|
||||
current state is CS_EXECUTE.
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_CALLER_H
|
||||
|
@ -42,50 +52,87 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
struct switch_caller_step {
|
||||
char *step_name;
|
||||
struct switch_caller_step *next_step;
|
||||
};
|
||||
|
||||
/*! \brief Caller specific data including callid information
|
||||
*/
|
||||
/*! \brief Call Specific Data
|
||||
*/
|
||||
struct switch_caller_profile {
|
||||
/*! The name of the dialplan */
|
||||
char *dialplan;
|
||||
/*! Caller ID Name */
|
||||
char *caller_id_name;
|
||||
/*! Caller ID Number */
|
||||
char *caller_id_number;
|
||||
/*! Caller Network Address (when applicable) */
|
||||
char *network_addr;
|
||||
/*! ANI (when applicable) */
|
||||
char *ani;
|
||||
/*! ANI II (when applicable) */
|
||||
char *ani2;
|
||||
/*! Destination Number */
|
||||
char *destination_number;
|
||||
struct switch_caller_step *steps;
|
||||
};
|
||||
|
||||
/*! \brief An Abstract Representation of a dialplan Application */
|
||||
struct switch_caller_application {
|
||||
/*! The name of the registered application to call */
|
||||
char *application_name;
|
||||
/*! An optional argument string to pass to the application */
|
||||
char *application_data;
|
||||
/*! A function pointer to the application */
|
||||
switch_application_function application_function;
|
||||
struct switch_caller_application *next;
|
||||
};
|
||||
|
||||
/*! \brief An Abstract Representation of a dialplan extension */
|
||||
struct switch_caller_extension {
|
||||
/*! The name of the extension */
|
||||
char *extension_name;
|
||||
/*! The number of the extension */
|
||||
char *extension_number;
|
||||
/*! Pointer to the current application for this extension */
|
||||
struct switch_caller_application *current_application;
|
||||
/*! Pointer to the last application for this extension */
|
||||
struct switch_caller_application *last_application;
|
||||
/*! Pointer to the entire stack of applications for this extension */
|
||||
struct switch_caller_application *applications;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Create a new extension with desired parameters
|
||||
\param session session associated with the extension (bound by scope)
|
||||
\param extension_name extension name
|
||||
\param extension_number extension number
|
||||
\return a new extension object allocated from the session's memory pool
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
|
||||
char *extension_name,
|
||||
char *extension_number
|
||||
);
|
||||
|
||||
/*!
|
||||
\brief Add an application (instruction) to the given extension
|
||||
\param session session associated with the extension (bound by scope)
|
||||
\param caller_extension extension to add the application to
|
||||
\param application_name the name of the application
|
||||
\param extra_data optional argument to the application
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
|
||||
switch_caller_extension *caller_extension,
|
||||
char *application_name,
|
||||
char *extra_data);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Create a new caller profile object
|
||||
\param session session associated with the profile (bound by scope)
|
||||
\param dialplan name of the dialplan module in use
|
||||
\param caller_id_name caller ID name
|
||||
\param caller_id_number caller ID number
|
||||
\param network_addr network address
|
||||
\param ani ANI information
|
||||
\param ani2 ANI II information
|
||||
\param destination_number destination number
|
||||
\return a new profile object allocated from the session's memory pool
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session,
|
||||
char *dialplan,
|
||||
char *caller_id_name,
|
||||
|
@ -95,9 +142,22 @@ extern "C" {
|
|||
char *ani2,
|
||||
char *destination_number);
|
||||
|
||||
/*!
|
||||
\brief Clone an existing caller profile object
|
||||
\param session session associated with the profile (bound by scope)
|
||||
\param tocopy the existing profile
|
||||
*/
|
||||
|
||||
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session,
|
||||
switch_caller_profile *tocopy);
|
||||
|
||||
/*!
|
||||
\brief Add headers to an existing event in regards to a specific profile
|
||||
\param caller_profile the desired profile
|
||||
\param prefix a prefix string to all of the field names (for uniqueness)
|
||||
\param event the event to add the information to
|
||||
*/
|
||||
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix, switch_event *event);
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
*/
|
||||
/*! \file switch_channel.h
|
||||
\brief Media Channel Interface
|
||||
|
||||
The switch_channel object is a private entity that belongs to a session that contains the call
|
||||
specific information such as the call state, variables, caller profiles and DTMF queue
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_CHANNEL_H
|
||||
|
@ -42,50 +45,246 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/*! \brief Get the current state of a channel in the state engine
|
||||
* \param channel switch_channel object tot retreive state for
|
||||
* \return state of a type in switch_channel_state enum
|
||||
*/
|
||||
/*!
|
||||
\defgroup chans Channel Functions
|
||||
\ingroup FREESWITCH
|
||||
\{
|
||||
*/
|
||||
|
||||
/*!
|
||||
\brief Get the current state of a channel in the state engine
|
||||
\param channel channel to retrieve state from
|
||||
\return current state of channel
|
||||
*/
|
||||
SWITCH_DECLARE(switch_channel_state) switch_channel_get_state(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Set the current state of a channel
|
||||
\param channel channel to set state of
|
||||
\param state new state
|
||||
\return current state of channel after application of new state
|
||||
*/
|
||||
SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Allocate a new channel
|
||||
\param channel NULL pointer to allocate channel to
|
||||
\param pool memory_pool to use for allocation
|
||||
\returns SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Connect a newly allocated channel to a session object and setup it's initial state
|
||||
\param channel the channel to initilize
|
||||
\param session the session to connect the channel to
|
||||
\param state the initial state of the channel
|
||||
\param flags the initial channel flags
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_init(switch_channel *channel,
|
||||
switch_core_session *session,
|
||||
switch_channel_state state,
|
||||
switch_channel_flag flags);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Set the given channel's caller profile
|
||||
\param channel channel to assign the profile to
|
||||
\param caller_profile the profile to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
|
||||
|
||||
/*!
|
||||
\brief Retrive the given channel's caller profile
|
||||
\param channel channel to retrive the profile from
|
||||
\return the requested profile
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Set the given channel's originator caller profile
|
||||
\param channel channel to assign the profile to
|
||||
\param caller_profile the profile to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
|
||||
|
||||
/*!
|
||||
\brief Retrive the given channel's originator caller profile
|
||||
\param channel channel to retrive the profile from
|
||||
\return the requested profile
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Set the given channel's originatee caller profile
|
||||
\param channel channel to assign the profile to
|
||||
\param caller_profile the profile to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
|
||||
|
||||
/*!
|
||||
\brief Retrive the given channel's originatee caller profile
|
||||
\param channel channel to retrive the profile from
|
||||
\return the requested profile
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel);
|
||||
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel *channel, char *varname);
|
||||
|
||||
/*!
|
||||
\brief Set a variable on a given channel
|
||||
\param channel channel to set variable on
|
||||
\param varname the name of the variable
|
||||
\param value the vaule of the variable
|
||||
\returns SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_variable(switch_channel *channel, char *varname, char *value);
|
||||
|
||||
/*!
|
||||
\brief Retrieve a variable from a given channel
|
||||
\param channel channel to retrieve variable from
|
||||
\param varname the name of the variable
|
||||
\return the value of the requested variable
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel *channel, char *varname);
|
||||
|
||||
/*!
|
||||
\brief Assign a caller extension to a given channel
|
||||
\param channel channel to assign extension to
|
||||
\param caller_extension extension to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel, switch_caller_extension *caller_extension);
|
||||
|
||||
/*!
|
||||
\brief Retrieve caller extension from a given channel
|
||||
\param channel channel to retrieve extension from
|
||||
\return the requested extension
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_extension *) switch_channel_get_caller_extension(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Test for presence of given flag(s) on a given channel
|
||||
\param channel channel to test
|
||||
\param flags or'd list of channel flags to test
|
||||
\return SWITCH_STATUS_SUCCESS if provided flags are set
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_test_flag(switch_channel *channel, int flags);
|
||||
|
||||
/*!
|
||||
\brief Set given flag(s) on a given channel
|
||||
\param channel channel on which to set flag(s)
|
||||
\param flags or'd list of flags to set
|
||||
\return SWITCH_STATUS_SUCCESS if flags were set
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_flag(switch_channel *channel, int flags);
|
||||
|
||||
/*!
|
||||
\brief Clear given flag(s) from a channel
|
||||
\param channel channel to clear flags from
|
||||
\param flags or'd list of flags to clear
|
||||
\return SWITCH_STATUS_SUCCESS if flags were cleared
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_clear_flag(switch_channel *channel, int flags);
|
||||
|
||||
/*!
|
||||
\brief Answer a channel (initiate/acknowledge a successful connection)
|
||||
\param channel channel to answer
|
||||
\return SWITCH_STATUS_SUCCESS if channel was answered successfully
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Assign an event handler table to a given channel
|
||||
\param channel channel on which to assign the event handler table
|
||||
\param event_handlers table of event handler functions
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel, const struct switch_event_handler_table *event_handlers);
|
||||
|
||||
/*!
|
||||
\brief Retrieve an event handler tablefrom a given channel
|
||||
\param channel channel from which to retrieve the event handler table
|
||||
\return given channel's event handler table
|
||||
*/
|
||||
SWITCH_DECLARE(const struct switch_event_handler_table *) switch_channel_get_event_handlers(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Set private data on channel
|
||||
\param channel channel on which to set data
|
||||
\param private void pointer to private data
|
||||
\return SWITCH_STATUS_SUCCESS if data was set
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_private(switch_channel *channel, void *private);
|
||||
|
||||
/*!
|
||||
\brief Retrieve private from a given channel
|
||||
\param channel channel to retrieve data from
|
||||
\return void pointer to channel's private data
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Assign a name to a given channel
|
||||
\param channel channel to assign name to
|
||||
\param name name to assign
|
||||
\return SWITCH_STATUS_SUCCESS if name was assigned
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_name(switch_channel *channel, char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the name of a given channel
|
||||
\param channel channel to get name of
|
||||
\return the channel's name
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Hangup a channel flagging it's state machine to end
|
||||
\param channel channel to hangup
|
||||
\return SWITCH_STATUS_SUCCESS if channel state was set to hangup
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_hangup(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Test for presence of DTMF on a given channel
|
||||
\param channel channel to test
|
||||
\return number of digits in the queue
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_channel_has_dtmf(switch_channel *channel);
|
||||
|
||||
/*!
|
||||
\brief Queue DTMF on a given channel
|
||||
\param channel channel to queue DTMF to
|
||||
\param dtmf string of digits to queue
|
||||
\return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_channel_queue_dtmf(switch_channel *channel, char *dtmf);
|
||||
|
||||
/*!
|
||||
\brief Retrieve DTMF digits from a given channel
|
||||
\param channel channel to retrieve digits from
|
||||
\param dtmf buffer to write dtmf to
|
||||
\param len max size in bytes of the buffer
|
||||
\return number of bytes read into the buffer
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_channel_dequeue_dtmf(switch_channel *channel, char *dtmf, size_t len);
|
||||
|
||||
/*!
|
||||
\brief Render the name of the provided state enum
|
||||
\param state state to get name of
|
||||
\return the string representation of the state
|
||||
*/
|
||||
SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state state);
|
||||
|
||||
/*!
|
||||
\brief Add information about a given channel to an event object
|
||||
\param channel channel to add information about
|
||||
\param event event to add information to
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, switch_event *event);
|
||||
|
||||
|
||||
// These may go away
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode (switch_channel *channel, int freq, int bits, int channels, int ms, int kbps);
|
||||
SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode (switch_channel *channel, int *freq, int *bits, int *channels, int *ms, int *kbps);
|
||||
SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state state);
|
||||
SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, switch_event *event);
|
||||
///\}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,21 @@
|
|||
*
|
||||
*/
|
||||
/*! \file switch_config.h
|
||||
\brief Configuration File Parser
|
||||
\brief Basic Configuration File Parser
|
||||
|
||||
This module implements a basic interface and file format parser it may be depricated in favor of database entries
|
||||
or expanded to tie to external handlers in the future as necessary.
|
||||
<pre>
|
||||
|
||||
EXAMPLE
|
||||
|
||||
[category1]
|
||||
var1 => val1
|
||||
var2 => val2
|
||||
\# lines that begin with \# are comments
|
||||
\#var3 => val3
|
||||
</pre>
|
||||
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_CONFIG_H
|
||||
|
@ -42,18 +56,40 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/*! \brief A simple file handle representing an open configuration file **/
|
||||
struct switch_config {
|
||||
/*! FILE stream buffer to the opened file */
|
||||
FILE *file;
|
||||
/*! path to the file */
|
||||
char *path;
|
||||
/*! current category */
|
||||
char category[256];
|
||||
/*! buffer of current line being read */
|
||||
char buf[1024];
|
||||
/*! current line number in file */
|
||||
int lineno;
|
||||
};
|
||||
|
||||
typedef struct switch_config switch_config;
|
||||
|
||||
/*!
|
||||
\brief Open a configuration file
|
||||
\param cfg (switch_config *) config handle to use
|
||||
\param file_path path to the file
|
||||
\return 1 (true) on success 0 (false) on failure
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_config_open_file(switch_config *cfg, char *file_path);
|
||||
|
||||
/*!
|
||||
\brief Close a previously opened configuration file
|
||||
\param cfg (switch_config *) config handle to use
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_config_close_file(switch_config *cfg);
|
||||
|
||||
/*!
|
||||
\brief Retrieve next name/value pair from configuration file
|
||||
\param cfg (switch_config *) config handle to use
|
||||
\param var pointer to aim at the new variable name
|
||||
\param val pointer to aim at the new value
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char **val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
*/
|
||||
/*! \file switch_console.h
|
||||
\brief Simple Console
|
||||
|
||||
This module implements a basic console i/o and by basic I mean, um yeah, basic
|
||||
Right now the primary function of this portion of the program is to keep it from exiting.
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_CONSOLE_H
|
||||
|
@ -42,7 +45,14 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/*!
|
||||
\brief A simple comand loop that reads input from the terminal
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_console_loop(void);
|
||||
|
||||
/*!
|
||||
\brief A method akin to printf that allows you to redirect output to a specific console "channel"
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *file, const char *func, int line, char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
*/
|
||||
/*! \file switch_core.h
|
||||
\brief Core Library
|
||||
|
||||
This module is the main core library and is the intended location of all fundamental operations.
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_CORE_H
|
||||
|
@ -43,69 +45,469 @@ extern "C" {
|
|||
#include <switch.h>
|
||||
|
||||
#define MAX_CORE_THREAD_SESSION_OBJS 128
|
||||
|
||||
/*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
|
||||
struct switch_core_thread_session {
|
||||
/*! status of the thread */
|
||||
int running;
|
||||
/*! array of void pointers to pass mutiple data objects */
|
||||
void *objs[MAX_CORE_THREAD_SESSION_OBJS];
|
||||
/*! a pointer to a memory pool if the thread has it's own pool */
|
||||
switch_memory_pool *pool;
|
||||
};
|
||||
|
||||
struct switch_core_session;
|
||||
struct switch_core_runtime;
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup core1 Core Library
|
||||
\ingroup FREESWITCH
|
||||
\{
|
||||
*/
|
||||
|
||||
///\defgroup ss Startup/Shutdown
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Initilize the core
|
||||
\note to be called at application startup
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_init(void);
|
||||
|
||||
/*!
|
||||
\brief Destroy the core
|
||||
\note to be called at application shutdown
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_destroy(void);
|
||||
SWITCH_DECLARE(switch_status) switch_core_do_perl(char *txt);
|
||||
///\}
|
||||
|
||||
|
||||
///\defgroup memp Memory Pooling/Allocation
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Create a new sub memory pool from the core's master pool
|
||||
\return SWITCH_STATUS_SUCCESS on success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_new_memory_pool(switch_memory_pool **pool);
|
||||
|
||||
/*!
|
||||
\brief Returns a subpool back to the main pool
|
||||
\return SWITCH_STATUS_SUCCESS on success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_destroy_memory_pool(switch_memory_pool **pool);
|
||||
|
||||
/*!
|
||||
\brief Start the session's state machine
|
||||
\param session the session on which to start the state machine
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session);
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface, switch_memory_pool *pool);
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool *pool);
|
||||
SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session *session, size_t memory);
|
||||
SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *session);
|
||||
SWITCH_DECLARE(switch_channel *) switch_core_session_get_channel(switch_core_session *session);
|
||||
SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session *session, size_t memory);
|
||||
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session);
|
||||
|
||||
/*!
|
||||
\brief Allocate memory from the main pool with no intention of returning it
|
||||
\param memory the number of bytes to allocate
|
||||
\return a void pointer to the allocated memory
|
||||
\note this memory never goes out of scope until the core is destroyed
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_core_permenant_alloc(size_t memory);
|
||||
SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup);
|
||||
SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session, char *todup);
|
||||
SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *session);
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_session *session, void *private);
|
||||
|
||||
/*!
|
||||
\brief Allocate memory directly from a memory pool
|
||||
\param pool the memory pool to allocate from
|
||||
\param memory the number of bytes to allocate
|
||||
\return a void pointer to the allocated memory
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool *pool, size_t memory);
|
||||
/* Hash Frontend */
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_init(switch_hash **hash, switch_memory_pool *pool);
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_destroy(switch_hash *hash);
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_insert(switch_hash *hash, char *key, void *data);
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_insert_dup(switch_hash *hash, char *key, void *data);
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_delete(switch_hash *hash, char *key);
|
||||
SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash *hash, char *key);
|
||||
SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread *, void*), void *obj, switch_memory_pool *pool);
|
||||
SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel);
|
||||
|
||||
/*!
|
||||
\brief Allocate memory from a session's pool
|
||||
\param session the session to request memory from
|
||||
\param memory the amount of memory to allocate
|
||||
\return a void pointer to the newly allocated memory
|
||||
\note the memory will be in scope as long as the session exists
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session *session, size_t memory);
|
||||
|
||||
/*!
|
||||
\brief Copy a string using permenant memory allocation
|
||||
\param todup the string to duplicate
|
||||
\return a pointer to the newly duplicated string
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup);
|
||||
|
||||
/*!
|
||||
\brief Copy a string using memory allocation from a session's pool
|
||||
\param session a session to use for allocation
|
||||
\param todup the string to duplicate
|
||||
\return a pointer to the newly duplicated string
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session, char *todup);
|
||||
|
||||
/*!
|
||||
\brief Copy a string using memory allocation from a given pool
|
||||
\param pool the pool to use for allocation
|
||||
\param todup the string to duplicate
|
||||
\return a pointer to the newly duplicated string
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the memory pool from a session
|
||||
\param session the session to retrieve the pool from
|
||||
\return the session's pool
|
||||
\note to be used sparingly
|
||||
*/
|
||||
SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
|
||||
///\}
|
||||
|
||||
///\defgroup sessm Session Creation / Management
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Allocate and return a new session from the core
|
||||
\param endpoint_interface the endpoint interface the session is to be based on
|
||||
\param pool the pool to use for the allocation (a new one will be used if NULL)
|
||||
\return the newly created session
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Destroy a session and return the memory pool to the core
|
||||
\param session pointer to a pointer of the session to destroy
|
||||
\return
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session);
|
||||
|
||||
/*!
|
||||
\brief Allocate and return a new session from the core based on a given endpoint module name
|
||||
\param endpoint_name the name of the endpoint module
|
||||
\param pool the pool to use
|
||||
\return the newly created session
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Launch the session thread (state machine) on a given session
|
||||
\param session the session to activate the state machine on
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *session);
|
||||
|
||||
/*!
|
||||
\brief Retrieve a pointer to the channel object associated with a given session
|
||||
\param session the session to retrieve from
|
||||
\return a pointer to the channel object
|
||||
*/
|
||||
SWITCH_DECLARE(switch_channel *) switch_core_session_get_channel(switch_core_session *session);
|
||||
|
||||
/*!
|
||||
\brief Signal a session's state machine thread that a state change has occured
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session *session);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the unique identifier from a session
|
||||
\param session the session to retrieve the uuid from
|
||||
\return a string representing the uuid
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session *session);
|
||||
|
||||
/*!
|
||||
\brief Retrieve private user data from a session
|
||||
\param session the session to retrieve from
|
||||
\return a pointer to the private data
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *session);
|
||||
|
||||
/*!
|
||||
\brief Add private user data to a session
|
||||
\param session the session to add used data to
|
||||
\param private the used data to add
|
||||
\return SWITCH_STATUS_SUCCESS if data is added
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_session *session, void *private);
|
||||
|
||||
/*!
|
||||
\brief Launch a thread designed to exist within the scope of a given session
|
||||
\param session a session to allocate the thread from
|
||||
\param func a function to execute in the thread
|
||||
\param obj an arguement
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, void *(*func)(switch_thread *, void *), void *obj);
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples, switch_memory_pool *pool);
|
||||
SWITCH_DECLARE(int) switch_core_timer_next(switch_timer *timer);
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_destroy(switch_timer *timer);
|
||||
|
||||
/*!
|
||||
\brief Signal a thread using a thread session to terminate
|
||||
\param thread_session the thread_session to indicate to
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *thread_session);
|
||||
|
||||
/*!
|
||||
\brief Launch a service thread on a session to drop inbound data
|
||||
\param session the session the launch thread on
|
||||
\param thread_session the thread_session to use
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session);
|
||||
|
||||
/*!
|
||||
\brief Request an outgoing session spawned from an existing session using a desired endpoing module
|
||||
\param session the originating session
|
||||
\param endpoint_name the name of the module to use for the new session
|
||||
\param caller_profile the originator's caller profile
|
||||
\param new_session a NULL pointer to aim at the newly created session
|
||||
\return SWITCH_STATUS_SUCCESS if the session was created
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
|
||||
char *endpoint_name,
|
||||
switch_caller_profile *caller_profile,
|
||||
switch_core_session **new_session);
|
||||
|
||||
/*!
|
||||
\brief Answer the channel of a given session
|
||||
\param session the session to answer the channel of
|
||||
\return SWITCH_STATUS_SUCCESS if the channel was answered
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_session *session);
|
||||
|
||||
/*!
|
||||
\brief Read a frame from a session
|
||||
\param session the session to read from
|
||||
\param frame a NULL pointer to a frame to aim at the newly read frame
|
||||
\param timeout number of milliseconds to wait for data
|
||||
\return SWITCH_STATUS_SUCCESS a the frame was read
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout);
|
||||
|
||||
/*!
|
||||
\brief Write a frame to a session
|
||||
\param session the session to write to
|
||||
\param frame the frame to write
|
||||
\param timeout number of milliseconds to wait for data
|
||||
\return SWITCH_STATUS_SUCCESS a the frame was written
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout);
|
||||
|
||||
/*!
|
||||
\brief Send a signal to a channel
|
||||
\param session session to send signal to
|
||||
\param sig signal to send
|
||||
\return status returned by the session's signal handler
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_session *session, switch_signal sig);
|
||||
|
||||
/*!
|
||||
\brief Wait for a session to be ready for input
|
||||
\param session session to wait for
|
||||
\param timeout number of milliseconds to wait for data
|
||||
\return SWITCH_STATUS_SUCCESS if data is available for read within timeframe specified
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout);
|
||||
|
||||
/*!
|
||||
\brief Wait for a session to be ready for output
|
||||
\param session session to wait for
|
||||
\param timeout number of milliseconds to wait for data
|
||||
\return SWITCH_STATUS_SUCCESS if the session is available for write within timeframe specified
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout);
|
||||
|
||||
/*!
|
||||
\brief Send DTMF to a session
|
||||
\param session session to send DTMF to
|
||||
\param dtmf string to send to the session
|
||||
\return SWITCH_STATUS_SUCCESS if the dtmf was written
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_send_dtmf(switch_core_session *session, char *dtmf);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session requests an outgoing extension
|
||||
\param session session to bind hook to
|
||||
\param outgoing_channel hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session, switch_outgoing_channel_hook outgoing_channel);
|
||||
///\}
|
||||
|
||||
///\defgroup shooks Session Hook Callbacks
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session requests an outgoing extension
|
||||
\param session session to bind hook to
|
||||
\param answer_channel hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session, switch_answer_channel_hook answer_channel);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session reads a frame
|
||||
\param session session to bind hook to
|
||||
\param read_frame hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session, switch_read_frame_hook read_frame);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session writes a frame
|
||||
\param session session to bind hook to
|
||||
\param write_frame hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session, switch_write_frame_hook write_frame);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session kills a channel
|
||||
\param session session to bind hook to
|
||||
\param kill_channel hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session, switch_kill_channel_hook kill_channel);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session waits for a read event
|
||||
\param session session to bind hook to
|
||||
\param waitfor_read hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session, switch_waitfor_read_hook waitfor_read);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session waits for a write event
|
||||
\param session session to bind hook to
|
||||
\param waitfor_write hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session, switch_waitfor_write_hook waitfor_write);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session sends dtmf
|
||||
\param session session to bind hook to
|
||||
\param send_dtmf hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session, switch_send_dtmf_hook send_dtmf);
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, int rate, int ms, int channels, switch_codec_flag flags, const switch_codec_settings *codec_settings, switch_memory_pool *pool);
|
||||
///\}
|
||||
|
||||
///\defgroup hashf Hash Functions
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Initilize a hash table
|
||||
\param hash a NULL pointer to a hash table to aim at the new hash
|
||||
\param pool the pool to use for the new hash
|
||||
\return SWITCH_STATUS_SUCCESS if the hash is created
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_init(switch_hash **hash, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Destroy an existing hash table
|
||||
\param hash the hash to destroy
|
||||
\return SWITCH_STATUS_SUCCESS if the hash is destroyed
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_destroy(switch_hash *hash);
|
||||
|
||||
/*!
|
||||
\brief Insert data into a hash
|
||||
\param hash the hash to add data to
|
||||
\param key the name of the key to add the data to
|
||||
\param data the data to add
|
||||
\return SWITCH_STATUS_SUCCESS if the data is added
|
||||
\note the string key must be a constant or a dynamic string
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_insert(switch_hash *hash, char *key, void *data);
|
||||
|
||||
/*!
|
||||
\brief Insert data into a hash with dynamicly allocated key name
|
||||
\param hash the hash to add data to
|
||||
\param key the name of the key to add the data to
|
||||
\param data the data to add
|
||||
\return SWITCH_STATUS_SUCCESS if the data is added
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_insert_dup(switch_hash *hash, char *key, void *data);
|
||||
|
||||
/*!
|
||||
\brief Delete data from a hash based on desired key
|
||||
\param hash the hash to delete from
|
||||
\param key the key from which to delete the data
|
||||
\return SWITCH_STATUS_SUCCESS if the data is deleted
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_hash_delete(switch_hash *hash, char *key);
|
||||
|
||||
/*!
|
||||
\brief Retrieve data from a given hash
|
||||
\param hash the hash to retrieve from
|
||||
\param key the key to retrieve
|
||||
\return a pointer to the data held in the key
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash *hash, char *key);
|
||||
///\}
|
||||
|
||||
///\defgroup timer Timer Functions
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Request a timer handle using given time module
|
||||
\param timer a timer object to allocate to
|
||||
\param timer_name the name of the timer module to use
|
||||
\param interval desired interval
|
||||
\param samples the number of samples to increment on each cycle
|
||||
\param pool the memory pool to use for allocation
|
||||
\return
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Wait for one cycle on an existing timer
|
||||
\param timer the timer to wait on
|
||||
\return the newest sample count
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_timer_next(switch_timer *timer);
|
||||
|
||||
/*!
|
||||
\brief Destroy an allocated timer
|
||||
\param timer timer to destroy
|
||||
\return SWITCH_STATUS_SUCCESS after destruction
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_destroy(switch_timer *timer);
|
||||
///\}
|
||||
|
||||
///\defgroup codecs Codec Functions
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Initialize a codec handle
|
||||
\param codec the handle to initilize
|
||||
\param codec_name the name of the codec module to use
|
||||
\param rate the desired rate (0 for any)
|
||||
\param ms the desired number of milliseconds (0 for any)
|
||||
\param channels the desired number of channels (0 for any)
|
||||
\param flags flags to alter behaviour
|
||||
\param codec_settings desired codec settings
|
||||
\param pool the memory pool to use
|
||||
\return SWITCH_STATUS_SUCCESS if the handle is allocated
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec,
|
||||
char *codec_name,
|
||||
int rate,
|
||||
int ms,
|
||||
int channels,
|
||||
switch_codec_flag flags,
|
||||
const switch_codec_settings *codec_settings,
|
||||
switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Encode data using a codec handle
|
||||
\param codec the codec handle to use
|
||||
\param other_codec the codec handle of the last codec used
|
||||
\param decoded_data the raw data
|
||||
\param decoded_data_len then length of the raw buffer
|
||||
\param decoded_rate the rate of the decoded data
|
||||
\param encoded_data the buffer to write the encoded data to
|
||||
\param encoded_data_len the size of the encoded_data buffer
|
||||
\param encoded_rate the new rate of the encoded data
|
||||
\param flag flags to exchange
|
||||
\return SWITCH_STATUS_SUCCESS if the data was encoded
|
||||
\note encoded_data_len will be rewritten to the in-use size of encoded_data
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *decoded_data,
|
||||
|
@ -115,6 +517,21 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
|||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag);
|
||||
|
||||
/*!
|
||||
\brief Decode data using a codec handle
|
||||
\param codec the codec handle to use
|
||||
\param other_codec the codec handle of the last codec used
|
||||
\param encoded_data the buffer to read the encoded data from
|
||||
\param encoded_data_len the size of the encoded_data buffer
|
||||
\param encoded_rate the rate of the encoded data
|
||||
\param decoded_data the raw data buffer
|
||||
\param decoded_data_len then length of the raw buffer
|
||||
\param decoded_rate the new rate of the decoded data
|
||||
\param flag flags to exchange
|
||||
\return SWITCH_STATUS_SUCCESS if the data was decoded
|
||||
\note decoded_data_len will be rewritten to the in-use size of decoded_data
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *encoded_data,
|
||||
|
@ -124,23 +541,128 @@ SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
|||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag);
|
||||
|
||||
/*!
|
||||
\brief Destroy an initalized codec handle
|
||||
\param codec the codec handle to destroy
|
||||
\return SWITCH_STATUS_SUCCESS if the codec was destroyed
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_destroy(switch_codec *codec);
|
||||
|
||||
/*!
|
||||
\brief Assign the read codec to a given session
|
||||
\param session session to add the codec to
|
||||
\param codec the codec to add
|
||||
\return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_session *session, switch_codec *codec);
|
||||
|
||||
/*!
|
||||
\brief Assign the write codec to a given session
|
||||
\param session session to add the codec to
|
||||
\param codec the codec to add
|
||||
\return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec);
|
||||
SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
|
||||
SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session);
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup);
|
||||
///\}
|
||||
|
||||
///\defgroup db Databse Functions
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Open a core db (SQLite) file
|
||||
\param filename the path to the db file to open
|
||||
\return
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_db *) switch_core_db_open_file(char *filename);
|
||||
SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session *session);
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags, switch_memory_pool *pool);
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void *data, size_t *len);
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, size_t *len);
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples, int whence);
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_close(switch_file_handle *fh);
|
||||
|
||||
#define SWITCH_CORE_DB "core"
|
||||
/*!
|
||||
\brief Open the default system database
|
||||
*/
|
||||
#define switch_core_db_handle() switch_core_db_open_file(SWITCH_CORE_DB)
|
||||
|
||||
///\}
|
||||
|
||||
///\defgroup Media File Functions
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Open a media file using file format modules
|
||||
\param fh a file handle to use
|
||||
\param file_path the path to the file
|
||||
\param flags read/write flags
|
||||
\param pool the pool to use (NULL for new pool)
|
||||
\return SWITCH_STATUS_SUCCESS if the file is opened
|
||||
\note the loadable module used is chosen based on the file extension
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Read media from a file handle
|
||||
\param fh the file handle to read from
|
||||
\param data the buffer to read the data to
|
||||
\param len the max size of the buffer
|
||||
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes read if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void *data, size_t *len);
|
||||
|
||||
/*!
|
||||
\brief Write media to a file handle
|
||||
\param fh the file handle to write to
|
||||
\param data the buffer to write
|
||||
\param len the amount of data to write from the buffer
|
||||
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, size_t *len);
|
||||
|
||||
/*!
|
||||
\brief Seek a position in a file
|
||||
\param fh the file handle to seek
|
||||
\param cur_pos the current position in the file
|
||||
\param samples the amount of samples to seek from the beginning of the file
|
||||
\param whence the indicator (see traditional seek)
|
||||
\return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples, int whence);
|
||||
|
||||
/*!
|
||||
\brief Close an open file handle
|
||||
\param fh the file handle to close
|
||||
\return SWITCH_STATUS_SUCCESS if the file handle was closed
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_close(switch_file_handle *fh);
|
||||
///\}
|
||||
|
||||
///\defgroup misc Misc
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Retrieve a FILE stream of a given text channel name
|
||||
\param channel text channel enumeration
|
||||
\return a FILE stream
|
||||
*/
|
||||
SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel);
|
||||
|
||||
/*!
|
||||
\brief Launch a thread
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread *, void*), void *obj, switch_memory_pool *pool);
|
||||
///\}
|
||||
|
||||
#ifdef USE_PERL
|
||||
/*!
|
||||
\brief Execute some perl when compiled with perl support
|
||||
\return SWITCH_STATUS_SUCCESS on success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_core_do_perl(char *txt);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,28 @@
|
|||
*/
|
||||
/*! \file switch_event.h
|
||||
\brief Event System
|
||||
|
||||
The event system uses a backend thread and an APR threadsafe FIFO queue to accept event objects from various threads
|
||||
and allow the backend to take control and deliver the events to registered callbacks.
|
||||
|
||||
The typical usage would be to bind to one or all of the events and use a callback function to react in various ways
|
||||
(see the more_xmpp_event_handler or mod_event_test modules for examples).
|
||||
|
||||
Builtin events are fired by the core at various points in the execution of the application and custom events can be
|
||||
reserved and registered so events from an external module can be rendered and handled by an another even handler module.
|
||||
|
||||
If the work time to process an event in a callback is anticipated to grow beyond a very small amount of time it is reccommended
|
||||
that you impelment your own handler thread and FIFO queue so you can accept the events int the callback and queue them
|
||||
into your own thread rather than tie up the delivery agent. It is in to opinion of the author that such a necessity
|
||||
should be judged on a per-use basis and therefore does not fall within the scope of this system to provide that
|
||||
functionality at a core level.
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\defgroup events Eventing Engine
|
||||
\ingroup FREESWITCH
|
||||
\{
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_EVENT_H
|
||||
|
@ -42,56 +64,211 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/*! \brief An event Header */
|
||||
struct switch_event_header {
|
||||
/*! the header name */
|
||||
char *name;
|
||||
/*! the header value */
|
||||
char *value;
|
||||
struct switch_event_header *next;
|
||||
};
|
||||
|
||||
/*! \brief A registered custom event subclass */
|
||||
struct switch_event_subclass {
|
||||
/*! the owner of the subclass */
|
||||
char *owner;
|
||||
/*! the subclass name */
|
||||
char *name;
|
||||
};
|
||||
|
||||
/*! \brief Representation of an event */
|
||||
struct switch_event {
|
||||
/*! the event id (descriptor) */
|
||||
switch_event_t event_id;
|
||||
/*! the owner of the event */
|
||||
char *owner;
|
||||
/*! the subclass of the event */
|
||||
switch_event_subclass *subclass;
|
||||
/*! the event headers */
|
||||
struct switch_event_header *headers;
|
||||
/*! the body of the event */
|
||||
char *body;
|
||||
/*! user data from the subclass provider */
|
||||
void *bind_user_data;
|
||||
/*! user data from the event sender */
|
||||
void *event_user_data;
|
||||
struct switch_event *next;
|
||||
};
|
||||
|
||||
/*! \brief A node to store binded events */
|
||||
struct switch_event_node {
|
||||
/*! the id of the node */
|
||||
char *id;
|
||||
/*! the event id enumeration to bind to */
|
||||
switch_event_t event_id;
|
||||
/*! the event subclass to bind to for custom events */
|
||||
switch_event_subclass *subclass;
|
||||
/*! a callback function to execute when the event is triggered */
|
||||
switch_event_callback_t callback;
|
||||
/*! private data */
|
||||
void *user_data;
|
||||
struct switch_event_node *next;
|
||||
};
|
||||
|
||||
#define SWITCH_EVENT_SUBCLASS_ANY NULL
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_shutdown(void);
|
||||
/*!
|
||||
\brief Start the eventing system
|
||||
\param pool the memory pool to use for the event system (creates a new one if NULL)
|
||||
\return SWITCH_STATUS_SUCCESS when complete
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Stop the eventing system
|
||||
\return SWITCH_STATUS_SUCCESS when complete
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_shutdown(void);
|
||||
|
||||
/*!
|
||||
\brief Create an event
|
||||
\param event a NULL pointer on which to create the event
|
||||
\param event_id the event id enumeration of the desired event
|
||||
\param subclass_name the subclass name for custom event (only valid when event_id is SWITCH_EVENT_CUSTOM)
|
||||
\return SWITCH_STATUS_SUCCESS on success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event, switch_event_t event_id, char *subclass_name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve a header value from an event
|
||||
\param event the event to read the header from
|
||||
\param header_name the name of the header to read
|
||||
\return the value of the requested header
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_event_get_header(switch_event *event, char *header_name);
|
||||
|
||||
/*!
|
||||
\brief Add a header to an event
|
||||
\param event the event to add the header to
|
||||
\param stack the stack sense (stack it on the top or on the bottom)
|
||||
\param header_name the name of the header to add
|
||||
\param fmt the value of the header (varargs see standard sprintf family)
|
||||
\return SWITCH_STATUS_SUCCESS if the header was added
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name, char *fmt, ...);
|
||||
|
||||
/*!
|
||||
\brief Destroy an event
|
||||
\param event pointer to the pointer to event to destroy
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_event_destroy(switch_event **event);
|
||||
|
||||
/*!
|
||||
\brief Duplicate an event
|
||||
\param event a NULL pointer on which to duplicate the event
|
||||
\param todup an event to duplicate
|
||||
\return SWITCH_STATUS_SUCCESS if the event was duplicated
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_dup(switch_event **event, switch_event *todup);
|
||||
|
||||
/*!
|
||||
\brief Fire an event with full arguement list
|
||||
\param file the calling file
|
||||
\param func the calling function
|
||||
\param line the calling line number
|
||||
\param event the event to send (will be nulled on success)
|
||||
\param user_data optional private data to pass to the event handlers
|
||||
\return
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event, void *user_data);
|
||||
|
||||
/*!
|
||||
\brief Bind an event callback to a specific event
|
||||
\param id an identifier token of the binder
|
||||
\param event the event enumeration to bind to
|
||||
\param subclass_name the event subclass to bind to in the case if SWITCH_EVENT_CUSTOM
|
||||
\param callback the callback functon to bind
|
||||
\param user_data optional user specific data to pass whenever the callback is invoked
|
||||
\return SWITCH_STATUS_SUCCESS if the event was binded
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event, char *subclass_name, switch_event_callback_t callback, void *user_data);
|
||||
|
||||
/*!
|
||||
\brief Render the name of an event id enumeration
|
||||
\param event the event id to render the name of
|
||||
\return the rendered name
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_event_name(switch_event_t event);
|
||||
|
||||
/*!
|
||||
\brief Reserve a subclass name for private use with a custom event
|
||||
\param owner the owner of the event name
|
||||
\param subclass_name the name to reserve
|
||||
\return SWITCH_STATUS_SUCCESS if the name was reserved
|
||||
\note There is nothing to enforce this but I reccommend using module::event_name for the subclass names
|
||||
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_reserve_subclass_detailed(char *owner, char *subclass_name);
|
||||
|
||||
/*!
|
||||
\brief Render a string representation of an event sutable for printing or network transport
|
||||
\param event the event to render
|
||||
\param buf a string buffer to write the data to
|
||||
\param buflen the size in bytes of the buffer
|
||||
\param fmt optional body of the event (varargs see standard sprintf family)
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was successful
|
||||
\note the body supplied by this function will supersede an existing body the event may have
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *buf, size_t buflen, char *fmt, ...);
|
||||
|
||||
/*!
|
||||
\brief Determine if the event system has been initilized
|
||||
\return SWITCH_STATUS_SUCCESS if the system is running
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_running(void);
|
||||
|
||||
/*!
|
||||
\brief Add a body to an event
|
||||
\param event the event to add to body to
|
||||
\param fmt optional body of the event (varargs see standard sprintf family)
|
||||
\return SWITCH_STATUS_SUCCESS if the body was added to the event
|
||||
\note the body parameter can be shadowed by the switch_event_reserve_subclass_detailed function
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_event_add_body(switch_event *event, char *fmt, ...);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Reserve a subclass assuming the owner string is the current filename
|
||||
\param subclass_name the subclass name to reserve
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was successful
|
||||
\note the body supplied by this function will supersede an existing body the event may have
|
||||
*/
|
||||
#define switch_event_reserve_subclass(subclass_name) switch_event_reserve_subclass_detailed(__FILE__, subclass_name)
|
||||
|
||||
/*!
|
||||
\brief Create a new event assuming it will not be custom event and therefore hiding the unused parameters
|
||||
\param event a NULL pointer on which to create the event
|
||||
\param id the event id enumeration of the desired event
|
||||
\return SWITCH_STATUS_SUCCESS on success
|
||||
*/
|
||||
#define switch_event_create(event, id) switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY)
|
||||
|
||||
/*!
|
||||
\brief Fire an event filling in most of the arguements with obvious values
|
||||
\param event the event to send (will be nulled on success)
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was successful
|
||||
\note the body supplied by this function will supersede an existing body the event may have
|
||||
*/
|
||||
#define switch_event_fire(event) switch_event_fire_detailed(__FILE__, (char * )__FUNCTION__, __LINE__, event, NULL)
|
||||
|
||||
/*!
|
||||
\brief Fire an event filling in most of the arguements with obvious values and allowing user_data to be sent
|
||||
\param event the event to send (will be nulled on success)
|
||||
\param data user data to send to the event handlers
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was successful
|
||||
\note the body supplied by this function will supersede an existing body the event may have
|
||||
*/
|
||||
#define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__FUNCTION__, __LINE__, event, data)
|
||||
///\}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,12 +42,19 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/*! \brief An abstraction of a data frame */
|
||||
struct switch_frame {
|
||||
/*! a pointer to the codec information */
|
||||
switch_codec *codec;
|
||||
/*! the frame data */
|
||||
void *data;
|
||||
/*! the size of the buffer that is in use */
|
||||
size_t datalen;
|
||||
/*! the entire size of the buffer */
|
||||
size_t buflen;
|
||||
/*! the number of audio samples present (audio only) */
|
||||
int samples;
|
||||
/*! the rate of the frame */
|
||||
int rate;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,12 @@
|
|||
*
|
||||
*/
|
||||
/*! \file switch_loadable_module.h
|
||||
\brief Loadable Modules
|
||||
\brief 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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_LOADABLE_MODULE_H
|
||||
|
@ -42,30 +47,129 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/*!
|
||||
\defgroup mods Loadable Module Functions
|
||||
\ingroup FREESWITCH
|
||||
\{
|
||||
*/
|
||||
|
||||
/*! \brief The abstraction of a loadable module */
|
||||
struct switch_loadable_module_interface {
|
||||
/*! the name of the module */
|
||||
const char *module_name;
|
||||
/*! the table of endpoints the module has implmented */
|
||||
const switch_endpoint_interface *endpoint_interface;
|
||||
/*! the table of timers the module has implmented */
|
||||
const switch_timer_interface *timer_interface;
|
||||
/*! the table of dialplans the module has implmented */
|
||||
const switch_dialplan_interface *dialplan_interface;
|
||||
/*! the table of codecs the module has implmented */
|
||||
const switch_codec_interface *codec_interface;
|
||||
/*! the table of applications the module has implmented */
|
||||
const switch_application_interface *application_interface;
|
||||
/*! the table of api functions the module has implmented */
|
||||
const switch_api_interface *api_interface;
|
||||
/*! the table of file formats the module has implmented */
|
||||
const switch_file_interface *file_interface;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Initilize the module backend and load all the modules
|
||||
\return SWITCH_STATUS_SUCCESS when complete
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_loadable_module_init(void);
|
||||
SWITCH_DECLARE(switch_endpoint_interface *) loadable_module_get_endpoint_interface(char *name);
|
||||
SWITCH_DECLARE(switch_codec_interface *) loadable_module_get_codec_interface(char *name);
|
||||
SWITCH_DECLARE(switch_dialplan_interface *) loadable_module_get_dialplan_interface(char *name);
|
||||
SWITCH_DECLARE(switch_timer_interface *) loadable_module_get_timer_interface(char *name);
|
||||
SWITCH_DECLARE(switch_application_interface *) loadable_module_get_application_interface(char *name);
|
||||
SWITCH_DECLARE(switch_api_interface *) loadable_module_get_api_interface(char *name);
|
||||
SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen);
|
||||
SWITCH_DECLARE(int) loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen);
|
||||
|
||||
/*!
|
||||
\brief Shutdown the module backend and call the shutdown routine in all loaded modules
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_loadable_module_shutdown(void);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the endpoint interface by it's registered name
|
||||
\param name the name of the endpoint
|
||||
\return the desired endpoint interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_endpoint_interface *) switch_loadable_module_get_endpoint_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the codec interface by it's registered name
|
||||
\param name the name of the codec
|
||||
\return the desired codec interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_codec_interface *) switch_loadable_module_get_codec_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the dialplan interface by it's registered name
|
||||
\param name the name of the dialplan
|
||||
\return the desired dialplan interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_dialplan_interface *) switch_loadable_module_get_dialplan_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the timer interface by it's registered name
|
||||
\param name the name of the timer
|
||||
\return the desired timer interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_timer_interface *) switch_loadable_module_get_timer_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the application interface by it's registered name
|
||||
\param name the name of the application
|
||||
\return the desired application interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_application_interface *) switch_loadable_module_get_application_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the API interface by it's registered name
|
||||
\param name the name of the API
|
||||
\return the desired API interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_api_interface *) switch_loadable_module_get_api_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the file format interface by it's registered name
|
||||
\param name the name of the file format
|
||||
\return the desired file format interface
|
||||
*/
|
||||
SWITCH_DECLARE(switch_file_interface *) switch_loadable_module_get_file_interface(char *name);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the list of loaded codecs into an array
|
||||
\param pool the memory pool to use for the hash index
|
||||
\param array the array to populate
|
||||
\param arraylen the max size in elements of the array
|
||||
\return the number of elements added to the array
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool,
|
||||
switch_codec_interface **array,
|
||||
int arraylen);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the list of loaded codecs into an array based on another array showing the sorted order
|
||||
\param pool the memory pool to use for the hash index
|
||||
\param array the array to populate
|
||||
\param arraylen the max size in elements of the array
|
||||
\param prefs the array of preferred codec names
|
||||
\param preflen the size in elements of the prefs
|
||||
\return the number of elements added to the array
|
||||
\note this function only considers codecs that are listed in the "prefs" array and ignores the rest.
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool,
|
||||
switch_codec_interface **array,
|
||||
int arraylen,
|
||||
char **prefs,
|
||||
int preflen);
|
||||
|
||||
/*!
|
||||
\brief Execute a registered API command
|
||||
\param cmd the name of the API command to execute
|
||||
\param arg the optional arguement to the command
|
||||
\param retbuf a buffer to write output to
|
||||
\param len the length in bytes of retbuf
|
||||
\return the status returned by the API call
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_api_execute(char *cmd, char *arg, char *retbuf, size_t len);
|
||||
SWITCH_DECLARE(switch_file_interface *) loadable_module_get_file_interface(char *name);
|
||||
SWITCH_DECLARE(void) loadable_module_shutdown(void);
|
||||
///\}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
*/
|
||||
/*! \file switch_module_interfaces.h
|
||||
\brief Module Interface Definitions
|
||||
|
||||
This module holds the definition of data abstractions used to implement various pluggable
|
||||
interfaces and pluggable event handlers.
|
||||
|
||||
*/
|
||||
#ifndef SWITCH_MODULE_INTERFACES_H
|
||||
#define SWITCH_MODULE_INTERFACES_H
|
||||
|
@ -41,192 +45,306 @@ extern "C" {
|
|||
|
||||
#include <switch.h>
|
||||
|
||||
/* A table of functions to execute at various states */
|
||||
/*! \brief A table of functions to execute at various states
|
||||
*/
|
||||
struct switch_event_handler_table {
|
||||
/*! executed when the state changes to init */
|
||||
switch_event_handler on_init;
|
||||
/*! executed when the state changes to ring */
|
||||
switch_event_handler on_ring;
|
||||
/*! executed when the state changes to execute */
|
||||
switch_event_handler on_execute;
|
||||
/*! executed when the state changes to hangup */
|
||||
switch_event_handler on_hangup;
|
||||
/*! executed when the state changes to loopback*/
|
||||
switch_event_handler on_loopback;
|
||||
/*! executed when the state changes to transmit*/
|
||||
switch_event_handler on_transmit;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom outgoing channel callback hooks */
|
||||
struct switch_io_event_hook_outgoing_channel {
|
||||
/*! the outgoing channel callback hook*/
|
||||
switch_outgoing_channel_hook outgoing_channel;
|
||||
struct switch_io_event_hook_outgoing_channel *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom answer channel callback hooks */
|
||||
struct switch_io_event_hook_answer_channel {
|
||||
/*! the answer channel callback hook*/
|
||||
switch_answer_channel_hook answer_channel;
|
||||
struct switch_io_event_hook_answer_channel *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom read frame channel callback hooks */
|
||||
struct switch_io_event_hook_read_frame {
|
||||
/*! the read frame channel callback hook*/
|
||||
switch_read_frame_hook read_frame;
|
||||
struct switch_io_event_hook_read_frame *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom write_frame channel callback hooks */
|
||||
struct switch_io_event_hook_write_frame {
|
||||
/*! the write_frame channel callback hook*/
|
||||
switch_write_frame_hook write_frame;
|
||||
struct switch_io_event_hook_write_frame *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom kill channel callback hooks */
|
||||
struct switch_io_event_hook_kill_channel {
|
||||
/*! the kill channel callback hook*/
|
||||
switch_kill_channel_hook kill_channel;
|
||||
struct switch_io_event_hook_kill_channel *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom waitfor read channel callback hooks */
|
||||
struct switch_io_event_hook_waitfor_read {
|
||||
/*! the waitfor read channel callback hook*/
|
||||
switch_waitfor_read_hook waitfor_read;
|
||||
struct switch_io_event_hook_waitfor_read *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom waitfor write channel callback hooks */
|
||||
struct switch_io_event_hook_waitfor_write {
|
||||
/*! the waitfor write channel callback hook*/
|
||||
switch_waitfor_write_hook waitfor_write;
|
||||
struct switch_io_event_hook_waitfor_write *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom send dtmf channel callback hooks */
|
||||
struct switch_io_event_hook_send_dtmf {
|
||||
/*! the send dtmf channel callback hook*/
|
||||
switch_send_dtmf_hook send_dtmf;
|
||||
struct switch_io_event_hook_send_dtmf *next;
|
||||
};
|
||||
|
||||
/*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */
|
||||
struct switch_io_event_hooks {
|
||||
/*! a list of outgoing channel hooks */
|
||||
struct switch_io_event_hook_outgoing_channel *outgoing_channel;
|
||||
/*! a list of answer channel hooks */
|
||||
struct switch_io_event_hook_answer_channel *answer_channel;
|
||||
/*! a list of read frame hooks */
|
||||
struct switch_io_event_hook_read_frame *read_frame;
|
||||
/*! a list of write frame hooks */
|
||||
struct switch_io_event_hook_write_frame *write_frame;
|
||||
/*! a list of kill channel hooks */
|
||||
struct switch_io_event_hook_kill_channel *kill_channel;
|
||||
/*! a list of wait for read hooks */
|
||||
struct switch_io_event_hook_waitfor_read *waitfor_read;
|
||||
/*! a list of wait for write hooks */
|
||||
struct switch_io_event_hook_waitfor_write *waitfor_write;
|
||||
/*! a list of send dtmf hooks */
|
||||
struct switch_io_event_hook_send_dtmf *send_dtmf;
|
||||
};
|
||||
|
||||
/*! \brief A table of i/o routines that an endpoint interface can implement */
|
||||
struct switch_io_routines {
|
||||
/*! creates an outgoing session from given session, caller profile */
|
||||
switch_status (*outgoing_channel)(switch_core_session *, switch_caller_profile *, switch_core_session **);
|
||||
/*! answers the given session's channel */
|
||||
switch_status (*answer_channel)(switch_core_session *);
|
||||
/*! read a frame from a session */
|
||||
switch_status (*read_frame)(switch_core_session *, switch_frame **, int, switch_io_flag);
|
||||
/*! write a frame to a session */
|
||||
switch_status (*write_frame)(switch_core_session *, switch_frame *, int, switch_io_flag);
|
||||
/*! send a kill signal to the session's channel */
|
||||
switch_status (*kill_channel)(switch_core_session *, int);
|
||||
/*! wait for the session's channel to be ready to read audio */
|
||||
switch_status (*waitfor_read)(switch_core_session *, int);
|
||||
/*! wait for the session's channel to be ready to write audio */
|
||||
switch_status (*waitfor_write)(switch_core_session *, int);
|
||||
/*! send a string of DTMF digits to a session's channel */
|
||||
switch_status (*send_dtmf)(switch_core_session *, char *);
|
||||
};
|
||||
|
||||
/*
|
||||
/*! \brief Abstraction of an module endpoint interface
|
||||
This is the glue between the abstract idea of a "channel" and what is really going on under the
|
||||
hood. Each endpoint module fills out one of these tables and makes it available when a channel
|
||||
is created of it's paticular type.
|
||||
*/
|
||||
|
||||
struct switch_endpoint_interface {
|
||||
/* the interface's name */
|
||||
/*! the interface's name */
|
||||
const char *interface_name;
|
||||
|
||||
/* channel abstraction methods */
|
||||
/*! channel abstraction methods */
|
||||
const switch_io_routines *io_routines;
|
||||
|
||||
/* state machine methods */
|
||||
/*! state machine methods */
|
||||
const switch_event_handler_table *event_handlers;
|
||||
|
||||
/* private information */
|
||||
/*! private information */
|
||||
void *private;
|
||||
|
||||
/* to facilitate linking */
|
||||
const struct switch_endpoint_interface *next;
|
||||
};
|
||||
|
||||
/*! \brief Abstract handler to a timer module */
|
||||
struct switch_timer {
|
||||
/*! time interval expressed in milliseconds */
|
||||
int interval;
|
||||
/*! flags to control behaviour */
|
||||
unsigned int flags;
|
||||
/*! sample count to increment by on each cycle */
|
||||
unsigned int samples;
|
||||
/*! current sample count based on samples parameter */
|
||||
unsigned int samplecount;
|
||||
/*! the timer interface provided from a loadable module */
|
||||
struct switch_timer_interface *timer_interface;
|
||||
/*! the timer's memory pool */
|
||||
switch_memory_pool *memory_pool;
|
||||
/*! private data for loadable modules to store information */
|
||||
void *private;
|
||||
};
|
||||
|
||||
/*! \brief A table of functions that a timer module implements */
|
||||
struct switch_timer_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to allocate the timer */
|
||||
switch_status (*timer_init)(switch_timer *);
|
||||
/*! function to wait for one cycle to pass */
|
||||
switch_status (*timer_next)(switch_timer *);
|
||||
/*! function to deallocate the timer */
|
||||
switch_status (*timer_destroy)(switch_timer *);
|
||||
const struct switch_timer_interface *next;
|
||||
};
|
||||
|
||||
/*! \brief Abstract interface to a dialplan module */
|
||||
struct switch_dialplan_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! the function to read an extension and set a channels dialpan */
|
||||
switch_dialplan_hunt_function hunt_function;
|
||||
const struct switch_dialplan_interface *next;
|
||||
};
|
||||
|
||||
/*! \brief Abstract interface to a file format module */
|
||||
struct switch_file_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to open the file */
|
||||
switch_status (*file_open)(switch_file_handle *, char *file_path);
|
||||
/*! function to close the file */
|
||||
switch_status (*file_close)(switch_file_handle *);
|
||||
/*! function to read from the file */
|
||||
switch_status (*file_read)(switch_file_handle *, void *data, unsigned int *len);
|
||||
/*! function to write from the file */
|
||||
switch_status (*file_write)(switch_file_handle *, void *data, unsigned int *len);
|
||||
/*! function to seek to a certian position in the file */
|
||||
switch_status (*file_seek)(switch_file_handle *, unsigned int *cur_pos, unsigned int samples, int whence);
|
||||
/*! list of supported file extensions */
|
||||
char **extens;
|
||||
const struct switch_file_interface *next;
|
||||
};
|
||||
|
||||
/*! an abstract representation of a file handle (some parameters based on compat with libsndfile) */
|
||||
struct switch_file_handle {
|
||||
/*! the interface of the module that implemented the current file type */
|
||||
const struct switch_file_interface *file_interface;
|
||||
/*! flags to control behaviour */
|
||||
unsigned int flags;
|
||||
/*! a file descriptor if neceessary */
|
||||
switch_file_t *fd;
|
||||
/*! samples position of the handle */
|
||||
unsigned int samples;
|
||||
/*! the current samplerate */
|
||||
unsigned int samplerate;
|
||||
/*! the number of channels */
|
||||
unsigned int channels;
|
||||
/*! integer representation of the format */
|
||||
unsigned int format;
|
||||
/*! integer representation of the sections */
|
||||
unsigned int sections;
|
||||
/*! is the file seekable */
|
||||
int seekable;
|
||||
/*! the sample count of the file */
|
||||
unsigned int sample_count;
|
||||
/*! the handle's memory pool */
|
||||
switch_memory_pool *memory_pool;
|
||||
/*! private data for the format module to store handle specific info */
|
||||
void *private;
|
||||
};
|
||||
|
||||
|
||||
/* nobody has more setting than speex so we will let them set the standard */
|
||||
/*! \brief Various codec settings (currently only relevant to speex) */
|
||||
struct switch_codec_settings {
|
||||
/*! desired quality */
|
||||
int quality;
|
||||
/*! desired complexity */
|
||||
int complexity;
|
||||
/*! desired enhancement */
|
||||
int enhancement;
|
||||
/*! desired vad level */
|
||||
int vad;
|
||||
/*! desired vbr level */
|
||||
int vbr;
|
||||
/*! desired vbr quality */
|
||||
float vbr_quality;
|
||||
/*! desired abr level */
|
||||
int abr;
|
||||
/*! desired dtx setting */
|
||||
int dtx;
|
||||
/*! desired preprocessor settings */
|
||||
int preproc;
|
||||
/*! preprocessor vad settings */
|
||||
int pp_vad;
|
||||
/*! preprocessor gain control settings */
|
||||
int pp_agc;
|
||||
/*! preprocessor gain level */
|
||||
float pp_agc_level;
|
||||
/*! preprocessor denoise level */
|
||||
int pp_denoise;
|
||||
/*! preprocessor dereverb settings */
|
||||
int pp_dereverb;
|
||||
/*! preprocessor dereverb decay level */
|
||||
float pp_dereverb_decay;
|
||||
/*! preprocessor dereverb level */
|
||||
float pp_dereverb_level;
|
||||
};
|
||||
|
||||
/*! an abstract handle to a codec module */
|
||||
struct switch_codec {
|
||||
/*! the codec interface table this handle uses */
|
||||
const struct switch_codec_interface *codec_interface;
|
||||
/*! the specific implementation of the above codec */
|
||||
const struct switch_codec_implementation *implementation;
|
||||
/*! codec settings for this handle */
|
||||
struct switch_codec_settings codec_settings;
|
||||
/*! flags to modify behaviour */
|
||||
switch_codec_flag flags;
|
||||
/*! the handle's memory pool*/
|
||||
switch_memory_pool *memory_pool;
|
||||
/*! private data for the codec module to store handle specific info */
|
||||
void *private;
|
||||
};
|
||||
|
||||
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
|
||||
struct switch_codec_implementation {
|
||||
/*! samples transferred per second */
|
||||
int samples_per_second;
|
||||
/*! bits transferred per second */
|
||||
int bits_per_second;
|
||||
/*! number of microseconds that denote one frame */
|
||||
int microseconds_per_frame;
|
||||
/*! number of samples that denote one frame */
|
||||
int samples_per_frame;
|
||||
/*! number of bytes that denote one frame decompressed */
|
||||
int bytes_per_frame;
|
||||
/*! number of bytes that denote one frame compressed */
|
||||
int encoded_bytes_per_frame;
|
||||
/*! number of channels represented */
|
||||
int number_of_channels;
|
||||
/*! number of frames to send in one netowrk packet */
|
||||
int pref_frames_per_packet;
|
||||
/*! max number of frames to send in one network packet */
|
||||
int max_frames_per_packet;
|
||||
/*! function to initialize a codec handle using this implementation */
|
||||
switch_status (*init)(switch_codec *, switch_codec_flag, const switch_codec_settings *codec_settings);
|
||||
/*! function to encode raw data into encoded data */
|
||||
switch_status (*encode)(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *decoded_data,
|
||||
|
@ -236,6 +354,7 @@ struct switch_codec_implementation {
|
|||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag);
|
||||
/*! function to decode encoded data into raw data */
|
||||
switch_status (*decode)(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *encoded_data,
|
||||
|
@ -245,32 +364,48 @@ struct switch_codec_implementation {
|
|||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag);
|
||||
/*! deinitalize a codec handle using this implementation */
|
||||
switch_status (*destroy)(switch_codec *);
|
||||
const struct switch_codec_implementation *next;
|
||||
};
|
||||
|
||||
/*! \brief Top level module interface to implement a series of codec implementations */
|
||||
struct switch_codec_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! enumeration defining the type of the codec */
|
||||
const switch_codec_type codec_type;
|
||||
/*! the IANA code number */
|
||||
int ianacode;
|
||||
/*! the IANA code name */
|
||||
char *iananame;
|
||||
/*! a list of codec implementations related to the codec */
|
||||
const switch_codec_implementation *implementations;
|
||||
const struct switch_codec_interface *next;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief A module interface to implement an application */
|
||||
struct switch_application_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function the application implements */
|
||||
switch_application_function application_function;
|
||||
/*! the long winded description of the application */
|
||||
const char *long_desc;
|
||||
/*! the short and sweet description of the application */
|
||||
const char *short_desc;
|
||||
/*! an example of the application syntax */
|
||||
const char *syntax;
|
||||
const struct switch_application_interface *next;
|
||||
};
|
||||
|
||||
/*! \brief A module interface to implement an api function */
|
||||
struct switch_api_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! a description of the api function */
|
||||
const char *desc;
|
||||
/*! function the api call uses */
|
||||
switch_api_function function;
|
||||
const struct switch_api_interface *next;
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ extern "C" {
|
|||
|
||||
/**
|
||||
* @defgroup switch_thread_mutex Thread Mutex Routines
|
||||
* @ingroup FREESWITCH
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
*/
|
||||
/*! \file switch_resample.h
|
||||
\brief Audio Resample Code
|
||||
|
||||
This module implements a generic interface for doing audio resampling it currently uses libresample but can be ported to
|
||||
any resample library with a little effort. I decided against making this interface pluggable because there are not many
|
||||
options in terms of resample libraries so it seemed like a waste but I did opt to frontend the interface in case a better
|
||||
way comes along some day. =D
|
||||
|
||||
*/
|
||||
|
||||
#ifndef SWITCH_RESAMPLE_H
|
||||
|
@ -40,21 +46,42 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <switch.h>
|
||||
|
||||
/*! \brief An audio resampling handle */
|
||||
struct switch_audio_resampler {
|
||||
/*! a pointer to store the resampler object */
|
||||
void *resampler;
|
||||
/*! the rate to resample from in hz */
|
||||
int from_rate;
|
||||
/*! the rate to resample to in hz */
|
||||
int to_rate;
|
||||
/*! the factor to resample by (from / to) */
|
||||
double factor;
|
||||
/*! a pointer to store a float buffer for data to be resampled */
|
||||
float *from;
|
||||
/*! the size of the from buffer used */
|
||||
int from_len;
|
||||
/*! the total size of the from buffer */
|
||||
size_t from_size;
|
||||
/*! a pointer to store a float buffer for resampled data */
|
||||
float *to;
|
||||
/*! the size of the to buffer used */
|
||||
int to_len;
|
||||
/*! the total size of the to buffer */
|
||||
size_t to_size;
|
||||
};
|
||||
|
||||
#include <switch.h>
|
||||
/*!
|
||||
\brief Prepare a new resampler handle
|
||||
\param new_resampler NULL pointer to aim at the new handle
|
||||
\param from_rate the rate to transfer from in hz
|
||||
\param from_size the size of the buffer to allocate for the from data
|
||||
\param to_rate the rate to transfer to in hz
|
||||
\param to_size the size of the buffer to allocate for the to data
|
||||
\param pool the memory pool to use for buffer allocation
|
||||
\return SWITCH_STATUS_SUCCESS if the handle was created
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
|
||||
int from_rate,
|
||||
size_t from_size,
|
||||
|
@ -62,14 +89,66 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
|||
size_t to_size,
|
||||
switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Destroy an existing resampler handle
|
||||
\param resampler the resampler handle to destroy
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler);
|
||||
|
||||
/*!
|
||||
\brief Resample one float buffer into another using specifications of a given handle
|
||||
\param resampler the resample handle
|
||||
\param src the source data
|
||||
\param srclen the length of the source data
|
||||
\param dst the destination data
|
||||
\param dstlen the length of the destination data
|
||||
\param last parameter denoting the last sample is being resampled
|
||||
\return the used size of dst
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, int dstlen, int last);
|
||||
|
||||
/*!
|
||||
\brief Convert an array of floats to an array of shorts
|
||||
\param f the float buffer
|
||||
\param s the short buffer
|
||||
\param len the length of the buffers
|
||||
\return the size of the converted buffer
|
||||
*/
|
||||
SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len);
|
||||
|
||||
/*!
|
||||
\brief Convert an array of chars to an array of floats
|
||||
\param c the char buffer
|
||||
\param f the float buffer
|
||||
\param len the length of the buffers
|
||||
\return the size of the converted buffer
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len);
|
||||
|
||||
/*!
|
||||
\brief Convert an array of floats to an array of chars
|
||||
\param f an array of floats
|
||||
\param c an array of chars
|
||||
\param len the length of the buffers
|
||||
\return the size of the converted buffer
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len);
|
||||
|
||||
/*!
|
||||
\brief Convert an array of shorts to an array of floats
|
||||
\param s an array of shorts
|
||||
\param f an array of floats
|
||||
\param len the size of the buffers
|
||||
\return the size of the converted buffer
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len);
|
||||
|
||||
/*!
|
||||
\brief Perform a byteswap on a buffer of 16 bit samples
|
||||
\param buf an array of samples
|
||||
\param len the size of the array
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len);
|
||||
SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,11 +41,17 @@ extern "C" {
|
|||
#include <sqlite3.h>
|
||||
|
||||
/**
|
||||
* @defgroup switch_sqlite Database Routines
|
||||
* @defgroup switch_sqlite_top Brought To You By SQLite
|
||||
* @ingroup FREESWITCH
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup switch_sqlite Database Routines
|
||||
* @ingroup switch_sqlite_top
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Each open sqlite database is represented by an instance of the
|
||||
* following opaque structure.
|
||||
|
@ -161,6 +167,7 @@ typedef sqlite3 switch_core_db;
|
|||
#define switch_core_db_vmprintf sqlite3_vmprintf
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -44,11 +44,36 @@ extern "C" {
|
|||
#define SWITCH_GLOBAL_VERSION "1"
|
||||
#define SWITCH_MAX_CODECS 30
|
||||
|
||||
/*!
|
||||
\enum switch_stack_t
|
||||
\brief Expression of how to stack a list
|
||||
<pre>
|
||||
SWITCH_STACK_BOTTOM - Stack on the bottom
|
||||
SWITCH_STACK_TOP - Stack on the top
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_STACK_BOTTOM,
|
||||
SWITCH_STACK_TOP
|
||||
} switch_stack_t;
|
||||
|
||||
/*!
|
||||
\enum switch_status
|
||||
\brief Common return values
|
||||
<pre>
|
||||
SWITCH_STATUS_SUCCESS - General Success (common return value for most functions)
|
||||
SWITCH_STATUS_FALSE - General Falsehood
|
||||
SWITCH_STATUS_TIMEOUT - A Timeout has occured
|
||||
SWITCH_STATUS_RESTART - An indication to restart the previous operation
|
||||
SWITCH_STATUS_TERM - An indication to terminate
|
||||
SWITCH_STATUS_NOTIMPL - An indication that requested resource is not impelemented
|
||||
SWITCH_STATUS_MEMERR - General memory error
|
||||
SWITCH_STATUS_NOOP - NOTHING
|
||||
SWITCH_STATUS_RESAMPLE - An indication that a resample has occured
|
||||
SWITCH_STATUS_GENERR - A general Error
|
||||
SWITCH_STATUS_INUSE - An indication that requested resource is in use
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_STATUS_SUCCESS,
|
||||
SWITCH_STATUS_FALSE,
|
||||
|
@ -63,6 +88,15 @@ typedef enum {
|
|||
SWITCH_STATUS_INUSE
|
||||
} switch_status;
|
||||
|
||||
/*!
|
||||
\enum switch_text_channel
|
||||
\brief A target to write log/debug info to
|
||||
<pre>
|
||||
SWITCH_CHANNEL_ID_CONSOLE - Write to the currently defined console
|
||||
SWITCH_CHANNEL_ID_CONSOLE_CLEAN - Write to the currently defined console with no extra file/line/date information
|
||||
SWITCH_CHANNEL_ID_EVENT - Write to the event engine as a LOG event
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_CHANNEL_ID_CONSOLE,
|
||||
SWITCH_CHANNEL_ID_CONSOLE_CLEAN,
|
||||
|
@ -74,7 +108,19 @@ typedef enum {
|
|||
#define SWITCH_CHANNEL_CONSOLE_CLEAN SWITCH_CHANNEL_ID_CONSOLE_CLEAN, __FILE__, __FUNCTION__, __LINE__
|
||||
#define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __FUNCTION__, __LINE__
|
||||
|
||||
/*! \brief Channel States
|
||||
/*!
|
||||
\enum switch_channel_state
|
||||
\brief Channel States
|
||||
<pre>
|
||||
CS_NEW - Channel is newly created
|
||||
CS_INIT - Channel has been initilized
|
||||
CS_RING - Channel is looking for a dialplan
|
||||
CS_TRANSMIT - Channel is in a passive transmit state
|
||||
CS_EXECUTE - Channel is executing it's dialplan
|
||||
CS_LOOPBACK - Channel is in loopback
|
||||
CS_HANGUP - Channel is flagged for hangup and ready to end
|
||||
CS_DONE - Channel is ready to be destroyed and out of the state machine
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
CS_NEW,
|
||||
|
@ -84,9 +130,22 @@ typedef enum {
|
|||
CS_EXECUTE,
|
||||
CS_LOOPBACK,
|
||||
CS_HANGUP,
|
||||
CS_DONE
|
||||
CS_DONE
|
||||
} switch_channel_state;
|
||||
|
||||
|
||||
/*!
|
||||
\enum switch_channel_flag
|
||||
\brief Channel Flags
|
||||
|
||||
<pre>
|
||||
CF_SEND_AUDIO = (1 << 0) - Channel will send audio
|
||||
CF_RECV_AUDIO = (1 << 1) - Channel will recieve audio
|
||||
CF_ANSWERED = (1 << 2) - Channel is answered
|
||||
CF_OUTBOUND = (1 << 3) - Channel is an outbound channel
|
||||
</pre>
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
CF_SEND_AUDIO = (1 << 0),
|
||||
CF_RECV_AUDIO = (1 << 1),
|
||||
|
@ -94,24 +153,84 @@ typedef enum {
|
|||
CF_OUTBOUND = (1 << 3),
|
||||
} switch_channel_flag;
|
||||
|
||||
|
||||
/*!
|
||||
\enum switch_signal
|
||||
\brief Signals to send to channels
|
||||
<pre>
|
||||
SWITCH_SIG_KILL - Kill the channel
|
||||
</pre>
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
SWITCH_SIG_KILL
|
||||
} switch_signal;
|
||||
|
||||
/*!
|
||||
\enum switch_codec_flag
|
||||
\brief Codec related flags
|
||||
<pre>
|
||||
SWITCH_CODEC_FLAG_ENCODE = (1 << 0) - Codec can encode
|
||||
SWITCH_CODEC_FLAG_DECODE = (1 << 1) - Codec can decode
|
||||
SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2) - Start period of silence
|
||||
SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3) - End period of silence
|
||||
SWITCH_CODEC_FLAG_SILENCE = (1 << 4) - Silence
|
||||
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5) - Free codec's pool on destruction
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_CODEC_FLAG_ENCODE = (1 << 0),
|
||||
SWITCH_CODEC_FLAG_DECODE = (1 << 1),
|
||||
SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2),
|
||||
SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3),
|
||||
SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
|
||||
SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
|
||||
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5),
|
||||
|
||||
} switch_codec_flag;
|
||||
|
||||
/*!
|
||||
\enum switch_codec_type
|
||||
\brief Codec types
|
||||
<pre>
|
||||
SWITCH_CODEC_TYPE_AUDIO - Audio Codec
|
||||
SWITCH_CODEC_TYPE_VIDEO - Video Codec
|
||||
SWITCH_CODEC_TYPE_T38 - T38 Codec
|
||||
SWITCH_CODEC_TYPE_APP - Application Codec
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_CODEC_TYPE_AUDIO,
|
||||
SWITCH_CODEC_TYPE_VIDEO,
|
||||
SWITCH_CODEC_TYPE_T38,
|
||||
SWITCH_CODEC_TYPE_APP
|
||||
} switch_codec_type;
|
||||
|
||||
|
||||
/*!
|
||||
\enum switch_timer_flag
|
||||
\brief Timer related flags
|
||||
<pre>
|
||||
SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0) - Free timer's pool on destruction
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0),
|
||||
} switch_timer_flag;
|
||||
|
||||
/*!
|
||||
\enum switch_file_flag
|
||||
\brief File flags
|
||||
<pre>
|
||||
SWITCH_FILE_FLAG_READ = (1 << 0) - Open for read
|
||||
SWITCH_FILE_FLAG_WRITE = (1 << 1) - Open for write
|
||||
SWITCH_FILE_FLAG_FREE_POOL = (1 << 2) - Free file handle's pool on destruction
|
||||
SWITCH_FILE_DATA_SHORT = (1 << 3) - Read data in shorts
|
||||
SWITCH_FILE_DATA_INT = (1 << 4) - Read data in ints
|
||||
SWITCH_FILE_DATA_FLOAT = (1 << 5) - Read data in floats
|
||||
SWITCH_FILE_DATA_DOUBLE = (1 << 6) - Read data in doubles
|
||||
SWITCH_FILE_DATA_RAW = (1 << 7) - Read data asis
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_FILE_FLAG_READ = (1 << 0),
|
||||
SWITCH_FILE_FLAG_WRITE = (1 << 1),
|
||||
|
@ -123,13 +242,6 @@ typedef enum {
|
|||
SWITCH_FILE_DATA_RAW = (1 << 7),
|
||||
} switch_file_flag;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_CODEC_TYPE_AUDIO,
|
||||
SWITCH_CODEC_TYPE_VIDEO,
|
||||
SWITCH_CODEC_TYPE_T38,
|
||||
SWITCH_CODEC_TYPE_APP
|
||||
} switch_codec_type;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_IO_FLAG_NOOP = 0,
|
||||
} switch_io_flag;
|
||||
|
@ -137,16 +249,34 @@ typedef enum {
|
|||
/* make sure this is synced with the EVENT_NAMES array in switch_event.c
|
||||
also never put any new ones before EVENT_ALL
|
||||
*/
|
||||
/*!
|
||||
\enum switch_event_t
|
||||
\brief Built-in Events
|
||||
|
||||
<pre>
|
||||
SWITCH_EVENT_CUSTOM - A custom event
|
||||
SWITCH_EVENT_CHANNEL_STATE - A channel has changed state
|
||||
SWITCH_EVENT_CHANNEL_ANSWER - A channel has been answered
|
||||
SWITCH_EVENT_CHANNEL_HANGUP - A channel has been hungup
|
||||
SWITCH_EVENT_API - An API call has been executed
|
||||
SWITCH_EVENT_LOG - A LOG event has been triggered
|
||||
SWITCH_EVENT_INBOUND_CHAN - A new inbound channel has been created
|
||||
SWITCH_EVENT_OUTBOUND_CHAN - A new outbound channel has been created
|
||||
SWITCH_EVENT_STARTUP - The system has been started
|
||||
SWITCH_EVENT_SHUTDOWN - The system has been shutdown
|
||||
SWITCH_EVENT_ALL - All events at once
|
||||
</pre>
|
||||
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_EVENT_CUSTOM,
|
||||
SWITCH_EVENT_CHANNEL_STATE,
|
||||
SWITCH_EVENT_CHANNEL_ANSWER,
|
||||
SWITCH_EVENT_CHANNEL_HANGUP,
|
||||
SWITCH_EVENT_API,
|
||||
SWITCH_EVENT_LOG,
|
||||
SWITCH_EVENT_INBOUND_CHAN,
|
||||
SWITCH_EVENT_OUTBOUND_CHAN,
|
||||
SWITCH_EVENT_ANSWER_CHAN,
|
||||
SWITCH_EVENT_HANGUP_CHAN,
|
||||
SWITCH_EVENT_STARTUP,
|
||||
SWITCH_EVENT_SHUTDOWN,
|
||||
SWITCH_EVENT_ALL
|
||||
|
@ -192,6 +322,7 @@ typedef struct switch_io_routines switch_io_routines;
|
|||
typedef struct switch_io_event_hooks switch_io_event_hooks;
|
||||
typedef struct switch_buffer switch_buffer;
|
||||
typedef struct switch_codec_settings switch_codec_settings;
|
||||
typedef struct switch_config switch_config;
|
||||
typedef void (*switch_application_function)(switch_core_session *, char *);
|
||||
typedef void (*switch_event_callback_t)(switch_event *);
|
||||
typedef switch_caller_extension *(*switch_dialplan_hunt_function)(switch_core_session *);
|
||||
|
@ -207,7 +338,10 @@ typedef switch_status (*switch_send_dtmf_hook)(switch_core_session *, char *);
|
|||
typedef switch_status (*switch_api_function)(char *in, char *out, size_t outlen);
|
||||
|
||||
/* things we don't deserve to know about */
|
||||
|
||||
/*! \brief A channel */
|
||||
struct switch_channel;
|
||||
/*! \brief A core session representing a call and all of it's resources */
|
||||
struct switch_core_session;
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
*/
|
||||
/*! \file switch_utils.h
|
||||
\brief Compatability and Helper Code
|
||||
|
||||
Just a miscelaneaous set of general utility/helper functions.
|
||||
|
||||
*/
|
||||
#ifndef SWITCH_UTILS_H
|
||||
#define SWITCH_UTILS_H
|
||||
|
@ -59,21 +62,98 @@ typedef typeof(tv.tv_usec) switch_suseconds_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief Duplicate a string
|
||||
*/
|
||||
#define switch_copy_string apr_cpystrn
|
||||
|
||||
/*!
|
||||
\brief Test for the existance of a flag on an arbitary object
|
||||
\param obj the object to test
|
||||
\param flag the or'd list of flags to test
|
||||
\return true value if the object has the flags defined
|
||||
*/
|
||||
#define switch_test_flag(obj, flag) ((obj)->flags & flag)
|
||||
|
||||
/*!
|
||||
\brief Set a flag on an arbitrary object
|
||||
\param obj the object to set the flags on
|
||||
\param flag the or'd list of flags to set
|
||||
*/
|
||||
#define switch_set_flag(obj, flag) (obj)->flags |= (flag)
|
||||
|
||||
/*!
|
||||
\brief Clear a flag on an arbitrary object
|
||||
\param obj the object to test
|
||||
\param flag the or'd list of flags to clear
|
||||
*/
|
||||
#define switch_clear_flag(obj, flag) (obj)->flags &= ~(flag)
|
||||
|
||||
/*!
|
||||
\brief Copy flags from one arbitrary object to another
|
||||
\param dest the object to copy the flags to
|
||||
\param src the object to copy the flags from
|
||||
\param flags the flags to copy
|
||||
*/
|
||||
#define switch_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags))
|
||||
|
||||
/*!
|
||||
\brief Test for NULL or zero length string
|
||||
\param s the string to test
|
||||
\return true value if the string is NULL or zero length
|
||||
*/
|
||||
#define switch_strlen_zero(s) (s && *s != '\0') ? 0 : 1
|
||||
|
||||
/*!
|
||||
\brief Wait a desired number of microseconds and yield the CPU
|
||||
*/
|
||||
#define switch_yield(ms) apr_sleep(ms * 10); apr_thread_yield();
|
||||
|
||||
/*!
|
||||
\brief Declares a function designed to set a dymaic global string
|
||||
\param fname the function name to declare
|
||||
\param vname the name of the global pointer to modify with the new function
|
||||
*/
|
||||
#define SWITCH_DECLARE_GLOBAL_STRING_FUNC(fname, vname) static void fname(char *string) { if (vname) {free(vname); vname = NULL;}vname = strdup(string);}
|
||||
|
||||
/*!
|
||||
\brief Separate a string into an array based on a character delimeter
|
||||
\param buf the string to parse
|
||||
\param delim the character delimeter
|
||||
\param array the array to split the values into
|
||||
\param arraylen the max number of elements in the array
|
||||
\return the number of elements added to the array
|
||||
*/
|
||||
SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen);
|
||||
|
||||
/*!
|
||||
\brief Create a set of file descriptors to poll
|
||||
\param poll the polfd to create
|
||||
\param sock the socket to add
|
||||
\param flags the flags to modify the behaviour
|
||||
\param pool the memory pool to use
|
||||
\return SWITCH_STATUS_SUCCESS when successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool);
|
||||
|
||||
/*!
|
||||
\brief Wait for a socket
|
||||
\param poll the pollfd to wait on
|
||||
\param ms the number of milliseconds to wait
|
||||
\return the requested condition
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
|
||||
|
||||
/*!
|
||||
\brief Create a pointer to the file name in a given file path eliminating the directory name
|
||||
\return the pointer to the next character after the final / or \\ characters
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_cut_path(char *in);
|
||||
|
||||
|
||||
|
||||
/* stuff below will probably be tossed soon */
|
||||
|
||||
#if !defined(switch_strdupa) && defined(__GNUC__)
|
||||
# define switch_strdupa(s) \
|
||||
(__extension__ \
|
||||
|
|
|
@ -252,7 +252,7 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
sdp_message_m_media_add(tech_pvt->local_sdp, "audio", port, NULL, "RTP/AVP");
|
||||
/* Add in every codec we support on this outbound call */
|
||||
if ((num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
|
@ -823,7 +823,7 @@ static switch_status exosip_create_call(eXosip_event_t *event)
|
|||
osip_rfc3264_init(&tech_pvt->sdp_config);
|
||||
/* Add in what codecs we support locally */
|
||||
|
||||
if ((num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
|
|||
int x;
|
||||
|
||||
if (globals.codec_string) {
|
||||
if (!(num_codecs = loadable_module_get_codecs_sorted(switch_core_session_get_pool(tech_pvt->session),
|
||||
if (!(num_codecs = switch_loadable_module_get_codecs_sorted(switch_core_session_get_pool(tech_pvt->session),
|
||||
codecs,
|
||||
SWITCH_MAX_CODECS,
|
||||
globals.codec_order,
|
||||
|
@ -181,7 +181,7 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
} else if (!(num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS)) > 0) {
|
||||
} else if (!(num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS)) > 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Clean up modules.\n");
|
||||
loadable_module_shutdown();
|
||||
switch_loadable_module_shutdown();
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Tearing down environment.\n");
|
||||
switch_core_destroy();
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Exiting Now.\n");
|
||||
|
|
|
@ -383,7 +383,7 @@ default:
|
|||
if (ok) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||
channel->state = state;
|
||||
pbx_core_session_signal_state_change(channel->session);
|
||||
switch_core_session_signal_state_change(channel->session);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||
|
||||
|
@ -509,7 +509,7 @@ SWITCH_DECLARE(switch_status) switch_channel_hangup(switch_channel *channel)
|
|||
assert(channel != NULL);
|
||||
if (channel->state < CS_HANGUP) {
|
||||
channel->state = CS_HANGUP;
|
||||
pbx_core_session_signal_state_change(channel->session);
|
||||
switch_core_session_signal_state_change(channel->session);
|
||||
}
|
||||
return channel->state;
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
|||
|
||||
memset(codec, 0, sizeof(*codec));
|
||||
|
||||
if (!(codec_interface = loadable_module_get_codec_interface(codec_name))) {
|
||||
if (!(codec_interface = switch_loadable_module_get_codec_interface(codec_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "invalid codec %s!\n", codec_name);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char
|
|||
}
|
||||
ext++;
|
||||
|
||||
if (!(fh->file_interface = loadable_module_get_file_interface(ext))) {
|
||||
if (!(fh->file_interface = switch_loadable_module_get_file_interface(ext))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "invalid file format [%s]!\n", ext);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *
|
|||
switch_timer_interface *timer_interface;
|
||||
switch_status status;
|
||||
memset(timer, 0, sizeof(*timer));
|
||||
if (!(timer_interface = loadable_module_get_timer_interface(timer_name))) {
|
||||
if (!(timer_interface = switch_loadable_module_get_timer_interface(timer_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "invalid timer %s!\n", timer_name);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_s
|
|||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
const switch_endpoint_interface *endpoint_interface;
|
||||
|
||||
if (!(endpoint_interface = loadable_module_get_endpoint_interface(endpoint_name))) {
|
||||
if (!(endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not locate channel type %s\n", endpoint_name);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
@ -1315,7 +1315,7 @@ static void switch_core_standard_on_ring(switch_core_session *session)
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't get profile!\n");
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
} else {
|
||||
if (!(dialplan_interface = loadable_module_get_dialplan_interface(caller_profile->dialplan))) {
|
||||
if (!(dialplan_interface = switch_loadable_module_get_dialplan_interface(caller_profile->dialplan))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't get dialplan [%s]!\n", caller_profile->dialplan);
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
} else {
|
||||
|
@ -1342,7 +1342,7 @@ static void switch_core_standard_on_execute(switch_core_session *session)
|
|||
while (switch_channel_get_state(session->channel) == CS_EXECUTE && extension->current_application) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Execute %s(%s)\n", extension->current_application->application_name,
|
||||
extension->current_application->application_data);
|
||||
if (!(application_interface = loadable_module_get_application_interface(extension->current_application->application_name))) {
|
||||
if (!(application_interface = switch_loadable_module_get_application_interface(extension->current_application->application_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Application %s\n", extension->current_application->application_name);
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
return;
|
||||
|
@ -1381,7 +1381,7 @@ static void switch_core_standard_on_transmit(switch_core_session *session)
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session)
|
||||
SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session *session)
|
||||
{
|
||||
switch_thread_cond_signal(session->cond);
|
||||
}
|
||||
|
@ -1756,7 +1756,7 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request_by_name(char *
|
|||
{
|
||||
const switch_endpoint_interface *endpoint_interface;
|
||||
|
||||
if (!(endpoint_interface = loadable_module_get_endpoint_interface(endpoint_name))) {
|
||||
if (!(endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not locate channel type %s\n", endpoint_name);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -90,12 +90,11 @@ static char *EVENT_NAMES[] = {
|
|||
"CUSTOM",
|
||||
"CHANNEL_STATE",
|
||||
"CHANNEL_ANSWER",
|
||||
"CHANNEL_HANGUP",
|
||||
"API",
|
||||
"LOG",
|
||||
"INBOUND_CHAN",
|
||||
"OUTBOUND_CHAN",
|
||||
"ANSWER_CHAN",
|
||||
"HANGUP_CHAN",
|
||||
"STARTUP",
|
||||
"SHUTDOWN",
|
||||
"ALL"
|
||||
|
|
|
@ -342,7 +342,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) loadable_module_shutdown(void)
|
||||
SWITCH_DECLARE(void) switch_loadable_module_shutdown(void)
|
||||
{
|
||||
switch_hash_index_t* hi;
|
||||
void *val;
|
||||
|
@ -362,42 +362,42 @@ SWITCH_DECLARE(void) loadable_module_shutdown(void)
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_endpoint_interface *) loadable_module_get_endpoint_interface(char *name)
|
||||
SWITCH_DECLARE(switch_endpoint_interface *) switch_loadable_module_get_endpoint_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.endpoint_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_codec_interface *) loadable_module_get_codec_interface(char *name)
|
||||
SWITCH_DECLARE(switch_codec_interface *) switch_loadable_module_get_codec_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.codec_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_dialplan_interface *) loadable_module_get_dialplan_interface(char *name)
|
||||
SWITCH_DECLARE(switch_dialplan_interface *) switch_loadable_module_get_dialplan_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.dialplan_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_timer_interface *) loadable_module_get_timer_interface(char *name)
|
||||
SWITCH_DECLARE(switch_timer_interface *) switch_loadable_module_get_timer_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.timer_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_application_interface *) loadable_module_get_application_interface(char *name)
|
||||
SWITCH_DECLARE(switch_application_interface *) switch_loadable_module_get_application_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.application_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_api_interface *) loadable_module_get_api_interface(char *name)
|
||||
SWITCH_DECLARE(switch_api_interface *) switch_loadable_module_get_api_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.api_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_file_interface *) loadable_module_get_file_interface(char *name)
|
||||
SWITCH_DECLARE(switch_file_interface *) switch_loadable_module_get_file_interface(char *name)
|
||||
{
|
||||
return switch_core_hash_find(loadable_modules.file_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen)
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen)
|
||||
{
|
||||
switch_hash_index_t* hi;
|
||||
void *val;
|
||||
|
@ -415,13 +415,13 @@ SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen)
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen)
|
||||
{
|
||||
int x, i = 0;
|
||||
switch_codec_interface *codec_interface;
|
||||
|
||||
for(x = 0; x < preflen; x++) {
|
||||
if ((codec_interface = loadable_module_get_codec_interface(prefs[x]))) {
|
||||
if ((codec_interface = switch_loadable_module_get_codec_interface(prefs[x]))) {
|
||||
array[i++] = codec_interface;
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ SWITCH_DECLARE(switch_status) switch_api_execute(char *cmd, char *arg, char *ret
|
|||
switch_status status;
|
||||
switch_event *event;
|
||||
|
||||
if ((api = loadable_module_get_api_interface(cmd))) {
|
||||
if ((api = switch_loadable_module_get_api_interface(cmd))) {
|
||||
status = api->function(arg, retbuf, len);
|
||||
} else {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
|
|
Loading…
Reference in New Issue