FS-6373
This commit is contained in:
parent
8951d26f8c
commit
a79a9ea9ed
|
@ -120,6 +120,7 @@ typedef struct {
|
||||||
double f;
|
double f;
|
||||||
/* freq_table_t ft; */
|
/* freq_table_t ft; */
|
||||||
avmd_state_t state;
|
avmd_state_t state;
|
||||||
|
switch_time_t start_time;
|
||||||
} avmd_session_t;
|
} avmd_session_t;
|
||||||
|
|
||||||
static void avmd_process(avmd_session_t *session, switch_frame_t *frame);
|
static void avmd_process(avmd_session_t *session, switch_frame_t *frame);
|
||||||
|
@ -183,6 +184,7 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
|
||||||
case SWITCH_ABC_TYPE_INIT:
|
case SWITCH_ABC_TYPE_INIT:
|
||||||
read_codec = switch_core_session_get_read_codec(avmd_session->session);
|
read_codec = switch_core_session_get_read_codec(avmd_session->session);
|
||||||
avmd_session->rate = read_codec->implementation->samples_per_second;
|
avmd_session->rate = read_codec->implementation->samples_per_second;
|
||||||
|
avmd_session->start_time = switch_micro_time_now();
|
||||||
/* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */
|
/* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -539,7 +541,8 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
|
||||||
/*! If variance is less than threshold then we have detection */
|
/*! If variance is less than threshold then we have detection */
|
||||||
if(v < VARIANCE_THRESHOLD){
|
if(v < VARIANCE_THRESHOLD){
|
||||||
|
|
||||||
switch_channel_execute_on(switch_core_session_get_channel(session->session), "execute_on_avmd_beep");
|
switch_channel_set_variable_printf(channel, "avmd_total_time", "%d", (int)(switch_micro_time_now() - session->start_time) / 1000);
|
||||||
|
switch_channel_execute_on(channel, "execute_on_avmd_beep");
|
||||||
|
|
||||||
/*! Throw an event to FreeSWITCH */
|
/*! Throw an event to FreeSWITCH */
|
||||||
status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP);
|
status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP);
|
||||||
|
|
|
@ -2999,6 +2999,7 @@ typedef struct {
|
||||||
int default_sleep;
|
int default_sleep;
|
||||||
int default_expires;
|
int default_expires;
|
||||||
int once;
|
int once;
|
||||||
|
switch_time_t start_time;
|
||||||
switch_tone_detect_callback_t callback;
|
switch_tone_detect_callback_t callback;
|
||||||
} switch_tone_detect_t;
|
} switch_tone_detect_t;
|
||||||
|
|
||||||
|
@ -3011,6 +3012,16 @@ typedef struct {
|
||||||
int detect_fax;
|
int detect_fax;
|
||||||
} switch_tone_container_t;
|
} switch_tone_container_t;
|
||||||
|
|
||||||
|
|
||||||
|
static void tone_detect_set_total_time(switch_tone_container_t *cont, int index)
|
||||||
|
{
|
||||||
|
char *total_time = switch_mprintf("%d", (int)(switch_micro_time_now() - cont->list[index].start_time) / 1000);
|
||||||
|
|
||||||
|
switch_channel_set_variable_name_printf(switch_core_session_get_channel(cont->session), total_time, "tone_detect_%s_total_time",
|
||||||
|
cont->list[index].key);
|
||||||
|
switch_safe_free(total_time);
|
||||||
|
}
|
||||||
|
|
||||||
static switch_status_t tone_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
|
static switch_status_t tone_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
|
||||||
{
|
{
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
@ -3023,6 +3034,7 @@ static switch_status_t tone_on_dtmf(switch_core_session_t *session, const switch
|
||||||
|
|
||||||
i = cont->detect_fax;
|
i = cont->detect_fax;
|
||||||
|
|
||||||
|
tone_detect_set_total_time(cont, i);
|
||||||
if (cont->list[i].callback) {
|
if (cont->list[i].callback) {
|
||||||
cont->list[i].callback(cont->session, cont->list[i].app, cont->list[i].data);
|
cont->list[i].callback(cont->session, cont->list[i].app, cont->list[i].data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3038,7 +3050,6 @@ static switch_status_t tone_on_dtmf(switch_core_session_t *session, const switch
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
|
static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
|
||||||
{
|
{
|
||||||
switch_tone_container_t *cont = (switch_tone_container_t *) user_data;
|
switch_tone_container_t *cont = (switch_tone_container_t *) user_data;
|
||||||
|
@ -3101,6 +3112,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da
|
||||||
if (cont->list[i].hits >= cont->list[i].total_hits) {
|
if (cont->list[i].hits >= cont->list[i].total_hits) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "TONE %s DETECTED\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "TONE %s DETECTED\n",
|
||||||
cont->list[i].key);
|
cont->list[i].key);
|
||||||
|
tone_detect_set_total_time(cont, i);
|
||||||
cont->list[i].up = 0;
|
cont->list[i].up = 0;
|
||||||
|
|
||||||
if (cont->list[i].callback) {
|
if (cont->list[i].callback) {
|
||||||
|
@ -3280,6 +3292,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
|
||||||
|
|
||||||
cont->list[cont->index].hits = 0;
|
cont->list[cont->index].hits = 0;
|
||||||
cont->list[cont->index].total_hits = hits;
|
cont->list[cont->index].total_hits = hits;
|
||||||
|
cont->list[cont->index].start_time = switch_micro_time_now();
|
||||||
|
|
||||||
cont->list[cont->index].up = 1;
|
cont->list[cont->index].up = 1;
|
||||||
memset(&cont->list[cont->index].mt, 0, sizeof(cont->list[cont->index].mt));
|
memset(&cont->list[cont->index].mt, 0, sizeof(cont->list[cont->index].mt));
|
||||||
|
|
Loading…
Reference in New Issue