mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-11 15:07:07 +00:00
Another round of tweaks for spandsp. There should be no functional changes,
although quite a few things have changed in the test suite
This commit is contained in:
parent
d30e82e226
commit
4a7bbf4ec6
@ -69,6 +69,8 @@ SPAN_DECLARE(SNDFILE *) sf_open_telephony_read(const char *name, int channels);
|
||||
|
||||
SPAN_DECLARE(SNDFILE *) sf_open_telephony_write(const char *name, int channels);
|
||||
|
||||
SPAN_DECLARE(int) sf_close_telephony(SNDFILE *handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -70,6 +70,16 @@ static int circle_init = FALSE;
|
||||
static complex_t icircle[MAX_FFT_LEN/2];
|
||||
static int icircle_init = FALSE;
|
||||
|
||||
#define SF_MAX_HANDLE 32
|
||||
static int sf_close_at_exit_registered = FALSE;
|
||||
static SNDFILE *sf_close_at_exit_list[SF_MAX_HANDLE] =
|
||||
{
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
SPAN_DECLARE(complexify_state_t *) complexify_init(void)
|
||||
{
|
||||
complexify_state_t *s;
|
||||
@ -349,6 +359,42 @@ SPAN_DECLARE(void) codec_munge(codec_munge_state_t *s, int16_t amp[], int len)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void sf_close_at_exit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SF_MAX_HANDLE; i++)
|
||||
{
|
||||
if (sf_close_at_exit_list[i])
|
||||
{
|
||||
sf_close(sf_close_at_exit_list[i]);
|
||||
sf_close_at_exit_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int sf_record_handle(SNDFILE *handle)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SF_MAX_HANDLE; i++)
|
||||
{
|
||||
if (sf_close_at_exit_list[i] == NULL)
|
||||
break;
|
||||
}
|
||||
if (i >= SF_MAX_HANDLE)
|
||||
return -1;
|
||||
sf_close_at_exit_list[i] = handle;
|
||||
if (!sf_close_at_exit_registered)
|
||||
{
|
||||
atexit(sf_close_at_exit);
|
||||
sf_close_at_exit_registered = TRUE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(SNDFILE *) sf_open_telephony_read(const char *name, int channels)
|
||||
{
|
||||
SNDFILE *handle;
|
||||
@ -370,7 +416,7 @@ SPAN_DECLARE(SNDFILE *) sf_open_telephony_read(const char *name, int channels)
|
||||
printf(" Unexpected number of channels in audio file '%s'\n", name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
sf_record_handle(handle);
|
||||
return handle;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -393,8 +439,29 @@ SPAN_DECLARE(SNDFILE *) sf_open_telephony_write(const char *name, int channels)
|
||||
fprintf(stderr, " Cannot open audio file '%s' for writing\n", name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
sf_record_handle(handle);
|
||||
return handle;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(int) sf_close_telephony(SNDFILE *handle)
|
||||
{
|
||||
int res;
|
||||
int i;
|
||||
|
||||
if ((res = sf_close(handle)) == 0)
|
||||
{
|
||||
for (i = 0; i < SF_MAX_HANDLE; i++)
|
||||
{
|
||||
if (sf_close_at_exit_list[i] == handle)
|
||||
{
|
||||
sf_close(sf_close_at_exit_list[i]);
|
||||
sf_close_at_exit_list[i] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
|
@ -5311,7 +5311,7 @@ static const char *at_cmd_plus_WSTL(at_state_t *s, const char *t)
|
||||
|
||||
#include "at_interpreter_dictionary.h"
|
||||
|
||||
static int command_search(const char *u, int len, int *matched)
|
||||
static int command_search(const char *u, int *matched)
|
||||
{
|
||||
int i;
|
||||
int index;
|
||||
@ -5445,7 +5445,7 @@ SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len)
|
||||
t = s->line + 2;
|
||||
while (t && *t)
|
||||
{
|
||||
if ((entry = command_search(t, 15, &matched)) <= 0)
|
||||
if ((entry = command_search(t, &matched)) <= 0)
|
||||
break;
|
||||
if ((t = at_commands[entry - 1](s, t)) == NULL)
|
||||
break;
|
||||
|
@ -144,9 +144,9 @@ static int image_resize_row(image_translate_state_t *s, uint8_t buf[], size_t le
|
||||
int output_length;
|
||||
int input_width;
|
||||
int input_length;
|
||||
int x;
|
||||
double c1;
|
||||
double c2;
|
||||
int x;
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
int frac_row;
|
||||
int frac_col;
|
||||
@ -198,7 +198,7 @@ static int image_resize_row(image_translate_state_t *s, uint8_t buf[], size_t le
|
||||
x = i*input_width/output_width;
|
||||
frac_col = x - x*output_width;
|
||||
c1 = s->raw_pixel_row[0][x] + (s->raw_pixel_row[0][x + 1] - s->raw_pixel_row[0][x])*frac_col;
|
||||
c1 = s->raw_pixel_row[1][x] + (s->raw_pixel_row[1][x + 1] - s->raw_pixel_row[1][x])*frac_col;
|
||||
c2 = s->raw_pixel_row[1][x] + (s->raw_pixel_row[1][x + 1] - s->raw_pixel_row[1][x])*frac_col;
|
||||
buf[i] = saturateu8(c1 + (c2 - c1)*frac_row);
|
||||
}
|
||||
#else
|
||||
|
@ -61,7 +61,7 @@ static __inline__ int32_t arctan2(float y, float x)
|
||||
return 0xc0000000;
|
||||
return 0x40000000;
|
||||
}
|
||||
|
||||
|
||||
abs_y = fabsf(y);
|
||||
|
||||
/* If we are in quadrant II or III, flip things around */
|
||||
|
@ -77,6 +77,8 @@
|
||||
#include <spandsp/private/t4_t6_encode.h>
|
||||
/*#include <spandsp/private/t81_t82_arith_coding.h>*/
|
||||
/*#include <spandsp/private/t85.h>*/
|
||||
/*#include <spandsp/private/t42.h>*/
|
||||
/*#include <spandsp/private/t43.h>*/
|
||||
#include <spandsp/private/t4_rx.h>
|
||||
#include <spandsp/private/t4_tx.h>
|
||||
#include <spandsp/private/t30.h>
|
||||
|
@ -66,7 +66,7 @@
|
||||
#define T30_DCS_BIT_200_200 15
|
||||
|
||||
#define T30_DIS_BIT_2D_CAPABLE 16
|
||||
#define T30_DCS_BIT_2D_CODING 16
|
||||
#define T30_DCS_BIT_2D_MODE 16
|
||||
|
||||
/* Standard facsimile terminals conforming to ITU-T Rec. T.4 must have the following capability:
|
||||
Paper length = 297 mm. */
|
||||
@ -101,7 +101,7 @@
|
||||
#define T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE 35
|
||||
|
||||
#define T30_DIS_BIT_T43_CAPABLE 36
|
||||
#define T30_DCS_BIT_T43_CODING 36
|
||||
#define T30_DCS_BIT_T43_MODE 36
|
||||
|
||||
#define T30_DIS_BIT_PLANE_INTERLEAVE_CAPABLE 37
|
||||
#define T30_DCS_BIT_PLANE_INTERLEAVE 37
|
||||
@ -270,11 +270,11 @@
|
||||
bits 49, 102 and 50 in DCS or bits 47, 101, 50 and 35 in DTC shall be set to "1" with the following
|
||||
meaning:
|
||||
Bit DIS DTC DCS
|
||||
35 Polled SubAddress capability Polled SubAddress transmission Not allowed – set to "0"
|
||||
47 Selective polling capability Selective polling transmission Not allowed – set to "0"
|
||||
35 Polled SubAddress capability Polled SubAddress transmission Not allowed - set to "0"
|
||||
47 Selective polling capability Selective polling transmission Not allowed - set to "0"
|
||||
49 Subaddressing capability Not allowed (Set to "0") Subaddressing transmission
|
||||
50 Password Password transmission Sender Identification transmission
|
||||
101 Internet Selective Polling Address capability Internet Selective Polling Address transmission Not allowed – set to "0"
|
||||
101 Internet Selective Polling Address capability Internet Selective Polling Address transmission Not allowed - set to "0"
|
||||
102 Internet Routing Address capability Not allowed (Set to "0") Internet Routing Address transmission
|
||||
|
||||
Terminals conforming to the 1993 version of T.30 may set the above bits to "0" even though PWD/SEP/SUB
|
||||
|
@ -42,6 +42,10 @@ struct t4_state_s
|
||||
/*! \brief The time at which handling of the current page began. */
|
||||
time_t page_start_time;
|
||||
|
||||
/*! \brief TRUE for FAX page headers to overlay (i.e. replace) the beginning of the
|
||||
page image. FALSE for FAX page headers to add to the overall length of
|
||||
the page. */
|
||||
int header_overlays_image;
|
||||
/*! \brief The text which will be used in FAX page header. No text results
|
||||
in no header line. */
|
||||
const char *header_info;
|
||||
|
@ -86,7 +86,7 @@ struct v17_rx_state_s
|
||||
/*! \brief The register for the data scrambler. */
|
||||
uint32_t scramble_reg;
|
||||
/*! \brief Scrambler tap */
|
||||
//int scrambler_tap;
|
||||
int scrambler_tap;
|
||||
|
||||
/*! \brief TRUE if the short training sequence is to be used. */
|
||||
int short_train;
|
||||
|
@ -58,9 +58,13 @@ struct v17_tx_state_s
|
||||
|
||||
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
complexi16_t rrc_filter[2*V17_TX_FILTER_STEPS];
|
||||
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
|
||||
int16_t rrc_filter_re[V17_TX_FILTER_STEPS];
|
||||
int16_t rrc_filter_im[V17_TX_FILTER_STEPS];
|
||||
#else
|
||||
complexf_t rrc_filter[2*V17_TX_FILTER_STEPS];
|
||||
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
|
||||
float rrc_filter_re[V17_TX_FILTER_STEPS];
|
||||
float rrc_filter_im[V17_TX_FILTER_STEPS];
|
||||
#endif
|
||||
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
|
||||
int rrc_filter_step;
|
||||
@ -75,7 +79,7 @@ struct v17_tx_state_s
|
||||
/*! \brief The register for the data scrambler. */
|
||||
uint32_t scramble_reg;
|
||||
/*! \brief Scrambler tap */
|
||||
//int scrambler_tap;
|
||||
int scrambler_tap;
|
||||
/*! \brief TRUE if transmitting the training sequence. FALSE if transmitting user data. */
|
||||
int in_training;
|
||||
/*! \brief TRUE if the short training sequence is to be used. */
|
||||
|
@ -547,12 +547,10 @@ typedef struct
|
||||
int error_correcting_mode_retries;
|
||||
/*! \brief Current status. */
|
||||
int current_status;
|
||||
#if 0
|
||||
/*! \brief The number of RTP events in this call. */
|
||||
int rtp_events;
|
||||
/*! \brief The number of RTN events in this call. */
|
||||
int rtn_events;
|
||||
#endif
|
||||
} t30_stats_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -144,6 +144,12 @@ SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info);
|
||||
\param info A POSIX timezone description string. */
|
||||
SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring);
|
||||
|
||||
/*! Set page header extends or overlays the image mode.
|
||||
\brief Set page header overlay mode.
|
||||
\param s The T.4 context.
|
||||
\param header_overlays_image TRUE for overlay, or FALSE for extend the page. */
|
||||
SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_state_t *s, int header_overlays_image);
|
||||
|
||||
/*! \brief Set the row read handler for a T.4 transmit context.
|
||||
\param s The T.4 transmit context.
|
||||
\param handler A pointer to the handler routine.
|
||||
|
@ -60,10 +60,18 @@
|
||||
#include "spandsp/v27ter_tx.h"
|
||||
#include "spandsp/t4_rx.h"
|
||||
#include "spandsp/t4_tx.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/t43.h"
|
||||
#endif
|
||||
#include "spandsp/t4_t6_decode.h"
|
||||
#include "spandsp/t4_t6_encode.h"
|
||||
#include "spandsp/t30_fcf.h"
|
||||
@ -73,10 +81,18 @@
|
||||
#include "spandsp/t30_logging.h"
|
||||
|
||||
#include "spandsp/private/logging.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/private/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/private/t43.h"
|
||||
#endif
|
||||
#include "spandsp/private/t4_t6_decode.h"
|
||||
#include "spandsp/private/t4_t6_encode.h"
|
||||
#include "spandsp/private/t4_rx.h"
|
||||
@ -387,6 +403,7 @@ static void repeat_last_command(t30_state_t *s);
|
||||
static void disconnect(t30_state_t *s);
|
||||
static void decode_20digit_msg(t30_state_t *s, char *msg, const uint8_t *pkt, int len);
|
||||
static void decode_url_msg(t30_state_t *s, char *msg, const uint8_t *pkt, int len);
|
||||
static int decode_nsf_nss_nsc(t30_state_t *s, uint8_t *msg[], const uint8_t *pkt, int len);
|
||||
static int set_min_scan_time_code(t30_state_t *s);
|
||||
static int send_cfr_sequence(t30_state_t *s, int start);
|
||||
static void timer_t2_start(t30_state_t *s);
|
||||
@ -1312,6 +1329,19 @@ static int build_dcs(t30_state_t *s)
|
||||
/* Select the compression to use. */
|
||||
switch (s->line_encoding)
|
||||
{
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
case T4_COMPRESSION_ITU_T42:
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_FULL_COLOUR_MODE);
|
||||
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
|
||||
break;
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
case T4_COMPRESSION_ITU_T43:
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T43_MODE);
|
||||
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
|
||||
break;
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
case T4_COMPRESSION_ITU_T85:
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE);
|
||||
clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE);
|
||||
@ -1322,12 +1352,13 @@ static int build_dcs(t30_state_t *s)
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE);
|
||||
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
|
||||
break;
|
||||
#endif
|
||||
case T4_COMPRESSION_ITU_T6:
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T6_MODE);
|
||||
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
|
||||
break;
|
||||
case T4_COMPRESSION_ITU_T4_2D:
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_2D_CODING);
|
||||
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_2D_MODE);
|
||||
set_ctrl_bits(s->dcs_frame, s->min_scan_time_code, 21);
|
||||
break;
|
||||
case T4_COMPRESSION_ITU_T4_1D:
|
||||
@ -1515,7 +1546,7 @@ static int build_dcs(t30_state_t *s)
|
||||
if (bad != T30_ERR_OK)
|
||||
{
|
||||
s->current_status = bad;
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Image width (%d pixels) not an acceptable FAX image width\n", s->image_width);
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Image width (%d pixels) is not an acceptable FAX image width\n", s->image_width);
|
||||
return -1;
|
||||
}
|
||||
switch (s->image_width)
|
||||
@ -1557,7 +1588,7 @@ static int build_dcs(t30_state_t *s)
|
||||
if (bad != T30_ERR_OK)
|
||||
{
|
||||
s->current_status = bad;
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Image width (%d pixels) not an acceptable FAX image width\n", s->image_width);
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Image width (%d pixels) is not an acceptable FAX image width\n", s->image_width);
|
||||
return -1;
|
||||
}
|
||||
/* Deal with the image length */
|
||||
@ -2132,6 +2163,60 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
/* T.4 1D is always available */
|
||||
bi_level_support = T30_SUPPORT_T4_1D_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE))
|
||||
bi_level_support |= T30_SUPPORT_T4_2D_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE))
|
||||
bi_level_support |= T30_SUPPORT_T6_COMPRESSION;
|
||||
/* Bit 79 set with bit 78 clear is invalid, so let's completely ignore 79
|
||||
if 78 is clear. */
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE))
|
||||
{
|
||||
bi_level_support |= T30_SUPPORT_T85_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE)
|
||||
bi_level_support |= T30_SUPPORT_T85_L0_COMPRESSION;
|
||||
}
|
||||
|
||||
gray_support = 0;
|
||||
colour_support = 0;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_200_200_CAPABLE) && test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE))
|
||||
{
|
||||
/* Multi-level coding available */
|
||||
gray_support |= T30_SUPPORT_T81_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE))
|
||||
gray_support |= T30_SUPPORT_T81_12BIT_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE))
|
||||
{
|
||||
gray_support |= T30_SUPPORT_T43_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE))
|
||||
gray_support |= T30_SUPPORT_T43_COMPRESSION_12BIT;
|
||||
}
|
||||
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, bit69))
|
||||
{
|
||||
/* Colour coding available */
|
||||
colour_support |= T30_SUPPORT_T81_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE))
|
||||
colour_support |= T30_SUPPORT_T81_12BIT_COMPRESSION;
|
||||
if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_NO_SUBSAMPLING))
|
||||
{
|
||||
colour_support |= T30_SUPPORT_T81_SUBSAMPLING_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE))
|
||||
colour_support |= T30_SUPPORT_T81_SUBSAMPLING_COMPRESSION_12BIT;
|
||||
}
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE))
|
||||
{
|
||||
colour_support |= T30_SUPPORT_T43_COMPRESSION;
|
||||
if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE))
|
||||
colour_support |= T30_SUPPORT_T43_12BIT_COMPRESSION;
|
||||
}
|
||||
}
|
||||
/* bit74 custom illuminant */
|
||||
/* bit75 custom gamut range */
|
||||
}
|
||||
#endif
|
||||
queue_phase(s, T30_PHASE_B_TX);
|
||||
/* Try to send something */
|
||||
if (s->tx_file[0])
|
||||
@ -2289,7 +2374,7 @@ static int process_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
|
||||
{
|
||||
s->line_encoding = T4_COMPRESSION_ITU_T6;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_2D_CODING))
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_2D_MODE))
|
||||
{
|
||||
s->line_encoding = T4_COMPRESSION_ITU_T4_2D;
|
||||
}
|
||||
@ -4415,11 +4500,13 @@ static void process_rx_control_msg(t30_state_t *s, const uint8_t *msg, int len)
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "The remote was made by '%s'\n", s->vendor);
|
||||
if (s->model)
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "The remote is a '%s'\n", s->model);
|
||||
s->rx_info.nsf_len = decode_nsf_nss_nsc(s, &s->rx_info.nsf, &msg[2], len - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* NSC - Non-standard facilities command */
|
||||
/* OK in (NSC) (CIG) DTC */
|
||||
s->rx_info.nsc_len = decode_nsf_nss_nsc(s, &s->rx_info.nsc, &msg[2], len - 2);
|
||||
}
|
||||
break;
|
||||
case (T30_PWD & 0xFE):
|
||||
@ -4487,6 +4574,7 @@ static void process_rx_control_msg(t30_state_t *s, const uint8_t *msg, int len)
|
||||
break;
|
||||
case (T30_NSS & 0xFE):
|
||||
/* Non-standard facilities set-up */
|
||||
s->rx_info.nss_len = decode_nsf_nss_nsc(s, &s->rx_info.nss, &msg[2], len - 2);
|
||||
break;
|
||||
case (T30_SUB & 0xFE):
|
||||
/* Sub-address */
|
||||
@ -5209,6 +5297,18 @@ static void decode_url_msg(t30_state_t *s, char *msg, const uint8_t *pkt, int le
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int decode_nsf_nss_nsc(t30_state_t *s, uint8_t *msg[], const uint8_t *pkt, int len)
|
||||
{
|
||||
uint8_t *t;
|
||||
|
||||
if ((t = malloc(len - 1)) == NULL)
|
||||
return 0;
|
||||
memcpy(t, pkt + 1, len - 1);
|
||||
*msg = t;
|
||||
return len - 1;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void t30_non_ecm_rx_status(void *user_data, int status)
|
||||
{
|
||||
t30_state_t *s;
|
||||
@ -6175,10 +6275,8 @@ SPAN_DECLARE(void) t30_get_transfer_statistics(t30_state_t *s, t30_stats_t *t)
|
||||
t->encoding = stats.encoding;
|
||||
t->image_size = stats.line_image_size;
|
||||
t->current_status = s->current_status;
|
||||
#if 0
|
||||
t->rtn_events = s->rtn_events;
|
||||
t->rtp_events = s->rtp_events;
|
||||
#endif
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
@ -60,10 +60,18 @@
|
||||
#include "spandsp/v27ter_tx.h"
|
||||
#include "spandsp/t4_rx.h"
|
||||
#include "spandsp/t4_tx.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/t43.h"
|
||||
#endif
|
||||
#include "spandsp/t4_t6_decode.h"
|
||||
#include "spandsp/t4_t6_encode.h"
|
||||
#include "spandsp/t30_fcf.h"
|
||||
@ -73,10 +81,18 @@
|
||||
#include "spandsp/t30_logging.h"
|
||||
|
||||
#include "spandsp/private/logging.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/private/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/private/t43.h"
|
||||
#endif
|
||||
#include "spandsp/private/t4_t6_decode.h"
|
||||
#include "spandsp/private/t4_t6_encode.h"
|
||||
#include "spandsp/private/t4_rx.h"
|
||||
@ -548,10 +564,8 @@ SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *addre
|
||||
|
||||
SPAN_DECLARE(int) t30_set_tx_page_header_overlays_image(t30_state_t *s, int header_overlays_image)
|
||||
{
|
||||
#if 0
|
||||
s->header_overlays_image = header_overlays_image;
|
||||
t4_tx_set_header_overlays_image(&s->t4.tx, s->header_overlays_image);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -686,12 +700,17 @@ SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_c
|
||||
mask = T30_SUPPORT_T4_1D_COMPRESSION
|
||||
| T30_SUPPORT_T4_2D_COMPRESSION
|
||||
| T30_SUPPORT_T6_COMPRESSION
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
| T30_SUPPORT_T42_COMPRESSION
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
| T30_SUPPORT_T43_COMPRESSION
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
| T30_SUPPORT_T85_COMPRESSION
|
||||
| T30_SUPPORT_T85_L0_COMPRESSION;
|
||||
#else
|
||||
| 0;
|
||||
| T30_SUPPORT_T85_L0_COMPRESSION
|
||||
#endif
|
||||
| 0;
|
||||
s->supported_compressions = supported_compressions & mask;
|
||||
t30_build_dis_or_dtc(s);
|
||||
return 0;
|
||||
|
@ -60,10 +60,18 @@
|
||||
#include "spandsp/v27ter_tx.h"
|
||||
#include "spandsp/t4_rx.h"
|
||||
#include "spandsp/t4_tx.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/t43.h"
|
||||
#endif
|
||||
#include "spandsp/t4_t6_decode.h"
|
||||
#include "spandsp/t4_t6_encode.h"
|
||||
#include "spandsp/t30_fcf.h"
|
||||
@ -72,10 +80,18 @@
|
||||
#include "spandsp/t30_logging.h"
|
||||
|
||||
#include "spandsp/private/logging.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/private/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/private/t43.h"
|
||||
#endif
|
||||
#include "spandsp/private/t4_t6_decode.h"
|
||||
#include "spandsp/private/t4_t6_encode.h"
|
||||
#include "spandsp/private/t4_rx.h"
|
||||
|
@ -2167,6 +2167,9 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len)
|
||||
}
|
||||
dle_unstuff(s, t, len);
|
||||
break;
|
||||
case AT_MODE_CONNECTED:
|
||||
/* TODO: Implement for data modem operation */
|
||||
break;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
@ -73,10 +73,18 @@
|
||||
#include "spandsp/modem_connect_tones.h"
|
||||
#include "spandsp/t4_rx.h"
|
||||
#include "spandsp/t4_tx.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/t43.h"
|
||||
#endif
|
||||
#include "spandsp/t4_t6_decode.h"
|
||||
#include "spandsp/t4_t6_encode.h"
|
||||
#include "spandsp/t30_fcf.h"
|
||||
@ -100,10 +108,18 @@
|
||||
#include "spandsp/private/modem_connect_tones.h"
|
||||
#include "spandsp/private/hdlc.h"
|
||||
#include "spandsp/private/fax_modems.h"
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t81_t82_arith_coding.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T85)
|
||||
#include "spandsp/private/t85.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T42)
|
||||
#include "spandsp/private/t42.h"
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
#include "spandsp/private/t43.h"
|
||||
#endif
|
||||
#include "spandsp/private/t4_t6_decode.h"
|
||||
#include "spandsp/private/t4_t6_encode.h"
|
||||
#include "spandsp/private/t4_rx.h"
|
||||
@ -930,7 +946,7 @@ static void monitor_control_messages(t38_gateway_state_t *s,
|
||||
case T30_EOS | 1:
|
||||
#if 0
|
||||
/* If we are hitting one of these conditions, it will take another DCS/DTC to select
|
||||
the fast modem again, so abandon our idea of t. */
|
||||
the fast modem again, so abandon our idea of it. */
|
||||
s->core.fast_bit_rate = 0;
|
||||
s->core.fast_rx_modem = T38_NONE;
|
||||
s->core.image_data_mode = FALSE;
|
||||
|
@ -399,7 +399,7 @@ static void make_header(t4_state_t *s, char *header)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int t4_tx_put_fax_header(t4_state_t *s)
|
||||
static int t4_tx_put_fax_header(t4_state_t *s, int *rows)
|
||||
{
|
||||
int row;
|
||||
int i;
|
||||
@ -435,6 +435,7 @@ static int t4_tx_put_fax_header(t4_state_t *s)
|
||||
repeats = 1;
|
||||
break;
|
||||
}
|
||||
*rows = 16*repeats;
|
||||
for (row = 0; row < 16; row++)
|
||||
{
|
||||
t = header;
|
||||
@ -1285,6 +1286,7 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s)
|
||||
int run_space;
|
||||
int len;
|
||||
int old_image_width;
|
||||
int header_rows;
|
||||
uint8_t *bufptr8;
|
||||
uint32_t *bufptr;
|
||||
|
||||
@ -1336,7 +1338,7 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s)
|
||||
|
||||
if (s->header_info && s->header_info[0])
|
||||
{
|
||||
if (t4_tx_put_fax_header(s))
|
||||
if (t4_tx_put_fax_header(s, &header_rows))
|
||||
return -1;
|
||||
}
|
||||
if (s->t4_t6_tx.row_read_handler)
|
||||
@ -1501,6 +1503,12 @@ SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_state_t *s, int header_overlays_image)
|
||||
{
|
||||
s->header_overlays_image = header_overlays_image;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident)
|
||||
{
|
||||
s->tiff.local_ident = (ident && ident[0]) ? ident : NULL;
|
||||
|
@ -44,6 +44,9 @@
|
||||
|
||||
#include "spandsp/telephony.h"
|
||||
#include "spandsp/logging.h"
|
||||
#include "spandsp/fast_convert.h"
|
||||
#include "spandsp/math_fixed.h"
|
||||
#include "spandsp/saturated.h"
|
||||
#include "spandsp/complex.h"
|
||||
#include "spandsp/vector_float.h"
|
||||
#include "spandsp/complex_vector_float.h"
|
||||
@ -62,13 +65,13 @@
|
||||
#include "spandsp/private/logging.h"
|
||||
#include "spandsp/private/v17rx.h"
|
||||
|
||||
#include "v17_v32bis_tx_constellation_maps.h"
|
||||
#include "v17_v32bis_rx_constellation_maps.h"
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
#include "v17_v32bis_rx_fixed_rrc.h"
|
||||
#else
|
||||
#include "v17_v32bis_rx_floating_rrc.h"
|
||||
#endif
|
||||
#include "v17_v32bis_tx_constellation_maps.h"
|
||||
#include "v17_v32bis_rx_constellation_maps.h"
|
||||
|
||||
/*! The nominal frequency of the carrier, in Hertz */
|
||||
#define CARRIER_NOMINAL_FREQ 1800.0f
|
||||
@ -295,8 +298,7 @@ static int descramble(v17_rx_state_t *s, int in_bit)
|
||||
{
|
||||
int out_bit;
|
||||
|
||||
//out_bit = (in_bit ^ (s->scramble_reg >> s->scrambler_tap) ^ (s->scramble_reg >> (23 - 1))) & 1;
|
||||
out_bit = (in_bit ^ (s->scramble_reg >> (18 - 1)) ^ (s->scramble_reg >> (23 - 1))) & 1;
|
||||
out_bit = (in_bit ^ (s->scramble_reg >> s->scrambler_tap) ^ (s->scramble_reg >> (23 - 1))) & 1;
|
||||
s->scramble_reg <<= 1;
|
||||
if (s->training_stage > TRAINING_STAGE_NORMAL_OPERATION && s->training_stage < TRAINING_STAGE_TCM_WINDUP)
|
||||
s->scramble_reg |= out_bit;
|
||||
@ -1425,7 +1427,7 @@ SPAN_DECLARE(v17_rx_state_t *) v17_rx_init(v17_rx_state_t *s, int bit_rate, put_
|
||||
s->put_bit = put_bit;
|
||||
s->put_bit_user_data = user_data;
|
||||
s->short_train = FALSE;
|
||||
//s->scrambler_tap = 18 - 1;
|
||||
s->scrambler_tap = 18 - 1;
|
||||
v17_rx_signal_cutoff(s, -45.5f);
|
||||
s->carrier_phase_rate_save = dds_phase_ratef(CARRIER_NOMINAL_FREQ);
|
||||
v17_rx_restart(s, bit_rate, s->short_train);
|
||||
|
@ -100,8 +100,7 @@ static __inline__ int scramble(v17_tx_state_t *s, int in_bit)
|
||||
{
|
||||
int out_bit;
|
||||
|
||||
//out_bit = (in_bit ^ (s->scramble_reg >> s->scrambler_tap) ^ (s->scramble_reg >> (23 - 1))) & 1;
|
||||
out_bit = (in_bit ^ (s->scramble_reg >> (18 - 1)) ^ (s->scramble_reg >> (23 - 1))) & 1;
|
||||
out_bit = (in_bit ^ (s->scramble_reg >> s->scrambler_tap) ^ (s->scramble_reg >> (23 - 1))) & 1;
|
||||
s->scramble_reg = (s->scramble_reg << 1) | out_bit;
|
||||
return out_bit;
|
||||
}
|
||||
@ -287,13 +286,16 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s)
|
||||
SPAN_DECLARE_NONSTD(int) v17_tx(v17_tx_state_t *s, int16_t amp[], int len)
|
||||
{
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
complexi_t x;
|
||||
complexi_t z;
|
||||
complexi16_t v;
|
||||
complexi32_t x;
|
||||
complexi32_t z;
|
||||
int16_t iamp;
|
||||
#else
|
||||
complexf_t v;
|
||||
complexf_t x;
|
||||
complexf_t z;
|
||||
float famp;
|
||||
#endif
|
||||
int i;
|
||||
int sample;
|
||||
|
||||
if (s->training_step >= V17_TRAINING_SHUTDOWN_END)
|
||||
@ -306,37 +308,30 @@ SPAN_DECLARE_NONSTD(int) v17_tx(v17_tx_state_t *s, int16_t amp[], int len)
|
||||
if ((s->baud_phase += 3) >= 10)
|
||||
{
|
||||
s->baud_phase -= 10;
|
||||
s->rrc_filter[s->rrc_filter_step] =
|
||||
s->rrc_filter[s->rrc_filter_step + V17_TX_FILTER_STEPS] = getbaud(s);
|
||||
v = getbaud(s);
|
||||
s->rrc_filter_re[s->rrc_filter_step] = v.re;
|
||||
s->rrc_filter_im[s->rrc_filter_step] = v.im;
|
||||
if (++s->rrc_filter_step >= V17_TX_FILTER_STEPS)
|
||||
s->rrc_filter_step = 0;
|
||||
}
|
||||
/* Root raised cosine pulse shaping at baseband */
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
x = complex_seti(0, 0);
|
||||
for (i = 0; i < V17_TX_FILTER_STEPS; i++)
|
||||
{
|
||||
x.re += (int32_t) tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].re;
|
||||
x.im += (int32_t) tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].im;
|
||||
}
|
||||
/* Root raised cosine pulse shaping at baseband */
|
||||
x.re = vec_circular_dot_prodi16(s->rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V17_TX_FILTER_STEPS, s->rrc_filter_step) >> 4;
|
||||
x.im = vec_circular_dot_prodi16(s->rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V17_TX_FILTER_STEPS, s->rrc_filter_step) >> 4;
|
||||
/* Now create and modulate the carrier */
|
||||
x.re >>= 4;
|
||||
x.im >>= 4;
|
||||
z = dds_complexi(&(s->carrier_phase), s->carrier_phase_rate);
|
||||
z = dds_complexi32(&s->carrier_phase, s->carrier_phase_rate);
|
||||
iamp = ((int32_t) x.re*z.re - x.im*z.im) >> 15;
|
||||
/* Don't bother saturating. We should never clip. */
|
||||
i = (x.re*z.re - x.im*z.im) >> 15;
|
||||
amp[sample] = (int16_t) ((i*s->gain) >> 15);
|
||||
amp[sample] = (int16_t) (((int32_t) iamp*s->gain) >> 11);
|
||||
#else
|
||||
x = complex_setf(0.0f, 0.0f);
|
||||
for (i = 0; i < V17_TX_FILTER_STEPS; i++)
|
||||
{
|
||||
x.re += tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].re;
|
||||
x.im += tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].im;
|
||||
}
|
||||
/* Root raised cosine pulse shaping at baseband */
|
||||
x.re = vec_circular_dot_prodf(s->rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V17_TX_FILTER_STEPS, s->rrc_filter_step);
|
||||
x.im = vec_circular_dot_prodf(s->rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V17_TX_FILTER_STEPS, s->rrc_filter_step);
|
||||
/* Now create and modulate the carrier */
|
||||
z = dds_complexf(&(s->carrier_phase), s->carrier_phase_rate);
|
||||
z = dds_complexf(&s->carrier_phase, s->carrier_phase_rate);
|
||||
famp = x.re*z.re - x.im*z.im;
|
||||
/* Don't bother saturating. We should never clip. */
|
||||
amp[sample] = (int16_t) lfastrintf((x.re*z.re - x.im*z.im)*s->gain);
|
||||
amp[sample] = (int16_t) lfastrintf(famp*s->gain);
|
||||
#endif
|
||||
}
|
||||
return sample;
|
||||
@ -345,12 +340,15 @@ SPAN_DECLARE_NONSTD(int) v17_tx(v17_tx_state_t *s, int16_t amp[], int len)
|
||||
|
||||
SPAN_DECLARE(void) v17_tx_power(v17_tx_state_t *s, float power)
|
||||
{
|
||||
float gain;
|
||||
|
||||
/* The constellation design seems to keep the average power the same, regardless
|
||||
of which bit rate is in use. */
|
||||
gain = 0.223f*powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*32768.0f/TX_PULSESHAPER_GAIN;
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
s->gain = 0.223f*powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*16.0f*(32767.0f/30672.52f)*32768.0f/TX_PULSESHAPER_GAIN;
|
||||
s->gain = (int16_t) gain;
|
||||
#else
|
||||
s->gain = 0.223f*powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*32768.0f/TX_PULSESHAPER_GAIN;
|
||||
s->gain = gain;
|
||||
#endif
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -410,9 +408,11 @@ SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int s
|
||||
/* NB: some modems seem to use 3 instead of 1 for long training */
|
||||
s->diff = (short_train) ? 0 : 1;
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
cvec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
|
||||
vec_zeroi16(s->rrc_filter_re, sizeof(s->rrc_filter_re)/sizeof(s->rrc_filter_re[0]));
|
||||
vec_zeroi16(s->rrc_filter_im, sizeof(s->rrc_filter_im)/sizeof(s->rrc_filter_im[0]));
|
||||
#else
|
||||
cvec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
|
||||
vec_zerof(s->rrc_filter_re, sizeof(s->rrc_filter_re)/sizeof(s->rrc_filter_re[0]));
|
||||
vec_zerof(s->rrc_filter_im, sizeof(s->rrc_filter_im)/sizeof(s->rrc_filter_im[0]));
|
||||
#endif
|
||||
s->rrc_filter_step = 0;
|
||||
s->convolution = 0;
|
||||
@ -452,7 +452,7 @@ SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int
|
||||
span_log_set_protocol(&s->logging, "V.17 TX");
|
||||
s->get_bit = get_bit;
|
||||
s->get_bit_user_data = user_data;
|
||||
//s->scrambler_tap = 18 - 1;
|
||||
s->scrambler_tap = 18 - 1;
|
||||
s->carrier_phase_rate = dds_phase_ratef(CARRIER_NOMINAL_FREQ);
|
||||
v17_tx_power(s, -14.0f);
|
||||
v17_tx_restart(s, bit_rate, tep, FALSE);
|
||||
|
@ -713,7 +713,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(int standard)
|
||||
{
|
||||
adsi_rx(rx_adsi, amp, frames);
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
@ -819,7 +819,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
adsi_rx(rx_adsi, amp, len);
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -857,7 +857,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
error = 100.0*(1.0 - sqrt(total/total_samples)/noise_source.rms);
|
||||
printf("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
|
||||
log10(sqrt(total/total_samples)/32768.0)*20.0 + DBM0_MAX_POWER,
|
||||
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) + DBM0_MAX_POWER,
|
||||
j,
|
||||
error,
|
||||
clip_low,
|
||||
|
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
while (len > 0);
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
|
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
|
||||
if (fabs(power_meter_current_dbm0(&meter) + 10.0f) > 0.05f)
|
||||
if (fabs(power_meter_current_dbm0(&meter) + 10.0f) > 0.1f)
|
||||
{
|
||||
printf("Test failed.\n");
|
||||
exit(2);
|
||||
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
|
||||
if (fabs(power_meter_current_dbov(&meter) + 10.0f) > 0.05f)
|
||||
if (fabs(power_meter_current_dbov(&meter) + 10.0f) > 0.1f)
|
||||
{
|
||||
printf("Test failed.\n");
|
||||
exit(2);
|
||||
@ -159,7 +159,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_COMPLEX);
|
||||
exit(2);
|
||||
|
@ -659,7 +659,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
|
||||
hits += len;
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
|
@ -215,7 +215,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
while (len > 0);
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -228,9 +228,9 @@ int echo_can_monitor_line_spectrum_update(const int16_t amp[], int len)
|
||||
{
|
||||
s->spec_re_plot[2*i] = i*4000.0/512.0;
|
||||
#if defined(HAVE_FFTW3_H)
|
||||
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768)) + 3.14;
|
||||
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
|
||||
#else
|
||||
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768)) + 3.14;
|
||||
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
|
||||
#endif
|
||||
}
|
||||
s->spec_re = new Ca_Line(512, s->spec_re_plot, 0, 0, FL_BLUE, CA_NO_POINT);
|
||||
|
@ -212,7 +212,7 @@ static void signal_load(signal_source_t *sig, const char *name)
|
||||
|
||||
static void signal_free(signal_source_t *sig)
|
||||
{
|
||||
if (sf_close(sig->handle) != 0)
|
||||
if (sf_close_telephony(sig->handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
@ -324,7 +324,7 @@ static float level_measurement_device(level_measurement_device_t *dev, int16_t a
|
||||
}
|
||||
if (signal <= 0.0f)
|
||||
return -99.0f;
|
||||
power = DBM0_MAX_POWER + 20.0f*log10f(signal/32767.0f);
|
||||
power = DBM0_MAX_POWER + 20.0f*log10f(signal/32767.0f + 1.0e-10f);
|
||||
if (power > dev->peak)
|
||||
dev->peak = power;
|
||||
return power;
|
||||
@ -368,7 +368,7 @@ static void print_results(void)
|
||||
printf("%-4s %-1d %-5.1f%6.2fs%9.2f%9.2f%9.2f%9.2f%9.2f\n",
|
||||
test_name,
|
||||
chan_model.model_no,
|
||||
20.0f*log10f(-chan_model.erl),
|
||||
20.0f*log10f(-chan_model.erl + 1.0e-10f),
|
||||
0.0f, //test_clock,
|
||||
level_measurement_device_get_peak(rin_power_meter),
|
||||
level_measurement_device_get_peak(rout_power_meter),
|
||||
@ -1559,14 +1559,14 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
|
||||
if (two_channel_file)
|
||||
{
|
||||
sf_close(rxtxfile);
|
||||
sf_close_telephony(rxtxfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
sf_close(txfile);
|
||||
sf_close(rxfile);
|
||||
sf_close_telephony(txfile);
|
||||
sf_close_telephony(rxfile);
|
||||
}
|
||||
sf_close(ecfile);
|
||||
sf_close_telephony(ecfile);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@ -1703,7 +1703,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
match_test_name(argv[i]);
|
||||
}
|
||||
if (sf_close(result_handle) != 0)
|
||||
if (sf_close_telephony(result_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "result_sound.wav");
|
||||
exit(2);
|
||||
@ -1712,7 +1712,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
signal_free(&local_css);
|
||||
signal_free(&far_css);
|
||||
if (sf_close(residue_handle) != 0)
|
||||
if (sf_close_telephony(residue_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", RESIDUE_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -545,7 +545,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
t4_rx_release(&t4_state);
|
||||
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", filename);
|
||||
exit(2);
|
||||
|
@ -26,7 +26,7 @@
|
||||
/*! \file */
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
@ -287,7 +287,7 @@ static void hdlc_rx_status(void *user_data, int status)
|
||||
faxtester_state_t *s;
|
||||
|
||||
s = (faxtester_state_t *) user_data;
|
||||
fprintf(stderr, "HDLC carrier status is %s (%d)\n", signal_status_to_str(status), status);
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "HDLC carrier status is %s (%d)\n", signal_status_to_str(status), status);
|
||||
switch (status)
|
||||
{
|
||||
case SIG_STATUS_TRAINING_FAILED:
|
||||
|
@ -82,7 +82,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -95,9 +95,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
|
||||
if (use_receiver_not_ready)
|
||||
t30_set_receiver_not_ready(s, 3);
|
||||
@ -138,9 +138,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
i = (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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
machines[i - 'A'].succeeded = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
|
||||
machines[i - 'A'].done = TRUE;
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "spandsp-sim.h"
|
||||
#include "fax_utils.h"
|
||||
|
||||
void log_tx_parameters(t30_state_t *s, const char *tag)
|
||||
void fax_log_tx_parameters(t30_state_t *s, const char *tag)
|
||||
{
|
||||
const char *u;
|
||||
|
||||
@ -59,7 +59,7 @@ void log_tx_parameters(t30_state_t *s, const char *tag)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
void log_rx_parameters(t30_state_t *s, const char *tag)
|
||||
void fax_log_rx_parameters(t30_state_t *s, const char *tag)
|
||||
{
|
||||
const char *u;
|
||||
|
||||
@ -84,7 +84,7 @@ void log_rx_parameters(t30_state_t *s, const char *tag)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
void log_transfer_statistics(t30_state_t *s, const char *tag)
|
||||
void fax_log_transfer_statistics(t30_state_t *s, const char *tag)
|
||||
{
|
||||
t30_stats_t t;
|
||||
|
||||
@ -105,4 +105,22 @@ void log_transfer_statistics(t30_state_t *s, const char *tag)
|
||||
#endif
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int get_tiff_total_pages(const char *file)
|
||||
{
|
||||
TIFF *tiff_file;
|
||||
int max;
|
||||
|
||||
if ((tiff_file = TIFFOpen(file, "r")) == NULL)
|
||||
return -1;
|
||||
/* Each page *should* contain the total number of pages, but can this be
|
||||
trusted? Some files say 0. Actually searching for the last page is
|
||||
more reliable. */
|
||||
max = 0;
|
||||
while (TIFFSetDirectory(tiff_file, (tdir_t) max))
|
||||
max++;
|
||||
TIFFClose(tiff_file);
|
||||
return max;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
|
@ -33,11 +33,13 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void log_tx_parameters(t30_state_t *s, const char *tag);
|
||||
void fax_log_tx_parameters(t30_state_t *s, const char *tag);
|
||||
|
||||
void log_rx_parameters(t30_state_t *s, const char *tag);
|
||||
void fax_log_rx_parameters(t30_state_t *s, const char *tag);
|
||||
|
||||
void log_transfer_statistics(t30_state_t *s, const char *tag);
|
||||
void fax_log_transfer_statistics(t30_state_t *s, const char *tag);
|
||||
|
||||
int get_tiff_total_pages(const char *file);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ int main(int argc, char *argv[])
|
||||
fsk_rx(caller_rx, caller_model_amp, samples);
|
||||
}
|
||||
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -519,7 +519,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -73,7 +73,7 @@ static void signal_load(signal_source_t *sig, const char *name)
|
||||
|
||||
static void signal_free(signal_source_t *sig)
|
||||
{
|
||||
if (sf_close(sig->handle) != 0)
|
||||
if (sf_close_telephony(sig->handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
|
@ -324,7 +324,7 @@ static void compliance_tests(int log_audio)
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
@ -486,7 +486,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (encode)
|
||||
{
|
||||
if (sf_close(inhandle))
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
@ -498,7 +498,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (decode)
|
||||
{
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -58,7 +58,7 @@ and the resulting audio stored in post_g722.wav.
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -347,6 +347,58 @@ static void itu_compliance_tests(void)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void signal_to_distortion_tests(void)
|
||||
{
|
||||
g722_encode_state_t enc_state;
|
||||
g722_decode_state_t dec_state;
|
||||
swept_tone_state_t *swept;
|
||||
power_meter_t in_meter;
|
||||
power_meter_t out_meter;
|
||||
int16_t original[1024];
|
||||
uint8_t compressed[1024];
|
||||
int16_t decompressed[1024];
|
||||
int len;
|
||||
int len2;
|
||||
int len3;
|
||||
int i;
|
||||
int32_t in_level;
|
||||
int32_t out_level;
|
||||
|
||||
/* Test a back to back encoder/decoder pair to ensure we comply with Figure 11/G.722 to
|
||||
Figure 16/G.722, Figure A.1/G.722, and Figure A.2/G.722 */
|
||||
g722_encode_init(&enc_state, 64000, 0);
|
||||
g722_decode_init(&dec_state, 64000, 0);
|
||||
power_meter_init(&in_meter, 7);
|
||||
power_meter_init(&out_meter, 7);
|
||||
|
||||
/* First some silence */
|
||||
len = 1024;
|
||||
memset(original, 0, len*sizeof(original[0]));
|
||||
for (i = 0; i < len; i++)
|
||||
in_level = power_meter_update(&in_meter, original[i]);
|
||||
len2 = g722_encode(&enc_state, compressed, original, len);
|
||||
len3 = g722_decode(&dec_state, decompressed, compressed, len2);
|
||||
for (i = 0; i < len3; i++)
|
||||
out_level = power_meter_update(&out_meter, decompressed[i]);
|
||||
printf("Silence produces %d at the output\n", out_level);
|
||||
|
||||
/* Now a swept tone test */
|
||||
swept = swept_tone_init(NULL, 25.0f, 3500.0f, -10.0f, 60*16000, FALSE);
|
||||
do
|
||||
{
|
||||
len = swept_tone(swept, original, 1024);
|
||||
for (i = 0; i < len; i++)
|
||||
in_level = power_meter_update(&in_meter, original[i]);
|
||||
len2 = g722_encode(&enc_state, compressed, original, len);
|
||||
len3 = g722_decode(&dec_state, decompressed, compressed, len2);
|
||||
for (i = 0; i < len3; i++)
|
||||
out_level = power_meter_update(&out_meter, decompressed[i]);
|
||||
printf("%10d, %10d, %f\n", in_level, out_level, (float) out_level/in_level);
|
||||
}
|
||||
while (len > 0);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
g722_encode_state_t enc_state;
|
||||
@ -445,6 +497,7 @@ int main(int argc, char *argv[])
|
||||
if (itutests)
|
||||
{
|
||||
itu_compliance_tests();
|
||||
signal_to_distortion_tests();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ decompressed, and the resulting audio stored in post_g726.wav.
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -1285,12 +1285,12 @@ int main(int argc, char *argv[])
|
||||
frames = g726_decode(&dec_state, amp, adpcmdata, adpcm);
|
||||
outframes = sf_writef_short(outhandle, amp, frames);
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
printf(" Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
printf(" Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -608,12 +608,12 @@ int main(int argc, char *argv[])
|
||||
outframes = sf_writef_short(outhandle, post_amp, frames);
|
||||
}
|
||||
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -182,12 +182,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
outframes = sf_writef_short(outhandle, post_amp, dec_frames);
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -228,9 +228,9 @@ int line_model_monitor_line_spectrum_update(const int16_t amp[], int len)
|
||||
{
|
||||
s->spec_re_plot[2*i] = i*4000.0/512.0;
|
||||
#if defined(HAVE_FFTW3_H)
|
||||
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768)) + 3.14;
|
||||
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
|
||||
#else
|
||||
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768)) + 3.14;
|
||||
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
|
||||
#endif
|
||||
}
|
||||
s->spec_re = new Ca_Line(512, s->spec_re_plot, 0, 0, FL_BLUE, CA_NO_POINT);
|
||||
|
@ -96,7 +96,7 @@ static void complexify_tests(void)
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_COMPLEXIFY);
|
||||
exit(2);
|
||||
@ -174,13 +174,13 @@ static void test_one_way_model(int line_model_no, int speech_test)
|
||||
}
|
||||
if (speech_test)
|
||||
{
|
||||
if (sf_close(inhandle1))
|
||||
if (sf_close_telephony(inhandle1))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME1);
|
||||
exit(2);
|
||||
@ -288,18 +288,18 @@ static void test_both_ways_model(int line_model_no, int speech_test)
|
||||
}
|
||||
if (speech_test)
|
||||
{
|
||||
if (sf_close(inhandle1))
|
||||
if (sf_close_telephony(inhandle1))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(inhandle2))
|
||||
if (sf_close_telephony(inhandle2))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME2);
|
||||
exit(2);
|
||||
@ -313,6 +313,7 @@ static void test_line_filter(int line_model_no)
|
||||
float out;
|
||||
double sumin;
|
||||
double sumout;
|
||||
double gain;
|
||||
int i;
|
||||
int j;
|
||||
int p;
|
||||
@ -353,7 +354,8 @@ static void test_line_filter(int line_model_no)
|
||||
sumout += out*out;
|
||||
}
|
||||
/*endfor*/
|
||||
printf("%7.1f %f\n", swept_tone_current_frequency(s), 10.0*log10(sumout/sumin));
|
||||
gain = (sumin != 0.0) ? 10.0*log10(sumout/sumin + 1.0e-10) : 0.0;
|
||||
printf("%7.1f %f\n", swept_tone_current_frequency(s), gain);
|
||||
}
|
||||
/*endfor*/
|
||||
swept_tone_free(s);
|
||||
|
@ -29,7 +29,7 @@
|
||||
\section lpc10_tests_page_sec_1 What does it do?
|
||||
|
||||
\section lpc10_tests_page_sec_2 How is it used?
|
||||
To perform a general audio quality test, lpc10 should be run. The file ../test-data/local/short_nb_voice.wav
|
||||
To perform a general audio quality test, lpc10 should be run. The file ../test-data/local/dam9.wav
|
||||
will be compressed to LPC10 data, decompressed, and the resulting audio stored in post_lpc10.wav.
|
||||
*/
|
||||
|
||||
@ -220,19 +220,19 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
outframes = sf_writef_short(outhandle, post_amp, dec_len);
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(refhandle) != 0)
|
||||
if (sf_close_telephony(refhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", REF_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -267,7 +267,7 @@ int main(int argc, char *argv[])
|
||||
outframes = sf_writef_short(filehandle, silence_sound, C1_SILENCE_SAMPLES);
|
||||
printf("%d samples of silence\n", C1_SILENCE_SAMPLES);
|
||||
|
||||
if (sf_close(filehandle) != 0)
|
||||
if (sf_close(filehandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "sound_c1.wav");
|
||||
exit(2);
|
||||
@ -333,7 +333,7 @@ int main(int argc, char *argv[])
|
||||
outframes = sf_writef_short(filehandle, silence_sound, C3_SILENCE_SAMPLES);
|
||||
printf("%d samples of silence\n", C3_SILENCE_SAMPLES);
|
||||
|
||||
if (sf_close(filehandle) != 0)
|
||||
if (sf_close(filehandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "sound_c3.wav");
|
||||
exit(2);
|
||||
|
@ -396,7 +396,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
/*endif*/
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
printf(" Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
@ -1374,7 +1374,7 @@ int main(int argc, char *argv[])
|
||||
/*endif*/
|
||||
}
|
||||
/*endwhile*/
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
@ -1417,7 +1417,7 @@ int main(int argc, char *argv[])
|
||||
modem_connect_tones_rx(&ans_pr_rx, amp, frames);
|
||||
}
|
||||
/*endwhile*/
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
|
@ -166,7 +166,7 @@ static void signal_load(signal_source_t *sig, const char *name)
|
||||
|
||||
static void signal_free(signal_source_t *sig)
|
||||
{
|
||||
if (sf_close(sig->handle) != 0)
|
||||
if (sf_close_telephony(sig->handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
@ -386,7 +386,7 @@ int main(int argc, char *argv[])
|
||||
modem_echo_can_free(ctx);
|
||||
signal_free(&local_css);
|
||||
|
||||
if (sf_close(resulthandle) != 0)
|
||||
if (sf_close_telephony(resulthandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "result_sound.wav");
|
||||
exit(2);
|
||||
|
@ -322,10 +322,7 @@ int qam_monitor_update_audio_level(qam_monitor_t *s, const int16_t amp[], int le
|
||||
s->audio_meter->sample(amp[i]/32768.0);
|
||||
s->power_reading += ((amp[i]*amp[i] - s->power_reading) >> 10);
|
||||
}
|
||||
if (s->power_reading <= 0)
|
||||
val = -90.0;
|
||||
else
|
||||
val = log10((double) s->power_reading/(32767.0f*32767.0f))*10.0f + 3.14 + 3.02;
|
||||
val = 10.0*log10((double) s->power_reading/(32767.0*32767.0) + 1.0e-10) + 3.14 + 3.02;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%5.1fdBm0", val);
|
||||
s->audio_level->value(buf);
|
||||
|
@ -104,12 +104,12 @@ int main (int argc, char *argv[])
|
||||
total += ((double) value)*((double) value);
|
||||
}
|
||||
printf ("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
|
||||
log10(sqrt(total/total_samples)/32768.0)*20.0,
|
||||
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10),
|
||||
level,
|
||||
100.0*(1.0 - sqrt(total/total_samples)/(pow(10.0, level/20.0)*32768.0)),
|
||||
clip_low,
|
||||
clip_high);
|
||||
if (level < -5 && fabs(log10(sqrt(total/total_samples)/32768.0)*20.0 - level) > 0.2)
|
||||
if (level < -5 && fabs(10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) - level) > 0.2)
|
||||
{
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
@ -195,12 +195,12 @@ int main (int argc, char *argv[])
|
||||
total += ((double) value)*((double) value);
|
||||
}
|
||||
printf ("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
|
||||
log10(sqrt(total/total_samples)/32768.0)*20.0,
|
||||
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10),
|
||||
level,
|
||||
100.0*(1.0 - sqrt(total/total_samples)/(pow(10.0, level/20.0)*32768.0)),
|
||||
clip_low,
|
||||
clip_high);
|
||||
if (level < -5 && fabs(log10(sqrt(total/total_samples)/32768.0)*20.0 - level) > 0.2)
|
||||
if (level < -5 && fabs(10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) - level) > 0.2)
|
||||
{
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
@ -223,7 +223,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -282,7 +282,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
oki_adpcm_release(oki_enc_state);
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
@ -290,7 +290,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
oki_adpcm_release(oki_dec_state);
|
||||
oki_adpcm_release(oki_dec_state2);
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -36,7 +36,6 @@ extern "C"
|
||||
typedef int (pcap_timing_update_handler_t)(void *user_data, struct timeval *ts);
|
||||
typedef int (pcap_packet_handler_t)(void *user_data, const uint8_t *pkt, int len);
|
||||
|
||||
|
||||
int pcap_scan_pkts(const char *file,
|
||||
uint32_t src_addr,
|
||||
uint16_t src_port,
|
||||
|
@ -205,12 +205,12 @@ printf("len = %d\n", len);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -165,13 +165,13 @@ int main(int argc, char *argv[])
|
||||
printf("Dropped %d of %d blocks\n", lost_blocks, block_no);
|
||||
if (tone < 0)
|
||||
{
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -33,7 +33,7 @@ Both tones and noise are used to check the meter's behaviour.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -145,7 +145,11 @@ static int power_surge_detector_tests(void)
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
sf_close(outhandle);
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
printf("Min on %d, max on %d, min off %d, max off %d\n", extremes[0], extremes[1], extremes[2], extremes[3]);
|
||||
return 0;
|
||||
}
|
||||
@ -168,7 +172,7 @@ static int power_surge_detector_file_test(const char *file)
|
||||
|
||||
if ((inhandle = sf_open_telephony_read(file, 1)) == NULL)
|
||||
{
|
||||
printf(" Cannot open speech file '%s'\n", file);
|
||||
printf(" Cannot open audio file '%s'\n", file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@ -202,8 +206,16 @@ static int power_surge_detector_file_test(const char *file)
|
||||
sf_writef_short(outhandle, amp_out, inframes);
|
||||
sample += inframes;
|
||||
}
|
||||
sf_close(inhandle);
|
||||
sf_close(outhandle);
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", file);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -102,7 +102,7 @@ int main(int argc, char *argv[])
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
|
@ -295,10 +295,7 @@ static void map_frequency_response(sig_tone_rx_state_t *s, template_t template[]
|
||||
sumout += (double) buf[i]*(double) buf[i];
|
||||
/*endfor*/
|
||||
freq = swept_tone_current_frequency(swept);
|
||||
if (sumin)
|
||||
gain = 10.0*log10(sumout/sumin);
|
||||
else
|
||||
gain = 0.0;
|
||||
gain = (sumin != 0.0) ? 10.0*log10(sumout/sumin + 1.0e-10) : 0.0;
|
||||
printf("%7.1f Hz %.3f dBm0 < %.3f dBm0 < %.3f dBm0\n",
|
||||
freq,
|
||||
template[template_entry].min_level,
|
||||
@ -367,7 +364,7 @@ static void speech_immunity_tests(sig_tone_rx_state_t *s)
|
||||
sig_tone_rx(s, amp, frames);
|
||||
}
|
||||
/*endwhile*/
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
@ -509,7 +506,7 @@ static void sequence_tests(sig_tone_tx_state_t *tx_state, sig_tone_rx_state_t *r
|
||||
/*endif*/
|
||||
}
|
||||
/*endfor*/
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -405,7 +405,7 @@ int main(int argc, char *argv[])
|
||||
sample += x;
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle))
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
@ -427,7 +427,7 @@ int main(int argc, char *argv[])
|
||||
sample += x;
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
|
@ -62,7 +62,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Test with swept tone.\n");
|
||||
s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, 1);
|
||||
s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, TRUE);
|
||||
for (j = 0; j < 60*SAMPLE_RATE; j += BLOCK_LEN)
|
||||
{
|
||||
len = swept_tone(s, buf, BLOCK_LEN);
|
||||
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -282,7 +282,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -295,9 +295,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -310,9 +310,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
//exit(0);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -942,7 +942,7 @@ static int t30_tests(int log_audio, int test_sending)
|
||||
}
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (sf_close(in_handle) != 0)
|
||||
if (sf_close_telephony(in_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -950,7 +950,7 @@ static int t30_tests(int log_audio, int test_sending)
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(wave_handle) != 0)
|
||||
if (sf_close_telephony(wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -31,7 +31,7 @@ These tests exercise the T.38 core ASN.1 processing code.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Written by Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
* Copyright (C) 2009 Steve Underwood
|
||||
* Copyright (C) 2010 Steve Underwood
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -21,12 +21,13 @@
|
||||
* 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.
|
||||
*
|
||||
* Some code from SIPP (http://sf.net/projects/sipp) was used as a model
|
||||
* for how to work with PCAP files. That code was authored by Guillaume
|
||||
* TEISSIER from FTR&D 02/02/2006, and released under the GPL2 licence.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
/* Enable the following definition to enable direct probing into the FAX structures */
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
@ -43,17 +44,38 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
//#endif
|
||||
|
||||
#include "udptl.h"
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#include "fax_utils.h"
|
||||
#include "pcap_parse.h"
|
||||
|
||||
#define INPUT_FILE_NAME "t38.pcap"
|
||||
#define OUTPUT_FILE_NAME "t38pcap.tif"
|
||||
#define INPUT_TIFF_FILE_NAME "../test-data/itu/fax/itutests.tif"
|
||||
#define OUTPUT_TIFF_FILE_NAME "t38pcap.tif"
|
||||
|
||||
t38_terminal_state_t *t38_state;
|
||||
struct timeval now;
|
||||
#define OUTPUT_WAVE_FILE_NAME "t38_decode2.wav"
|
||||
|
||||
#define SAMPLES_PER_CHUNK 160
|
||||
|
||||
static t38_core_state_t *t38_core;
|
||||
static t38_terminal_state_t *t38_terminal_state;
|
||||
static t38_gateway_state_t *t38_gateway_state;
|
||||
static fax_state_t *fax_state;
|
||||
static struct timeval now;
|
||||
static SNDFILE *wave_handle;
|
||||
|
||||
static int log_audio;
|
||||
static int use_transmit_on_idle;
|
||||
static int done = FALSE;
|
||||
|
||||
static int started = FALSE;
|
||||
static int64_t current = 0;
|
||||
|
||||
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
{
|
||||
@ -63,7 +85,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -76,9 +98,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -92,9 +114,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -105,14 +127,12 @@ static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int timing_update(void *user_data, struct timeval *ts)
|
||||
static int t38_terminal_timing_update(void *user_data, struct timeval *ts)
|
||||
{
|
||||
t30_state_t *t30;
|
||||
t38_core_state_t *t38_core;
|
||||
logging_state_t *logging;
|
||||
int samples;
|
||||
int partial;
|
||||
static int64_t current = 0;
|
||||
int64_t when;
|
||||
int64_t diff;
|
||||
|
||||
@ -120,24 +140,125 @@ static int timing_update(void *user_data, struct timeval *ts)
|
||||
|
||||
when = ts->tv_sec*1000000LL + ts->tv_usec;
|
||||
if (current == 0)
|
||||
current = when;
|
||||
{
|
||||
if (started)
|
||||
current = when;
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff = when - current;
|
||||
samples = diff/125LL;
|
||||
while (samples > 0)
|
||||
{
|
||||
partial = (samples > 160) ? 160 : samples;
|
||||
partial = (samples > SAMPLES_PER_CHUNK) ? SAMPLES_PER_CHUNK : samples;
|
||||
//fprintf(stderr, "Update time by %d samples\n", partial);
|
||||
logging = t38_terminal_get_logging_state(t38_state);
|
||||
logging = t38_terminal_get_logging_state(t38_terminal_state);
|
||||
span_log_bump_samples(logging, partial);
|
||||
t38_core = t38_terminal_get_t38_core_state(t38_state);
|
||||
logging = t38_core_get_logging_state(t38_core);
|
||||
span_log_bump_samples(logging, partial);
|
||||
t30 = t38_terminal_get_t30_state(t38_state);
|
||||
t30 = t38_terminal_get_t30_state(t38_terminal_state);
|
||||
logging = t30_get_logging_state(t30);
|
||||
span_log_bump_samples(logging, partial);
|
||||
|
||||
t38_terminal_send_timeout(t38_terminal_state, partial);
|
||||
current = when;
|
||||
samples -= partial;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int t38_gateway_timing_update(void *user_data, struct timeval *ts)
|
||||
{
|
||||
t30_state_t *t30;
|
||||
logging_state_t *logging;
|
||||
int samples;
|
||||
int partial;
|
||||
int64_t when;
|
||||
int64_t diff;
|
||||
int16_t t38_amp[SAMPLES_PER_CHUNK];
|
||||
int16_t t30_amp[SAMPLES_PER_CHUNK];
|
||||
int16_t out_amp[2*SAMPLES_PER_CHUNK];
|
||||
int t38_len;
|
||||
int t30_len;
|
||||
int outframes;
|
||||
int i;
|
||||
|
||||
memcpy(&now, ts, sizeof(now));
|
||||
|
||||
when = ts->tv_sec*1000000LL + ts->tv_usec;
|
||||
if (current == 0)
|
||||
{
|
||||
if (started)
|
||||
current = when;
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff = when - current;
|
||||
samples = diff/125LL;
|
||||
while (samples > 0)
|
||||
{
|
||||
partial = (samples > SAMPLES_PER_CHUNK) ? SAMPLES_PER_CHUNK : samples;
|
||||
//fprintf(stderr, "Update time by %d samples\n", partial);
|
||||
logging = t38_gateway_get_logging_state(t38_gateway_state);
|
||||
span_log_bump_samples(logging, partial);
|
||||
logging = t38_core_get_logging_state(t38_core);
|
||||
span_log_bump_samples(logging, partial);
|
||||
logging = fax_get_logging_state(fax_state);
|
||||
span_log_bump_samples(logging, partial);
|
||||
t30 = fax_get_t30_state(fax_state);
|
||||
logging = t30_get_logging_state(t30);
|
||||
span_log_bump_samples(logging, partial);
|
||||
|
||||
memset(out_amp, 0, sizeof(out_amp));
|
||||
|
||||
t30_len = fax_tx(fax_state, t30_amp, partial);
|
||||
if (!use_transmit_on_idle)
|
||||
{
|
||||
/* The receive side always expects a full block of samples, but the
|
||||
transmit side may not be sending any when it doesn't need to. We
|
||||
may need to pad with some silence. */
|
||||
if (t30_len < partial)
|
||||
{
|
||||
memset(t30_amp + t30_len, 0, sizeof(int16_t)*(partial - t30_len));
|
||||
t30_len = partial;
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
for (i = 0; i < t30_len; i++)
|
||||
out_amp[2*i + 1] = t30_amp[i];
|
||||
}
|
||||
if (t38_gateway_rx(t38_gateway_state, t30_amp, t30_len))
|
||||
break;
|
||||
|
||||
t38_terminal_send_timeout(t38_state, partial);
|
||||
t38_len = t38_gateway_tx(t38_gateway_state, t38_amp, partial);
|
||||
if (!use_transmit_on_idle)
|
||||
{
|
||||
if (t38_len < partial)
|
||||
{
|
||||
memset(t38_amp + t38_len, 0, sizeof(int16_t)*(partial - t38_len));
|
||||
t38_len = partial;
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
for (i = 0; i < t38_len; i++)
|
||||
out_amp[2*i] = t38_amp[i];
|
||||
}
|
||||
if (fax_rx(fax_state, t38_amp, partial))
|
||||
break;
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = sf_writef_short(wave_handle, out_amp, partial);
|
||||
if (outframes != partial)
|
||||
break;
|
||||
}
|
||||
|
||||
if (done)
|
||||
break;
|
||||
|
||||
current = when;
|
||||
samples -= partial;
|
||||
}
|
||||
@ -147,15 +268,15 @@ static int timing_update(void *user_data, struct timeval *ts)
|
||||
|
||||
static int ifp_handler(void *user_data, const uint8_t msg[], int len, int seq_no)
|
||||
{
|
||||
t38_core_state_t *t38_core;
|
||||
int i;
|
||||
|
||||
|
||||
started = TRUE;
|
||||
|
||||
printf("%5d >>> ", seq_no);
|
||||
for (i = 0; i < len; i++)
|
||||
printf("%02X ", msg[i]);
|
||||
printf("\n");
|
||||
|
||||
t38_core = t38_terminal_get_t38_core_state(t38_state);
|
||||
t38_core_rx_ifp_packet(t38_core, msg, len, seq_no);
|
||||
|
||||
return 0;
|
||||
@ -174,42 +295,75 @@ static int process_packet(void *user_data, const uint8_t *pkt, int len)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static uint32_t parse_inet_addr(const char *s)
|
||||
{
|
||||
int i;
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
uint32_t d;
|
||||
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
i = sscanf(s, "%" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32, &a, &b, &c, &d);
|
||||
switch (i)
|
||||
{
|
||||
case 4:
|
||||
c = (c << 8) | d;
|
||||
case 3:
|
||||
b = (b << 16) | c;
|
||||
case 2:
|
||||
a = (a << 24) | b;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
t30_state_t *t30;
|
||||
t38_core_state_t *t38_core;
|
||||
logging_state_t *logging;
|
||||
const char *input_file_name;
|
||||
int t38_version;
|
||||
int caller;
|
||||
int use_ecm;
|
||||
int use_tep;
|
||||
int options;
|
||||
int supported_modems;
|
||||
int fill_removal;
|
||||
int opt;
|
||||
int t38_terminal_operation;
|
||||
uint32_t src_addr;
|
||||
uint16_t src_port;
|
||||
uint32_t dest_addr;
|
||||
uint16_t dest_port;
|
||||
|
||||
|
||||
caller = FALSE;
|
||||
use_ecm = FALSE;
|
||||
t38_version = 1;
|
||||
t38_version = 0;
|
||||
options = 0;
|
||||
input_file_name = INPUT_FILE_NAME;
|
||||
fill_removal = FALSE;
|
||||
use_tep = FALSE;
|
||||
use_transmit_on_idle = TRUE;
|
||||
supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
|
||||
t38_terminal_operation = TRUE;
|
||||
log_audio = FALSE;
|
||||
src_addr = 0;
|
||||
src_port = 0;
|
||||
dest_addr = 0;
|
||||
dest_port = 0;
|
||||
while ((opt = getopt(argc, argv, "D:d:eFi:m:oS:s:tv:")) != -1)
|
||||
while ((opt = getopt(argc, argv, "cD:d:eFGi:lm:oS:s:tv:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'c':
|
||||
caller = TRUE;
|
||||
break;
|
||||
case 'D':
|
||||
dest_addr = atoi(optarg);
|
||||
dest_addr = parse_inet_addr(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
dest_port = atoi(optarg);
|
||||
@ -220,9 +374,15 @@ int main(int argc, char *argv[])
|
||||
case 'F':
|
||||
fill_removal = TRUE;
|
||||
break;
|
||||
case 'G':
|
||||
t38_terminal_operation = FALSE;
|
||||
break;
|
||||
case 'i':
|
||||
input_file_name = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
log_audio = TRUE;
|
||||
break;
|
||||
case 'm':
|
||||
supported_modems = atoi(optarg);
|
||||
break;
|
||||
@ -230,7 +390,7 @@ int main(int argc, char *argv[])
|
||||
options = atoi(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
src_addr = atoi(optarg);
|
||||
src_addr = parse_inet_addr(optarg);
|
||||
break;
|
||||
case 's':
|
||||
src_port = atoi(optarg);
|
||||
@ -248,44 +408,128 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if ((t38_state = t38_terminal_init(NULL, FALSE, tx_packet_handler, NULL)) == NULL)
|
||||
printf("Using T.38 version %d\n", t38_version);
|
||||
|
||||
if (t38_terminal_operation)
|
||||
{
|
||||
fprintf(stderr, "Cannot start the T.38 channel\n");
|
||||
exit(2);
|
||||
}
|
||||
t30 = t38_terminal_get_t30_state(t38_state);
|
||||
t38_core = t38_terminal_get_t38_core_state(t38_state);
|
||||
t38_set_t38_version(t38_core, t38_version);
|
||||
t38_terminal_set_config(t38_state, options);
|
||||
t38_terminal_set_tep_mode(t38_state, use_tep);
|
||||
if ((t38_terminal_state = t38_terminal_init(NULL, caller, tx_packet_handler, NULL)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot start the T.38 channel\n");
|
||||
exit(2);
|
||||
}
|
||||
t30 = t38_terminal_get_t30_state(t38_terminal_state);
|
||||
t38_core = t38_terminal_get_t38_core_state(t38_terminal_state);
|
||||
t38_set_t38_version(t38_core, t38_version);
|
||||
t38_terminal_set_config(t38_terminal_state, options);
|
||||
t38_terminal_set_tep_mode(t38_terminal_state, use_tep);
|
||||
|
||||
logging = t38_terminal_get_logging_state(t38_state);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
logging = t38_terminal_get_logging_state(t38_terminal_state);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
|
||||
logging = t38_core_get_logging_state(t38_core);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
logging = t38_core_get_logging_state(t38_core);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
|
||||
logging = t30_get_logging_state(t30);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
logging = t30_get_logging_state(t30);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
|
||||
t30_set_supported_modems(t30, supported_modems);
|
||||
t30_set_tx_ident(t30, "11111111");
|
||||
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
|
||||
t30_set_rx_file(t30, OUTPUT_FILE_NAME, -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_ecm_capability(t30, TRUE);
|
||||
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
|
||||
t30_set_supported_modems(t30, supported_modems);
|
||||
t30_set_tx_ident(t30, "11111111");
|
||||
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
|
||||
if (caller)
|
||||
t30_set_tx_file(t30, INPUT_TIFF_FILE_NAME, -1, -1);
|
||||
else
|
||||
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -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_ecm_capability(t30, TRUE);
|
||||
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
|
||||
|
||||
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, timing_update, process_packet, NULL))
|
||||
exit(2);
|
||||
/* Push the time along, to flush out any remaining activity from the application. */
|
||||
now.tv_sec += 60;
|
||||
timing_update(NULL, &now);
|
||||
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, t38_terminal_timing_update, process_packet, NULL))
|
||||
exit(2);
|
||||
/* Push the time along, to flush out any remaining activity from the application. */
|
||||
now.tv_sec += 60;
|
||||
t38_terminal_timing_update(NULL, &now);
|
||||
}
|
||||
else
|
||||
{
|
||||
wave_handle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((wave_handle = sf_open_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if ((t38_gateway_state = t38_gateway_init(NULL, tx_packet_handler, NULL)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot start the T.38 channel\n");
|
||||
exit(2);
|
||||
}
|
||||
t38_core = t38_gateway_get_t38_core_state(t38_gateway_state);
|
||||
t38_gateway_set_transmit_on_idle(t38_gateway_state, use_transmit_on_idle);
|
||||
t38_set_t38_version(t38_core, t38_version);
|
||||
t38_gateway_set_ecm_capability(t38_gateway_state, TRUE);
|
||||
|
||||
logging = t38_gateway_get_logging_state(t38_gateway_state);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
|
||||
logging = t38_core_get_logging_state(t38_core);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "T.38");
|
||||
|
||||
if ((fax_state = fax_init(NULL, caller)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot start FAX\n");
|
||||
exit(2);
|
||||
}
|
||||
t30 = fax_get_t30_state(fax_state);
|
||||
fax_set_transmit_on_idle(fax_state, use_transmit_on_idle);
|
||||
fax_set_tep_mode(fax_state, use_tep);
|
||||
t30_set_supported_modems(t30, supported_modems);
|
||||
t30_set_tx_ident(t30, "22222222");
|
||||
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
|
||||
if (caller)
|
||||
t30_set_tx_file(t30, INPUT_TIFF_FILE_NAME, -1, -1);
|
||||
else
|
||||
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1);
|
||||
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'B');
|
||||
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'B');
|
||||
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'B');
|
||||
t30_set_ecm_capability(t30, TRUE);
|
||||
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
|
||||
|
||||
logging = fax_get_logging_state(fax_state);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "FAX ");
|
||||
|
||||
logging = t30_get_logging_state(t30);
|
||||
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
|
||||
span_log_set_tag(logging, "FAX ");
|
||||
|
||||
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, t38_gateway_timing_update, process_packet, NULL))
|
||||
exit(2);
|
||||
/* Push the time along, to flush out any remaining activity from the application. */
|
||||
now.tv_sec += 60;
|
||||
t38_gateway_timing_update(NULL, &now);
|
||||
|
||||
fax_release(fax_state);
|
||||
t38_gateway_release(t38_gateway_state);
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close_telephony(wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
|
@ -36,7 +36,7 @@ These tests exercise the path
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
|
||||
@ -95,7 +95,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -108,9 +108,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -124,9 +124,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
|
||||
done[i - 'A'] = TRUE;
|
||||
@ -647,7 +647,7 @@ int main(int argc, char *argv[])
|
||||
fax_release(fax_state_b);
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(wave_handle) != 0)
|
||||
if (sf_close_telephony(wave_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
|
@ -36,7 +36,7 @@ These tests exercise the path
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
|
||||
@ -103,7 +103,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -116,9 +116,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -132,9 +132,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
|
||||
done[i - 'A'] = TRUE;
|
||||
@ -363,7 +363,7 @@ static int decode_test(const char *decode_test_file)
|
||||
}
|
||||
t38_gateway_release(t38_state_a);
|
||||
t38_terminal_release(t38_state_b);
|
||||
if (sf_close(wave_handle) != 0)
|
||||
if (sf_close_telephony(wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -690,7 +690,7 @@ int main(int argc, char *argv[])
|
||||
t38_terminal_release(t38_state_b);
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(wave_handle) != 0)
|
||||
if (sf_close_telephony(wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
|
@ -32,7 +32,7 @@ module, used for T.38 gateways.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -35,7 +35,7 @@ These tests exercise the path
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
|
||||
@ -90,7 +90,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -103,9 +103,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -119,9 +119,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
|
||||
//done[i - 'A'] = TRUE;
|
||||
|
@ -36,7 +36,7 @@ These tests exercise the path
|
||||
//#define WITH_SPANDSP_INTERNALS
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
|
||||
@ -94,7 +94,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -107,9 +107,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
return T30_ERR_OK;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@ -123,9 +123,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
|
||||
done[i - 'A'] = TRUE;
|
||||
@ -496,7 +496,7 @@ int main(int argc, char *argv[])
|
||||
fax_release(fax_state_b);
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(wave_handle) != 0)
|
||||
if (sf_close_telephony(wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
|
@ -151,12 +151,12 @@ int main(int argc, char *argv[])
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
printf(" Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
printf(" Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -239,7 +239,7 @@ int main(int argc, char *argv[])
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
|
@ -28,6 +28,7 @@ run_tsb85_test()
|
||||
fi
|
||||
}
|
||||
|
||||
for TEST in PPS-MPS-lost-PPS ; do
|
||||
for TEST in PPS-MPS-lost-PPS
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
@ -26,7 +26,7 @@
|
||||
/*! \file */
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
@ -69,7 +69,7 @@
|
||||
|
||||
#define OUTPUT_TIFF_FILE_NAME "tsb85.tif"
|
||||
|
||||
#define OUTPUT_FILE_NAME_WAVE "tsb85.wav"
|
||||
#define OUTPUT_WAVE_FILE_NAME "tsb85.wav"
|
||||
|
||||
#define SAMPLES_PER_CHUNK 160
|
||||
|
||||
@ -220,9 +220,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
||||
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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
|
||||
if (use_receiver_not_ready)
|
||||
t30_set_receiver_not_ready(s, 3);
|
||||
@ -262,9 +262,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
i = (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);
|
||||
fax_log_transfer_statistics(s, tag);
|
||||
fax_log_tx_parameters(s, tag);
|
||||
fax_log_rx_parameters(s, tag);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@ -869,7 +869,7 @@ static int next_step(faxtester_state_t *s)
|
||||
else if (strcasecmp((const char *) tag, "TXFILE") == 0)
|
||||
{
|
||||
sprintf(next_tx_file, "%s/%s", image_path, (const char *) value);
|
||||
printf("Push '%s'\n", next_tx_file);
|
||||
printf("Push '%s'\n", next_tx_file);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1066,9 +1066,9 @@ static void exchange(faxtester_state_t *s)
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if ((out_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == NULL)
|
||||
if ((out_handle = sf_open_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ static void exchange(faxtester_state_t *s)
|
||||
|
||||
span_log_bump_samples(&s->logging, len);
|
||||
|
||||
len = faxtester_tx(s, amp, 160);
|
||||
len = faxtester_tx(s, amp, SAMPLES_PER_CHUNK);
|
||||
if (fax_rx(fax, amp, len))
|
||||
break;
|
||||
/*endif*/
|
||||
@ -1134,9 +1134,9 @@ static void exchange(faxtester_state_t *s)
|
||||
/*endfor*/
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(out_handle))
|
||||
if (sf_close_telephony(out_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ run_tsb85_test()
|
||||
fi
|
||||
}
|
||||
|
||||
for TEST in MRGN01 MRGN02 MRGN03 MRGN04 MRGN05 MRGN06a MRGN06b MRGN07 MRGN08 ; do
|
||||
for TEST in MRGN01 MRGN02 MRGN03 MRGN04 MRGN05 MRGN06a MRGN06b MRGN07 MRGN08
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
@ -37,16 +38,19 @@ done
|
||||
#MRGN16 fails because we don't adequately distinguish between receiving a
|
||||
#bad image signal and receiving none at all.
|
||||
|
||||
#for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN14 MRGN15 MRGN16 MRGN17 ; do
|
||||
for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 MRGN17 ; do
|
||||
#for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN14 MRGN15 MRGN16 MRGN17
|
||||
for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 MRGN17
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in ORGC01 ORGC02 ORGC03 ; do
|
||||
for TEST in ORGC01 ORGC02 ORGC03
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in OREN01 OREN02 OREN03 OREN04 OREN05 OREN06 OREN07 OREN08 OREN09 OREN10 ; do
|
||||
for TEST in OREN01 OREN02 OREN03 OREN04 OREN05 OREN06 OREN07 OREN08 OREN09 OREN10
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
@ -54,69 +58,84 @@ done
|
||||
# MRGX05 is failing because we don't distinguish MPS immediately after MCF from MPS after
|
||||
# a corrupt image signal.
|
||||
|
||||
#for TEST in MRGX01 MRGX02 MRGX03 MRGX04 MRGX05 MRGX06 MRGX07 MRGX08 ; do
|
||||
for TEST in MRGX01 MRGX02 MRGX04 MRGX06 MRGX07 MRGX08 ; do
|
||||
#for TEST in MRGX01 MRGX02 MRGX03 MRGX04 MRGX05 MRGX06 MRGX07 MRGX08
|
||||
for TEST in MRGX01 MRGX02 MRGX04 MRGX06 MRGX07 MRGX08
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MRGX09 MRGX10 MRGX11 MRGX12 MRGX13 MRGX14 MRGX15 ; do
|
||||
for TEST in MRGX09 MRGX10 MRGX11 MRGX12 MRGX13 MRGX14 MRGX15
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MTGP01 MTGP02 OTGP03 ; do
|
||||
for TEST in MTGP01 MTGP02 OTGP03
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MTGN01 MTGN02 MTGN03 MTGN04 MTGN05 MTGN06 MTGN07 MTGN08 MTGN09 MTGN10 ; do
|
||||
for TEST in MTGN01 MTGN02 MTGN03 MTGN04 MTGN05 MTGN06 MTGN07 MTGN08 MTGN09 MTGN10
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MTGN11 MTGN12 MTGN13 MTGN14 MTGN15 MTGN16 MTGN17 MTGN18 MTGN19 MTGN20 ; do
|
||||
for TEST in MTGN11 MTGN12 MTGN13 MTGN14 MTGN15 MTGN16 MTGN17 MTGN18 MTGN19 MTGN20
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MTGN21 MTGN22 MTGN23 MTGN24 MTGN25 MTGN26 MTGN27 MTGN28 ; do
|
||||
for TEST in MTGN21 MTGN22 MTGN23 MTGN24 MTGN25 MTGN26 MTGN27 MTGN28
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in OTGC01 OTGC02 OTGC03 OTGC04 OTGC05 OTGC06 OTGC07 OTGC08 ; do
|
||||
for TEST in OTGC01 OTGC02 OTGC03 OTGC04 OTGC05 OTGC06 OTGC07 OTGC08
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in OTGC09-01 OTGC09-02 OTGC09-03 OTGC09-04 OTGC09-05 OTGC09-06 OTGC09-07 OTGC09-08 OTGC09-09 OTGC09-10 OTGC09-11 OTGC09-12 ; do
|
||||
for TEST in OTGC09-01 OTGC09-02 OTGC09-03 OTGC09-04 OTGC09-05 OTGC09-06 OTGC09-07 OTGC09-08 OTGC09-09 OTGC09-10 OTGC09-11 OTGC09-12
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in OTGC10 OTGC11 ; do
|
||||
for TEST in OTGC10 OTGC11
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
#OTEN02 fails because ?????
|
||||
|
||||
#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 ; do
|
||||
for TEST in OTEN01 OTEN03 OTEN04 OTEN05 OTEN06 ; do
|
||||
#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06
|
||||
for TEST in OTEN01 OTEN03 OTEN04 OTEN05 OTEN06
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
#MTGX02 fails because ?????
|
||||
|
||||
#for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 ; do
|
||||
for TEST in MTGX01 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 ; do
|
||||
#for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08
|
||||
for TEST in MTGX01 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MTGX09 MTGX10 MTGX11 MTGX12 MTGX13 MTGX14 MTGX15 MTGX16 ; do
|
||||
for TEST in MTGX09 MTGX10 MTGX11 MTGX12 MTGX13 MTGX14 MTGX15 MTGX16
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MTGX17 MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23 ; do
|
||||
for TEST in MTGX17 MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in MRGP01 MRGP02 MRGP03 MRGP04 MRGP05 MRGP06 MRGP07 MRGP08 ; do
|
||||
for TEST in MRGP01 MRGP02 MRGP03 MRGP04 MRGP05 MRGP06 MRGP07 MRGP08
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
for TEST in ORGP09 ORGP10 ; do
|
||||
for TEST in ORGP09 ORGP10
|
||||
do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
@ -293,7 +293,7 @@ static int decode_test_data_file(int mode, const char *filename)
|
||||
break;
|
||||
v18_rx(v18_state, amp, len);
|
||||
}
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -493,7 +493,7 @@ int main(int argc, char *argv[])
|
||||
basic_tests(V18_MODE_5BIT_45);
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -412,7 +412,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (sf_close(inhandle))
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -420,7 +420,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle) != 0)
|
||||
if (sf_close_telephony(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -532,7 +532,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (sf_close(inhandle))
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -540,7 +540,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -561,7 +561,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (sf_close(inhandle))
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -569,7 +569,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
@ -56,13 +56,13 @@ int tx_next[3] = {0};
|
||||
|
||||
static void v42_status(void *user_data, int status)
|
||||
{
|
||||
int x;
|
||||
v42_state_t *s;
|
||||
|
||||
x = (intptr_t) user_data;
|
||||
s = (v42_state_t *) user_data;
|
||||
if (status < 0)
|
||||
printf("%d: Status is '%s' (%d)\n", x, signal_status_to_str(status), status);
|
||||
printf("%p: Status is '%s' (%d)\n", s, signal_status_to_str(status), status);
|
||||
else
|
||||
printf("%d: Status is '%s' (%d)\n", x, lapm_status_to_str(status), status);
|
||||
printf("%p: Status is '%s' (%d)\n", s, lapm_status_to_str(status), status);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@ -72,13 +72,15 @@ static int v42_get_frames(void *user_data, uint8_t *msg, int len)
|
||||
int j;
|
||||
int k;
|
||||
int x;
|
||||
v42_state_t *s;
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
v42_status(user_data, len);
|
||||
return 0;
|
||||
}
|
||||
x = (intptr_t) user_data;
|
||||
s = (v42_state_t *) user_data;
|
||||
x = (s == &caller) ? 1 : 2;
|
||||
if (variable_length)
|
||||
{
|
||||
j = make_mask32(len);
|
||||
@ -99,24 +101,42 @@ static int v42_get_frames(void *user_data, uint8_t *msg, int len)
|
||||
static void v42_put_frames(void *user_data, const uint8_t *msg, int len)
|
||||
{
|
||||
int i;
|
||||
v42_state_t *s;
|
||||
int x;
|
||||
static int count = 0;
|
||||
static int xxx = 0;
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
v42_status(user_data, len);
|
||||
return;
|
||||
}
|
||||
x = (intptr_t) user_data;
|
||||
s = (v42_state_t *) user_data;
|
||||
x = (s == &caller) ? 1 : 2;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (msg[i] != (rx_next[x] & 0xFF))
|
||||
{
|
||||
printf("%d: Mismatch 0x%02X 0x%02X\n", x, msg[i], rx_next[x] & 0xFF);
|
||||
printf("%p: Mismatch 0x%02X 0x%02X\n", user_data, msg[i], rx_next[x] & 0xFF);
|
||||
exit(2);
|
||||
}
|
||||
rx_next[x]++;
|
||||
}
|
||||
printf("%d: Got frame len %d\n", x, len);
|
||||
printf("%p: Got frame len %d\n", user_data, len);
|
||||
printf("%p: %d Far end busy status %d\n", user_data, count, v42_get_far_busy_status(s));
|
||||
if (s == &caller)
|
||||
{
|
||||
if (++count == 5)
|
||||
{
|
||||
v42_set_local_busy_status(s, TRUE);
|
||||
xxx = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xxx && ++count == 45)
|
||||
v42_set_local_busy_status(&caller, FALSE);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@ -149,10 +169,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
v42_init(&caller, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) 1);
|
||||
v42_init(&answerer, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) 2);
|
||||
v42_set_status_callback(&caller, v42_status, (void *) 1);
|
||||
v42_set_status_callback(&answerer, v42_status, (void *) 2);
|
||||
v42_init(&caller, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) &caller);
|
||||
v42_init(&answerer, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) &answerer);
|
||||
v42_set_status_callback(&caller, v42_status, (void *) &caller);
|
||||
v42_set_status_callback(&answerer, v42_status, (void *) &answerer);
|
||||
v42_restart(&caller);
|
||||
v42_restart(&answerer);
|
||||
|
||||
|
@ -631,7 +631,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
v8_free(v8_caller);
|
||||
v8_free(v8_answerer);
|
||||
if (sf_close(inhandle) != 0)
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
@ -663,7 +663,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (outhandle)
|
||||
{
|
||||
if (sf_close(outhandle))
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user