int32_t idx;
uint32_t hups;
char file[512];
+ char error_file[512];
+ int confirm_timeout;
char key[80];
uint8_t early_ok;
uint8_t ring_ready;
struct key_collect {
char *key;
char *file;
+ char *error_file;
+ int confirm_timeout;
switch_core_session_t *session;
};
struct key_collect *collect = (struct key_collect *) obj;
switch_channel_t *channel = switch_core_session_get_channel(collect->session);
char buf[10] = SWITCH_BLANK_STRING;
- char *p, term;
switch_application_interface_t *application_interface = NULL;
if (collect->session) {
if (!strcasecmp(collect->key, "exec")) {
char *data;
char *app_name, *app_data;
-
+
if (!(data = collect->file)) {
goto wbreak;
}
}
while (switch_channel_ready(channel)) {
+ switch_size_t len = strlen(collect->key);
+ const char *file = collect->file;
+ switch_status_t status;
+
memset(buf, 0, sizeof(buf));
- if (collect->file) {
- switch_status_t status;
- switch_input_args_t args = { 0 };
- args.buf = buf;
- args.buflen = sizeof(buf);
- status = switch_ivr_play_file(collect->session, NULL, collect->file, &args);
- if (!SWITCH_READ_ACCEPTABLE(status)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect->session), SWITCH_LOG_ERROR, "%s Error Playing File!",
- switch_channel_get_name(channel));
- switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- }
- } else {
- switch_ivr_collect_digits_count(collect->session, buf, sizeof(buf), 1, SWITCH_BLANK_STRING, &term, 0, 0, 0);
+ if (zstr(file)) {
+ file = "silence";
+ }
+
+ status = switch_ivr_read(collect->session,
+ len,
+ len,
+ collect->file, NULL, buf, sizeof(buf), collect->confirm_timeout, "#");
+
+
+ if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK && status != SWITCH_STATUS_TOO_SMALL) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect->session), SWITCH_LOG_ERROR, "%s Error Playing File!",
+ switch_channel_get_name(channel));
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
-
- for (p = buf; *p; p++) {
- if (*collect->key == *p) {
- switch_channel_set_flag(channel, CF_WINNER);
- goto wbreak;
- }
+
+ if (!strcmp(collect->key, buf)) {
+ switch_channel_set_flag(channel, CF_WINNER);
+ goto wbreak;
+ } else if (collect->error_file) {
+ switch_ivr_play_file(collect->session, NULL, collect->error_file, NULL);
}
}
wbreak:
if (!zstr(oglobals->file)) {
collect->file = switch_core_session_strdup(originate_status[i].peer_session, oglobals->file);
}
+ if (!zstr(oglobals->error_file)) {
+ collect->error_file = switch_core_session_strdup(originate_status[i].peer_session, oglobals->error_file);
+ }
+
+ if (oglobals->confirm_timeout) {
+ collect->confirm_timeout = oglobals->confirm_timeout;
+ } else {
+ collect->confirm_timeout = 5000;
+ }
+
switch_channel_audio_sync(originate_status[i].peer_channel);
collect->session = originate_status[i].peer_session;
launch_collect_thread(collect);
if ((var = switch_event_get_header(var_event, "group_confirm_file"))) {
switch_copy_string(oglobals.file, var, sizeof(oglobals.file));
}
+ if ((var = switch_event_get_header(var_event, "group_confirm_error_file"))) {
+ switch_copy_string(oglobals.error_file, var, sizeof(oglobals.error_file));
+ }
+ if ((var = switch_event_get_header(var_event, "group_confirm_read_timeout"))) {
+ int tmp = atoi(var);
+
+ if (tmp >= 0) {
+ oglobals.confirm_timeout = tmp;
+ }
+
+ }
}
/* When using the AND operator, the fail_on_single_reject flag may be set in order to indicate that a single
rejections should terminate the attempt rather than a timeout, answer, or rejection by all.
*oglobals.file = '\0';
}
+ if ((*oglobals.error_file != '\0') && (!strcmp(oglobals.error_file, "undef"))) {
+ *oglobals.error_file = '\0';
+ }
+
if ((var_val = switch_event_get_header(var_event, "bridge_early_media"))) {
if (switch_true(var_val)) {
oglobals.early_ok = 0;