summaryrefslogtreecommitdiff
path: root/net/asterisk12/files/patch-apps::app_rxfax.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/asterisk12/files/patch-apps::app_rxfax.c')
-rw-r--r--net/asterisk12/files/patch-apps::app_rxfax.c90
1 files changed, 54 insertions, 36 deletions
diff --git a/net/asterisk12/files/patch-apps::app_rxfax.c b/net/asterisk12/files/patch-apps::app_rxfax.c
index 820208e1943d..d294ecdfd5e2 100644
--- a/net/asterisk12/files/patch-apps::app_rxfax.c
+++ b/net/asterisk12/files/patch-apps::app_rxfax.c
@@ -1,9 +1,9 @@
$FreeBSD$
---- /dev/null Thu Jan 12 17:44:40 2006
-+++ apps/app_rxfax.c Thu Jan 12 17:41:53 2006
-@@ -0,0 +1,373 @@
+--- apps/app_rxfax.c.orig
++++ apps/app_rxfax.c
+@@ -0,0 +1,391 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
@@ -17,31 +17,35 @@ $FreeBSD$
+ * the GNU General Public License
+ */
+
-+#include <stdio.h>
-+#include <asterisk/lock.h>
-+#include <asterisk/file.h>
-+#include <asterisk/logger.h>
-+#include <asterisk/channel.h>
-+#include <asterisk/pbx.h>
-+#include <asterisk/module.h>
-+#include <asterisk/translate.h>
-+#include <asterisk/dsp.h>
-+#include <asterisk/manager.h>
-+#include <asterisk/version.h>
+#include <string.h>
+#include <stdlib.h>
-+#if defined(__FreeBSD__) && __FreeBSD_version < 500028
++#include <stdio.h>
++#if !defined(__FreeBSD__) || __FreeBSD_version < 500028
+#include <inttypes.h>
+#else
+#include <stdint.h>
+#endif
+#include <pthread.h>
+#include <errno.h>
-+#include <math.h>
++#include <tgmath.h>
+#include <tiffio.h>
+
+#include <spandsp.h>
+
++#include "asterisk.h"
++
++ASTERISK_FILE_VERSION(__FILE__, "$Revision:$")
++
++#include "asterisk/lock.h"
++#include "asterisk/file.h"
++#include "asterisk/logger.h"
++#include "asterisk/channel.h"
++#include "asterisk/pbx.h"
++#include "asterisk/module.h"
++#include "asterisk/translate.h"
++#include "asterisk/dsp.h"
++#include "asterisk/manager.h"
++
+static char *tdesc = "Trivial FAX Receive Application";
+
+static char *app = "RxFAX";
@@ -70,6 +74,20 @@ $FreeBSD$
+
+#define MAX_BLOCK_SIZE 240
+
++static void span_message(int level, const char *msg)
++{
++ int ast_level;
++
++ if (level == SPAN_LOG_WARNING)
++ ast_level = __LOG_WARNING;
++ else if (level == SPAN_LOG_WARNING)
++ ast_level = __LOG_WARNING;
++ else
++ ast_level = __LOG_DEBUG;
++ ast_log(ast_level, __FILE__, __LINE__, __PRETTY_FUNCTION__, msg);
++}
++/*- End of function --------------------------------------------------------*/
++
+static void t30_flush(t30_state_t *s, int which)
+{
+ //TODO:
@@ -85,11 +103,11 @@ $FreeBSD$
+ char buf[11];
+
+ chan = (struct ast_channel *) user_data;
-+ if (result)
++ if (result == T30_ERR_OK)
+ {
-+ fax_get_transfer_statistics(s, &t);
-+ fax_get_far_ident(s, far_ident);
-+ fax_get_local_ident(s, local_ident);
++ t30_get_transfer_statistics(s, &t);
++ t30_get_far_ident(s, far_ident);
++ t30_get_local_ident(s, local_ident);
+ ast_log(LOG_DEBUG, "==============================================================================\n");
+ ast_log(LOG_DEBUG, "Fax successfully received.\n");
+ ast_log(LOG_DEBUG, "Remote station id: %s\n", far_ident);
@@ -102,11 +120,7 @@ $FreeBSD$
+ "FaxReceived", "Channel: %s\nExten: %s\nCallerID: %s\nRemoteStationID: %s\nLocalStationID: %s\nPagesTransferred: %i\nResolution: %i\nTransferRate: %i\nFileName: %s\n",
+ chan->name,
+ chan->exten,
-+#if ASTERISK_VERSION_NUM <= 010010
-+ chan->callerid,
-+#else
+ (chan->cid.cid_num) ? chan->cid.cid_num : "",
-+#endif
+ far_ident,
+ local_ident,
+ t.pages_transferred,
@@ -124,7 +138,7 @@ $FreeBSD$
+ else
+ {
+ ast_log(LOG_DEBUG, "==============================================================================\n");
-+ ast_log(LOG_DEBUG, "Fax receive not successful.\n");
++ ast_log(LOG_DEBUG, "Fax receive not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result));
+ ast_log(LOG_DEBUG, "==============================================================================\n");
+ }
+}
@@ -138,7 +152,7 @@ $FreeBSD$
+ chan = (struct ast_channel *) user_data;
+ if (result)
+ {
-+ fax_get_transfer_statistics(s, &t);
++ t30_get_transfer_statistics(s, &t);
+ ast_log(LOG_DEBUG, "==============================================================================\n");
+ ast_log(LOG_DEBUG, "Pages transferred: %i\n", t.pages_transferred);
+ ast_log(LOG_DEBUG, "Image size: %i x %i\n", t.columns, t.rows);
@@ -186,6 +200,8 @@ $FreeBSD$
+ return -1;
+ }
+
++ span_set_message_handler(span_message);
++
+ /* The next few lines of code parse out the filename and header from the input string */
+ if (data == NULL)
+ {
@@ -203,7 +219,7 @@ $FreeBSD$
+ t = s;
+ v = strchr(s, '|');
+ s = (v) ? v : s + strlen(s);
-+ strncpy(buf, t, s - t);
++ strncpy((char *) buf, t, s - t);
+ buf[s - t] = '\0';
+ if (option == 0)
+ {
@@ -274,17 +290,18 @@ $FreeBSD$
+ }
+ }
+ fax_init(&fax, calling_party, NULL);
-+ fax.verbose = verbose;
++ if (verbose)
++ fax.logging.level = SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW;
+ x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
+ if (x && x[0])
-+ fax_set_local_ident(&fax, x);
++ t30_set_local_ident(&fax, x);
+ x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
+ if (x && x[0])
-+ fax_set_header_info(&fax, x);
-+ fax_set_rx_file(&fax, target_file);
-+ //fax_set_phase_b_handler(&fax, phase_b_handler, chan);
-+ fax_set_phase_d_handler(&fax, phase_d_handler, chan);
-+ fax_set_phase_e_handler(&fax, phase_e_handler, chan);
++ t30_set_header_info(&fax, x);
++ t30_set_rx_file(&fax, target_file, -1);
++ //t30_set_phase_b_handler(&fax, phase_b_handler, chan);
++ t30_set_phase_d_handler(&fax, phase_d_handler, chan);
++ t30_set_phase_e_handler(&fax, phase_e_handler, chan);
+ while (ast_waitfor(chan, -1) > -1)
+ {
+ inf = ast_read(chan);
@@ -295,10 +312,10 @@ $FreeBSD$
+ }
+ if (inf->frametype == AST_FRAME_VOICE)
+ {
-+ if (fax_rx_process(&fax, inf->data, inf->samples))
++ if (fax_rx(&fax, inf->data, inf->samples))
+ break;
+ samples = (inf->samples <= MAX_BLOCK_SIZE) ? inf->samples : MAX_BLOCK_SIZE;
-+ len = fax_tx_process(&fax, (int16_t *) &buf[AST_FRIENDLY_OFFSET], samples);
++ len = fax_tx(&fax, (int16_t *) &buf[AST_FRIENDLY_OFFSET], samples);
+ if (len)
+ {
+ memset(&outf, 0, sizeof(outf));
@@ -335,6 +352,7 @@ $FreeBSD$
+ if (res)
+ ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", chan->name);
+ }
++ fax_release(&fax);
+ }
+ else
+ {