);
}
-#define OZ_SYNTAX "list || dump <span_id> [<chan_id>] || q931_pcap <span_id> on|off [pcapfilename without suffix] || gains <txgain> <rxgain> <span_id> [<chan_id>]"
+#define OZ_SYNTAX "list || dump <span_id> [<chan_id>] || q931_pcap <span_id> on|off [pcapfilename without suffix] || gains <txgain> <rxgain> <span_id> [<chan_id>] || dtmf on|off <span_id> [<chan_id>]"
SWITCH_STANDARD_API(oz_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
}
}
stream->write_function(stream, "+OK gains set to Rx %f and Tx %f\n", rxgain, txgain);
+ } else if (!strcasecmp(argv[0], "dtmf")) {
+ int i = 0;
+ uint32_t chan_id = 0;
+ zap_span_t *span = NULL;
+ zap_command_t zapcmd = ZAP_COMMAND_ENABLE_DTMF_DETECT;
+ if (argc < 3) {
+ stream->write_function(stream, "-ERR Usage: dtmf on|off <span_id> [<chan_id>]\n");
+ goto end;
+ }
+
+ if (switch_true(argv[1])) {
+ zapcmd = ZAP_COMMAND_ENABLE_DTMF_DETECT;
+ } else {
+ zapcmd = ZAP_COMMAND_DISABLE_DTMF_DETECT;
+ }
+
+ zap_span_find_by_name(argv[2], &span);
+ if (!span) {
+ stream->write_function(stream, "-ERR invalid span\n");
+ goto end;
+ }
+
+ if (argc > 3) {
+ chan_id = atoi(argv[3]);
+ if (chan_id > span->chan_count) {
+ stream->write_function(stream, "-ERR invalid chan\n");
+ goto end;
+ }
+ }
+
+ if (chan_id) {
+ zap_channel_command(span->channels[chan_id], zapcmd, NULL);
+ } else {
+ for (i = 1; i <= (int)span->chan_count; i++) {
+ zap_channel_command(span->channels[i], zapcmd, NULL);
+ }
+ }
+
+ stream->write_function(stream, "+OK DTMF detection was %s\n", zapcmd == ZAP_COMMAND_ENABLE_DTMF_DETECT ? "enabled" : "disabled");
} else if (!strcasecmp(argv[0], "trace")) {
char tracepath[255];
int i = 0;
zap_log(ZAP_LOG_INFO, "Echo Canceller Disabled\n");
}
+SWITCH_STANDARD_APP(disable_dtmf_function)
+{
+ private_t *tech_pvt;
+ 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);
+
+ if (switch_test_flag(tech_pvt, TFLAG_DEAD)) {
+ switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_LOSE_RACE);
+ return;
+ }
+
+ zap_channel_command(tech_pvt->zchan, ZAP_COMMAND_DISABLE_DTMF_DETECT, NULL);
+ zap_log(ZAP_LOG_INFO, "DTMF detection Disabled in channel %d:%d\n", tech_pvt->zchan->span_id, tech_pvt->zchan->chan_id);
+}
+
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);
+ SWITCH_ADD_APP(app_interface, "disable_dtmf", "Disable DTMF Detection", "Disable DTMF Detection", disable_dtmf_function, "", SAF_NONE);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
{
err=sangoma_tdm_enable_hwec(zchan->sockfd, &tdm_api);
if (err) {
- snprintf(zchan->last_error, sizeof(zchan->last_error), "HWEC Enable Failed");
+ snprintf(zchan->last_error, sizeof(zchan->last_error), "HWEC Enable Failed");
return ZAP_FAIL;
}
}
{
err=sangoma_tdm_disable_hwec(zchan->sockfd, &tdm_api);
if (err) {
- snprintf(zchan->last_error, sizeof(zchan->last_error), "HWEC Disable Failed");
+ snprintf(zchan->last_error, sizeof(zchan->last_error), "HWEC Disable Failed");
return ZAP_FAIL;
}
}
break;
- case ZAP_COMMAND_ENABLE_LOOP:
+ case ZAP_COMMAND_ENABLE_DTMF_DETECT:
+ {
+#ifdef WP_API_FEATURE_DTMF_EVENTS
+ err = sangoma_tdm_enable_dtmf_events(zchan->sockfd, &tdm_api);
+ if (err) {
+ zap_log(ZAP_LOG_WARNING, "Enabling of Sangoma HW DTMF failed\n");
+ snprintf(zchan->last_error, sizeof(zchan->last_error), "HW DTMF Enable Failed");
+ return ZAP_FAIL;
+ }
+ zap_log(ZAP_LOG_DEBUG, "Enabled DTMF events on chan %d:%d\n", zchan->span_id, zchan->chan_id);
+#else
+ return ZAP_NOTIMPL;
+#endif
+ }
+ break;
+ case ZAP_COMMAND_DISABLE_DTMF_DETECT:
+ {
+#ifdef WP_API_FEATURE_DTMF_EVENTS
+ err = sangoma_tdm_disable_dtmf_events(zchan->sockfd, &tdm_api);
+ if (err) {
+ zap_log(ZAP_LOG_WARNING, "Disabling of Sangoma HW DTMF failed\n");
+ snprintf(zchan->last_error, sizeof(zchan->last_error), "HW DTMF Disable Failed");
+ return ZAP_FAIL;
+ }
+ zap_log(ZAP_LOG_DEBUG, "Disabled DTMF events on chan %d:%d\n", zchan->span_id, zchan->chan_id);
+#else
+ return ZAP_NOTIMPL;
+#endif
+ }
+ break;
{
#ifdef WP_API_FEATURE_LOOP
err=sangoma_tdm_enable_loop(zchan->sockfd, &tdm_api);
{
/* if they don't have thier own, use ours */
if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_DTMF_DETECT)) {
- zap_tone_type_t tt = ZAP_COMMAND_OBJ_INT;
- if (tt == ZAP_TONE_DTMF) {
- teletone_dtmf_detect_init (&zchan->dtmf_detect, zchan->rate);
- zap_set_flag_locked(zchan, ZAP_CHANNEL_DTMF_DETECT);
- zap_set_flag_locked(zchan, ZAP_CHANNEL_SUPRESS_DTMF);
- GOTO_STATUS(done, ZAP_SUCCESS);
- } else {
- snprintf(zchan->last_error, sizeof(zchan->last_error), "invalid command");
- GOTO_STATUS(done, ZAP_FAIL);
- }
+ teletone_dtmf_detect_init (&zchan->dtmf_detect, zchan->rate);
+ zap_set_flag_locked(zchan, ZAP_CHANNEL_DTMF_DETECT);
+ zap_set_flag_locked(zchan, ZAP_CHANNEL_SUPRESS_DTMF);
+ GOTO_STATUS(done, ZAP_SUCCESS);
}
}
break;
case ZAP_COMMAND_DISABLE_DTMF_DETECT:
{
if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_DTMF_DETECT)) {
- zap_tone_type_t tt = ZAP_COMMAND_OBJ_INT;
- if (tt == ZAP_TONE_DTMF) {
- teletone_dtmf_detect_init (&zchan->dtmf_detect, zchan->rate);
- zap_clear_flag(zchan, ZAP_CHANNEL_DTMF_DETECT);
- zap_clear_flag(zchan, ZAP_CHANNEL_SUPRESS_DTMF);
- GOTO_STATUS(done, ZAP_SUCCESS);
- } else {
- snprintf(zchan->last_error, sizeof(zchan->last_error), "invalid command");
- GOTO_STATUS(done, ZAP_FAIL);
- }
+ teletone_dtmf_detect_init (&zchan->dtmf_detect, zchan->rate);
+ zap_clear_flag(zchan, ZAP_CHANNEL_DTMF_DETECT);
+ zap_clear_flag(zchan, ZAP_CHANNEL_SUPRESS_DTMF);
+ GOTO_STATUS(done, ZAP_SUCCESS);
}
}
-
+ break;
case ZAP_COMMAND_SET_PRE_BUFFER_SIZE:
{
int val = ZAP_COMMAND_OBJ_INT;