freetdm: more cleanup, remove unused callbacks
This commit is contained in:
parent
ff960d7862
commit
ec4e2c5a45
|
@ -846,15 +846,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_find(uint32_t id, ftdm_span_t **span)
|
|||
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_set_event_callback(ftdm_span_t *span, fio_event_cb_t event_callback)
|
||||
{
|
||||
ftdm_mutex_lock(span->mutex);
|
||||
span->event_callback = event_callback;
|
||||
ftdm_mutex_unlock(span->mutex);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms)
|
||||
{
|
||||
assert(span->fio != NULL);
|
||||
|
@ -941,15 +932,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_send_fsk_data(ftdm_channel_t *ftdmchan, f
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_set_event_callback(ftdm_channel_t *ftdmchan, fio_event_cb_t event_callback)
|
||||
{
|
||||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
ftdmchan->event_callback = event_callback;
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_clear_token(ftdm_channel_t *ftdmchan, const char *token)
|
||||
{
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
|
@ -1555,7 +1537,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc
|
|||
static ftdm_status_t ftdm_channel_reset(ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_OPEN);
|
||||
ftdmchan->event_callback = NULL;
|
||||
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_DTMF_DETECT);
|
||||
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUPRESS_DTMF);
|
||||
ftdm_channel_done(ftdmchan);
|
||||
|
@ -2720,7 +2701,7 @@ FT_DECLARE(ftdm_size_t) ftdm_channel_dequeue_dtmf(ftdm_channel_t *ftdmchan, char
|
|||
assert(ftdmchan != NULL);
|
||||
|
||||
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_READY)) {
|
||||
return FTDM_FAIL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ftdmchan->digit_buffer && ftdm_buffer_inuse(ftdmchan->digit_buffer)) {
|
||||
|
@ -3080,27 +3061,11 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
|
|||
teletone_dtmf_get(&ftdmchan->dtmf_detect, digit_str, sizeof(digit_str));
|
||||
|
||||
if(*digit_str) {
|
||||
fio_event_cb_t event_callback = NULL;
|
||||
|
||||
if (ftdmchan->state == FTDM_CHANNEL_STATE_CALLWAITING && (*digit_str == 'D' || *digit_str == 'A')) {
|
||||
ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK]++;
|
||||
} else {
|
||||
ftdm_channel_queue_dtmf(ftdmchan, digit_str);
|
||||
|
||||
if (ftdmchan->span->event_callback) {
|
||||
event_callback = ftdmchan->span->event_callback;
|
||||
} else if (ftdmchan->event_callback) {
|
||||
event_callback = ftdmchan->event_callback;
|
||||
}
|
||||
|
||||
if (event_callback) {
|
||||
ftdmchan->event_header.channel = ftdmchan;
|
||||
ftdmchan->event_header.e_type = FTDM_EVENT_DTMF;
|
||||
ftdmchan->event_header.data = digit_str;
|
||||
event_callback(ftdmchan, &ftdmchan->event_header);
|
||||
ftdmchan->event_header.e_type = FTDM_EVENT_NONE;
|
||||
ftdmchan->event_header.data = NULL;
|
||||
}
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUPRESS_DTMF)) {
|
||||
ftdmchan->skip_read_frames = 20;
|
||||
}
|
||||
|
|
|
@ -161,22 +161,6 @@ typedef enum {
|
|||
FTDM_BOTTOM_UP
|
||||
} ftdm_direction_t;
|
||||
|
||||
/*! \brief Event types */
|
||||
typedef enum {
|
||||
FTDM_EVENT_NONE,
|
||||
FTDM_EVENT_DTMF,
|
||||
FTDM_EVENT_OOB,
|
||||
FTDM_EVENT_COUNT
|
||||
} ftdm_event_type_t;
|
||||
|
||||
/*! \brief Generic event data type */
|
||||
struct ftdm_event {
|
||||
ftdm_event_type_t e_type;
|
||||
uint32_t enum_id;
|
||||
ftdm_channel_t *channel;
|
||||
void *data;
|
||||
};
|
||||
|
||||
/*! \brief I/O channel type */
|
||||
typedef enum {
|
||||
FTDM_CHAN_TYPE_B, /*!< Bearer channel */
|
||||
|
@ -787,13 +771,13 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_get_alarms(ftdm_channel_t *ftdmchan, ftdm
|
|||
FT_DECLARE(ftdm_chan_type_t) ftdm_channel_get_type(const ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*!
|
||||
* \brief Get the channel type
|
||||
* \brief Dequeue DTMF from the given channel
|
||||
*
|
||||
* \param ftdmchan The channel to get the type from
|
||||
* \param ftdmchan The channel to dequeue DTMF from
|
||||
* \param dtmf DTMF buffer to store the dtmf (you are responsible for its allocation and deallocation)
|
||||
* \param len The size of the DTMF buffer
|
||||
* \param len The size of the provided DTMF buffer
|
||||
*
|
||||
* \retval channel type (FXO, FXS, B-channel, D-channel, etc)
|
||||
* \retval The size of the dequeued DTMF (it might be zero if there is no DTMF in the queue)
|
||||
*/
|
||||
FT_DECLARE(ftdm_size_t) ftdm_channel_dequeue_dtmf(ftdm_channel_t *ftdmchan, char *dtmf, ftdm_size_t len);
|
||||
|
||||
|
@ -827,24 +811,6 @@ FT_DECLARE(void) ftdm_channel_flush_dtmf(ftdm_channel_t *ftdmchan);
|
|||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms);
|
||||
|
||||
/*!
|
||||
* \brief Retrieves an event from the span
|
||||
*
|
||||
* \note
|
||||
* This function is non-reentrant and not thread-safe.
|
||||
* The event returned may be modified if the function is called again
|
||||
* from a different thread or even the same. It is recommended to
|
||||
* handle events from the same span in a single thread.
|
||||
*
|
||||
* \param span The span to retrieve the event from
|
||||
* \param event Pointer to store the pointer to the event
|
||||
*
|
||||
* \retval FTDM_SUCCESS success (at least one event available)
|
||||
* \retval FTDM_TIMEOUT Timed out waiting for events
|
||||
* \retval FTDM_FAIL failure
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_next_event(ftdm_span_t *span, ftdm_event_t **event);
|
||||
|
||||
/*!
|
||||
* \brief Find a span by its id
|
||||
*
|
||||
|
@ -894,9 +860,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_create(const char *iotype, const char *name,
|
|||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_add_channel(ftdm_span_t *span, ftdm_socket_t sockfd, ftdm_chan_type_t type, ftdm_channel_t **chan);
|
||||
|
||||
/*! \brief Set an event callback for the span */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_set_event_callback(ftdm_span_t *span, fio_event_cb_t event_callback);
|
||||
|
||||
/*! \brief Add the channel to a hunt group */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_add_to_group(const char* name, ftdm_channel_t* ftdmchan);
|
||||
|
||||
|
@ -912,9 +875,6 @@ FT_DECLARE(ftdm_status_t) ftdm_group_find_by_name(const char *name, ftdm_group_t
|
|||
/*! \brief Create a group with the given name */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_group_create(ftdm_group_t **group, const char *name);
|
||||
|
||||
/*! \brief Set the event callback for the channel */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_set_event_callback(ftdm_channel_t *ftdmchan, fio_event_cb_t event_callback);
|
||||
|
||||
/*! \brief Get the number of channels in use on a span */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_channel_use_count(ftdm_span_t *span, uint32_t *count);
|
||||
|
||||
|
|
|
@ -527,6 +527,26 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan);
|
|||
FT_DECLARE(ftdm_status_t) ftdm_span_close_all(void);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*!
|
||||
* \brief Retrieves an event from the span
|
||||
*
|
||||
* \note
|
||||
* This function is non-reentrant and not thread-safe.
|
||||
* The event returned may be modified if the function is called again
|
||||
* from a different thread or even the same. It is recommended to
|
||||
* handle events from the same span in a single thread.
|
||||
* WARNING: this function used to be public ( in freetdm.h )
|
||||
* but since is really of no use to users better keep it here
|
||||
*
|
||||
* \param span The span to retrieve the event from
|
||||
* \param event Pointer to store the pointer to the event
|
||||
*
|
||||
* \retval FTDM_SUCCESS success (at least one event available)
|
||||
* \retval FTDM_TIMEOUT Timed out waiting for events
|
||||
* \retval FTDM_FAIL failure
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_next_event(ftdm_span_t *span, ftdm_event_t **event);
|
||||
|
||||
/*!
|
||||
\brief Assert condition
|
||||
*/
|
||||
|
|
|
@ -137,6 +137,24 @@ typedef enum {
|
|||
#define OOB_STRINGS "ONHOOK", "OFFHOOK", "WINK", "FLASH", "RING_START", "RING_STOP", "ALARM_TRAP", "ALARM_CLEAR", "NOOP", "CAS_BITS_CHANGE", "INVALID"
|
||||
FTDM_STR2ENUM_P(ftdm_str2ftdm_oob_event, ftdm_oob_event2str, ftdm_oob_event_t)
|
||||
|
||||
/*! \brief Event types */
|
||||
typedef enum {
|
||||
FTDM_EVENT_NONE,
|
||||
/* DTMF digit was just detected */
|
||||
FTDM_EVENT_DTMF,
|
||||
/* Out of band event */
|
||||
FTDM_EVENT_OOB,
|
||||
FTDM_EVENT_COUNT
|
||||
} ftdm_event_type_t;
|
||||
|
||||
/*! \brief Generic event data type */
|
||||
struct ftdm_event {
|
||||
ftdm_event_type_t e_type;
|
||||
uint32_t enum_id;
|
||||
ftdm_channel_t *channel;
|
||||
void *data;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
FTDM_SIGTYPE_NONE,
|
||||
FTDM_SIGTYPE_ISDN,
|
||||
|
|
Loading…
Reference in New Issue