From 53346e494876aaa5af9b9adf39e7f510cac938ad Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 15 Dec 2010 16:42:47 -0500 Subject: [PATCH] Freetdm: exposed channel availability rate to user --- libs/freetdm/src/ftdm_io.c | 12 ++++++++++++ libs/freetdm/src/include/freetdm.h | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 3fa763fe79..1750d6d7d9 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -1702,6 +1702,18 @@ static ftdm_status_t __inline__ get_best_rated(ftdm_channel_t **fchan, ftdm_chan return FTDM_SUCCESS; } + +FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan) +{ + int availability = -1; + ftdm_channel_lock(ftdmchan); + if (ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_AV_RATE)) { + availability = ftdmchan->availability_rate; + } + ftdm_channel_unlock(ftdmchan); + return availability; +} + FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) { ftdm_status_t status = FTDM_FAIL; diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 18da29f566..41bf819a1c 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -696,6 +696,14 @@ typedef enum { /*! \brief Override the default queue handler */ FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *handler); +/*! \brief Return the availability rate for a channel + * \param ftdmchan Channel to get the availability from + * + * \retval > 0 if availability is supported + * \retval -1 if availability is not supported + */ +FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan); + /*! \brief Answer call */ #define ftdm_channel_call_answer(ftdmchan) _ftdm_channel_call_answer(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))