Hi
A patch against trunk that calculates post dial delay is attached.
To use it, set endbeforehexten=yes in cdr.conf, and look at ${PDD} in
the h extension.
It doesn't work for channel that don't indicate ringing, like ZAP.
Bye
Damjan Jovanovic
(dacha)
Index: apps/app_dial.c
===================================================================
--- apps/app_dial.c (revision 4370)
+++ apps/app_dial.c (working copy)
@@ -281,7 +281,7 @@
dst->uniqueid);
}
-static struct opbx_channel *wait_for_answer(struct opbx_channel *in, struct outchan *outgoing, int *to, struct opbx_flags *peerflags, int *sentringing, char *status, size_t statussize, int busystart, int nochanstart, int congestionstart, int *result)
+static struct opbx_channel *wait_for_answer(struct opbx_channel *in, struct outchan *outgoing, int *to, struct opbx_flags *peerflags, int *sentringing, char *status, size_t statussize, int busystart, int nochanstart, int congestionstart, int *result, int start_time)
{
struct outchan *o;
int found;
@@ -294,6 +294,7 @@
int orig = *to;
struct opbx_frame *f;
struct opbx_channel *peer = NULL;
+ int has_rung = 0;
struct opbx_channel *watchers[OPBX_MAX_WATCHERS];
int pos;
int single;
@@ -488,6 +489,14 @@
case OPBX_CONTROL_RINGING:
if (option_verbose > 2)
opbx_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
+ if (!has_rung) {
+ /* Calculate the post-dial delay on the first ring */
+ char pdd_str[20];
+ time_t pdd = time(NULL) - start_time;
+ snprintf(pdd_str, sizeof(pdd_str), "%ld", (long)pdd);
+ pbx_builtin_setvar_helper(in, "PDD", pdd_str);
+ has_rung = 1;
+ }
if (!(*sentringing) && !opbx_test_flag(outgoing, DIAL_MUSICONHOLD)) {
opbx_indicate(in, OPBX_CONTROL_RINGING);
(*sentringing)++;
@@ -1233,7 +1242,7 @@
strcpy(status, "CHANUNAVAIL");
time(&start_time);
- peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, &result);
+ peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, &result, start_time);
if (!peer) {
if (result) {
Index: doc/README.variables
===================================================================
--- doc/README.variables (revision 4370)
+++ doc/README.variables (working copy)
@@ -656,6 +656,7 @@
${DIALEDPEERNAME} * Dialed peer name
${DIALEDPEERNUMBER} * Dialed peer number
${DIALEDTIME} * Time for the call (seconds)
+${PDD} * Post dial delay, time from dial to first ring (seconds)
${ANSWEREDTIME} * Time from dial to answer (seconds)
${DIALSTATUS} * Status of the call, one of:
(CHANUNAVAIL | CONGESTION | BUSY | NOANSWER
_______________________________________________
Callweaver-dev mailing list
[email protected]
http://lists.callweaver.org/mailman/listinfo/callweaver-dev