Hi

I've made a simple patch for spandsp and app_t38gateway that counts the
number of fax pages that have gone through T38Gateway and reports them
in ${FAXPAGES} just like RxFAX does.

If ${FAXPAGES} is not set the call wasn't a fax, if it's 0 the fax
failed, and if it's 1 or greater then at least some pages went through.
So now there's a way to tell whether a call was a fax and whether that
fax potentially succeeded (but, ${FAXPAGES} > 0 doesn't eliminate the
possibility that the fax sent some pages then failed).

You can endbeforehexten=yes in cdr.conf and add ${FAXPAGES} to the CDR
userfield in the h extension.

I'm not sure where to send spandsp patches, and I can't apply the patch
to app_t38gateway until spandsp is patched. Also spandsp doesn't provide
any way to query its version at runtime, which is necessary to preserve
binary compatibility with older versions. Should I send a patch for that
as well?

Bye
Damjan

diff -Nur spandsp-0.0.4/src/spandsp/t38_gateway.h spandsp-patched/src/spandsp/t38_gateway.h
--- spandsp-0.0.4/src/spandsp/t38_gateway.h	2007-12-30 06:45:33.000000000 +0200
+++ spandsp-patched/src/spandsp/t38_gateway.h	2008-01-09 02:44:46.000000000 +0200
@@ -230,6 +230,8 @@
     int fax_audio_tx_log;
     /*! \brief Error and flow logging control */
     logging_state_t logging;
+    /*! \brief Number of pages transferred, used for tracking statistics */
+    int pages_transferred;
 } t38_gateway_state_t;
 
 #if defined(__cplusplus)
diff -Nur spandsp-0.0.4/src/t38_gateway.c spandsp-patched/src/t38_gateway.c
--- spandsp-0.0.4/src/t38_gateway.c	2007-12-30 07:07:22.000000000 +0200
+++ spandsp-patched/src/t38_gateway.c	2008-01-09 02:52:49.000000000 +0200
@@ -749,6 +749,10 @@
         if (from_modem)
             s->tcf_mode_predictable_modem_start = 2;
         break;
+    case T30_MCF:
+        s->pages_transferred++;
+        span_log(&s->logging, SPAN_LOG_FLOW, "MCF - %d pages transferred\n", s->pages_transferred);
+        break;
     default:
         break;
     }
Index: apps/app_t38gateway.c
===================================================================
--- apps/app_t38gateway.c	(revision 4317)
+++ apps/app_t38gateway.c	(working copy)
@@ -48,7 +48,8 @@
 static const char *t38gateway_descrip =
 "Options:\n\n"
 " h -- Hangup if the call was successful.\n\n"
-" r -- Indicate 'ringing' to the caller.\n\n";
+" r -- Indicate 'ringing' to the caller.\n\n"
+"Sets FAXPAGES to the number of pages transferred\n\n";
 
 
 static int opbx_check_hangup_locked(struct opbx_channel *chan)
@@ -267,6 +268,7 @@
     t38_gateway_state_t t38_state;
     uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*OPBX_FRIENDLY_OFFSET];
     uint8_t *buf = __buf + OPBX_FRIENDLY_OFFSET;
+    char text[128];
 
     if ( chan->t38_status == T38_NEGOTIATED )
     {
@@ -385,6 +387,9 @@
         }
     }
 
+    snprintf(text, sizeof(text), "%d", t38_state.pages_transferred);
+    pbx_builtin_setvar_helper(chan, "FAXPAGES", text);
+
     if (original_read_fmt != OPBX_FORMAT_SLINEAR)
     {
         if ((res = opbx_set_read_format(channels[1], original_read_fmt)))
_______________________________________________
Callweaver-dev mailing list
[email protected]
http://lists.callweaver.org/mailman/listinfo/callweaver-dev

Reply via email to