mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 06:34:19 +00:00
upgrade fax_detect to tone_detect
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5379 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
8f6e8d6e65
commit
4ca73d77e0
6 files changed
+291
-108
No files matched your search
@@ -276,6 +276,51 @@ done:
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(tone_detect_session_function)
|
||||
{
|
||||
char *argv[6] = { 0 };
|
||||
int argc;
|
||||
char *mydata = NULL;
|
||||
time_t to = 0;
|
||||
switch_core_session_t *rsession;
|
||||
|
||||
mydata = switch_core_session_strdup(session, cmd);
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 3) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
|
||||
}
|
||||
|
||||
if (!(rsession = switch_core_session_locate(argv[0]))) {
|
||||
stream->write_function(stream, "-Error Cannot locate session!\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (argv[4]) {
|
||||
uint32_t mto;
|
||||
if (*argv[2] == '+') {
|
||||
if ((mto = atoi(argv[3]+1)) > 0) {
|
||||
to = time(NULL) + mto;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
if ((to = atoi(argv[3])) < time(NULL)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||
to = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, argv[5], argv[6]);
|
||||
stream->write_function(stream, "Enabling tone detection '%s' '%s' '%s'\n", argv[1], argv[2], argv[3]);
|
||||
|
||||
done:
|
||||
|
||||
switch_core_session_rwunlock(rsession);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(sched_transfer_function)
|
||||
{
|
||||
@@ -1385,13 +1430,22 @@ static switch_api_interface_t kill_api_interface = {
|
||||
/*.next */ &reload_api_interface
|
||||
};
|
||||
|
||||
static switch_api_interface_t tone_detect_session_interface = {
|
||||
/*.interface_name */ "tone_Detect",
|
||||
/*.desc */ "Start Tone Detection on a channel",
|
||||
/*.function */ tone_detect_session_function,
|
||||
/*.syntax */
|
||||
"<uuid> <key> <tone_spec> [<flags> <timeout> <app> <args>]",
|
||||
/*.next */ &kill_api_interface
|
||||
};
|
||||
|
||||
static switch_api_interface_t originate_api_interface = {
|
||||
/*.interface_name */ "originate",
|
||||
/*.desc */ "Originate a Call",
|
||||
/*.function */ originate_function,
|
||||
/*.syntax */
|
||||
"<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]",
|
||||
/*.next */ &kill_api_interface
|
||||
/*.next */ &tone_detect_session_interface
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface_t commands_module_interface = {
|
||||
|
||||
@@ -664,20 +664,45 @@ static void stop_dtmf_session_function(switch_core_session_t *session, char *dat
|
||||
|
||||
static void fax_detect_session_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enabling fax detection\n");
|
||||
switch_ivr_fax_detect_session(session);
|
||||
switch_ivr_tone_detect_session(session, "fax", "1100.0", "r", 0, NULL, NULL);
|
||||
}
|
||||
|
||||
static void system_session_function(switch_core_session_t *session, char *data)
|
||||
static void tone_detect_session_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n",data);
|
||||
system(data);
|
||||
char *argv[6] = { 0 };
|
||||
int argc;
|
||||
char *mydata = NULL;
|
||||
time_t to = 0;
|
||||
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
|
||||
}
|
||||
if (argv[3]) {
|
||||
uint32_t mto;
|
||||
if (*argv[2] == '+') {
|
||||
if ((mto = atoi(argv[2]+1)) > 0) {
|
||||
to = time(NULL) + mto;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||
}
|
||||
} else {
|
||||
if ((to = atoi(argv[2])) < time(NULL)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
|
||||
to = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enabling tone detection '%s' '%s'\n", argv[0], argv[1]);
|
||||
|
||||
switch_ivr_tone_detect_session(session, argv[0], argv[1], argv[2], to, argv[4], argv[5]);
|
||||
}
|
||||
|
||||
static void stop_fax_detect_session_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disabling fax detection\n");
|
||||
switch_ivr_stop_fax_detect_session(session);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disabling tone detection\n");
|
||||
switch_ivr_stop_tone_detect_session(session);
|
||||
}
|
||||
|
||||
static void echo_function(switch_core_session_t *session, char *data)
|
||||
@@ -1018,15 +1043,6 @@ static switch_api_interface_t presence_api_interface = {
|
||||
/*.next */ &dptools_api_interface
|
||||
};
|
||||
|
||||
static switch_application_interface_t system_application_interface = {
|
||||
/*.interface_name */ "system",
|
||||
/*.application_function */ system_session_function,
|
||||
/* long_desc */ "Execute a system command",
|
||||
/* short_desc */ "Execute a system command",
|
||||
/* syntax */ "<command>",
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next */ NULL
|
||||
};
|
||||
|
||||
static switch_application_interface_t bridge_application_interface = {
|
||||
/*.interface_name */ "bridge",
|
||||
@@ -1034,8 +1050,7 @@ static switch_application_interface_t bridge_application_interface = {
|
||||
/* long_desc */ "Bridge the audio between two sessions",
|
||||
/* short_desc */ "Bridge Audio",
|
||||
/* syntax */ "<channel_url>",
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/* next */ &system_application_interface
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA
|
||||
};
|
||||
|
||||
static switch_application_interface_t speak_application_interface = {
|
||||
@@ -1129,6 +1144,17 @@ static switch_application_interface_t echo_application_interface = {
|
||||
/*.next */ &park_application_interface
|
||||
};
|
||||
|
||||
|
||||
static switch_application_interface_t tone_detect_application_interface = {
|
||||
/*.interface_name */ "tone_detect",
|
||||
/*.application_function */ tone_detect_session_function,
|
||||
/* long_desc */ "Detect tones",
|
||||
/* short_desc */ "Detect tones",
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next */ &echo_application_interface
|
||||
};
|
||||
|
||||
static switch_application_interface_t fax_detect_application_interface = {
|
||||
/*.interface_name */ "fax_detect",
|
||||
/*.application_function */ fax_detect_session_function,
|
||||
@@ -1136,14 +1162,14 @@ static switch_application_interface_t fax_detect_application_interface = {
|
||||
/* short_desc */ "Detect faxes",
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next */ &echo_application_interface
|
||||
/*.next */ &tone_detect_application_interface
|
||||
};
|
||||
|
||||
static switch_application_interface_t stop_fax_detect_application_interface = {
|
||||
/*.interface_name */ "stop_fax_detect",
|
||||
static switch_application_interface_t stop_tone_detect_application_interface = {
|
||||
/*.interface_name */ "stop_tone_detect",
|
||||
/*.application_function */ stop_fax_detect_session_function,
|
||||
/* long_desc */ "Stop detecting fax send tones",
|
||||
/* short_desc */ "stop detecting faxes",
|
||||
/* long_desc */ "Stop detecting tones",
|
||||
/* short_desc */ "stop detecting tones",
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_NONE,
|
||||
/* next */ &fax_detect_application_interface
|
||||
@@ -1156,7 +1182,7 @@ static switch_application_interface_t dtmf_application_interface = {
|
||||
/* short_desc */ "Detect dtmf",
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_NONE,
|
||||
/* next */ &stop_fax_detect_application_interface
|
||||
/* next */ &stop_tone_detect_application_interface
|
||||
};
|
||||
|
||||
static switch_application_interface_t stop_dtmf_application_interface = {
|
||||
|
||||
Reference in new issue
Block a user