提交 a4d3a30a authored 作者: Anthony Minessale's avatar Anthony Minessale

what's up doc

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@280 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 8a292bf0
......@@ -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);
SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
/*!
\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);
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);
/*!
\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);
///\}
#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,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
}
......
......@@ -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;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论