From f9f8279d8c1001ed73a0be314cfba35886e61620 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sat, 18 Sep 2010 23:07:38 +0000 Subject: [PATCH] Use Diva resources for IP endpoints --- chan_capi.c | 9 +++++++-- chan_capi.h | 5 +++++ chan_capi_chat.c | 5 +++-- chan_capi_utils.c | 14 ++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/chan_capi.c b/chan_capi.c index 9145215..dad3a25 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -219,7 +219,6 @@ static int pbx_capi_indicate(struct ast_channel *c, int condition, const void *d static int pbx_capi_indicate(struct ast_channel *c, int condition); #endif static struct capi_pvt* get_active_plci (struct ast_channel *c); -static _cstruct diva_get_b1_conf (struct capi_pvt *i); static void clear_channel_fax_loop (struct ast_channel *c, struct capi_pvt *i); static struct ast_channel* capidev_acquire_locks_from_thread_context (struct capi_pvt *i); static void pbx_capi_add_diva_protocol_independent_extension (struct capi_pvt *i, unsigned char *facilityarray, struct ast_channel *c, const char* variable); @@ -1646,7 +1645,7 @@ static int pbx_capi_call(struct ast_channel *c, char *idest, int timeout) return 0; } -static _cstruct diva_get_b1_conf (struct capi_pvt *i) { +_cstruct diva_get_b1_conf (struct capi_pvt *i) { _cstruct b1conf = b_protocol_table[i->bproto].b1configuration; if (i->bproto == CC_BPROTO_VOCODER) { @@ -9020,3 +9019,9 @@ static void pbx_capi_add_diva_protocol_independent_extension (struct capi_pvt *i return; } +int pbx_capi_get_controller_codecs (int controller) { + return (capi_controllers[controller]->rtpcodec); +} + + + diff --git a/chan_capi.h b/chan_capi.h index 11b2417..0623d7d 100644 --- a/chan_capi.h +++ b/chan_capi.h @@ -726,6 +726,11 @@ extern char chatinfo_usage[]; typedef int (*pbx_capi_command_proc_t)(struct ast_channel *, char *); pbx_capi_command_proc_t pbx_capi_lockup_command_by_name(const char* name); +/*! + * \brief returns list of supported by this controller RTP codecs + */ +int pbx_capi_get_controller_codecs (int controller); +_cstruct diva_get_b1_conf (struct capi_pvt *i); #ifdef DIVA_STREAMING struct _diva_streaming_vector; diff --git a/chan_capi_chat.c b/chan_capi_chat.c index 3babe28..c0f6c18 100644 --- a/chan_capi_chat.c +++ b/chan_capi_chat.c @@ -446,9 +446,10 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i, waitfd = i->readerfd; if (i->channeltype == CAPI_CHANNELTYPE_NULL) { + int fmt = (i->bproto == CC_BPROTO_VOCODER) ? i->codec : capi_capability; nfds = 1; - ast_set_read_format(chan, capi_capability); - ast_set_write_format(chan, capi_capability); + ast_set_read_format(chan, fmt); + ast_set_write_format(chan, fmt); } if ((flags & CHAT_FLAG_MOH) && ((room->active < 2) || (voice_message != NULL))) { diff --git a/chan_capi_utils.c b/chan_capi_utils.c index ab123a3..a580060 100644 --- a/chan_capi_utils.c +++ b/chan_capi_utils.c @@ -248,6 +248,7 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long control struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long controllermask, struct capi_pvt *data_plci_ifc) { struct capi_pvt *data_ifc /*, *line_ifc */; unsigned int controller = 1; + int fmt = 0; if (data_plci_ifc == 0) { int contrcount; @@ -269,6 +270,9 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con } } else { controller = data_plci_ifc->controller; + fmt = pbx_capi_get_controller_codecs (controller) & c->nativeformats; + if (fmt != 0) + fmt = ast_best_codec(fmt); } data_ifc = ast_malloc(sizeof(struct capi_pvt)); @@ -298,7 +302,8 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con data_ifc->ecTail = EC_DEFAULT_TAIL; data_ifc->isdnmode = CAPI_ISDNMODE_MSN; data_ifc->ecSelector = FACILITYSELECTOR_ECHO_CANCEL; - data_ifc->capability = capi_capability; + data_ifc->capability = (fmt != 0 && data_plci_ifc != 0) ? fmt : capi_capability; + data_ifc->codec = (fmt != 0 && data_plci_ifc != 0) ? fmt : data_ifc->codec; data_ifc->rxgain = 1.0; data_ifc->txgain = 1.0; @@ -314,7 +319,7 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con data_ifc->writerfd = -1; } - data_ifc->bproto = CC_BPROTO_TRANSPARENT; + data_ifc->bproto = (fmt != 0 && data_plci_ifc != 0) ? CC_BPROTO_VOCODER : CC_BPROTO_TRANSPARENT; data_ifc->doB3 = CAPI_B3_DONT; data_ifc->smoother = ast_smoother_new(CAPI_MAX_B3_BLOCK_SIZE); data_ifc->isdnstate |= CAPI_ISDN_STATE_PBX; @@ -348,13 +353,14 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con CAPI_MANUFACTURER_REQ, controller, data_ifc->MessageNumber, - "dw(wbb(www()()()()))", + "dw(wbb(wwws()()()))", _DI_MANU_ID, _DI_ASSIGN_PLCI, (data_plci_ifc == 0) ? 4 : 5, /* data */ (data_plci_ifc == 0) ? 0 : (unsigned char)(data_plci_ifc->PLCI >> 8), /* bchannel */ 1, /* connect */ - 1, 1, 0); + (data_ifc->bproto == CC_BPROTO_VOCODER) ? 0x1f : 1, 1, 0, + diva_get_b1_conf(data_ifc)); cc_mutex_unlock(&data_ifc->lock); if (data_plci_ifc != 0) {