add ring_wait callstate for devstate interface
This commit is contained in:
parent
386807f19d
commit
4783af2ee2
|
@ -109,6 +109,7 @@ typedef struct switch_device_stats_s {
|
|||
uint32_t early;
|
||||
uint32_t early_in;
|
||||
uint32_t early_out;
|
||||
uint32_t ring_wait;
|
||||
} switch_device_stats_t;
|
||||
|
||||
|
||||
|
|
|
@ -1116,6 +1116,7 @@ typedef enum {
|
|||
CCS_EARLY,
|
||||
CCS_ACTIVE,
|
||||
CCS_HELD,
|
||||
CCS_RING_WAIT,
|
||||
CCS_HANGUP,
|
||||
CCS_UNHOLD
|
||||
} switch_channel_callstate_t;
|
||||
|
|
|
@ -240,6 +240,7 @@ static struct switch_callstate_table CALLSTATE_CHART[] = {
|
|||
{"EARLY", CCS_EARLY},
|
||||
{"ACTIVE", CCS_ACTIVE},
|
||||
{"HELD", CCS_HELD},
|
||||
{"RING_WAIT", CCS_RING_WAIT},
|
||||
{"HANGUP", CCS_HANGUP},
|
||||
{"UNHOLD", CCS_UNHOLD},
|
||||
{NULL, 0}
|
||||
|
@ -1747,6 +1748,10 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw
|
|||
channel->flags[flag] = value;
|
||||
switch_mutex_unlock(channel->flag_mutex);
|
||||
|
||||
if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
|
||||
switch_channel_set_callstate(channel, CCS_RING_WAIT);
|
||||
}
|
||||
|
||||
if (HELD) {
|
||||
switch_hold_record_t *hr;
|
||||
const char *brto = switch_channel_get_partner_uuid(channel);
|
||||
|
@ -1923,6 +1928,10 @@ SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch
|
|||
switch_mutex_unlock(channel->profile_mutex);
|
||||
}
|
||||
|
||||
if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
|
||||
switch_channel_set_callstate(channel, CCS_ACTIVE);
|
||||
}
|
||||
|
||||
if (flag == CF_OUTBOUND) {
|
||||
switch_channel_set_variable(channel, "is_outbound", NULL);
|
||||
}
|
||||
|
@ -4658,6 +4667,8 @@ static void fetch_device_stats(switch_device_record_t *drec)
|
|||
} else {
|
||||
drec->stats.ringing_out++;
|
||||
}
|
||||
} else if (np->callstate == CCS_RING_WAIT) {
|
||||
drec->stats.ring_wait++;
|
||||
} else if (np->callstate == CCS_HANGUP) {
|
||||
drec->stats.hup++;
|
||||
if (np->direction == SWITCH_CALL_DIRECTION_INBOUND) {
|
||||
|
@ -4821,7 +4832,7 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
|
|||
drec->state = SDS_HANGUP;
|
||||
} else {
|
||||
if (drec->stats.active == 0) {
|
||||
if ((drec->stats.ringing_out + drec->stats.early_out) > 0) {
|
||||
if ((drec->stats.ringing_out + drec->stats.early_out) > 0 || drec->stats.ring_wait > 0) {
|
||||
drec->state = SDS_RINGING;
|
||||
} else {
|
||||
if (drec->stats.held > 0) {
|
||||
|
@ -4849,25 +4860,32 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
|
|||
|
||||
switch(drec->state) {
|
||||
case SDS_RINGING:
|
||||
if (!drec->ring_start) {
|
||||
drec->ring_start = switch_micro_time_now();
|
||||
drec->ring_stop = 0;
|
||||
}
|
||||
break;
|
||||
case SDS_ACTIVE:
|
||||
case SDS_ACTIVE_MULTI:
|
||||
if (drec->active_start && drec->last_state != SDS_HELD) {
|
||||
drec->active_stop = switch_micro_time_now();
|
||||
} else if (!drec->active_start) {
|
||||
if (!drec->active_start) {
|
||||
drec->active_start = switch_micro_time_now();
|
||||
drec->active_stop = 0;
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "SET START start:%ld stop:%ld\n", drec->active_start, drec->active_stop);
|
||||
}
|
||||
break;
|
||||
case SDS_HELD:
|
||||
if (!drec->hold_start) {
|
||||
drec->hold_start = switch_micro_time_now();
|
||||
drec->hold_stop = 0;
|
||||
default:
|
||||
if (drec->active_start && drec->last_state != SDS_HELD) {
|
||||
drec->active_stop = switch_micro_time_now();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (drec->active_start && drec->state != SDS_ACTIVE && drec->state != SDS_ACTIVE_MULTI) {
|
||||
drec->active_stop = switch_micro_time_now();
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "SET STOP start:%ld stop:%ld\n", drec->active_start, drec->active_stop);
|
||||
}
|
||||
|
||||
if (drec->ring_start && !drec->ring_stop && drec->state != SDS_RINGING) {
|
||||
|
@ -4929,6 +4947,7 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
|
|||
if (drec->state == SDS_ACTIVE || drec->state == SDS_ACTIVE_MULTI) {
|
||||
drec->active_start = switch_micro_time_now();
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "SET START start:%ld stop:%ld\n", drec->active_start, drec->active_stop);
|
||||
}
|
||||
|
||||
if (drec->hold_stop) {
|
||||
|
|
Loading…
Reference in New Issue