mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
freetdm: initial changes to make FreeTDM APIs non-blocking
This commit is contained in:
@@ -349,11 +349,13 @@ typedef enum {
|
||||
FTDM_SIGEVENT_FACILITY, /*!< In call facility event */
|
||||
FTDM_SIGEVENT_TRACE, /*!<Interpreted trace event */
|
||||
FTDM_SIGEVENT_TRACE_RAW, /*!<Raw trace event */
|
||||
FTDM_SIGEVENT_INDICATION_COMPLETED, /*!< Last requested indication was completed */
|
||||
FTDM_SIGEVENT_INVALID, /*!<Invalid */
|
||||
} ftdm_signal_event_t;
|
||||
#define SIGNAL_STRINGS "START", "STOP", "RELEASED", "UP", "FLASH", "PROCEED", "RINGING", "PROGRESS", \
|
||||
"PROGRESS_MEDIA", "ALARM_TRAP", "ALARM_CLEAR", \
|
||||
"COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "FACILITY", "TRACE", "TRACE_RAW", "INVALID"
|
||||
"COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "FACILITY", \
|
||||
"TRACE", "TRACE_RAW", "INDICATION_COMPLETED", "INVALID"
|
||||
|
||||
/*! \brief Move from string to ftdm_signal_event_t and viceversa */
|
||||
FTDM_STR2ENUM_P(ftdm_str2ftdm_signal_event, ftdm_signal_event2str, ftdm_signal_event_t)
|
||||
@@ -434,6 +436,31 @@ typedef struct {
|
||||
char digits[FTDM_DIGITS_LIMIT];
|
||||
} ftdm_event_collected_t;
|
||||
|
||||
/*! \brief FreeTDM supported indications.
|
||||
* This is used during incoming calls when you want to request the signaling stack
|
||||
* to notify about indications occurring locally. See ftdm_channel_call_indicate for more info */
|
||||
typedef enum {
|
||||
FTDM_CHANNEL_INDICATE_RINGING,
|
||||
FTDM_CHANNEL_INDICATE_PROCEED,
|
||||
FTDM_CHANNEL_INDICATE_PROGRESS,
|
||||
FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA,
|
||||
FTDM_CHANNEL_INDICATE_BUSY,
|
||||
/* Using this indication is equivalent to call ftdm_channel_call_answer API */
|
||||
FTDM_CHANNEL_INDICATE_ANSWER,
|
||||
FTDM_CHANNEL_INDICATE_INVALID,
|
||||
} ftdm_channel_indication_t;
|
||||
#define INDICATION_STRINGS "RINGING", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "BUSY", "ANSWER", "INVALID"
|
||||
|
||||
/*! \brief Move from string to ftdm_channel_indication_t and viceversa */
|
||||
FTDM_STR2ENUM_P(ftdm_str2channel_indication, ftdm_channel_indication2str, ftdm_channel_indication_t)
|
||||
|
||||
typedef struct {
|
||||
/* The indication that was completed */
|
||||
ftdm_channel_indication_t indication;
|
||||
/* Completion status of the indication */
|
||||
ftdm_status_t status;
|
||||
} ftdm_event_indication_completed_t;
|
||||
|
||||
/*! \brief Generic signaling message */
|
||||
struct ftdm_sigmsg {
|
||||
ftdm_signal_event_t event_id; /*!< The type of message */
|
||||
@@ -444,7 +471,8 @@ struct ftdm_sigmsg {
|
||||
union {
|
||||
ftdm_event_sigstatus_t sigstatus; /*!< valid if event_id is FTDM_SIGEVENT_SIGSTATUS_CHANGED */
|
||||
ftdm_event_trace_t logevent; /*!< valid if event_id is FTDM_SIGEVENT_TRACE or FTDM_SIGEVENT_TRACE_RAW */
|
||||
ftdm_event_collected_t collected; /*!< valif if event_id is FTDM_SIGEVENT_COLLECTED_DIGIT */
|
||||
ftdm_event_collected_t collected; /*!< valid if event_id is FTDM_SIGEVENT_COLLECTED_DIGIT */
|
||||
ftdm_event_indication_completed_t indication_completed; /*!< valid if the event_id is FTDM_SIGEVENT_INDICATION_COMPLETED */
|
||||
} ev_data;
|
||||
struct {
|
||||
uint8_t autofree; /*!< Whether the freetdm core will free it after message delivery */
|
||||
@@ -708,17 +736,6 @@ typedef enum {
|
||||
FTDM_CODEC_NONE = (1 << 30)
|
||||
} ftdm_codec_t;
|
||||
|
||||
/*! \brief FreeTDM supported indications.
|
||||
* This is used during incoming calls when you want to request the signaling stack
|
||||
* to notify about indications occurring locally */
|
||||
typedef enum {
|
||||
FTDM_CHANNEL_INDICATE_RINGING,
|
||||
FTDM_CHANNEL_INDICATE_PROCEED,
|
||||
FTDM_CHANNEL_INDICATE_PROGRESS,
|
||||
FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA,
|
||||
FTDM_CHANNEL_INDICATE_BUSY,
|
||||
} ftdm_channel_indication_t;
|
||||
|
||||
/*! \brief FreeTDM supported hardware alarms. */
|
||||
typedef enum {
|
||||
FTDM_ALARM_NONE = 0,
|
||||
@@ -741,7 +758,12 @@ FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *ha
|
||||
*/
|
||||
FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*! \brief Answer call */
|
||||
/*! \brief Answer call. This can also be accomplished by ftdm_channel_call_indicate with FTDM_CHANNEL_INDICATE_ANSWER, in both
|
||||
* cases you will get a FTDM_SIGEVENT_INDICATION_COMPLETED when the indication is sent (or an error occurs)
|
||||
* \note Although this API will result in FTDM_SIGEVENT_INDICATION_COMPLETED event being delivered,
|
||||
* there is no guarantee of whether the event will arrive after or before your execution thread returns
|
||||
* from ftdm_channel_call_answer
|
||||
*/
|
||||
#define ftdm_channel_call_answer(ftdmchan) _ftdm_channel_call_answer(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
|
||||
/*! \brief Answer call recording the source code point where the it was called (see ftdm_channel_call_answer for an easy to use macro) */
|
||||
@@ -753,7 +775,13 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char
|
||||
/*! \brief Place an outgoing call recording the source code point where it was called (see ftdm_channel_call_place for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*! \brief Indicate a new condition in an incoming call */
|
||||
/*! \brief Indicate a new condition in an incoming call
|
||||
* \note Every indication request will result in FTDM_SIGEVENT_INDICATION_COMPLETED event being delivered with
|
||||
* the proper status that will inform you if the request was successful or not.
|
||||
* Be aware there is no guarantee of whether the event will arrive after or before your execution thread returns
|
||||
* from ftdm_channel_call_indicate. This means you could get FTDM_SIGEVENT_INDICATION_COMPLETED even before
|
||||
* your execution thread returns from the ftdm_channel_call_indicate() API
|
||||
*/
|
||||
#define ftdm_channel_call_indicate(ftdmchan, indication) _ftdm_channel_call_indicate(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (indication))
|
||||
|
||||
/*! \brief Indicate a new condition in an incoming call recording the source code point where it was called (see ftdm_channel_call_indicate for an easy to use macro) */
|
||||
@@ -1494,9 +1522,14 @@ FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *c
|
||||
*/
|
||||
FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *channel);
|
||||
|
||||
/*! \brief Initialize channel state for an outgoing call */
|
||||
/*! \brief Initialize channel state for an outgoing call
|
||||
* \note This API will eventually be deprecated, is only needed if you use boost signaling
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_init(ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*! \brief Enable/disable blocking mode in the channels for this span */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_set_blocking_mode(const ftdm_span_t *span, ftdm_bool_t enabled);
|
||||
|
||||
/*! \brief Initialize the library */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_global_init(void);
|
||||
|
||||
|
@@ -183,7 +183,15 @@ typedef enum {
|
||||
FTDM_TIMEOUT, /*!< Operation timed out (ie: polling on a device)*/
|
||||
FTDM_NOTIMPL, /*!< Operation not implemented */
|
||||
FTDM_BREAK, /*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */
|
||||
FTDM_EINVAL /*!< Invalid argument */
|
||||
|
||||
/*!< Any new return codes should try to mimc unix style error codes, no need to reinvent */
|
||||
/* Remapping some of the codes that were before */
|
||||
FTDM_ENOMEM = FTDM_MEMERR, /*!< Memory error */
|
||||
FTDM_ETIMEDOUT = FTDM_TIMEOUT, /*!< Operation timedout */
|
||||
FTDM_ENOSYS = FTDM_NOTIMPL, /*!< The function is not implemented */
|
||||
|
||||
FTDM_EINVAL, /*!< Invalid argument */
|
||||
FTDM_ECANCELED, /*!< Operation cancelled */
|
||||
} ftdm_status_t;
|
||||
|
||||
/*! \brief FreeTDM bool type. */
|
||||
|
@@ -606,6 +606,7 @@ FT_DECLARE(int) ftdm_vasprintf(char **ret, const char *fmt, va_list ap);
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_close_all(void);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(void) ftdm_ack_indication(const ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_status_t status);
|
||||
|
||||
/*!
|
||||
* \brief Retrieves an event from the span
|
||||
|
@@ -260,9 +260,16 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channe
|
||||
#define FTDM_CHANNEL_OUTBOUND (1ULL << 18)
|
||||
#define FTDM_CHANNEL_SUSPENDED (1ULL << 19)
|
||||
#define FTDM_CHANNEL_3WAY (1ULL << 20)
|
||||
|
||||
/* this 3 flags are really nonsense used by boost module only, as soon
|
||||
* as we deprecate/delete boost module we can get rid of them
|
||||
* ==================
|
||||
* */
|
||||
#define FTDM_CHANNEL_PROGRESS (1ULL << 21)
|
||||
#define FTDM_CHANNEL_MEDIA (1ULL << 22)
|
||||
#define FTDM_CHANNEL_ANSWERED (1ULL << 23)
|
||||
/* ================== */
|
||||
|
||||
#define FTDM_CHANNEL_MUTE (1ULL << 24)
|
||||
#define FTDM_CHANNEL_USE_RX_GAIN (1ULL << 25)
|
||||
#define FTDM_CHANNEL_USE_TX_GAIN (1ULL << 26)
|
||||
@@ -273,6 +280,8 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channe
|
||||
#define FTDM_CHANNEL_TX_DISABLED (1ULL << 31)
|
||||
/*!< The user knows about a call in this channel */
|
||||
#define FTDM_CHANNEL_CALL_STARTED (1ULL << 32)
|
||||
/*!< The user wants non-blocking operations in the channel */
|
||||
#define FTDM_CHANNEL_NONBLOCK (1ULL << 33)
|
||||
|
||||
typedef enum {
|
||||
ZSM_NONE,
|
||||
|
Reference in New Issue
Block a user