mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-21 10:53:48 +00:00
add ring_wait callstate for devstate interface
This commit is contained in:
parent
c32bd46853
commit
e2e8a57d9d
@ -109,6 +109,7 @@ typedef struct switch_device_stats_s {
|
|||||||
uint32_t early;
|
uint32_t early;
|
||||||
uint32_t early_in;
|
uint32_t early_in;
|
||||||
uint32_t early_out;
|
uint32_t early_out;
|
||||||
|
uint32_t ring_wait;
|
||||||
} switch_device_stats_t;
|
} switch_device_stats_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1140,6 +1140,7 @@ typedef enum {
|
|||||||
CCS_EARLY,
|
CCS_EARLY,
|
||||||
CCS_ACTIVE,
|
CCS_ACTIVE,
|
||||||
CCS_HELD,
|
CCS_HELD,
|
||||||
|
CCS_RING_WAIT,
|
||||||
CCS_HANGUP,
|
CCS_HANGUP,
|
||||||
CCS_UNHOLD
|
CCS_UNHOLD
|
||||||
} switch_channel_callstate_t;
|
} switch_channel_callstate_t;
|
||||||
|
@ -240,6 +240,7 @@ static struct switch_callstate_table CALLSTATE_CHART[] = {
|
|||||||
{"EARLY", CCS_EARLY},
|
{"EARLY", CCS_EARLY},
|
||||||
{"ACTIVE", CCS_ACTIVE},
|
{"ACTIVE", CCS_ACTIVE},
|
||||||
{"HELD", CCS_HELD},
|
{"HELD", CCS_HELD},
|
||||||
|
{"RING_WAIT", CCS_RING_WAIT},
|
||||||
{"HANGUP", CCS_HANGUP},
|
{"HANGUP", CCS_HANGUP},
|
||||||
{"UNHOLD", CCS_UNHOLD},
|
{"UNHOLD", CCS_UNHOLD},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
@ -1757,6 +1758,10 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw
|
|||||||
channel->flags[flag] = value;
|
channel->flags[flag] = value;
|
||||||
switch_mutex_unlock(channel->flag_mutex);
|
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) {
|
if (HELD) {
|
||||||
switch_hold_record_t *hr;
|
switch_hold_record_t *hr;
|
||||||
const char *brto = switch_channel_get_partner_uuid(channel);
|
const char *brto = switch_channel_get_partner_uuid(channel);
|
||||||
@ -1939,6 +1944,10 @@ SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch
|
|||||||
switch_mutex_unlock(channel->profile_mutex);
|
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) {
|
if (flag == CF_OUTBOUND) {
|
||||||
switch_channel_set_variable(channel, "is_outbound", NULL);
|
switch_channel_set_variable(channel, "is_outbound", NULL);
|
||||||
}
|
}
|
||||||
@ -4708,6 +4717,8 @@ static void fetch_device_stats(switch_device_record_t *drec)
|
|||||||
} else {
|
} else {
|
||||||
drec->stats.ringing_out++;
|
drec->stats.ringing_out++;
|
||||||
}
|
}
|
||||||
|
} else if (np->callstate == CCS_RING_WAIT) {
|
||||||
|
drec->stats.ring_wait++;
|
||||||
} else if (np->callstate == CCS_HANGUP) {
|
} else if (np->callstate == CCS_HANGUP) {
|
||||||
drec->stats.hup++;
|
drec->stats.hup++;
|
||||||
if (np->direction == SWITCH_CALL_DIRECTION_INBOUND) {
|
if (np->direction == SWITCH_CALL_DIRECTION_INBOUND) {
|
||||||
@ -4871,7 +4882,7 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
|
|||||||
drec->state = SDS_HANGUP;
|
drec->state = SDS_HANGUP;
|
||||||
} else {
|
} else {
|
||||||
if (drec->stats.active == 0) {
|
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;
|
drec->state = SDS_RINGING;
|
||||||
} else {
|
} else {
|
||||||
if (drec->stats.held > 0) {
|
if (drec->stats.held > 0) {
|
||||||
@ -4899,25 +4910,32 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
|
|||||||
|
|
||||||
switch(drec->state) {
|
switch(drec->state) {
|
||||||
case SDS_RINGING:
|
case SDS_RINGING:
|
||||||
|
if (!drec->ring_start) {
|
||||||
drec->ring_start = switch_micro_time_now();
|
drec->ring_start = switch_micro_time_now();
|
||||||
drec->ring_stop = 0;
|
drec->ring_stop = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDS_ACTIVE:
|
case SDS_ACTIVE:
|
||||||
case SDS_ACTIVE_MULTI:
|
case SDS_ACTIVE_MULTI:
|
||||||
if (drec->active_start && drec->last_state != SDS_HELD) {
|
if (!drec->active_start) {
|
||||||
drec->active_stop = switch_micro_time_now();
|
|
||||||
} else if (!drec->active_start) {
|
|
||||||
drec->active_start = switch_micro_time_now();
|
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;
|
break;
|
||||||
case SDS_HELD:
|
case SDS_HELD:
|
||||||
|
if (!drec->hold_start) {
|
||||||
drec->hold_start = switch_micro_time_now();
|
drec->hold_start = switch_micro_time_now();
|
||||||
drec->hold_stop = 0;
|
drec->hold_stop = 0;
|
||||||
default:
|
|
||||||
if (drec->active_start && drec->last_state != SDS_HELD) {
|
|
||||||
drec->active_stop = switch_micro_time_now();
|
|
||||||
}
|
}
|
||||||
break;
|
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) {
|
if (drec->ring_start && !drec->ring_stop && drec->state != SDS_RINGING) {
|
||||||
@ -4979,6 +4997,7 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
|
|||||||
if (drec->state == SDS_ACTIVE || drec->state == SDS_ACTIVE_MULTI) {
|
if (drec->state == SDS_ACTIVE || drec->state == SDS_ACTIVE_MULTI) {
|
||||||
drec->active_start = switch_micro_time_now();
|
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) {
|
if (drec->hold_stop) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user