From 15fe36a6d75d49bbfe0d51b231ba1c41f2b2e297 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 30 Jul 2008 15:05:07 +0000 Subject: [PATCH] add disable_ec app git-svn-id: http://svn.openzap.org/svn/openzap/trunk@506 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/mod_openzap/mod_openzap.c | 20 ++++++++++++++++++++ libs/freetdm/src/include/zap_types.h | 4 ++++ libs/freetdm/src/zap_buffer.c | 6 ++++-- libs/freetdm/src/zap_zt.c | 26 ++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/mod_openzap/mod_openzap.c b/libs/freetdm/mod_openzap/mod_openzap.c index c27870e45c..10aa079f03 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.c +++ b/libs/freetdm/mod_openzap/mod_openzap.c @@ -1848,10 +1848,28 @@ SWITCH_STANDARD_API(oz_function) } +SWITCH_STANDARD_APP(disable_ec_function) +{ + private_t *tech_pvt; + int x = 0; + + if (!switch_core_session_check_interface(session, openzap_endpoint_interface)) { + zap_log(ZAP_LOG_ERROR, "This application is only for OpenZAP channels.\n"); + return; + } + + tech_pvt = switch_core_session_get_private(session); + zap_channel_command(tech_pvt->zchan, ZAP_COMMAND_DISABLE_ECHOCANCEL, &x); + zap_channel_command(tech_pvt->zchan, ZAP_COMMAND_DISABLE_ECHOTRAIN, &x); + zap_log(ZAP_LOG_ERROR, "Echo Canceller Disabled\n"); +} + + SWITCH_MODULE_LOAD_FUNCTION(mod_openzap_load) { switch_api_interface_t *commands_api_interface; + switch_application_interface_t *app_interface; module_pool = pool; @@ -1875,6 +1893,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_openzap_load) SWITCH_ADD_API(commands_api_interface, "oz", "OpenZAP commands", oz_function, OZ_SYNTAX); + SWITCH_ADD_APP(app_interface, "disable_ec", "Disable Echo Canceller", "Disable Echo Canceller", disable_ec_function, "", SAF_NONE); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/libs/freetdm/src/include/zap_types.h b/libs/freetdm/src/include/zap_types.h index 483bddfb82..be43d0d069 100644 --- a/libs/freetdm/src/include/zap_types.h +++ b/libs/freetdm/src/include/zap_types.h @@ -260,6 +260,10 @@ typedef enum { ZAP_COMMAND_TRACE_OUTPUT, ZAP_COMMAND_ENABLE_CALLERID_DETECT, ZAP_COMMAND_DISABLE_CALLERID_DETECT, + ZAP_COMMAND_ENABLE_ECHOCANCEL, + ZAP_COMMAND_DISABLE_ECHOCANCEL, + ZAP_COMMAND_ENABLE_ECHOTRAIN, + ZAP_COMMAND_DISABLE_ECHOTRAIN, ZAP_COMMAND_COUNT } zap_command_t; diff --git a/libs/freetdm/src/zap_buffer.c b/libs/freetdm/src/zap_buffer.c index 525a3e2100..d5d7f1ef7d 100644 --- a/libs/freetdm/src/zap_buffer.c +++ b/libs/freetdm/src/zap_buffer.c @@ -204,6 +204,7 @@ zap_size_t zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t d if (freespace < datalen) { zap_size_t new_size, new_block_size; + void *data; new_size = buffer->datalen + datalen; new_block_size = buffer->datalen + buffer->blocksize; @@ -212,10 +213,11 @@ zap_size_t zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t d new_size = new_block_size; } buffer->head = buffer->data; - buffer->data = realloc(buffer->data, new_size); - if (!buffer->data) { + data = realloc(buffer->data, new_size); + if (!data) { return 0; } + buffer->data = data; buffer->head = buffer->data; buffer->datalen = new_size; } diff --git a/libs/freetdm/src/zap_zt.c b/libs/freetdm/src/zap_zt.c index ec6872b782..38c55ffae5 100644 --- a/libs/freetdm/src/zap_zt.c +++ b/libs/freetdm/src/zap_zt.c @@ -377,6 +377,32 @@ static ZIO_COMMAND_FUNCTION(zt_command) memset(&ztp, 0, sizeof(ztp)); switch(command) { + case ZAP_COMMAND_ENABLE_ECHOCANCEL: + { + int level = ZAP_COMMAND_OBJ_INT; + err = ioctl(zchan->sockfd, ZT_ECHOCANCEL, &level); + ZAP_COMMAND_OBJ_INT = level; + } + case ZAP_COMMAND_DISABLE_ECHOCANCEL: + { + int level = 0; + err = ioctl(zchan->sockfd, ZT_ECHOCANCEL, &level); + ZAP_COMMAND_OBJ_INT = level; + } + break; + case ZAP_COMMAND_ENABLE_ECHOTRAIN: + { + int level = ZAP_COMMAND_OBJ_INT; + err = ioctl(zchan->sockfd, ZT_ECHOTRAIN, &level); + ZAP_COMMAND_OBJ_INT = level; + } + case ZAP_COMMAND_DISABLE_ECHOTRAIN: + { + int level = 0; + err = ioctl(zchan->sockfd, ZT_ECHOTRAIN, &level); + ZAP_COMMAND_OBJ_INT = level; + } + break; case ZAP_COMMAND_OFFHOOK: { int command = ZT_OFFHOOK;