From da557fd631321ff0a7044fc2735e0545cec20db4 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Fri, 20 Feb 2009 18:30:05 +0000 Subject: [PATCH] update to snapshot spandsp-20090220 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12190 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/spandsp/src/spandsp/private/t4.h | 4 +- libs/spandsp/src/spandsp/t30.h | 8 +- libs/spandsp/src/spandsp/t4.h | 18 +- libs/spandsp/src/spandsp/version.h | 4 +- libs/spandsp/src/t30.c | 23 ++- libs/spandsp/src/t4.c | 188 ++++++++++++----- libs/spandsp/test-data/etsi/fax/Makefile.am | 40 ++-- .../etsi/fax/generate_etsi_300_242_pages.c | 24 ++- libs/spandsp/test-data/itu/fax/Makefile.am | 190 +++++++++--------- libs/spandsp/tests/Makefile.am | 16 +- libs/spandsp/tests/fax_tests.c | 110 ++++------ libs/spandsp/tests/fax_utils.c | 111 ++++++++++ libs/spandsp/tests/t31_tests.c | 152 ++++++++++---- libs/spandsp/tests/t38_gateway_tests.c | 53 ++--- .../tests/t38_gateway_to_terminal_tests.c | 53 ++--- libs/spandsp/tests/t38_terminal_tests.c | 55 ++--- .../tests/t38_terminal_to_gateway_tests.c | 53 ++--- libs/spandsp/tests/t4_tests.c | 8 +- libs/spandsp/tests/tsb85_tests.c | 112 ++++------- 19 files changed, 695 insertions(+), 527 deletions(-) create mode 100644 libs/spandsp/tests/fax_utils.c diff --git a/libs/spandsp/src/spandsp/private/t4.h b/libs/spandsp/src/spandsp/private/t4.h index df84f4b809..6d0e08e795 100644 --- a/libs/spandsp/src/spandsp/private/t4.h +++ b/libs/spandsp/src/spandsp/private/t4.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t4.h,v 1.3 2009/02/16 09:57:22 steveu Exp $ + * $Id: t4.h,v 1.4 2009/02/20 12:34:20 steveu Exp $ */ #if !defined(_SPANDSP_PRIVATE_T4_H_) @@ -107,7 +107,7 @@ struct t4_state_s int stop_page; /*! \brief The number of pages transferred to date. */ - int pages_transferred; + int current_page; /*! \brief The number of pages in the current image file. */ int pages_in_file; /*! \brief Column-to-column (X) resolution in pixels per metre. */ diff --git a/libs/spandsp/src/spandsp/t30.h b/libs/spandsp/src/spandsp/t30.h index 1b71adec96..e7c90416d6 100644 --- a/libs/spandsp/src/spandsp/t30.h +++ b/libs/spandsp/src/spandsp/t30.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t30.h,v 1.123 2009/02/04 13:18:53 steveu Exp $ + * $Id: t30.h,v 1.124 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -515,8 +515,10 @@ typedef struct int bit_rate; /*! \brief TRUE if error correcting mode is used. */ int error_correcting_mode; - /*! \brief The number of pages transferred so far. */ - int pages_transferred; + /*! \brief The number of pages sent so far. */ + int pages_tx; + /*! \brief The number of pages received so far. */ + int pages_rx; /*! \brief The number of pages in the file (<0 if not known). */ int pages_in_file; /*! \brief The horizontal column-to-column resolution of the page, in pixels per metre */ diff --git a/libs/spandsp/src/spandsp/t4.h b/libs/spandsp/src/spandsp/t4.h index 533d7c08de..ad986f41c4 100644 --- a/libs/spandsp/src/spandsp/t4.h +++ b/libs/spandsp/src/spandsp/t4.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t4.h,v 1.57 2009/02/10 13:06:47 steveu Exp $ + * $Id: t4.h,v 1.58 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -323,11 +323,14 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s); \return zero for success, -1 for failure. */ SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s); -/*! \brief Check for the existance of the next page. This information can - be needed before it is determined that the current page is finished with. +/*! \brief Check for the existance of the next page, and whether its format is like the + current one. This information can be needed before it is determined that the current + page is finished with. \param s The T.4 context. - \return zero for next page found, -1 for failure. */ -SPAN_DECLARE(int) t4_tx_more_pages(t4_state_t *s); + \return 0 for next page found with the same format as the current page. + 1 for next page found with different format from the current page. + -1 for no page found, or file failure. */ +SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s); /*! \brief Complete the sending of a page. \param s The T.4 context. @@ -435,6 +438,11 @@ SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s); \return The number of pages, or -1 if there is an error. */ SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s); +/*! \brief Get the currnet page number in the file. + \param s The T.4 context. + \return The page number, or -1 if there is an error. */ +SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s); + /*! Get the current image transfer statistics. \brief Get the current transfer statistics. \param s The T.4 context. diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index 6cd666fe9f..4dce7a7f8e 100644 --- a/libs/spandsp/src/spandsp/version.h +++ b/libs/spandsp/src/spandsp/version.h @@ -30,8 +30,8 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20090216 -#define SPANDSP_RELEASE_TIME 100031 +#define SPANDSP_RELEASE_DATE 20090220 +#define SPANDSP_RELEASE_TIME 124309 #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index 592cee5df8..65b274ae0b 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t30.c,v 1.285 2009/02/10 13:06:46 steveu Exp $ + * $Id: t30.c,v 1.286 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -469,7 +469,9 @@ static int copy_quality(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Image resolution = %d/m x %d/m\n", stats.x_resolution, stats.y_resolution); span_log(&s->logging, SPAN_LOG_FLOW, "Bad rows = %d\n", stats.bad_rows); span_log(&s->logging, SPAN_LOG_FLOW, "Longest bad row run = %d\n", stats.longest_bad_row_run); - if (stats.bad_rows == 0) + /* Don't treat a page as perfect because it has zero bad rows out of zero total rows. A zero row + page has got to be some kind of total page failure. */ + if (stats.bad_rows == 0 && stats.length != 0) { span_log(&s->logging, SPAN_LOG_FLOW, "Page quality is perfect\n"); quality = T30_COPY_QUALITY_PERFECT; @@ -587,10 +589,21 @@ static void release_resources(t30_state_t *s) static uint8_t check_next_tx_step(t30_state_t *s) { + int res; int more; - if (t4_tx_more_pages(&(s->t4)) == 0) + res = t4_tx_next_page_has_different_format(&(s->t4)); + if (res == 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "More pages to come with the same format\n"); return (s->local_interrupt_pending) ? T30_PRI_MPS : T30_MPS; + } + if (res > 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "More pages to come with a different format\n"); + s->tx_start_page = t4_tx_get_current_page_in_file(&(s->t4)) + 1; + return (s->local_interrupt_pending) ? T30_PRI_EOM : T30_EOM; + } /* Call a user handler, if one is set, to check if another document is to be sent. If so, we send an EOM, rather than an EOP. Then we will renegotiate, and the new document will begin. */ @@ -5778,7 +5791,8 @@ SPAN_DECLARE(void) t30_get_transfer_statistics(t30_state_t *s, t30_stats_t *t) t->error_correcting_mode = s->error_correcting_mode; t->error_correcting_mode_retries = s->error_correcting_mode_retries; t4_get_transfer_statistics(&s->t4, &stats); - t->pages_transferred = stats.pages_transferred; + t->pages_tx = s->ecm_tx_page; + t->pages_rx = s->ecm_rx_page; t->pages_in_file = stats.pages_in_file; t->width = stats.width; t->length = stats.length; @@ -5833,6 +5847,7 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s) s->far_end_detected = FALSE; s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T0); release_resources(s); + /* The ECM page number is only reset at call establishment */ s->ecm_rx_page = 0; s->ecm_tx_page = 0; return 0; diff --git a/libs/spandsp/src/t4.c b/libs/spandsp/src/t4.c index 9ff65867ea..381be75b68 100644 --- a/libs/spandsp/src/t4.c +++ b/libs/spandsp/src/t4.c @@ -24,7 +24,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t4.c,v 1.125 2009/02/16 09:57:22 steveu Exp $ + * $Id: t4.c,v 1.126 2009/02/20 12:34:20 steveu Exp $ */ /* @@ -239,8 +239,8 @@ static int set_tiff_directory_info(t4_state_t *s) /* Set the total pages to 1. For any one page document we will get this right. For multi-page documents we will need to come back and fill in the right answer when we know it. */ - TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, s->pages_transferred++, 1); - s->pages_in_file = s->pages_transferred; + TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, s->current_page++, 1); + s->pages_in_file = s->current_page; if (t->output_compression == COMPRESSION_CCITT_T4) { if (s->bad_rows) @@ -301,8 +301,6 @@ static int get_tiff_directory_info(t4_state_t *s) { -1.00f, -1, -1} }; uint16_t res_unit; - uint16_t photo_metric; - uint16_t fill_order; uint32_t parm; float x_resolution; float y_resolution; @@ -327,16 +325,14 @@ static int get_tiff_directory_info(t4_state_t *s) TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); res_unit = RESUNIT_INCH; TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); - photo_metric = PHOTOMETRIC_MINISWHITE; - TIFFGetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, &photo_metric); - if (photo_metric != PHOTOMETRIC_MINISWHITE) + t->photo_metric = PHOTOMETRIC_MINISWHITE; + TIFFGetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, &t->photo_metric); + if (t->photo_metric != PHOTOMETRIC_MINISWHITE) span_log(&s->logging, SPAN_LOG_FLOW, "%s: Photometric needs swapping.\n", s->file); - t->photo_metric = photo_metric; - fill_order = FILLORDER_LSB2MSB; - TIFFGetField(t->tiff_file, TIFFTAG_FILLORDER, &fill_order); - if (fill_order != FILLORDER_LSB2MSB) + t->fill_order = FILLORDER_LSB2MSB; + TIFFGetField(t->tiff_file, TIFFTAG_FILLORDER, &t->fill_order); + if (t->fill_order != FILLORDER_LSB2MSB) span_log(&s->logging, SPAN_LOG_FLOW, "%s: Fill order needs swapping.\n", s->file); - t->fill_order = fill_order; /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the precise value. The other value should be exact. */ @@ -367,6 +363,92 @@ static int get_tiff_directory_info(t4_state_t *s) } /*- End of function --------------------------------------------------------*/ +static int test_tiff_directory_info(t4_state_t *s) +{ + static const struct + { + float resolution; + int code; + } x_res_table[] = + { + { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4}, + { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8}, + { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300}, + { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16}, + { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600}, + { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800}, + {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200}, + { -1.00f, -1} + }; + static const struct + { + float resolution; + int code; + int max_rows_to_next_1d_row; + } y_res_table[] = + { + { 38.50f, T4_Y_RESOLUTION_STANDARD, 2}, + { 77.00f, T4_Y_RESOLUTION_FINE, 4}, + { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300, 6}, + { 154.00f, T4_Y_RESOLUTION_SUPERFINE, 8}, + { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600, 12}, + { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800, 16}, + {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200, 24}, + { -1.00f, -1, -1} + }; + uint16_t res_unit; + uint32_t parm; + float x_resolution; + float y_resolution; + int i; + t4_tiff_state_t *t; + + t = &s->tiff; + parm = 0; + TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm); + if (parm != 1) + return -1; + parm = 0; + TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm); + if (s->image_width != parm) + { +printf("Width changed\n"); + return 1; + } + x_resolution = 0.0f; + TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); + y_resolution = 0.0f; + TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); + res_unit = RESUNIT_INCH; + TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); + + /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the + precise value. The other value should be exact. */ + /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ + for (i = 0; x_res_table[i].code > 0; i++) + { + if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution)) + break; + } + if (s->x_resolution != x_res_table[i].code) + { +printf("X-res changed\n"); + return 1; + } + for (i = 0; y_res_table[i].code > 0; i++) + { + if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution)) + break; + } + if (s->y_resolution != y_res_table[i].code) + { +printf("Y-res changed\n"); + return 1; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + static int get_tiff_total_pages(t4_state_t *s) { int max; @@ -378,7 +460,7 @@ static int get_tiff_total_pages(t4_state_t *s) while (TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) max)) max++; /* Back to the previous page */ - if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->pages_transferred)) + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) return -1; return max; } @@ -460,15 +542,15 @@ static int close_tiff_output_file(t4_state_t *s) t = &s->tiff; /* Perform any operations needed to tidy up a written TIFF file before closure. */ - if (s->pages_transferred > 1) + if (s->current_page > 1) { /* We need to edit the TIFF directories. Until now we did not know the total page count, so the TIFF file currently says one. Now we need to set the correct total page count associated with each page. */ - for (i = 0; i < s->pages_transferred; i++) + for (i = 0; i < s->current_page; i++) { TIFFSetDirectory(t->tiff_file, (tdir_t) i); - TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, i, s->pages_transferred); + TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, i, s->current_page); TIFFWriteDirectory(t->tiff_file); } } @@ -478,7 +560,7 @@ static int close_tiff_output_file(t4_state_t *s) { /* Try not to leave a file behind, if we didn't receive any pages to put in it. */ - if (s->pages_transferred == 0) + if (s->current_page == 0) remove(s->file); free((char *) s->file); } @@ -501,6 +583,12 @@ static int get_tiff_directory_info(t4_state_t *s) } /*- End of function --------------------------------------------------------*/ +static int test_tiff_directory_info(t4_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + static int open_tiff_input_file(t4_state_t *s, const char *file) { return 0; @@ -1326,7 +1414,7 @@ SPAN_DECLARE(t4_state_t *) t4_rx_init(t4_state_t *s, const char *file, int outpu value to ensure it will be seen as changing when the real value is used. */ s->bytes_per_row = 0; - s->pages_transferred = 0; + s->current_page = 0; s->pages_in_file = 0; s->start_page = 0; s->stop_page = INT_MAX; @@ -1866,9 +1954,12 @@ SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start if (open_tiff_input_file(s, file) < 0) return NULL; s->file = strdup(file); + s->current_page = s->start_page = (start_page >= 0) ? start_page : 0; s->stop_page = (stop_page >= 0) ? stop_page : INT_MAX; + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) + return -1; if (get_tiff_directory_info(s)) { close_tiff_input_file(s); @@ -1877,7 +1968,6 @@ SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1; - s->pages_transferred = s->start_page; s->pages_in_file = -1; run_space = (s->image_width + 4)*sizeof(uint32_t); @@ -1937,7 +2027,7 @@ static void make_header(t4_state_t *s, char *header) tm.tm_min, s->header_info, s->tiff.local_ident, - s->pages_transferred + 1); + s->current_page + 1); } /*- End of function --------------------------------------------------------*/ @@ -1950,24 +2040,24 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s) int row_bufptr; int run_space; int len; - int this_image_width; + int old_image_width; char *t; char header[132 + 1]; uint8_t *bufptr8; uint32_t *bufptr; - span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d\n", s->pages_transferred); - if (s->pages_transferred > s->stop_page) + span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d\n", s->current_page); + if (s->current_page > s->stop_page) return -1; if (s->tiff.tiff_file == NULL) return -1; - this_image_width = 0; + old_image_width = s->image_width; if (s->row_read_handler == NULL) { #if defined(HAVE_LIBTIFF) - if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->pages_transferred)) + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) return -1; - TIFFGetField(s->tiff.tiff_file, TIFFTAG_IMAGEWIDTH, &this_image_width); + get_tiff_directory_info(s); #endif } s->image_size = 0; @@ -1977,10 +2067,9 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s) s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1; /* Allow for pages being of different width. */ - run_space = (this_image_width + 4)*sizeof(uint32_t); - if (this_image_width != s->image_width) + run_space = (s->image_width + 4)*sizeof(uint32_t); + if (old_image_width != s->image_width) { - s->image_width = this_image_width; s->bytes_per_row = (s->image_width + 7)/8; if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) @@ -2073,13 +2162,13 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s) } if (s->line_encoding == T4_COMPRESSION_ITU_T6) { - /* Attach an EOFB (end of facsimile block) to the end of the page */ + /* Attach an EOFB (end of facsimile block == 2 x EOLs) to the end of the page */ for (i = 0; i < EOLS_TO_END_T6_TX_PAGE; i++) encode_eol(s); } else { - /* Attach a return to control (RTC == 6 x EOLs) to the end of the page */ + /* Attach an RTC (return to control == 6 x EOLs) to the end of the page */ s->row_is_2d = FALSE; for (i = 0; i < EOLS_TO_END_T4_TX_PAGE; i++) encode_eol(s); @@ -2095,27 +2184,20 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_more_pages(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s) { - span_log(&s->logging, SPAN_LOG_FLOW, "Checking for the existance of page %d\n", s->pages_transferred + 1); - if (s->pages_transferred >= s->stop_page) + span_log(&s->logging, SPAN_LOG_FLOW, "Checking for the existance of page %d\n", s->current_page + 1); + if (s->current_page >= s->stop_page) return -1; - if (s->tiff.tiff_file == NULL) - return -1; - if (s->pages_in_file >= 0) + if (s->row_read_handler == NULL) { - if (s->pages_transferred + 1 >= s->pages_in_file) - return -1; - } - else - { - if (s->row_read_handler == NULL) - { #if defined(HAVE_LIBTIFF) - if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->pages_transferred + 1)) - return -1; + if (s->tiff.tiff_file == NULL) + return -1; + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page + 1)) + return -1; + return test_tiff_directory_info(s); #endif - } } return 0; } @@ -2131,7 +2213,7 @@ SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s) SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s) { - s->pages_transferred++; + s->current_page++; return 0; } /*- End of function --------------------------------------------------------*/ @@ -2261,9 +2343,15 @@ SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s) } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s) +{ + return s->current_page; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(void) t4_get_transfer_statistics(t4_state_t *s, t4_stats_t *t) { - t->pages_transferred = s->pages_transferred - s->start_page; + t->pages_transferred = s->current_page - s->start_page; t->pages_in_file = s->pages_in_file; t->width = s->image_width; t->length = s->image_length; diff --git a/libs/spandsp/test-data/etsi/fax/Makefile.am b/libs/spandsp/test-data/etsi/fax/Makefile.am index 7ab1609f40..0242f5590a 100644 --- a/libs/spandsp/test-data/etsi/fax/Makefile.am +++ b/libs/spandsp/test-data/etsi/fax/Makefile.am @@ -16,30 +16,33 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -## $Id: Makefile.am,v 1.2 2008/09/10 16:55:15 steveu Exp $ +## $Id: Makefile.am,v 1.3 2009/02/20 12:34:20 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) PBM2G3 = pbmtog3 FAX2TIFF = fax2tiff +TIFFCP = tiffcp + +ETSI_TEST_PAGES = etsi_300_242_a4_diago1.tif \ + etsi_300_242_a4_diago2.tif \ + etsi_300_242_a4_duration1.tif \ + etsi_300_242_a4_duration2.tif \ + etsi_300_242_a4_error.tif \ + etsi_300_242_a4_impress.tif \ + etsi_300_242_a4_impress_white.tif \ + etsi_300_242_a4_stairstep.tif \ + etsi_300_242_a4_white.tif \ + etsi_300_242_a4_white_2p.tif EXTRA_DIST = -nobase_data_DATA = etsi_300_242_a4_diago1.tif \ - etsi_300_242_a4_diago2.tif \ - etsi_300_242_a4_duration1.tif \ - etsi_300_242_a4_duration2.tif \ - etsi_300_242_a4_error.tif \ - etsi_300_242_a4_impress.tif \ - etsi_300_242_a4_impress_white.tif \ - etsi_300_242_a4_stairstep.tif \ - etsi_300_242_a4_white.tif \ - etsi_300_242_a4_white_2p.tif +nobase_data_DATA = ${ETSI_TEST_PAGES} -noinst_PROGRAMS = generate_etsi_300_242_pages +noinst_PROGRAMS = generate_etsi_300_242_pages generate_etsi_300_242_pages_SOURCES = generate_etsi_300_242_pages.c -generate_etsi_300_242_pages_LDADD = -ltiff +generate_etsi_300_242_pages_LDADD = -lspandsp -ltiff clean: rm -f *.tif *.g3 @@ -50,14 +53,5 @@ clean: .pbm.g3: ${PBM2G3} $*.pbm >$*.g3 -etsi_300_242_a4_diago1.tif \ -etsi_300_242_a4_diago2.tif \ -etsi_300_242_a4_duration1.tif \ -etsi_300_242_a4_duration2.tif \ -etsi_300_242_a4_error.tif \ -etsi_300_242_a4_impress.tif \ -etsi_300_242_a4_impress_white.tif \ -etsi_300_242_a4_stairstep.tif \ -etsi_300_242_a4_white.tif \ -etsi_300_242_a4_white_2p.tif: generate_etsi_300_242_pages$(EXEEXT) +${ETSI_TEST_PAGES}: generate_etsi_300_242_pages$(EXEEXT) ./generate_etsi_300_242_pages$(EXEEXT) diff --git a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c index 72a800f7f5..025f72286d 100644 --- a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c +++ b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: generate_etsi_300_242_pages.c,v 1.2 2008/09/10 16:55:15 steveu Exp $ + * $Id: generate_etsi_300_242_pages.c,v 1.3 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -177,6 +177,9 @@ struct }, }; +int reverse_photo_metric = FALSE; +int reverse_fill_order = FALSE; + static void clear_row(uint8_t buf[], int width) { memset(buf, 0, width/8 + 1); @@ -245,6 +248,7 @@ static int create_stairstep_page(TIFF *tiff_file) uint8_t image_buffer[8192]; int row; int start_pixel; + int i; /* TSB-85 STAIRSTEP page. */ start_pixel = 0; @@ -252,6 +256,13 @@ static int create_stairstep_page(TIFF *tiff_file) { clear_row(image_buffer, 1728); set_pixel_range(image_buffer, 1, start_pixel, start_pixel + 63); + if (reverse_photo_metric) + { + for (i = 0; i < 1728/8; i++) + image_buffer[i] = ~image_buffer[i]; + } + if (reverse_fill_order) + bit_reverse(image_buffer, image_buffer, 1728/8); if (TIFFWriteScanline(tiff_file, image_buffer, row, 0) < 0) { printf("Write error at row %d.\n", row); @@ -571,9 +582,14 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); - TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); - + if (reverse_photo_metric) + TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); + else + TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); + if (reverse_fill_order) + TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); + else + TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); x_resolution = sequence[i].x_res/100.0f; y_resolution = sequence[i].y_res/100.0f; TIFFSetField(tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*2.54f + 0.5f)); diff --git a/libs/spandsp/test-data/itu/fax/Makefile.am b/libs/spandsp/test-data/itu/fax/Makefile.am index d873dd6a4c..2ea7793e08 100644 --- a/libs/spandsp/test-data/itu/fax/Makefile.am +++ b/libs/spandsp/test-data/itu/fax/Makefile.am @@ -16,72 +16,93 @@ ## License along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -## $Id: Makefile.am,v 1.3 2008/05/03 13:05:04 steveu Exp $ +## $Id: Makefile.am,v 1.4 2009/02/20 12:34:20 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) PBM2G3 = pbmtog3 FAX2TIFF = fax2tiff +TIFFCP = tiffcp -EXTRA_DIST = itu1.pbm \ - itu2.pbm \ - itu3.pbm \ - itu4.pbm \ - itu5.pbm \ - itu6.pbm \ - itu7.pbm \ - itu8.pbm \ - test1.pbm \ - test2.pbm \ - test3.pbm \ - test4.pbm +ITU_TEST_PAGES_PBM = itu1.pbm \ + itu2.pbm \ + itu3.pbm \ + itu4.pbm \ + itu5.pbm \ + itu6.pbm \ + itu7.pbm \ + itu8.pbm \ + test1.pbm \ + test2.pbm \ + test3.pbm \ + test4.pbm + +ITU_TEST_PAGES_G3 = itu1.g3 \ + itu2.g3 \ + itu3.g3 \ + itu4.g3 \ + itu5.g3 \ + itu6.g3 \ + itu7.g3 \ + itu8.g3 \ + test1.g3 \ + test2.g3 \ + test3.g3 \ + test4.g3 + +ITU_TEST_PAGES = itu1.tif \ + itu2.tif \ + itu3.tif \ + itu4.tif \ + itu5.tif \ + itu6.tif \ + itu7.tif \ + itu8.tif \ + test1.tif \ + test2.tif \ + test3.tif \ + test4.tif + +MIXED_SIZE_PAGES = R1200_1200_A4.tif \ + R1200_1200_B4.tif \ + R1200_1200_A3.tif \ + R600_1200_A4.tif \ + R600_1200_B4.tif \ + R600_1200_A3.tif \ + R600_600_A4.tif \ + R600_600_B4.tif \ + R600_600_A3.tif \ + R16_800_A4.tif \ + R16_800_B4.tif \ + R16_800_A3.tif \ + R16_154_A4.tif \ + R16_154_B4.tif \ + R16_154_A3.tif \ + R300_600_A4.tif \ + R300_600_B4.tif \ + R300_600_A3.tif \ + R300_300_A4.tif \ + R300_300_B4.tif \ + R300_300_A3.tif \ + R8_154_A4.tif \ + R8_154_B4.tif \ + R8_154_A3.tif \ + R8_77_A4.tif \ + R8_77_B4.tif \ + R8_77_A3.tif \ + R8_385_A4.tif \ + R8_385_B4.tif \ + R8_385_A3.tif + +EXTRA_DIST = ${ITU_TEST_PAGES_PBM} nobase_data_DATA = itutests.tif \ - itu1.tif \ - itu2.tif \ - itu3.tif \ - itu4.tif \ - itu5.tif \ - itu6.tif \ - itu7.tif \ - itu8.tif \ - test1.tif \ - test2.tif \ - test3.tif \ - test4.tif \ + ${ITU_TEST_PAGES} \ dithered.tif \ 100pages.tif \ - R1200_1200_A4.tif \ - R1200_1200_B4.tif \ - R1200_1200_A3.tif \ - R600_1200_A4.tif \ - R600_1200_B4.tif \ - R600_1200_A3.tif \ - R600_600_A4.tif \ - R600_600_B4.tif \ - R600_600_A3.tif \ - R16_800_A4.tif \ - R16_800_B4.tif \ - R16_800_A3.tif \ - R16_154_A3.tif \ - R16_154_A4.tif \ - R16_154_B4.tif \ - R300_600_A4.tif \ - R300_600_B4.tif \ - R300_600_A3.tif \ - R300_300_A4.tif \ - R300_300_B4.tif \ - R300_300_A3.tif \ - R8_154_A3.tif \ - R8_154_A4.tif \ - R8_154_B4.tif \ - R8_77_A3.tif \ - R8_77_A4.tif \ - R8_77_B4.tif \ - R8_385_A3.tif \ - R8_385_A4.tif \ - R8_385_B4.tif + ${MIXED_SIZE_PAGES} \ + mixed_size_pages.tif noinst_PROGRAMS = generate_dithered_tif \ generate_sized_pages @@ -95,22 +116,19 @@ generate_sized_pages_LDADD = -ltiff clean: rm -f *.tif *.g3 -itutests.tif: itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 \ - test1.g3 test2.g3 test3.g3 test4.g3 - $(FAX2TIFF) -M -o $@ itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 \ - test1.g3 test2.g3 test3.g3 test4.g3 +itutests.tif: ${ITU_TEST_PAGES_G3} + $(FAX2TIFF) -M -o $@ ${ITU_TEST_PAGES_G3} -100pages.tif: itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 \ - test1.g3 test2.g3 test3.g3 test4.g3 +100pages.tif: ${ITU_TEST_PAGES_G3} $(FAX2TIFF) -M -o $@ \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ - itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 test1.g3 test2.g3 test3.g3 test4.g3 \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ + ${ITU_TEST_PAGES_G3} \ itu1.g3 itu2.g3 itu3.g3 itu4.g3 .g3.tif: @@ -122,34 +140,8 @@ itutests.tif: itu1.g3 itu2.g3 itu3.g3 itu4.g3 itu5.g3 itu6.g3 itu7.g3 itu8.g3 \ dithered.tif: generate_dithered_tif$(EXEEXT) ./generate_dithered_tif$(EXEEXT) -R1200_1200_A4.tif \ -R1200_1200_B4.tif \ -R1200_1200_A3.tif \ -R600_1200_A4.tif \ -R600_1200_B4.tif \ -R600_1200_A3.tif \ -R600_600_A4.tif \ -R600_600_B4.tif \ -R600_600_A3.tif \ -R16_800_A4.tif \ -R16_800_B4.tif \ -R16_800_A3.tif \ -R16_154_A3.tif \ -R16_154_A4.tif \ -R16_154_B4.tif \ -R300_600_A4.tif \ -R300_600_B4.tif \ -R300_600_A3.tif \ -R300_300_A4.tif \ -R300_300_B4.tif \ -R300_300_A3.tif \ -R8_154_A3.tif \ -R8_154_A4.tif \ -R8_154_B4.tif \ -R8_77_A3.tif \ -R8_77_A4.tif \ -R8_77_B4.tif \ -R8_385_A3.tif \ -R8_385_A4.tif \ -R8_385_B4.tif: generate_sized_pages$(EXEEXT) +${MIXED_SIZE_PAGES}: generate_sized_pages$(EXEEXT) ./generate_sized_pages$(EXEEXT) + +mixed_size_pages.tif: ${MIXED_SIZE_PAGES} + $(TIFFCP) ${MIXED_SIZE_PAGES} $@ diff --git a/libs/spandsp/tests/Makefile.am b/libs/spandsp/tests/Makefile.am index a75aef348e..7deec1247d 100644 --- a/libs/spandsp/tests/Makefile.am +++ b/libs/spandsp/tests/Makefile.am @@ -16,7 +16,7 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -## $Id: Makefile.am,v 1.109 2009/01/30 05:35:18 steveu Exp $ +## $Id: Makefile.am,v 1.110 2009/02/20 12:34:20 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) @@ -165,7 +165,7 @@ echo_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspand fax_decode_SOURCES = fax_decode.c fax_decode_LDADD = $(LIBDIR) -lspandsp -fax_tests_SOURCES = fax_tests.c +fax_tests_SOURCES = fax_tests.c fax_utils.c fax_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp fsk_tests_SOURCES = fsk_tests.c @@ -255,25 +255,25 @@ super_tone_tx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR t4_tests_SOURCES = t4_tests.c t4_tests_LDADD = $(LIBDIR) -lspandsp -t31_tests_SOURCES = t31_tests.c media_monitor.cpp +t31_tests_SOURCES = t31_tests.c fax_utils.c media_monitor.cpp t31_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp t38_core_tests_SOURCES = t38_core_tests.c t38_core_tests_LDADD = $(LIBDIR) -lspandsp -t38_gateway_tests_SOURCES = t38_gateway_tests.c media_monitor.cpp +t38_gateway_tests_SOURCES = t38_gateway_tests.c fax_utils.c media_monitor.cpp t38_gateway_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp -t38_gateway_to_terminal_tests_SOURCES = t38_gateway_to_terminal_tests.c media_monitor.cpp +t38_gateway_to_terminal_tests_SOURCES = t38_gateway_to_terminal_tests.c fax_utils.c media_monitor.cpp t38_gateway_to_terminal_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp t38_non_ecm_buffer_tests_SOURCES = t38_non_ecm_buffer_tests.c t38_non_ecm_buffer_tests_LDADD = $(LIBDIR) -lspandsp -t38_terminal_tests_SOURCES = t38_terminal_tests.c media_monitor.cpp +t38_terminal_tests_SOURCES = t38_terminal_tests.c fax_utils.c media_monitor.cpp t38_terminal_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp -t38_terminal_to_gateway_tests_SOURCES = t38_terminal_to_gateway_tests.c media_monitor.cpp +t38_terminal_to_gateway_tests_SOURCES = t38_terminal_to_gateway_tests.c fax_utils.c media_monitor.cpp t38_terminal_to_gateway_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp time_scale_tests_SOURCES = time_scale_tests.c @@ -285,7 +285,7 @@ tone_detect_tests_LDADD = $(LIBDIR) -lspandsp tone_generate_tests_SOURCES = tone_generate_tests.c tone_generate_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp -tsb85_tests_SOURCES = tsb85_tests.c fax_tester.c +tsb85_tests_SOURCES = tsb85_tests.c fax_utils.c fax_tester.c tsb85_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp v17_tests_SOURCES = v17_tests.c line_model_monitor.cpp modem_monitor.cpp diff --git a/libs/spandsp/tests/fax_tests.c b/libs/spandsp/tests/fax_tests.c index 11c1ad4d9a..2ce9c3b11a 100644 --- a/libs/spandsp/tests/fax_tests.c +++ b/libs/spandsp/tests/fax_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: fax_tests.c,v 1.100 2009/01/03 14:44:15 steveu Exp $ + * $Id: fax_tests.c,v 1.101 2009/02/20 12:34:20 steveu Exp $ */ /*! \page fax_tests_page FAX tests @@ -48,6 +48,8 @@ #include "spandsp.h" #include "spandsp-sim.h" +#include "fax_utils.h" + #define SAMPLES_PER_CHUNK 160 #define INPUT_TIFF_FILE_NAME "../test-data/itu/fax/itutests.tif" @@ -77,22 +79,12 @@ int t30_state_to_wreck = -1; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { int i; - const char *u; - - i = (intptr_t) user_data; - if ((u = t30_get_rx_ident(s))) - printf("%d: Phase B: remote ident '%s'\n", i, u); - if ((u = t30_get_rx_sub_address(s))) - printf("%d: Phase B: remote sub-address '%s'\n", i, u); - if ((u = t30_get_rx_polled_sub_address(s))) - printf("%d: Phase B: remote polled sub-address '%s'\n", i, u); - if ((u = t30_get_rx_selective_polling_address(s))) - printf("%d: Phase B: remote selective polling address '%s'\n", i, u); - if ((u = t30_get_rx_sender_ident(s))) - printf("%d: Phase B: remote sender ident '%s'\n", i, u); - if ((u = t30_get_rx_password(s))) - printf("%d: Phase B: remote password '%s'\n", i, u); - printf("%d: Phase B handler on channel %d - (0x%X) %s\n", i, i, result, t30_frametype(result)); + char tag[20]; + + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase B:", i); + printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -100,31 +92,14 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; - i = (intptr_t) user_data; - t30_get_transfer_statistics(s, &t); - - printf("%d: Phase D handler on channel %d - (0x%X) %s\n", i, i, result, t30_frametype(result)); - printf("%d: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%d: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%d: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%d: Phase D: pages in the file %d\n", i, t.pages_in_file); - printf("%d: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%d: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%d: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%d: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%d: Phase D: bad ECM frames %d\n", i, t.error_correcting_mode_retries); - printf("%d: Phase D: compression type %d\n", i, t.encoding); - printf("%d: Phase D: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%d: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%d: Phase D: remote ident '%s'\n", i, u); -#if defined(WITH_SPANDSP_INTERNALS) - printf("%d: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); -#endif + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase D:", i); + printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); if (use_receiver_not_ready) t30_set_receiver_not_ready(s, 3); @@ -160,34 +135,17 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; t30_stats_t t; - const char *u; - + char tag[20]; + i = (intptr_t) user_data; - printf("%d: Phase E handler on channel %d - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + snprintf(tag, sizeof(tag), "%c: Phase E:", i); + printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); t30_get_transfer_statistics(s, &t); - printf("%d: Phase E: bit rate %d\n", i, t.bit_rate); - printf("%d: Phase E: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%d: Phase E: pages transferred %d\n", i, t.pages_transferred); - printf("%d: Phase E: pages in the file %d\n", i, t.pages_in_file); - printf("%d: Phase E: image size %d x %d\n", i, t.width, t.length); - printf("%d: Phase E: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%d: Phase E: bad rows %d\n", i, t.bad_rows); - printf("%d: Phase E: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%d: Phase E: bad ECM frames %d\n", i, t.error_correcting_mode_retries); - printf("%d: Phase E: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%d: Phase E: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%d: Phase E: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%d: Phase E: remote ident '%s'\n", i, u); - if ((u = t30_get_rx_country(s))) - printf("%d: Phase E: Remote was made in '%s'\n", i, u); - if ((u = t30_get_rx_vendor(s))) - printf("%d: Phase E: Remote was made by '%s'\n", i, u); - if ((u = t30_get_rx_model(s))) - printf("%d: Phase E: Remote is model '%s'\n", i, u); - machines[i].succeeded = (result == T30_ERR_OK) && (t.pages_transferred == 12); - machines[i].done = TRUE; + machines[i - 'A'].succeeded = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12); + machines[i - 'A'].done = TRUE; } /*- End of function --------------------------------------------------------*/ @@ -200,7 +158,7 @@ static void real_time_frame_handler(t30_state_t *s, int i; i = (intptr_t) user_data; - printf("%d: Real time frame handler on channel %d - %s, %s, length = %d\n", + printf("%c: Real time frame handler on channel %c - %s, %s, length = %d\n", i, i, (direction) ? "line->T.30" : "T.30->line", @@ -214,7 +172,7 @@ static int document_handler(t30_state_t *s, void *user_data, int event) int i; i = (intptr_t) user_data; - printf("%d: Document handler on channel %d - event %d\n", i, i, event); + printf("%c: Document handler on channel %c - event %d\n", i, i, event); return FALSE; } /*- End of function --------------------------------------------------------*/ @@ -419,6 +377,7 @@ int main(int argc, char *argv[]) { sprintf(buf, "fax_tests_%d.tif", (mc->chan + 1)/2); t30_set_rx_file(t30, buf, -1); + t30_set_rx_encoding(t30, T4_COMPRESSION_ITU_T6); } } else @@ -427,6 +386,7 @@ int main(int argc, char *argv[]) { sprintf(buf, "fax_tests_%d.tif", (mc->chan + 1)/2); t30_set_rx_file(t30, buf, -1); + t30_set_rx_encoding(t30, T4_COMPRESSION_ITU_T6); } else { @@ -436,16 +396,18 @@ int main(int argc, char *argv[]) t30_set_tx_file(t30, input_tiff_file_name, -1, -1); } } - t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) mc->chan); - t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) mc->chan); - t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) mc->chan); - t30_set_real_time_frame_handler(t30, real_time_frame_handler, (void *) (intptr_t) mc->chan); - t30_set_document_handler(t30, document_handler, (void *) (intptr_t) mc->chan); + t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) mc->chan + 'A'); + t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) mc->chan + 'A'); + t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) mc->chan + 'A'); + t30_set_real_time_frame_handler(t30, real_time_frame_handler, (void *) (intptr_t) mc->chan + 'A'); + t30_set_document_handler(t30, document_handler, (void *) (intptr_t) mc->chan + 'A'); sprintf(mc->tag, "FAX-%d", j + 1); logging = t30_get_logging_state(t30); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); span_log_set_tag(logging, mc->tag); + span_log_set_level(&t30->t4.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); + span_log_set_tag(&t30->t4.logging, mc->tag); logging = fax_get_logging_state(mc->fax); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); diff --git a/libs/spandsp/tests/fax_utils.c b/libs/spandsp/tests/fax_utils.c new file mode 100644 index 0000000000..6219035364 --- /dev/null +++ b/libs/spandsp/tests/fax_utils.c @@ -0,0 +1,111 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * fax_utils.c + * + * Written by Steve Underwood + * + * Copyright (C) 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: fax_utils.c,v 1.1 2009/02/20 12:34:20 steveu Exp $ + */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +//#if defined(WITH_SPANDSP_INTERNALS) +#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES +//#endif + +#include "spandsp.h" +#include "spandsp-sim.h" +#include "fax_utils.h" + +void log_tx_parameters(t30_state_t *s, const char *tag) +{ + const char *u; + + if ((u = t30_get_tx_ident(s))) + printf("%s: Local ident '%s'\n", tag, u); + if ((u = t30_get_tx_sub_address(s))) + printf("%s: Local sub-address '%s'\n", tag, u); + if ((u = t30_get_tx_polled_sub_address(s))) + printf("%s: Local polled sub-address '%s'\n", tag, u); + if ((u = t30_get_tx_selective_polling_address(s))) + printf("%s: Local selective polling address '%s'\n", tag, u); + if ((u = t30_get_tx_sender_ident(s))) + printf("%s: Local sender ident '%s'\n", tag, u); + if ((u = t30_get_tx_password(s))) + printf("%s: Local password '%s'\n", tag, u); +} +/*- End of function --------------------------------------------------------*/ + +void log_rx_parameters(t30_state_t *s, const char *tag) +{ + const char *u; + + if ((u = t30_get_rx_ident(s))) + printf("%s: Remote ident '%s'\n", tag, u); + if ((u = t30_get_rx_sub_address(s))) + printf("%s: Remote sub-address '%s'\n", tag, u); + if ((u = t30_get_rx_polled_sub_address(s))) + printf("%s: Remote polled sub-address '%s'\n", tag, u); + if ((u = t30_get_rx_selective_polling_address(s))) + printf("%s: Remote selective polling address '%s'\n", tag, u); + if ((u = t30_get_rx_sender_ident(s))) + printf("%s: Remote sender ident '%s'\n", tag, u); + if ((u = t30_get_rx_password(s))) + printf("%s: Remote password '%s'\n", tag, u); + if ((u = t30_get_rx_country(s))) + printf("%s: Remote was made in '%s'\n", tag, u); + if ((u = t30_get_rx_vendor(s))) + printf("%s: Remote was made by '%s'\n", tag, u); + if ((u = t30_get_rx_model(s))) + printf("%s: Remote is model '%s'\n", tag, u); +} +/*- End of function --------------------------------------------------------*/ + +void log_transfer_statistics(t30_state_t *s, const char *tag) +{ + t30_stats_t t; + + t30_get_transfer_statistics(s, &t); + printf("%s: bit rate %d\n", tag, t.bit_rate); + printf("%s: ECM %s\n", tag, (t.error_correcting_mode) ? "on" : "off"); + printf("%s: pages tx %d, pages rx %d\n", tag, t.pages_tx, t.pages_rx); + printf("%s: pages in the file %d\n", tag, t.pages_in_file); + printf("%s: image size %d x %d\n", tag, t.width, t.length); + printf("%s: image resolution %d x %d\n", tag, t.x_resolution, t.y_resolution); + printf("%s: bad rows %d, longest bad row run %d\n", tag, t.bad_rows, t.longest_bad_row_run); + printf("%s: bad ECM frames %d\n", tag, t.error_correcting_mode_retries); + printf("%s: compression type %d\n", tag, t.encoding); + printf("%s: image size %d bytes\n", tag, t.image_size); +#if defined(WITH_SPANDSP_INTERNALS) + printf("%s: bits per row - min %d, max %d\n", tag, s->t4.min_row_bits, s->t4.max_row_bits); +#endif +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t31_tests.c b/libs/spandsp/tests/t31_tests.c index 099a5254d5..f96b9bec9e 100644 --- a/libs/spandsp/tests/t31_tests.c +++ b/libs/spandsp/tests/t31_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t31_tests.c,v 1.70 2009/02/02 13:05:28 steveu Exp $ + * $Id: t31_tests.c,v 1.71 2009/02/20 12:38:37 steveu Exp $ */ /*! \file */ @@ -61,14 +61,18 @@ #if defined(ENABLE_GUI) #include "media_monitor.h" #endif +#include "fax_utils.h" #define INPUT_FILE_NAME "../test-data/itu/fax/itu1.tif" #define OUTPUT_FILE_NAME "t31.tif" #define OUTPUT_WAVE_FILE_NAME "t31_tests.wav" -#define DLE 0x10 -#define ETX 0x03 -#define SUB 0x1A +enum +{ + ETX = 0x03, + DLE = 0x10, + SUB = 0x1A +}; #define MANUFACTURER "www.soft-switch.org" @@ -91,6 +95,7 @@ double when = 0.0; #define RESPONSE(b) {"", 0, b, sizeof(b) - 1} #define FAST_RESPONSE(b) {NULL, -1, b, sizeof(b) - 1} #define FAST_SEND(b) {(const char *) 1, -2, b, sizeof(b) - 1} +#define FAST_SEND_TCF(b) {(const char *) 2, -2, b, sizeof(b) - 1} static const struct command_response_s fax_send_test_seq[] = { @@ -121,7 +126,7 @@ static const struct command_response_s fax_send_test_seq[] = EXCHANGE("AT+FTS=8\r", "\r\nOK\r\n"), EXCHANGE("AT+FTM=96\r", "\r\nCONNECT\r\n"), // - FAST_SEND("\r\nOK\r\n"), + FAST_SEND_TCF("\r\nOK\r\n"), EXCHANGE("AT+FRH=3\r", "\r\nCONNECT\r\n"), // RESPONSE("\xFF\x13\x84\xEA\x7D\x10\x03"), @@ -206,9 +211,12 @@ t31_state_t *t31_state; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { int i; - + char tag[20]; + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase B:", i); printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -216,28 +224,14 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase D:", i); printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); - t30_get_transfer_statistics(s, &t); - printf("%c: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase D: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase D: image size %d\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase D: remote ident '%s'\n", i, u); -#if defined(WITH_SPANDSP_INTERNALS) - printf("%c: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); -#endif + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -245,9 +239,14 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; + char tag[20]; i = (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase E:", i); printf("Phase E handler on channel %c\n", i); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); //exit(0); } /*- End of function --------------------------------------------------------*/ @@ -404,6 +403,7 @@ static int t38_tests(int use_gui, int test_sending, int model_no, int speed_patt { t38_terminal_state_t *t38_state; int fast_send; + int fast_send_tcf; int fast_blocks; uint8_t fast_buf[1000]; int msg_len; @@ -417,6 +417,7 @@ static int t38_tests(int use_gui, int test_sending, int model_no, int speed_patt t30_state_t *t30; t38_core_state_t *t38_core; logging_state_t *logging; + int i; t38_version = 1; without_pacing = FALSE; @@ -503,6 +504,7 @@ static int t38_tests(int use_gui, int test_sending, int model_no, int speed_patt span_log_set_tag(logging, "T.38"); fast_send = FALSE; + fast_send_tcf = TRUE; fast_blocks = 0; kick = TRUE; #if defined(ENABLE_GUI) @@ -535,7 +537,7 @@ static int t38_tests(int use_gui, int test_sending, int model_no, int speed_patt if (kick) { kick = FALSE; - if (fax_test_seq[test_seq_ptr].command > (const char *) 1) + if (fax_test_seq[test_seq_ptr].command > (const char *) 2) { if (fax_test_seq[test_seq_ptr].command[0]) { @@ -545,15 +547,52 @@ static int t38_tests(int use_gui, int test_sending, int model_no, int speed_patt } else { - printf("Fast send\n"); - fast_send = TRUE; - fast_blocks = 100; + if (fax_test_seq[test_seq_ptr].command == (const char *) 2) + { + printf("Fast send TCF\n"); + fast_send = TRUE; + fast_send_tcf = TRUE; + fast_blocks = 100; + } + else + { + printf("Fast send image\n"); + fast_send = TRUE; + fast_send_tcf = FALSE; + fast_blocks = 100; + } } } if (fast_send) { /* Send fast modem data */ - memset(fast_buf, 0, 36); + if (fast_send_tcf) + { + memset(fast_buf, 0, 36); + } + else + { + if (fast_blocks == 1) + { + /* Create the end of page condition */ + for (i = 0; i < 36; i += 2) + { + fast_buf[i] = 0x00; + fast_buf[i + 1] = 0x80; + } + } + else + { + /* Create a chunk of white page */ + for (i = 0; i < 36; i += 4) + { + fast_buf[i] = 0x00; + fast_buf[i + 1] = 0x80; + fast_buf[i + 2] = 0xB2; + fast_buf[i + 3] = 0x01; + } + } + } if (fast_blocks == 1) { /* Insert EOLs */ @@ -625,10 +664,12 @@ static int t30_tests(int log_audio, int test_sending) AFfilehandle wave_handle; AFfilehandle in_handle; int fast_send; + int fast_send_tcf; int fast_blocks; uint8_t fast_buf[1000]; t30_state_t *t30; logging_state_t *logging; + int i; wave_handle = AF_NULL_FILEHANDLE; if (log_audio) @@ -694,6 +735,7 @@ static int t30_tests(int log_audio, int test_sending) span_log_set_tag(logging, "FAX"); fast_send = FALSE; + fast_send_tcf = TRUE; fast_blocks = 0; kick = TRUE; while (!done) @@ -701,7 +743,7 @@ static int t30_tests(int log_audio, int test_sending) if (kick) { kick = FALSE; - if (fax_test_seq[test_seq_ptr].command > (const char *) 1) + if (fax_test_seq[test_seq_ptr].command > (const char *) 2) { if (fax_test_seq[test_seq_ptr].command[0]) { @@ -711,15 +753,52 @@ static int t30_tests(int log_audio, int test_sending) } else { - printf("Fast send\n"); - fast_send = TRUE; - fast_blocks = 100; + if (fax_test_seq[test_seq_ptr].command == (const char *) 2) + { + printf("Fast send TCF\n"); + fast_send = TRUE; + fast_send_tcf = TRUE; + fast_blocks = 100; + } + else + { + printf("Fast send image\n"); + fast_send = TRUE; + fast_send_tcf = FALSE; + fast_blocks = 100; + } } } if (fast_send) { /* Send fast modem data */ - memset(fast_buf, 0, 36); + if (fast_send_tcf) + { + memset(fast_buf, 0, 36); + } + else + { + if (fast_blocks == 1) + { + /* Create the end of page condition */ + for (i = 0; i < 36; i += 2) + { + fast_buf[i] = 0x00; + fast_buf[i + 1] = 0x80; + } + } + else + { + /* Create a chunk of white page */ + for (i = 0; i < 36; i += 4) + { + fast_buf[i] = 0x00; + fast_buf[i + 1] = 0x80; + fast_buf[i + 2] = 0xB2; + fast_buf[i + 3] = 0x01; + } + } + } if (fast_blocks == 1) { /* Insert EOLs */ @@ -780,6 +859,9 @@ static int t30_tests(int log_audio, int test_sending) if (fax_rx(fax_state, t31_amp, SAMPLES_PER_CHUNK)) break; + span_log_bump_samples(&fax_state->logging, SAMPLES_PER_CHUNK); + span_log_bump_samples(&t30->logging, SAMPLES_PER_CHUNK); + if (log_audio) { outframes = afWriteFrames(wave_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK); diff --git a/libs/spandsp/tests/t38_gateway_tests.c b/libs/spandsp/tests/t38_gateway_tests.c index 06c789a9a1..4f62168b69 100644 --- a/libs/spandsp/tests/t38_gateway_tests.c +++ b/libs/spandsp/tests/t38_gateway_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_gateway_tests.c,v 1.79 2009/01/07 12:50:53 steveu Exp $ + * $Id: t38_gateway_tests.c,v 1.80 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -73,6 +73,7 @@ These tests exercise the path #if defined(ENABLE_GUI) #include "media_monitor.h" #endif +#include "fax_utils.h" #define SAMPLES_PER_CHUNK 160 @@ -102,9 +103,12 @@ int simulate_incrementing_repeats = FALSE; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { int i; - + char tag[20]; + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase B:", i); printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -112,28 +116,14 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase D:", i); printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); - t30_get_transfer_statistics(s, &t); - printf("%c: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase D: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase D: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase D: remote ident '%s'\n", i, u); -#if defined(WITH_SPANDSP_INTERNALS) - printf("%c: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); -#endif + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -142,25 +132,16 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase E:", i); printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); t30_get_transfer_statistics(s, &t); - printf("%c: Phase E: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase E: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase E: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase E: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase E: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase E: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase E: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase E: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase E: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase E: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase E: remote ident '%s'\n", i, u); - succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_transferred == 12); + succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12); done[i - 'A'] = TRUE; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t38_gateway_to_terminal_tests.c b/libs/spandsp/tests/t38_gateway_to_terminal_tests.c index 7d0bc8b4d0..cedaed446d 100644 --- a/libs/spandsp/tests/t38_gateway_to_terminal_tests.c +++ b/libs/spandsp/tests/t38_gateway_to_terminal_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_gateway_to_terminal_tests.c,v 1.63 2009/01/07 12:50:53 steveu Exp $ + * $Id: t38_gateway_to_terminal_tests.c,v 1.64 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -73,6 +73,7 @@ These tests exercise the path #if defined(ENABLE_GUI) #include "media_monitor.h" #endif +#include "fax_utils.h" #define SAMPLES_PER_CHUNK 160 @@ -97,9 +98,12 @@ int simulate_incrementing_repeats = FALSE; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { int i; - + char tag[20]; + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase B:", i); printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -107,28 +111,14 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase D:", i); printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); - t30_get_transfer_statistics(s, &t); - printf("%c: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase D: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase D: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase D: remote ident '%s'\n", i, u); -#if defined(WITH_SPANDSP_INTERNALS) - printf("%c: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); -#endif + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -137,25 +127,16 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase E:", i); printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); t30_get_transfer_statistics(s, &t); - printf("%c: Phase E: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase E: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase E: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase E: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase E: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase E: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase E: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase E: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase E: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase E: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase E: remote ident '%s'\n", i, u); - succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_transferred == 12); + succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12); done[i - 'A'] = TRUE; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t38_terminal_tests.c b/libs/spandsp/tests/t38_terminal_tests.c index 655e86cbd7..e6735d3e01 100644 --- a/libs/spandsp/tests/t38_terminal_tests.c +++ b/libs/spandsp/tests/t38_terminal_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_terminal_tests.c,v 1.64 2009/01/07 12:50:53 steveu Exp $ + * $Id: t38_terminal_tests.c,v 1.65 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -73,6 +73,7 @@ These tests exercise the path #if defined(ENABLE_GUI) #include "media_monitor.h" #endif +#include "fax_utils.h" #define SAMPLES_PER_CHUNK 160 @@ -95,9 +96,12 @@ int simulate_incrementing_repeats = FALSE; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { int i; - + char tag[20]; + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase B:", i); printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -105,28 +109,14 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase D:", i); printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); - t30_get_transfer_statistics(s, &t); - printf("%c: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase D: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase D: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase D: remote ident '%s'\n", i, u); -#if defined(WITH_SPANDSP_INTERNALS) - printf("%c: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); -#endif + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -135,25 +125,16 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; t30_stats_t t; - const char *u; - + char tag[20]; + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase E:", i); printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); t30_get_transfer_statistics(s, &t); - printf("%c: Phase E: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase E: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase E: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase E: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase E: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase E: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase E: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase E: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase E: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase E: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase E: remote ident '%s'\n", i, u); - succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_transferred == 12); + succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12); //done[i - 'A'] = TRUE; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t38_terminal_to_gateway_tests.c b/libs/spandsp/tests/t38_terminal_to_gateway_tests.c index ff35f36ec7..438121483b 100644 --- a/libs/spandsp/tests/t38_terminal_to_gateway_tests.c +++ b/libs/spandsp/tests/t38_terminal_to_gateway_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_terminal_to_gateway_tests.c,v 1.62 2009/01/07 12:50:53 steveu Exp $ + * $Id: t38_terminal_to_gateway_tests.c,v 1.63 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -73,6 +73,7 @@ These tests exercise the path #if defined(ENABLE_GUI) #include "media_monitor.h" #endif +#include "fax_utils.h" #define SAMPLES_PER_CHUNK 160 @@ -97,9 +98,12 @@ int simulate_incrementing_repeats = FALSE; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { int i; - + char tag[20]; + i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase B:", i); printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -107,28 +111,14 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase D:", i); printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); - t30_get_transfer_statistics(s, &t); - printf("%c: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase D: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase D: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase D: remote ident '%s'\n", i, u); -#if defined(WITH_SPANDSP_INTERNALS) - printf("%c: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); -#endif + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); return T30_ERR_OK; } /*- End of function --------------------------------------------------------*/ @@ -137,25 +127,16 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; t30_stats_t t; - const char *u; + char tag[20]; i = (int) (intptr_t) user_data; + snprintf(tag, sizeof(tag), "%c: Phase E:", i); printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); t30_get_transfer_statistics(s, &t); - printf("%c: Phase E: bit rate %d\n", i, t.bit_rate); - printf("%c: Phase E: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%c: Phase E: pages transferred %d\n", i, t.pages_transferred); - printf("%c: Phase E: image size %d x %d\n", i, t.width, t.length); - printf("%c: Phase E: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%c: Phase E: bad rows %d\n", i, t.bad_rows); - printf("%c: Phase E: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%c: Phase E: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%c: Phase E: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%c: Phase E: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%c: Phase E: remote ident '%s'\n", i, u); - succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_transferred == 12); + succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12); done[i - 'A'] = TRUE; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t4_tests.c b/libs/spandsp/tests/t4_tests.c index ed1370afa0..275d2d459d 100644 --- a/libs/spandsp/tests/t4_tests.c +++ b/libs/spandsp/tests/t4_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t4_tests.c,v 1.66 2009/02/10 13:06:47 steveu Exp $ + * $Id: t4_tests.c,v 1.67 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) printf("Failed to init T.4 rx\n"); exit(2); } - + span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); t4_rx_set_rx_encoding(&receive_state, compression); t4_rx_set_x_resolution(&receive_state, T4_X_RESOLUTION_R8); //t4_rx_set_y_resolution(&receive_state, T4_Y_RESOLUTION_FINE); @@ -365,6 +365,7 @@ int main(int argc, char *argv[]) printf("Failed to init T.4 send\n"); exit(2); } + span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); t4_tx_set_min_row_bits(&send_state, min_row_bits); t4_tx_set_local_ident(&send_state, "111 2222 3333"); @@ -374,6 +375,7 @@ int main(int argc, char *argv[]) printf("Failed to init T.4 rx\n"); exit(2); } + span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state)); t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state)); t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state)); @@ -521,6 +523,7 @@ int main(int argc, char *argv[]) printf("Failed to init T.4 tx\n"); exit(2); } + span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); t4_tx_set_row_read_handler(&send_state, row_read_handler, NULL); t4_tx_set_min_row_bits(&send_state, min_row_bits); t4_tx_set_local_ident(&send_state, "111 2222 3333"); @@ -531,6 +534,7 @@ int main(int argc, char *argv[]) printf("Failed to init T.4 rx\n"); exit(2); } + span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); t4_rx_set_row_write_handler(&receive_state, row_write_handler, NULL); t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state)); t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state)); diff --git a/libs/spandsp/tests/tsb85_tests.c b/libs/spandsp/tests/tsb85_tests.c index b06c8e4a77..a7bccf1632 100644 --- a/libs/spandsp/tests/tsb85_tests.c +++ b/libs/spandsp/tests/tsb85_tests.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: tsb85_tests.c,v 1.29 2009/02/10 13:06:47 steveu Exp $ + * $Id: tsb85_tests.c,v 1.30 2009/02/20 12:34:20 steveu Exp $ */ /*! \file */ @@ -67,6 +67,7 @@ #include "spandsp-sim.h" #include "fax_tester.h" +#include "fax_utils.h" #define OUTPUT_TIFF_FILE_NAME "tsb85.tif" @@ -107,10 +108,10 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) status = T30_ERR_OK; if ((u = t30_get_rx_ident(s))) { - printf("%d: Phase B: remote ident '%s'\n", i, u); + printf("%c: Phase B: remote ident '%s'\n", i, u); if (expected_rx_info.ident[0] && strcmp(expected_rx_info.ident, u)) { - printf("%d: Phase B: remote ident incorrect! - expected '%s'\n", i, expected_rx_info.ident); + printf("%c: Phase B: remote ident incorrect! - expected '%s'\n", i, expected_rx_info.ident); status = T30_ERR_IDENT_UNACCEPTABLE; } } @@ -118,16 +119,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { if (expected_rx_info.ident[0]) { - printf("%d: Phase B: remote ident missing!\n", i); + printf("%c: Phase B: remote ident missing!\n", i); status = T30_ERR_IDENT_UNACCEPTABLE; } } if ((u = t30_get_rx_sub_address(s))) { - printf("%d: Phase B: remote sub-address '%s'\n", i, u); + printf("%c: Phase B: remote sub-address '%s'\n", i, u); if (expected_rx_info.sub_address[0] && strcmp(expected_rx_info.sub_address, u)) { - printf("%d: Phase B: remote sub-address incorrect! - expected '%s'\n", i, expected_rx_info.sub_address); + printf("%c: Phase B: remote sub-address incorrect! - expected '%s'\n", i, expected_rx_info.sub_address); status = T30_ERR_SUB_UNACCEPTABLE; } } @@ -135,16 +136,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { if (expected_rx_info.sub_address[0]) { - printf("%d: Phase B: remote sub-address missing!\n", i); + printf("%c: Phase B: remote sub-address missing!\n", i); status = T30_ERR_SUB_UNACCEPTABLE; } } if ((u = t30_get_rx_polled_sub_address(s))) { - printf("%d: Phase B: remote polled sub-address '%s'\n", i, u); + printf("%c: Phase B: remote polled sub-address '%s'\n", i, u); if (expected_rx_info.polled_sub_address[0] && strcmp(expected_rx_info.polled_sub_address, u)) { - printf("%d: Phase B: remote polled sub-address incorrect! - expected '%s'\n", i, expected_rx_info.polled_sub_address); + printf("%c: Phase B: remote polled sub-address incorrect! - expected '%s'\n", i, expected_rx_info.polled_sub_address); status = T30_ERR_PSA_UNACCEPTABLE; } } @@ -152,16 +153,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { if (expected_rx_info.polled_sub_address[0]) { - printf("%d: Phase B: remote polled sub-address missing!\n", i); + printf("%c: Phase B: remote polled sub-address missing!\n", i); status = T30_ERR_PSA_UNACCEPTABLE; } } if ((u = t30_get_rx_selective_polling_address(s))) { - printf("%d: Phase B: remote selective polling address '%s'\n", i, u); + printf("%c: Phase B: remote selective polling address '%s'\n", i, u); if (expected_rx_info.selective_polling_address[0] && strcmp(expected_rx_info.selective_polling_address, u)) { - printf("%d: Phase B: remote selective polling address incorrect! - expected '%s'\n", i, expected_rx_info.selective_polling_address); + printf("%c: Phase B: remote selective polling address incorrect! - expected '%s'\n", i, expected_rx_info.selective_polling_address); status = T30_ERR_SEP_UNACCEPTABLE; } } @@ -169,16 +170,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { if (expected_rx_info.selective_polling_address[0]) { - printf("%d: Phase B: remote selective polling address missing!\n", i); + printf("%c: Phase B: remote selective polling address missing!\n", i); status = T30_ERR_SEP_UNACCEPTABLE; } } if ((u = t30_get_rx_sender_ident(s))) { - printf("%d: Phase B: remote sender ident '%s'\n", i, u); + printf("%c: Phase B: remote sender ident '%s'\n", i, u); if (expected_rx_info.sender_ident[0] && strcmp(expected_rx_info.sender_ident, u)) { - printf("%d: Phase B: remote sender ident incorrect! - expected '%s'\n", i, expected_rx_info.sender_ident); + printf("%c: Phase B: remote sender ident incorrect! - expected '%s'\n", i, expected_rx_info.sender_ident); status = T30_ERR_SID_UNACCEPTABLE; } } @@ -186,16 +187,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { if (expected_rx_info.sender_ident[0]) { - printf("%d: Phase B: remote sender ident missing!\n", i); + printf("%c: Phase B: remote sender ident missing!\n", i); status = T30_ERR_SID_UNACCEPTABLE; } } if ((u = t30_get_rx_password(s))) { - printf("%d: Phase B: remote password '%s'\n", i, u); + printf("%c: Phase B: remote password '%s'\n", i, u); if (expected_rx_info.password[0] && strcmp(expected_rx_info.password, u)) { - printf("%d: Phase B: remote password incorrect! - expected '%s'\n", i, expected_rx_info.password); + printf("%c: Phase B: remote password incorrect! - expected '%s'\n", i, expected_rx_info.password); status = T30_ERR_PWD_UNACCEPTABLE; } } @@ -203,11 +204,11 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) { if (expected_rx_info.password[0]) { - printf("%d: Phase B: remote password missing!\n", i); + printf("%c: Phase B: remote password missing!\n", i); status = T30_ERR_PWD_UNACCEPTABLE; } } - printf("%d: Phase B handler on channel %d - (0x%X) %s\n", i, i, result, t30_frametype(result)); + printf("%c: Phase B handler on channel %d - (0x%X) %s\n", i, i, result, t30_frametype(result)); return status; } /*- End of function --------------------------------------------------------*/ @@ -215,37 +216,24 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (intptr_t) user_data; - t30_get_transfer_statistics(s, &t); + snprintf(tag, sizeof(tag), "%c: Phase D:", i); - printf("%d: Phase D handler on channel %d - (0x%X) %s\n", i, i, result, t30_frametype(result)); - printf("%d: Phase D: bit rate %d\n", i, t.bit_rate); - printf("%d: Phase D: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%d: Phase D: pages transferred %d\n", i, t.pages_transferred); - printf("%d: Phase D: pages in the file %d\n", i, t.pages_in_file); - printf("%d: Phase D: image size %d x %d\n", i, t.width, t.length); - printf("%d: Phase D: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%d: Phase D: bad rows %d\n", i, t.bad_rows); - printf("%d: Phase D: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%d: Phase D: compression type %d\n", i, t.encoding); - printf("%d: Phase D: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%d: Phase D: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%d: Phase D: remote ident '%s'\n", i, u); - printf("%d: Phase D: bits per row - min %d, max %d\n", i, s->t4.min_row_bits, s->t4.max_row_bits); + printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); if (use_receiver_not_ready) t30_set_receiver_not_ready(s, 3); if (test_local_interrupt) { - if (i == 0) + if (i == 'A') { - printf("%d: Initiating interrupt request\n", i); + printf("%c: Initiating interrupt request\n", i); t30_local_interrupt_request(s, TRUE); } else @@ -256,7 +244,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) case T30_PRI_MPS: case T30_PRI_EOM: case T30_PRI_EOP: - printf("%d: Accepting interrupt request\n", i); + printf("%c: Accepting interrupt request\n", i); t30_local_interrupt_request(s, TRUE); break; case T30_PIN: @@ -271,32 +259,14 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) static void phase_e_handler(t30_state_t *s, void *user_data, int result) { int i; - t30_stats_t t; - const char *u; + char tag[20]; i = (intptr_t) user_data; - printf("%d: Phase E handler on channel %d - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); - t30_get_transfer_statistics(s, &t); - printf("%d: Phase E: bit rate %d\n", i, t.bit_rate); - printf("%d: Phase E: ECM %s\n", i, (t.error_correcting_mode) ? "on" : "off"); - printf("%d: Phase E: pages transferred %d\n", i, t.pages_transferred); - printf("%d: Phase E: pages in the file %d\n", i, t.pages_in_file); - printf("%d: Phase E: image size %d x %d\n", i, t.width, t.length); - printf("%d: Phase E: image resolution %d x %d\n", i, t.x_resolution, t.y_resolution); - printf("%d: Phase E: bad rows %d\n", i, t.bad_rows); - printf("%d: Phase E: longest bad row run %d\n", i, t.longest_bad_row_run); - printf("%d: Phase E: coding method %s\n", i, t4_encoding_to_str(t.encoding)); - printf("%d: Phase E: image size %d bytes\n", i, t.image_size); - if ((u = t30_get_tx_ident(s))) - printf("%d: Phase E: local ident '%s'\n", i, u); - if ((u = t30_get_rx_ident(s))) - printf("%d: Phase E: remote ident '%s'\n", i, u); - if ((u = t30_get_rx_country(s))) - printf("%d: Phase E: Remote was made in '%s'\n", i, u); - if ((u = t30_get_rx_vendor(s))) - printf("%d: Phase E: Remote was made by '%s'\n", i, u); - if ((u = t30_get_rx_model(s))) - printf("%d: Phase E: Remote is model '%s'\n", i, u); + snprintf(tag, sizeof(tag), "%c: Phase E:", i); + printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); + log_transfer_statistics(s, tag); + log_tx_parameters(s, tag); + log_rx_parameters(s, tag); } /*- End of function --------------------------------------------------------*/ @@ -439,11 +409,11 @@ static void fax_prepare(void) | T30_SUPPORT_600_1200_RESOLUTION); t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); - t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 1); - t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 1); - t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 1); - t30_set_real_time_frame_handler(t30, t30_real_time_frame_handler, (void *) (intptr_t) 1); - t30_set_document_handler(t30, document_handler, (void *) (intptr_t) 1); + t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'A'); + t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A'); + t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A'); + t30_set_real_time_frame_handler(t30, t30_real_time_frame_handler, (void *) (intptr_t) 'A'); + t30_set_document_handler(t30, document_handler, (void *) (intptr_t) 'A'); logging = fax_get_logging_state(fax); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);