mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
app_dial.c: RINGTIME, PROGRESSTIME and ms resolution dial timings
Added RINGTIME, RINGTIME_MS, PROGRESSTIME, PROGRESSTIME_MS variables filled at the earliest received PROGRESS or RINGING. Added millisecond versions of DIALEDTIME and ANSWEREDTIME. Added millisecond versions of ast_channel_get_up_time and ast_channel_get_duration in channel.c. ASTERISK-28363 Change-Id: If95f1a7d8c4acbac740037de0c6e3109ff6620b1
This commit is contained in:
committed by
Sean Bright
parent
92712891f9
commit
d6b37e2926
@@ -565,9 +565,27 @@
|
||||
<variable name="DIALEDTIME">
|
||||
<para>This is the time from dialing a channel until when it is disconnected.</para>
|
||||
</variable>
|
||||
<variable name="DIALEDTIME_MS">
|
||||
<para>This is the milliseconds version of the DIALEDTIME variable.</para>
|
||||
</variable>
|
||||
<variable name="ANSWEREDTIME">
|
||||
<para>This is the amount of time for actual call.</para>
|
||||
</variable>
|
||||
<variable name="ANSWEREDTIME_MS">
|
||||
<para>This is the milliseconds version of the ANSWEREDTIME variable.</para>
|
||||
</variable>
|
||||
<variable name="RINGTIME">
|
||||
<para>This is the time from creating the channel to the first RINGING event received. Empty if there was no ring.</para>
|
||||
</variable>
|
||||
<variable name="RINGTIME_MS">
|
||||
<para>This is the milliseconds version of the RINGTIME variable.</para>
|
||||
</variable>
|
||||
<variable name="PROGRESSTIME">
|
||||
<para>This is the time from creating the channel to the first PROGRESS event received. Empty if there was no such event.</para>
|
||||
</variable>
|
||||
<variable name="PROGRESSTIME_MS">
|
||||
<para>This is the milliseconds version of the PROGRESSTIME variable.</para>
|
||||
</variable>
|
||||
<variable name="DIALEDPEERNAME">
|
||||
<para>The name of the outbound channel that answered the call.</para>
|
||||
</variable>
|
||||
@@ -1162,6 +1180,23 @@ static void update_connected_line_from_peer(struct ast_channel *chan, struct ast
|
||||
ast_party_connected_line_free(&connected_caller);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \pre chan is locked
|
||||
*/
|
||||
static void set_duration_var(struct ast_channel *chan, const char *var_base, int64_t duration)
|
||||
{
|
||||
char buf[32];
|
||||
char full_var_name[128];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%" PRId64, duration / 1000);
|
||||
pbx_builtin_setvar_helper(chan, var_base, buf);
|
||||
|
||||
snprintf(full_var_name, sizeof(full_var_name), "%s_MS", var_base);
|
||||
snprintf(buf, sizeof(buf), "%" PRId64, duration);
|
||||
pbx_builtin_setvar_helper(chan, full_var_name, buf);
|
||||
}
|
||||
|
||||
static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
struct dial_head *out_chans, int *to, struct ast_flags64 *peerflags,
|
||||
char *opt_args[],
|
||||
@@ -1184,6 +1219,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
int is_cc_recall;
|
||||
int cc_frame_received = 0;
|
||||
int num_ringing = 0;
|
||||
int sent_ring = 0;
|
||||
int sent_progress = 0;
|
||||
struct timeval start = ast_tvnow();
|
||||
|
||||
if (single) {
|
||||
@@ -1457,6 +1494,23 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
ast_indicate(in, AST_CONTROL_RINGING);
|
||||
pa->sentringing++;
|
||||
}
|
||||
if (!sent_ring) {
|
||||
struct timeval now, then;
|
||||
int64_t diff;
|
||||
|
||||
now = ast_tvnow();
|
||||
|
||||
ast_channel_lock(in);
|
||||
ast_channel_stage_snapshot(in);
|
||||
|
||||
then = ast_channel_creationtime(c);
|
||||
diff = ast_tvzero(then) ? 0 : ast_tvdiff_ms(now, then);
|
||||
set_duration_var(in, "RINGTIME", diff);
|
||||
|
||||
ast_channel_stage_snapshot_done(in);
|
||||
ast_channel_unlock(in);
|
||||
sent_ring = 1;
|
||||
}
|
||||
}
|
||||
ast_channel_publish_dial(in, c, NULL, "RINGING");
|
||||
break;
|
||||
@@ -1472,6 +1526,23 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
ast_indicate(in, AST_CONTROL_PROGRESS);
|
||||
}
|
||||
}
|
||||
if (!sent_progress) {
|
||||
struct timeval now, then;
|
||||
int64_t diff;
|
||||
|
||||
now = ast_tvnow();
|
||||
|
||||
ast_channel_lock(in);
|
||||
ast_channel_stage_snapshot(in);
|
||||
|
||||
then = ast_channel_creationtime(c);
|
||||
diff = ast_tvzero(then) ? 0 : ast_tvdiff_ms(now, then);
|
||||
set_duration_var(in, "PROGRESSTIME", diff);
|
||||
|
||||
ast_channel_stage_snapshot_done(in);
|
||||
ast_channel_unlock(in);
|
||||
sent_progress = 1;
|
||||
}
|
||||
if (!ast_strlen_zero(dtmf_progress)) {
|
||||
ast_verb(3,
|
||||
"Sending DTMF '%s' to the called party as result of receiving a PROGRESS message.\n",
|
||||
@@ -2058,18 +2129,12 @@ static int setup_privacy_args(struct privacy_args *pa,
|
||||
|
||||
static void end_bridge_callback(void *data)
|
||||
{
|
||||
char buf[80];
|
||||
time_t end;
|
||||
struct ast_channel *chan = data;
|
||||
|
||||
time(&end);
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_channel_stage_snapshot(chan);
|
||||
snprintf(buf, sizeof(buf), "%d", ast_channel_get_up_time(chan));
|
||||
pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
|
||||
snprintf(buf, sizeof(buf), "%d", ast_channel_get_duration(chan));
|
||||
pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
|
||||
set_duration_var(chan, "ANSWEREDTIME", ast_channel_get_up_time_ms(chan));
|
||||
set_duration_var(chan, "DIALEDTIME", ast_channel_get_duration_ms(chan));
|
||||
ast_channel_stage_snapshot_done(chan);
|
||||
ast_channel_unlock(chan);
|
||||
}
|
||||
@@ -2211,7 +2276,13 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
|
||||
pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", "");
|
||||
pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", "");
|
||||
pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", "");
|
||||
pbx_builtin_setvar_helper(chan, "ANSWEREDTIME_MS", "");
|
||||
pbx_builtin_setvar_helper(chan, "DIALEDTIME", "");
|
||||
pbx_builtin_setvar_helper(chan, "DIALEDTIME_MS", "");
|
||||
pbx_builtin_setvar_helper(chan, "RINGTIME", "");
|
||||
pbx_builtin_setvar_helper(chan, "RINGTIME_MS", "");
|
||||
pbx_builtin_setvar_helper(chan, "PROGRESSTIME", "");
|
||||
pbx_builtin_setvar_helper(chan, "PROGRESSTIME_MS", "");
|
||||
ast_channel_stage_snapshot_done(chan);
|
||||
max_forwards = ast_max_forwards_get(chan);
|
||||
ast_channel_unlock(chan);
|
||||
|
Reference in New Issue
Block a user