## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.49 2009/05/30 05:55:22 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
debian/rules \
debian/watch \
README.testdata \
- spandsp.pc \
spandsp.spec \
spandsp/fax-tests.dtd \
+ spandsp/fax-tests.xml \
spandsp/global-tones.xml \
spandsp/tones.dtd \
spandsp/tsb85.xml \
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: autogen.sh,v 1.6 2008/03/30 18:33:24 steveu Exp $
-#
UNAME=`uname`
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: configure.ac,v 1.73 2009/10/03 04:37:25 steveu Exp $
# @start 1
AC_INIT
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
-
m4_include(config/ax_compiler_vendor.m4)
m4_include(config/ax_check_real_file.m4)
m4_include(config/ax_fixed_point_machine.m4)
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([sys/fcntl.h])
AC_CHECK_HEADERS([sndfile.h])
+AC_CHECK_HEADERS([fenv.h])
AC_CHECK_HEADERS([fftw3.h], , [AC_CHECK_HEADERS([fftw.h])])
+AC_CHECK_HEADERS([pcap.h])
AC_CHECK_HEADERS([pthread.h])
if test "${build}" == "${host}"
then
esac
fi
+#AC_DEFINE([SPANDSP_SUPPORT_T85], [1], [Support T.85 JBIG compression])
+SPANDSP_SUPPORT_T85="#undef SPANDSP_SUPPORT_T85"
+#AC_DEFINE([SPANDSP_SUPPORT_V34], [1], [Support the V.34 FAX modem])
+SPANDSP_SUPPORT_V34="#undef SPANDSP_SUPPORT_V34"
+
AC_CHECK_LIB([m], [cos])
# Some platforms still seem to lack the basic single precision trig and power related function.
AC_SEARCH_LIBS([sinf], [m], AC_DEFINE([HAVE_SINF], [1], [Define to 1 if you have the sinf() function.]))
AC_LANG([C])
AC_CHECK_LIB([sndfile], [sf_open], SIMLIBS="$SIMLIBS -lsndfile", AC_MSG_ERROR("Can't make tests without libsndfile (does your system require a libsndfile-devel package?)"))
AC_CHECK_LIB([fftw3], [fftw_plan_dft_1d], SIMLIBS="$SIMLIBS -lfftw3", [AC_CHECK_LIB([fftw], [fftw_create_plan], SIMLIBS="$SIMLIBS -lfftw", AC_MSG_ERROR("Can't make tests without FFTW 2 or 3 (does your system require an fftw?-devel package?)"))])
+ AC_CHECK_LIB([pcap], [pcap_open_offline], TESTLIBS="$TESTLIBS -lpcap", AC_MSG_ERROR("Can't make tests without libpcap (does your system require a libpcap-devel package?)"))
AC_CHECK_LIB([pthread], [pthread_attr_init], TESTLIBS="$TESTLIBS -lpthread")
AC_CHECK_LIB([dl], [dlopen], TESTLIBS="$TESTLIBS -ldl")
AC_CHECK_LIB([Xft], [XftFontOpen], TESTLIBS="$TESTLIBS -lXft",, $TESTLIBS)
COMP_VENDOR_LDFLAGS=
REMOVE_FROM_VAR(CFLAGS, -Xc)
;;
+intel)
+ COMP_VENDOR_CFLAGS="-std=c99 -D_POSIX_C_SOURCE=2 -D_GNU_SOURCE=1 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS"
+ if test "$enable_sse5" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse4a" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse4a $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse4_2" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse4_1" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse41 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_ssse3" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-mssse3 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse3" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse3 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse2" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse2 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_mmx" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-mmmx $COMP_VENDOR_CFLAGS"
+ fi
+ COMP_VENDOR_LDFLAGS=
+ ;;
*)
COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS"
COMP_VENDOR_LDFLAGS=
if test "$enable_builtin_tiff" = "yes" ; then
abs_tiffdir="`cd $srcdir/../tiff-3.8.2/ && pwd`"
- spandsp_builddir="`pwd`"
- abs_tiffbuilddir="`cd $spandsp_builddir/../tiff-3.8.2/ && pwd`"
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -I$abs_tiffdir/libtiff"
AC_CHECK_HEADERS([tiffio.h])
CFLAGS="$save_CFLAGS"
COMP_VENDOR_CFLAGS="-I$abs_tiffdir/libtiff $COMP_VENDOR_CFLAGS"
COMP_VENDOR_LDFLAGS="-L$abs_tiffdir/libtiff $COMP_VENDOR_LDFLAGS"
- LIBS="$LIBS $abs_tiffbuilddir/libtiff/libtiff.la"
+ LIBS="$LIBS $abs_tiffdir/libtiff/libtiff.la"
AC_DEFINE([HAVE_LIBTIFF], [1], [Define to 1 if you have the `tiff' library (-ltiff).])
else
AC_CHECK_HEADERS([tiffio.h])
AC_SUBST(SPANDSP_USE_FIXED_POINT)
AC_SUBST(SPANDSP_MISALIGNED_ACCESS_FAILS)
AC_SUBST(SPANDSP_USE_EXPORT_CAPABILITY)
+AC_SUBST(SPANDSP_SUPPORT_T85)
+AC_SUBST(SPANDSP_SUPPORT_V34)
AC_SUBST(INSERT_INTTYPES_HEADER)
AC_SUBST(INSERT_STDINT_HEADER)
AC_SUBST(INSERT_TGMATH_HEADER)
## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.12 2008/09/20 15:44:40 steveu Exp $
MAINTAINERCLEANFILES = Makefile.in
<?xml version="1.0" encoding="iso8859-1"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
-<!-- $Id: t38_manual.xml,v 1.5 2007/12/08 16:25:17 steveu Exp $ -->
<book>
<bookinfo>
<date>2007-11-14</date>
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.10 2009/06/02 16:03:55 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g1050.c,v 1.17 2009/06/02 14:55:36 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: line_model.c,v 1.14 2009/09/23 16:02:59 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
SPAN_DECLARE(both_ways_line_model_state_t *) both_ways_line_model_init(int model1,
float noise1,
+ float echo_level_cpe1,
+ float echo_level_co1,
int model2,
float noise2,
+ float echo_level_cpe2,
+ float echo_level_co2,
int codec,
int rbs_pattern)
{
- float echo_level;
both_ways_line_model_state_t *s;
if ((s = (both_ways_line_model_state_t *) malloc(sizeof(*s))) == NULL)
s->line2.mains_interference = 0;
/* Echos */
- echo_level = -15; /* in dB */
- s->line1.near_co_hybrid_echo = pow(10, echo_level/20.0f);
- s->line2.near_co_hybrid_echo = pow(10, echo_level/20.0f);
- s->line1.near_cpe_hybrid_echo = pow(10, echo_level/20.0f);
- s->line2.near_cpe_hybrid_echo = pow(10, echo_level/20.0f);
+ s->line1.near_co_hybrid_echo = pow(10, echo_level_co1/20.0f);
+ s->line2.near_co_hybrid_echo = pow(10, echo_level_co2/20.0f);
+ s->line1.near_cpe_hybrid_echo = pow(10, echo_level_cpe1/20.0f);
+ s->line2.near_cpe_hybrid_echo = pow(10, echo_level_cpe2/20.0f);
return s;
}
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: make_line_models.c,v 1.10 2009/09/23 16:02:59 steveu Exp $
*/
/*! \page make_line_models_page Telephony line model construction
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: rfc2198_sim.c,v 1.10 2009/06/01 16:27:12 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: spandsp-sim.h,v 1.5 2008/04/26 13:39:16 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g1050.h,v 1.12 2009/06/01 16:27:12 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: line_model.h,v 1.7.4.1 2009/12/19 10:16:44 steveu Exp $
*/
/*! \file */
SPAN_DECLARE(both_ways_line_model_state_t *) both_ways_line_model_init(int model1,
float noise1,
+ float echo_level_cpe1,
+ float echo_level_co1,
int model2,
float noise2,
+ float echo_level_cpe2,
+ float echo_level_co2,
int codec,
int rbs_pattern);
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: line_models.h,v 1.3 2008/04/17 18:03:23 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: rfc2198_sim.h,v 1.6 2009/05/31 14:47:10 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: test_utils.h,v 1.9 2009/05/31 14:47:10 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: test_utils.c,v 1.14 2009/06/01 16:27:12 steveu Exp $
*/
/*! \file */
<step freq="525" level="-12" length="0.1"/>
<step length="0.1"/>
</offering-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Austria" uncode="at">
<dial-tone>
<step freq="380+420" level="-12" length="0.4"/>
<step length="0.4"/>
</negative-indication-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Bahamas" uncode="bs">
<ringback-tone>
<step freq="1380" level="-12" length="0.333"/>
<step freq="1860" level="-12" length="0.333"/>
</special-information-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Benin" uncode="bj">
<ringback-tone>
<step freq="440" level="-12" length="0.05"/>
<step length="0.05"/>
</route-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Canada" uncode="ca">
<dial-tone>
<step freq="12000" level="-12" length="0.15"/>
<step length="0.15"/>
</pay-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Channel Islands: Jersey" uncode="??">
<dial-tone>
<step freq="425" level="-12" length="0.333"/>
<step length="1.5"/>
</offering-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Denmark" uncode="dk">
<dial-tone>
<step freq="1400+950" level="-12" length="0.2"/>
<step length="2.0"/>
</payphone-recognition-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Diego Garcia" uncode="??">
<dial-tone>
<step freq="1800" level="-12" length="0.33"/>
<step length="0.3"/>
</waiting-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Ethiopia" uncode="et">
<dial-tone>
<step freq="425" level="-12" length="0.15"/>
<step length="8.0"/>
</waiting-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="France" uncode="fr">
<dial-tone>
<step freq="440" level="-12" length="0.05"/>
<step length="0.05"/>
</route-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="French Polynesia" uncode="pf">
<dial-tone>
<step length="2.0"/>
</step>
</payphone-recognition-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Ghana" uncode="gh">
<dial-tone>
<step freq="450" level="-12"/>
</step>
</number-unobtainable-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Greenland" uncode="gl">
<dial-tone>
<step freq="750+1450" level="-12" length="0.2"/>
<step length="2.0"/>
</payphone-recognition-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Israel" uncode="il">
<dial-tone>
<step freq="400" level="-12" length="0.05"/>
<step length="2.0"/>
</holding-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Italy" uncode="it">
<dial-tone>
<step length="0.2"/>
</step>
</busy-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Ivory Coast" uncode="ci">
<dial-tone>
<step freq="425" level="-12" length="0.05"/>
<step length="0.05"/>
</route-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Jamaica" uncode="jm">
<dial-tone>
<step freq="400" level="-12" length="0.15"/>
<step length="0.15"/>
</pay-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Martinique (French Dep.)" uncode="mq">
<dial-tone>
<step freq="425 || 450" level="-12" length="0.0625"/>
<step length="0.0625"/>
</negative-indication-tone>
+ <!-- Billing signal: 50Hz/~50Vrms, longitudinal/~160ms -->
</tone-set>
<tone-set country="New Caledonia" uncode="nc">
<dial-tone>
<step length="2.0"/>
</step>
</payphone-recognition-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Oman" uncode="om">
<dial-tone>
<step freq="941" level="-12" length="0.2"/>
<step length="2.0"/>
</payphone-recognition-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Puerto Rico" uncode="pr">
<payphone-recognition-tone>
<step freq="440" level="-12" length="0.05"/>
<step length="0.05"/>
</route-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="St. Helena" uncode="sh">
<dial-tone>
<warning-tone type="conference">
<step freq="425" level="-12" length="0.66"/>
</warning-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Slovenia" uncode="si">
<dial-tone>
<step freq="1600" level="-12" length="0.05"/>
<step length="1.5"/>
</payphone-recognition-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Sri Lanka" uncode="lk">
<dial-tone>
<step length="3.6"/>
</step>
</pay-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Switzerland" uncode="ch">
<dial-tone>
<step freq="750+1450" level="-12" length="0.2"/>
<step length="2.0"/>
</payphone-recognition-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Syria" uncode="sy">
<dial-tone>
<step length="0.167"/>
</step>
</congestion-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Turkey" uncode="tr">
<dial-tone>
<step freq="450" level="-12" length="0.04"/>
<step length="0.04"/>
</confirmation-tone>
+ <!-- Billing signal: 12kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Turkmenistan" uncode="tm">
<dial-tone>
<step length="0.125"/>
</step>
</pay-tone>
+ <!-- Billing signal: 50Hz/~50Vrms, longitudinal/~160ms -->
</tone-set>
<tone-set country="United States" uncode="us">
<dial-tone>
<step freq="1800" level="-12" length="0.333"/>
<step length="1.0"/>
</special-information-tone>
+ <!-- Billing signal: 16kHz/~2Vrms, differential/~125ms -->
</tone-set>
<tone-set country="Zambia" uncode="zm">
<dial-tone>
<?xml version="1.0"?>
<!DOCTYPE fax-tests SYSTEM "./fax-tests.dtd">
<fax-tests>
-<!-- $Id: tsb85.xml,v 1.22 2009/05/24 07:18:36 steveu Exp $ -->
<config>
<path type="IMAGE" value="../test-data/etsi/fax"/>
</config>
<step dir="T" type="POSTAMBLE"/>
<step type="WAIT" value="75"/>
<step dir="T" type="PREAMBLE" modem="V.21"/>
- <step dir="T" type="HDLC" tag="PPS-MPS" value="FF C8 7D 72 00 00 08"/>
+ <step dir="T" type="HDLC" tag="PPS-MPS" value="FF C8 7D 72 00 80 08"/>
<step dir="T" type="POSTAMBLE"/>
<possible-step>
<step dir="T" type="POSTAMBLE"/>
<step type="WAIT" value="75"/>
<step dir="T" type="PREAMBLE" modem="V.21"/>
- <step dir="T" type="HDLC" tag="PPS-MPS" value="FF C8 7D 72 00 00 08"/>
+ <step dir="T" type="HDLC" tag="PPS-MPS" value="FF C8 7D 72 80 00 08"/>
<step dir="T" type="POSTAMBLE"/>
<possible-step>
## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.138.4.3 2009/12/19 10:30:10 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
libtiff.2005.vcproj \
libtiff.2008.vcproj \
filter_tools.c \
- make_at_dictionary.c \
- make_modem_filter.c \
+ make_at_dictionary.c \
+ make_modem_filter.c \
msvc/config.h \
msvc/Download_TIFF.2005.vcproj \
msvc/Download_TIFF.2008.vcproj \
gsm0610_short_term.c \
hdlc.c \
ima_adpcm.c \
+ image_translate.c \
logging.c \
lpc10_analyse.c \
lpc10_decode.c \
t38_terminal.c \
testcpuid.c \
time_scale.c \
+ timezone.c \
tone_detect.c \
tone_generate.c \
v17rx.c \
spandsp/gsm0610.h \
spandsp/hdlc.h \
spandsp/ima_adpcm.h \
+ spandsp/image_translate.h \
spandsp/logging.h \
spandsp/lpc10.h \
spandsp/modem_echo.h \
spandsp/super_tone_rx.h \
spandsp/super_tone_tx.h \
spandsp/swept_tone.h \
- spandsp/t4_rx.h \
- spandsp/t4_tx.h \
spandsp/t30.h \
spandsp/t30_api.h \
spandsp/t30_fcf.h \
spandsp/t38_gateway.h \
spandsp/t38_non_ecm_buffer.h \
spandsp/t38_terminal.h \
+ spandsp/t4_rx.h \
+ spandsp/t4_tx.h \
+ spandsp/t4_t6_decode.h \
+ spandsp/t4_t6_encode.h \
spandsp/telephony.h \
spandsp/time_scale.h \
+ spandsp/timezone.h \
spandsp/timing.h \
spandsp/tone_detect.h \
spandsp/tone_generate.h \
spandsp/private/gsm0610.h \
spandsp/private/hdlc.h \
spandsp/private/ima_adpcm.h \
+ spandsp/private/image_translate.h \
spandsp/private/logging.h \
spandsp/private/lpc10.h \
spandsp/private/modem_connect_tones.h \
spandsp/private/t38_terminal.h \
spandsp/private/t4_rx.h \
spandsp/private/t4_tx.h \
+ spandsp/private/t4_t6_decode.h \
+ spandsp/private/t4_t6_encode.h \
spandsp/private/time_scale.h \
+ spandsp/private/timezone.h \
spandsp/private/tone_detect.h \
spandsp/private/tone_generate.h \
spandsp/private/v17rx.h \
nodist_include_HEADERS = spandsp.h
-noinst_HEADERS = faxfont.h \
- filter_tools.h \
- gsm0610_local.h \
- lpc10_encdecs.h \
- mmx_sse_decs.h \
- t30_local.h \
- t4_t6_decode_states.h \
- v17_v32bis_rx_constellation_maps.h \
- v17_v32bis_tx_constellation_maps.h \
- v29tx_constellation_maps.h
+noinst_HEADERS = faxfont.h \
+ filter_tools.h \
+ gsm0610_local.h \
+ lpc10_encdecs.h \
+ mmx_sse_decs.h \
+ t30_local.h \
+ t4_t6_decode_states.h \
+ v17_v32bis_rx_constellation_maps.h \
+ v17_v32bis_tx_constellation_maps.h \
+ v29tx_constellation_maps.h
make_at_dictionary$(EXEEXT): $(top_srcdir)/src/make_at_dictionary.c
$(CC_FOR_BUILD) -o make_at_dictionary$(EXEEXT) $(top_srcdir)/src/make_at_dictionary.c -DHAVE_CONFIG_H -I$(top_builddir)/src
at_interpreter_dictionary.h: make_at_dictionary$(EXEEXT)
./make_at_dictionary$(EXEEXT) >at_interpreter_dictionary.h
-t4.$(OBJEXT): spandsp/version.h
+t4_rx.$(OBJEXT): spandsp/version.h
-t4.lo: spandsp/version.h
+t4_rx.lo: spandsp/version.h
-v17rx.$(OBJEXT): v17_v32bis_rx_fixed_rrc.h v17_v32bis_rx_floating_rrc.h
+V17_V32BIS_RX_INCL = v17_v32bis_rx_fixed_rrc.h \
+ v17_v32bis_rx_floating_rrc.h
-v17rx.lo: v17_v32bis_rx_fixed_rrc.h v17_v32bis_rx_floating_rrc.h
+v17rx.$(OBJEXT): ${V17_V32BIS_RX_INCL}
+
+v17rx.lo: ${V17_V32BIS_RX_INCL}
v17_v32bis_rx_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.17 -i -r >v17_v32bis_rx_fixed_rrc.h
v17_v32bis_rx_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.17 -r >v17_v32bis_rx_floating_rrc.h
-v17tx.$(OBJEXT): v17_v32bis_tx_fixed_rrc.h v17_v32bis_tx_floating_rrc.h
+V17_V32BIS_TX_INCL = v17_v32bis_tx_fixed_rrc.h \
+ v17_v32bis_tx_floating_rrc.h
+
+v17tx.$(OBJEXT): ${V17_V32BIS_TX_INCL}
-v17tx.lo: v17_v32bis_tx_fixed_rrc.h v17_v32bis_tx_floating_rrc.h
+v17tx.lo: ${V17_V32BIS_TX_INCL}
v17_v32bis_tx_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.17 -i -t >v17_v32bis_tx_fixed_rrc.h
v17_v32bis_tx_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.17 -t >v17_v32bis_tx_floating_rrc.h
-v22bis_rx.$(OBJEXT): v22bis_rx_1200_fixed_rrc.h \
- v22bis_rx_2400_fixed_rrc.h \
- v22bis_rx_1200_floating_rrc.h \
- v22bis_rx_2400_floating_rrc.h
+V22BIS_RX_INCL = v22bis_rx_1200_fixed_rrc.h \
+ v22bis_rx_2400_fixed_rrc.h \
+ v22bis_rx_1200_floating_rrc.h \
+ v22bis_rx_2400_floating_rrc.h
+
+v22bis_rx.$(OBJEXT): ${V22BIS_RX_INCL}
-v22bis_rx.lo: v22bis_rx_1200_fixed_rrc.h \
- v22bis_rx_2400_fixed_rrc.h \
- v22bis_rx_1200_floating_rrc.h \
- v22bis_rx_2400_floating_rrc.h
+v22bis_rx.lo: ${V22BIS_RX_INCL}
v22bis_rx_1200_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.22bis1200 -i -r >v22bis_rx_1200_fixed_rrc.h
v22bis_rx_2400_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.22bis2400 -r >v22bis_rx_2400_floating_rrc.h
-v22bis_tx.$(OBJEXT): v22bis_tx_fixed_rrc.h v22bis_tx_floating_rrc.h
+V22BIS_TX_INCL = v22bis_tx_fixed_rrc.h \
+ v22bis_tx_floating_rrc.h
-v22bis_tx.lo: v22bis_tx_fixed_rrc.h v22bis_tx_floating_rrc.h
+v22bis_tx.$(OBJEXT): ${V22BIS_TX_INCL}
+
+v22bis_tx.lo: ${V22BIS_TX_INCL}
v22bis_tx_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.22bis -i -t >v22bis_tx_fixed_rrc.h
v22bis_tx_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.22bis -t >v22bis_tx_floating_rrc.h
-v27ter_rx_.$(OBJEXT): v27ter_rx_2400_fixed_rrc.h \
- v27ter_rx_4800_fixed_rrc.h \
- v27ter_rx_2400_floating_rrc.h \
- v27ter_rx_4800_floating_rrc.h
-
-v27ter_rx.lo: v27ter_rx_2400_fixed_rrc.h \
+V27_RX_INCL = v27ter_rx_2400_fixed_rrc.h \
v27ter_rx_4800_fixed_rrc.h \
v27ter_rx_2400_floating_rrc.h \
v27ter_rx_4800_floating_rrc.h
+v27ter_rx.$(OBJEXT): ${V27_RX_INCL}
+
+v27ter_rx.lo: ${V27_RX_INCL}
+
v27ter_rx_2400_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.27ter2400 -i -r >v27ter_rx_2400_fixed_rrc.h
v27ter_rx_4800_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.27ter4800 -r >v27ter_rx_4800_floating_rrc.h
-v27ter_tx_.$(OBJEXT): v27ter_tx_2400_fixed_rrc.h \
- v27ter_tx_4800_fixed_rrc.h \
- v27ter_tx_2400_floating_rrc.h \
- v27ter_tx_4800_floating_rrc.h
+V27TER_TX_INCL = v27ter_tx_2400_fixed_rrc.h \
+ v27ter_tx_4800_fixed_rrc.h \
+ v27ter_tx_2400_floating_rrc.h \
+ v27ter_tx_4800_floating_rrc.h
+
+v27ter_tx_.$(OBJEXT): ${V27TER_TX_INCL}
-v27ter_tx.lo: v27ter_tx_2400_fixed_rrc.h \
- v27ter_tx_4800_fixed_rrc.h \
- v27ter_tx_2400_floating_rrc.h \
- v27ter_tx_4800_floating_rrc.h
+v27ter_tx.lo: ${V27TER_TX_INCL}
v27ter_tx_2400_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.27ter2400 -i -t >v27ter_tx_2400_fixed_rrc.h
v27ter_tx_4800_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.27ter4800 -t >v27ter_tx_4800_floating_rrc.h
-v29rx.$(OBJEXT): v29rx_fixed_rrc.h v29rx_floating_rrc.h
+V29_RX_INCL = v29rx_fixed_rrc.h \
+ v29rx_floating_rrc.h
-v29rx.lo: v29rx_fixed_rrc.h v29rx_floating_rrc.h
+v29rx.$(OBJEXT): ${V29_RX_INCL}
+
+v29rx.lo: ${V29_RX_INCL}
v29rx_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.29 -i -r >v29rx_fixed_rrc.h
v29rx_floating_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.29 -r >v29rx_floating_rrc.h
-v29tx.$(OBJEXT): v29tx_fixed_rrc.h v29tx_floating_rrc.h
+V29_TX_INCL = v29tx_fixed_rrc.h \
+ v29tx_floating_rrc.h
+
+v29tx.$(OBJEXT): ${V29_TX_INCL}
-v29tx.lo: v29tx_fixed_rrc.h v29tx_floating_rrc.h
+v29tx.lo: ${V29_TX_INCL}
v29tx_fixed_rrc.h: make_modem_filter$(EXEEXT)
./make_modem_filter$(EXEEXT) -m V.29 -i -t >v29tx_fixed_rrc.h
-e "s/\@INSERT_INTTYPES_HEADER\@/#include <msvc\/inttypes.h>/" \
-e "s/\@INSERT_MATH_HEADER\@/#include <math.h>/" $(srcdir)/spandsp.h.in > $(srcdir)/msvc/spandsp.h
+dist-hook: spandsp/version.h
+
spandsp/version.h:
mkdir -p $(@D)
NOWDATE=`date --utc +"%Y%m%d"` ; \
NOWTIME=`date --utc +"%H%M%S"` ; \
sed 's/$$SPANDSP_RELEASE_DATE/'$$NOWDATE'/;s/$$SPANDSP_RELEASE_TIME/'$$NOWTIME'/' \
<$(srcdir)/spandsp/version.h.in >$@
-
-dist-hook: spandsp/version.h
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: adsi.c,v 1.77 2009/11/02 13:25:20 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: async.c,v 1.19 2009/04/23 14:12:34 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: at_interpreter.c,v 1.42.4.1 2009/12/23 14:18:32 steveu Exp $
*/
/*! \file */
}
else
{
- /* FAX modem connection */
- at_set_at_rx_mode(s, AT_MODE_DELIVERY);
- if (s->silent_dial)
- at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_NOCNG_TONE);
+ if (s->command_dial)
+ {
+ at_put_response_code(s, AT_RESPONSE_CODE_OK);
+ at_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND);
+ }
else
- at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_CNG_TONE);
- s->dte_is_waiting = TRUE;
+ {
+ /* FAX modem connection */
+ at_set_at_rx_mode(s, AT_MODE_DELIVERY);
+ if (s->silent_dial)
+ at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_NOCNG_TONE);
+ else
+ at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_CNG_TONE);
+ s->dte_is_waiting = TRUE;
+ }
}
break;
case AT_CALL_EVENT_BUSY:
/* The spec. says no digits is valid, and should be treated as zero. */
i = 0;
- while (isdigit(**s))
+ while (isdigit((int) **s))
{
i = i*10 + ((**s) - '0');
(*s)++;
/* The spec. says a hex value is always 2 digits, and the alpha digits are
upper case. */
i = 0;
- if (isdigit(**s))
+ if (isdigit((int) **s))
i = **s - '0';
else if (**s >= 'A' && **s <= 'F')
i = **s - 'A';
return -1;
(*s)++;
- if (isdigit(**s))
+ if (isdigit((int) **s))
i = (i << 4) | (**s - '0');
else if (**s >= 'A' && **s <= 'F')
i = (i << 4) | (**s - 'A');
at_reset_call_info(s);
s->do_hangup = FALSE;
s->silent_dial = FALSE;
+ s->command_dial = FALSE;
t += 1;
ok = FALSE;
/* There are a numbers of options in a dial command string.
u = num;
for ( ; (ch = *t); t++)
{
- if (isdigit(ch))
+ if (isdigit((int) ch))
{
/* V.250 6.3.1.1 Basic digit set */
*u++ = ch;
break;
case ';':
/* V.250 6.3.1 - Dial string terminator - make voice call and remain in command mode */
- /* TODO: */
+ s->command_dial = TRUE;
break;
case '>':
/* GSM07.07 6.2 - Direct dialling from phone book supplementary service subscription
{
/* The character in u we are processing... */
/* V.250 5.4.1 says upper and lower case are equivalent in commands */
- index = (unsigned char) toupper(u[i]);
+ index = toupper((int) u[i]);
/* Is there a child node for this character? */
/* Note: First and last could have been packed into one uint16_t,
but space is not that critical, so the other packing is good
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: awgn.c,v 1.22 2009/02/10 13:06:46 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bell_r2_mf.c,v 1.39.4.1 2009/12/23 14:23:48 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bert.c,v 1.33 2009/04/14 16:04:53 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bit_operations.c,v 1.16 2009/02/03 16:28:39 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bitstream.c,v 1.18.4.1 2009/12/28 12:20:46 steveu Exp $
*/
/*! \file */
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(void) bitstream_flush(bitstream_state_t *s, uint8_t **c)
+SPAN_DECLARE(void) bitstream_emit(bitstream_state_t *s, uint8_t **c)
{
+ uint32_t bitstream;
+
if (s->residue > 0)
{
- s->bitstream &= ((1 << s->residue) - 1);
+ bitstream = s->bitstream & ((1 << s->residue) - 1);
if (s->lsb_first)
- *(*c)++ = (uint8_t) s->bitstream;
+ *(*c) = (uint8_t) bitstream;
else
- *(*c)++ = (uint8_t) (s->bitstream << (8 - s->residue));
+ *(*c) = (uint8_t) (bitstream << (8 - s->residue));
+ }
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) bitstream_flush(bitstream_state_t *s, uint8_t **c)
+{
+ if (s->residue > 0)
+ {
+ bitstream_emit(s, c);
+ (*c)++;
s->residue = 0;
}
s->bitstream = 0;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_filters.c,v 1.16 2009/02/03 16:28:39 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_vector_float.c,v 1.16 2009/07/12 09:23:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_vector_int.c,v 1.9 2009/07/12 09:23:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: crc.c,v 1.6 2009/02/03 16:28:39 steveu Exp $
*/
/*! \file */
static const uint32_t crc_itu32_table[] =
{
- 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
- 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
- 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
- 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
- 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
- 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
- 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
- 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
- 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
- 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
- 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
- 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
- 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
- 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
- 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
- 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
- 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
- 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
- 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
- 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
- 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
- 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
- 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
- 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
- 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
- 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
- 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
- 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
- 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
- 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
- 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
- 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
- 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
- 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
- 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
- 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
- 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
- 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
- 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
- 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
- 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
- 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
- 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
- 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
- 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
- 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
- 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
- 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
- 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
- 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
- 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
- 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
- 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
- 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
- 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
- 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
- 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
- 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
- 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
- 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
- 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
- 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
- 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
- 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
+ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
+ 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
+ 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
+ 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
+ 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
+ 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
+ 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
+ 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
+ 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
+ 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
+ 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
+ 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
+ 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
+ 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
+ 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
+ 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
+ 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
+ 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
+ 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
+ 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
+ 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
+ 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
+ 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
+ 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
+ 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
+ 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
+ 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
+ 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
+ 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
+ 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
+ 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
SPAN_DECLARE(uint32_t) crc_itu32_calc(const uint8_t *buf, int len, uint32_t crc)
}
/*- End of function --------------------------------------------------------*/
+SPAN_DECLARE(uint16_t) crc_itu16_bits(uint8_t buf, int len, uint16_t crc)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ {
+ if (((buf ^ crc) & 1))
+ crc = (crc >> 1) ^ 0x8408;
+ else
+ crc = crc >> 1;
+ buf >>= 1;
+ }
+ return crc;
+}
+/*- End of function --------------------------------------------------------*/
+
SPAN_DECLARE(int) crc_itu16_append(uint8_t *buf, int len)
{
uint16_t crc;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dds_float.c,v 1.11 2009/02/03 16:28:39 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dds_int.c,v 1.16 2009/02/21 04:27:46 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dtmf.c,v 1.53 2009/04/12 09:12:10 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo.c,v 1.33 2009/09/22 13:11:04 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax.c,v 1.96.4.1 2009/12/19 10:44:10 steveu Exp $
*/
/*! \file */
#include "spandsp/logging.h"
#include "spandsp/queue.h"
#include "spandsp/dc_restore.h"
+#include "spandsp/vector_int.h"
#include "spandsp/power_meter.h"
#include "spandsp/complex.h"
#include "spandsp/tone_detect.h"
#include "spandsp/async.h"
#include "spandsp/hdlc.h"
#include "spandsp/silence_gen.h"
+#include "spandsp/super_tone_rx.h"
#include "spandsp/fsk.h"
+#include "spandsp/modem_connect_tones.h"
+#include "spandsp/v8.h"
#include "spandsp/v29tx.h"
#include "spandsp/v29rx.h"
#include "spandsp/v27ter_tx.h"
#include "spandsp/v27ter_rx.h"
#include "spandsp/v17tx.h"
#include "spandsp/v17rx.h"
-#include "spandsp/super_tone_rx.h"
-#include "spandsp/modem_connect_tones.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/silence_gen.h"
#include "spandsp/private/fsk.h"
+#include "spandsp/private/modem_connect_tones.h"
+#include "spandsp/private/v8.h"
#include "spandsp/private/v17tx.h"
#include "spandsp/private/v17rx.h"
#include "spandsp/private/v27ter_tx.h"
#include "spandsp/private/v27ter_rx.h"
#include "spandsp/private/v29tx.h"
#include "spandsp/private/v29rx.h"
-#include "spandsp/private/modem_connect_tones.h"
#include "spandsp/private/hdlc.h"
#include "spandsp/private/fax_modems.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "spandsp/private/t30.h"
}
/*- End of function --------------------------------------------------------*/
+#if 0
+static void v8_handler(void *user_data, v8_parms_t *result)
+{
+ fax_state_t *s;
+
+ s = (fax_state_t *) user_data;
+ span_log(&s->logging, SPAN_LOG_FLOW, "V.8 report received\n");
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
static void hdlc_underflow_handler(void *user_data)
{
t30_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_rx(fax_state_t *s, int16_t *amp, int len)
+SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len)
{
int i;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_rx_fillin(fax_state_t *s, int len)
+SPAN_DECLARE_NONSTD(int) fax_rx_fillin(fax_state_t *s, int len)
{
/* To mitigate the effect of lost packets on a packet network we should
try to sustain the status quo. If there is no receive modem running, keep
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len)
+SPAN_DECLARE_NONSTD(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len)
{
int len;
#if defined(LOG_FAX_AUDIO)
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party)
+SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party)
{
- if (s == NULL)
- {
- if ((s = (fax_state_t *) malloc(sizeof(*s))) == NULL)
- return NULL;
- }
- memset(s, 0, sizeof(*s));
- span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
- span_log_set_protocol(&s->logging, "FAX");
- fax_modems_init(&s->modems,
- FALSE,
- t30_hdlc_accept,
- hdlc_underflow_handler,
- t30_non_ecm_put_bit,
- t30_non_ecm_get_bit,
- tone_detected,
- &s->t30);
- t30_init(&s->t30,
- calling_party,
- fax_set_rx_type,
- (void *) s,
- fax_set_tx_type,
- (void *) s,
- fax_send_hdlc,
- (void *) s);
- t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
+#if 0
+ v8_parms_t v8_parms;
+#endif
+
+ fax_modems_restart(&s->modems);
+#if 0
+ v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR;
+ v8_parms.call_function = V8_CALL_T30_RX;
+ v8_parms.modulations = V8_MOD_V21;
+ if (s->t30.supported_modems & T30_SUPPORT_V27TER)
+ v8_parms.modulations |= V8_MOD_V27TER;
+ if (s->t30.supported_modems & T30_SUPPORT_V29)
+ v8_parms.modulations |= V8_MOD_V29;
+ if (s->t30.supported_modems & T30_SUPPORT_V17)
+ v8_parms.modulations |= V8_MOD_V17;
+ if (s->t30.supported_modems & T30_SUPPORT_V34HDX)
+ v8_parms.modulations |= V8_MOD_V34HDX;
+ v8_parms.protocol = V8_PROTOCOL_NONE;
+ v8_parms.pcm_modem_availability = 0;
+ v8_parms.pstn_access = 0;
+ v8_parms.nsf = -1;
+ v8_parms.t66 = -1;
+ v8_restart(&s->v8, calling_party, &v8_parms);
+#endif
t30_restart(&s->t30);
#if defined(LOG_FAX_AUDIO)
{
s->modems.audio_tx_log = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0666);
}
#endif
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party)
+{
+#if 0
+ v8_parms_t v8_parms;
+#endif
+
+ if (s == NULL)
+ {
+ if ((s = (fax_state_t *) malloc(sizeof(*s))) == NULL)
+ return NULL;
+ }
+ memset(s, 0, sizeof(*s));
+ span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
+ span_log_set_protocol(&s->logging, "FAX");
+ fax_modems_init(&s->modems,
+ FALSE,
+ t30_hdlc_accept,
+ hdlc_underflow_handler,
+ t30_non_ecm_put_bit,
+ t30_non_ecm_get_bit,
+ tone_detected,
+ &s->t30);
+ t30_init(&s->t30,
+ calling_party,
+ fax_set_rx_type,
+ (void *) s,
+ fax_set_tx_type,
+ (void *) s,
+ fax_send_hdlc,
+ (void *) s);
+ t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
+#if 0
+ v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR;
+ v8_parms.call_function = V8_CALL_T30_RX;
+ v8_parms.modulations = V8_MOD_V21;
+ if (s->t30.supported_modems & T30_SUPPORT_V27TER)
+ v8_parms.modulations |= V8_MOD_V27TER;
+ if (s->t30.supported_modems & T30_SUPPORT_V29)
+ v8_parms.modulations |= V8_MOD_V29;
+ if (s->t30.supported_modems & T30_SUPPORT_V17)
+ v8_parms.modulations |= V8_MOD_V17;
+ if (s->t30.supported_modems & T30_SUPPORT_V34HDX)
+ v8_parms.modulations |= V8_MOD_V34HDX;
+ v8_parms.protocol = V8_PROTOCOL_NONE;
+ v8_parms.pcm_modem_availability = 0;
+ v8_parms.pstn_access = 0;
+ v8_parms.nsf = -1;
+ v8_parms.t66 = -1;
+ v8_init(&s->v8, calling_party, &v8_parms, v8_handler, s);
+#endif
+ fax_restart(s, calling_party);
return s;
}
/*- End of function --------------------------------------------------------*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_modems.c,v 1.8 2009/11/02 13:25:20 steveu Exp $
*/
/*! \file */
#define HDLC_FRAMING_OK_THRESHOLD 5
-SPAN_DECLARE(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len)
+SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len)
{
fax_modems_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len)
+SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len)
{
fax_modems_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len)
+SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len)
{
fax_modems_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len)
+SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len)
{
fax_modems_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len)
+SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len)
{
fax_modems_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len)
+SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len)
{
fax_modems_state_t *s;
}
/*- End of function --------------------------------------------------------*/
+SPAN_DECLARE(int) fax_modems_restart(fax_modems_state_t *s)
+{
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
int use_tep,
hdlc_frame_handler_t hdlc_accept,
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: faxfont.h,v 1.6 2008/04/17 14:26:56 steveu Exp $
*/
#if !defined(_FAXFONT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: filter_tools.c,v 1.11 2009/10/05 16:33:25 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: filter_tools.h,v 1.3 2008/04/17 14:26:56 steveu Exp $
*/
#if !defined(_FILTER_TOOLS_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: floating_fudge.h,v 1.7 2009/02/03 16:28:39 steveu Exp $
*/
#if !defined(_FLOATING_FUDGE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fsk.c,v 1.60 2009/11/02 13:25:20 steveu Exp $
*/
/*! \file */
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) fsk_rx_fillin(fsk_rx_state_t *s, int len)
+SPAN_DECLARE_NONSTD(int) fsk_rx_fillin(fsk_rx_state_t *s, int len)
{
/* The valid choice here is probably to do nothing. We don't change state
(i.e carrier on<->carrier off), and we'll just output less bits than we
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g711.c,v 1.16 2009/02/10 13:06:46 steveu Exp $
*/
/*! \file */
* Copyright (c) CMU 1993
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
- *
- * $Id: g722.c,v 1.10 2009/04/22 12:57:40 steveu Exp $
*/
/*! \file */
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
- *
- * $Id: g726.c,v 1.28.4.1 2009/12/28 12:20:46 steveu Exp $
*/
/*! \file */
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_decode.c,v 1.25 2009/02/03 16:28:39 steveu Exp $
*/
/*! \file */
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_encode.c,v 1.30 2009/02/10 13:06:46 steveu Exp $
*/
/*! \file */
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_local.h,v 1.15 2009/03/13 15:57:29 steveu Exp $
*/
#if !defined(_GSM0610_LOCAL_H_)
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_long_term.c,v 1.24 2009/04/20 16:36:36 steveu Exp $
*/
/*! \file */
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_lpc.c,v 1.29 2009/02/05 15:57:27 steveu Exp $
*/
/*! \file */
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_preprocess.c,v 1.17 2009/02/03 16:28:39 steveu Exp $
*/
/*! \file */
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_rpe.c,v 1.25.4.2 2009/12/28 11:54:58 steveu Exp $
*/
/*! \file */
: "eax", "edx", "esi", "memory"
);
#else
- int32_t L_result;
+ int32_t result;
int k;
/* The coefficients of the weighting filter are stored in a table
/* Compute the signal x[0..39] */
for (k = 0; k < 40; k++)
{
- L_result = 8192 >> 1;
+ result = 8192 >> 1;
/* for (i = 0; i <= 10; i++)
* {
- * L_temp = saturated_mul_16_32(wt[k + i], gsm_H[i]);
- * L_result = saturated_add32(L_result, L_temp);
+ * temp = saturated_mul16_32(wt[k + i], gsm_H[i]);
+ * result = saturated_add32(result, temp);
* }
*/
but I don't see an elegant way to optimize this.
Do you?
*/
- L_result += STEP( 0, -134);
- L_result += STEP( 1, -374);
- /* += STEP( 2, 0 ); */
- L_result += STEP( 3, 2054);
- L_result += STEP( 4, 5741);
- L_result += STEP( 5, 8192);
- L_result += STEP( 6, 5741);
- L_result += STEP( 7, 2054);
- /* += STEP( 8, 0 ); */
- L_result += STEP( 9, -374);
- L_result += STEP(10, -134);
+ result += STEP( 0, -134);
+ result += STEP( 1, -374);
+ /* += STEP( 2, 0 ); */
+ result += STEP( 3, 2054);
+ result += STEP( 4, 5741);
+ result += STEP( 5, 8192);
+ result += STEP( 6, 5741);
+ result += STEP( 7, 2054);
+ /* += STEP( 8, 0 ); */
+ result += STEP( 9, -374);
+ result += STEP(10, -134);
/* 2 adds vs. >> 16 => 14, minus one shift to compensate for
those we lost when replacing L_MULT by '*'. */
- L_result >>= 13;
- x[k] = saturate(L_result);
+ result >>= 13;
+ x[k] = saturate(result);
}
/*endfor*/
#endif
*
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
- *
- * $Id: gsm0610_short_term.c,v 1.19 2009/02/03 16:28:39 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: hdlc.c,v 1.72 2009/06/02 16:03:56 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: ima_adpcm.c,v 1.36 2009/04/11 18:11:19 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: logging.c,v 1.32 2009/02/10 17:44:18 steveu Exp $
*/
/*! \file */
* This code is based on the U.S. Department of Defense reference
* implementation of the LPC-10 2400 bps Voice Coder. They do not
* exert copyright claims on their code, and it may be freely used.
- *
- * $Id: lpc10_analyse.c,v 1.22 2009/01/28 03:41:27 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* This code is based on the U.S. Department of Defense reference
* implementation of the LPC-10 2400 bps Voice Coder. They do not
* exert copyright claims on their code, and it may be freely used.
- *
- * $Id: lpc10_decode.c,v 1.27.4.1 2009/12/24 17:00:19 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
float slope;
float uvpit;
float xxy;
+ float msix;
rci_dim1 = LPC10_ORDER;
rci_offset = rci_dim1 + 1;
xxy = expf(xxy);
rci[j + *nout*rci_dim1 + 1] = (xxy - 1.0f)/(xxy + 1.0f);
}
- rmsi[*nout - 1] = expf(logf(s->rmso) + prop*(logf(*rms) - logf(s->rmso)));
+ msix = logf(*rms) - logf(s->rmso);
+ msix = prop*msix;
+ msix = logf(s->rmso) + msix;
+ rmsi[*nout - 1] = expf(msix);
}
}
if (vflag != 1)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: lpc10_encdecs.h,v 1.11 2008/04/17 14:26:56 steveu Exp $
*/
#define LPC10_ORDER 10
* This code is based on the U.S. Department of Defense reference
* implementation of the LPC-10 2400 bps Voice Coder. They do not
* exert copyright claims on their code, and it may be freely used.
- *
- * $Id: lpc10_encode.c,v 1.28 2009/02/10 13:06:46 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* This code is based on the U.S. Department of Defense reference
* implementation of the LPC-10 2400 bps Voice Coder. They do not
* exert copyright claims on their code, and it may be freely used.
- *
- * $Id: lpc10_placev.c,v 1.19 2009/01/28 03:41:27 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* This code is based on the U.S. Department of Defense reference
* implementation of the LPC-10 2400 bps Voice Coder. They do not
* exert copyright claims on their code, and it may be freely used.
- *
- * $Id: lpc10_voicing.c,v 1.18 2009/02/03 16:28:39 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1,
- * as published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: make_at_dictionary.c,v 1.6 2009/10/09 14:53:57 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: make_modem_filter.c,v 1.17.4.1 2009/12/28 12:20:46 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
double baud_rate;
double rx_excess_bandwidth;
double tx_excess_bandwidth;
- const char *tag;
+ const char *rx_tag;
+ const char *tx_tag;
const char *modem;
fixed_point = FALSE;
tx_excess_bandwidth = 0.25;
carrier = 1800.0;
baud_rate = 2400.0;
- tag = "";
+ rx_tag = "";
+ tx_tag = "";
}
else if (strcmp(modem, "V.22bis") == 0)
{
/* This is only intended to apply to transmit. */
rx_coeff_sets = 12;
- rx_coeffs_per_filter = 37;
+ rx_coeffs_per_filter = 27;
rx_excess_bandwidth = 0.75;
tx_coeff_sets = 40;
tx_coeffs_per_filter = 9;
tx_excess_bandwidth = 0.75;
carrier = 1200.0;
baud_rate = 600.0;
- tag = "";
+ rx_tag = "";
+ tx_tag = "";
}
else if (strcmp(modem, "V.22bis1200") == 0)
{
/* This is only intended to apply to receive. */
rx_coeff_sets = 12;
- rx_coeffs_per_filter = 37;
+ rx_coeffs_per_filter = 27;
rx_excess_bandwidth = 0.75;
tx_coeff_sets = 40;
tx_coeffs_per_filter = 9;
tx_excess_bandwidth = 0.75;
carrier = 1200.0;
baud_rate = 600.0;
- tag = "_1200";
+ rx_tag = "_1200";
+ tx_tag = "_1200";
}
else if (strcmp(modem, "V.22bis2400") == 0)
{
/* This is only intended to apply to receive. */
rx_coeff_sets = 12;
- rx_coeffs_per_filter = 37;
+ rx_coeffs_per_filter = 27;
rx_excess_bandwidth = 0.75;
tx_coeff_sets = 40;
tx_coeffs_per_filter = 9;
tx_excess_bandwidth = 0.75;
carrier = 2400.0;
baud_rate = 600.0;
- tag = "_2400";
+ rx_tag = "_2400";
+ tx_tag = "_2400";
}
- else if (strcmp(modem, "V.27ter4800") == 0)
+ else if (strcmp(modem, "V.27ter2400") == 0)
{
- rx_coeff_sets = 8;
+ rx_coeff_sets = 12;
rx_coeffs_per_filter = 27;
rx_excess_bandwidth = 0.5;
- tx_coeff_sets = 5;
+ tx_coeff_sets = 20;
tx_coeffs_per_filter = 9;
tx_excess_bandwidth = 0.5;
carrier = 1800.0;
- baud_rate = 1600.0;
- tag = "_4800";
+ baud_rate = 1200.0;
+ rx_tag = "_2400";
+ tx_tag = "_2400";
}
- else if (strcmp(modem, "V.27ter2400") == 0)
+ else if (strcmp(modem, "V.27ter4800") == 0)
{
- rx_coeff_sets = 12;
+ rx_coeff_sets = 8;
rx_coeffs_per_filter = 27;
rx_excess_bandwidth = 0.5;
- tx_coeff_sets = 20;
+ tx_coeff_sets = 5;
tx_coeffs_per_filter = 9;
tx_excess_bandwidth = 0.5;
carrier = 1800.0;
- baud_rate = 1200.0;
- tag = "_2400";
+ baud_rate = 1600.0;
+ rx_tag = "_4800";
+ tx_tag = "_4800";
}
else if (strcmp(modem, "V.29") == 0)
{
tx_excess_bandwidth = 0.25;
carrier = 1700.0;
baud_rate = 2400.0;
- tag = "";
+ rx_tag = "";
+ tx_tag = "";
}
else
{
baud_rate,
tx_excess_bandwidth,
fixed_point,
- tag);
+ tx_tag);
}
else
{
baud_rate,
rx_excess_bandwidth,
fixed_point,
- tag);
+ rx_tag);
}
return 0;
}
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: mmx_sse_decs.h,v 1.1 2009/07/12 09:23:09 steveu Exp $
*/
#if !defined(_MMX_SSE_DECS_H_)
* SpanDSP - a series of DSP components for telephony
*
* modem_connect_tones.c - Generation and detection of tones
- * associated with modems calling and answering calls.
+ * associated with modems calling and answering calls.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_connect_tones.c,v 1.41 2009/11/06 19:21:33 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_echo.c,v 1.26 2009/09/22 13:11:04 steveu Exp $
*/
/*! \file */
#include "spandsp/private/modem_echo.h"
-SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_create(int len)
+SPAN_DECLARE(void) modem_echo_can_free(modem_echo_can_state_t *ec)
+{
+ fir16_free(&ec->fir_state);
+ free(ec->fir_taps32);
+ free(ec->fir_taps16);
+ free(ec);
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len)
{
modem_echo_can_state_t *ec;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(void) modem_echo_can_free(modem_echo_can_state_t *ec)
-{
- fir16_free(&ec->fir_state);
- free(ec->fir_taps32);
- free(ec->fir_taps16);
- free(ec);
-}
-/*- End of function --------------------------------------------------------*/
-
SPAN_DECLARE(void) modem_echo_can_flush(modem_echo_can_state_t *ec)
{
ec->tx_power = 0;
*
*
* This file is released in the public domain.
- *
- * $Id: config.h,v 1.4 2009/02/25 15:30:21 steveu Exp $
*/
#if !defined(_MSVC_CONFIG_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: noise.c,v 1.31 2009/02/10 13:06:46 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: playout.c,v 1.17 2009/02/10 13:06:46 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: plc.c,v 1.27.4.1 2009/12/23 14:23:49 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: power_meter.c,v 1.31 2009/05/30 17:29:23 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: queue.c,v 1.31 2009/04/11 18:11:19 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: schedule.c,v 1.22 2009/02/10 13:06:46 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: sig_tone.c,v 1.40 2010/05/12 15:32:41 steveu Exp $
*/
/*! \file */
SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int tone_type, tone_report_func_t sig_update, void *user_data)
{
-#if !defined(SPANDSP_USE_FIXED_POINT)
int i;
+#if !defined(SPANDSP_USE_FIXED_POINT)
int j;
#endif
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: silence_gen.c,v 1.23 2009/09/04 14:38:46 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: spandsp.h.in,v 1.19.4.1 2009/12/19 09:47:56 steveu Exp $
*/
/*! \file */
#include <spandsp/fsk.h>
#include <spandsp/modem_connect_tones.h>
#include <spandsp/silence_gen.h>
+#include <spandsp/v8.h>
+#include <spandsp/v42.h>
+#include <spandsp/v42bis.h>
#include <spandsp/v29rx.h>
#include <spandsp/v29tx.h>
#include <spandsp/v17rx.h>
#include <spandsp/v17tx.h>
+/*#include <spandsp/v32bis.h>*/
#include <spandsp/v22bis.h>
#include <spandsp/v27ter_rx.h>
#include <spandsp/v27ter_tx.h>
-#include <spandsp/v8.h>
+/*#include <spandsp/v34.h>*/
#include <spandsp/v18.h>
-#include <spandsp/v42.h>
-#include <spandsp/v42bis.h>
#include <spandsp/t4_rx.h>
#include <spandsp/t4_tx.h>
+#include <spandsp/image_translate.h>
+#include <spandsp/t4_t6_decode.h>
+#include <spandsp/t4_t6_encode.h>
+/*#include <spandsp/t81_t82_arith_coding.h>*/
+/*#include <spandsp/t85.h>*/
#include <spandsp/t30.h>
#include <spandsp/t30_api.h>
#include <spandsp/t30_fcf.h>
#include <spandsp/gsm0610.h>
#include <spandsp/plc.h>
#include <spandsp/playout.h>
+#include <spandsp/timezone.h>
#endif
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: adsi.h,v 1.40 2009/05/22 16:39:01 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: arctan2.h,v 1.13 2008/05/29 13:04:19 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: async.h,v 1.25 2009/04/23 14:12:34 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: at_interpreter.h,v 1.23 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: awgn.h,v 1.18 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bell_r2_mf.h,v 1.24 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bert.h,v 1.23 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_BERT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: biquad.h,v 1.14 2008/04/17 14:26:59 steveu Exp $
*/
/*! \page biquad_page Bi-quadratic filter sections
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bit_operations.h,v 1.27 2009/07/10 13:15:56 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bitstream.h,v 1.14.4.1 2009/12/28 12:20:47 steveu Exp $
*/
/*! \file */
\return The value retrieved from the input buffer. */
SPAN_DECLARE(uint32_t) bitstream_get(bitstream_state_t *s, const uint8_t **c, int bits);
-/*! \brief Flush any residual bit to the output buffer.
+/*! \brief Emit any residual bits to the output buffer, without actually flushing them.
+ This is useful for getting the buffer fully up to date, ready for things
+ like CRC calculations, while allowing bitstream_put() to be used to continue
+ the message later.
+ \param s A pointer to the bitstream context.
+ \param c A pointer to the bitstream output buffer. */
+SPAN_DECLARE(void) bitstream_emit(bitstream_state_t *s, uint8_t **c);
+
+/*! \brief Flush any residual bits to the output buffer.
\param s A pointer to the bitstream context.
\param c A pointer to the bitstream output buffer. */
SPAN_DECLARE(void) bitstream_flush(bitstream_state_t *s, uint8_t **c);
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex.h,v 1.20 2009/02/21 05:39:08 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_filters.h,v 1.14 2009/02/03 16:28:41 steveu Exp $
*/
#if !defined(_SPANDSP_COMPLEX_FILTERS_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_vector_float.h,v 1.13 2009/02/04 13:18:53 steveu Exp $
*/
#if !defined(_SPANDSP_COMPLEX_VECTOR_FLOAT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_vector_int.h,v 1.4 2009/01/31 08:48:11 steveu Exp $
*/
#if !defined(_SPANDSP_COMPLEX_VECTOR_INT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: crc.h,v 1.5 2009/01/31 08:48:11 steveu Exp $
*/
/*! \file */
*/
SPAN_DECLARE(int) crc_itu32_check(const uint8_t *buf, int len);
-/*! \brief Calculate the ITU/CCITT CRC-16 value in buffer.
+/*! \brief Calculate the ITU/CCITT CRC-16 value in buffer by whole bytes.
\param buf The buffer containing the data.
\param len The length of the frame.
\param crc The initial CRC value. This is usually 0xFFFF, or 0 for a new block (it depends on
*/
SPAN_DECLARE(uint16_t) crc_itu16_calc(const uint8_t *buf, int len, uint16_t crc);
+/*! \brief Calculate the ITU/CCITT CRC-16 value of some bits from a byte.
+ \param buf The buffer containing the byte of data.
+ \param len The number of bits, starting from the LSB.
+ \param crc The initial CRC value. This is usually 0xFFFF, or 0 for a new block (it depends on
+ the application). It is previous returned CRC value for the continuation of a block.
+ \return The CRC value.
+*/
+SPAN_DECLARE(uint16_t) crc_itu16_bits(uint8_t buf, int len, uint16_t crc);
+
/*! \brief Append an ITU/CCITT CRC-16 value to a frame.
\param buf The buffer containing the frame. This must be at least 2 bytes longer than
the frame it contains, to allow room for the CRC value.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dc_restore.h,v 1.24 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dds.h,v 1.23 2009/01/31 08:48:11 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dtmf.h,v 1.32 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_DTMF_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo.h,v 1.20 2009/09/22 13:11:04 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: expose.h,v 1.14.4.1 2009/12/19 09:47:56 steveu Exp $
*/
/*! \file */
#include <spandsp/private/modem_echo.h>
#include <spandsp/private/async.h>
#include <spandsp/private/fsk.h>
-#include <spandsp/private/v29rx.h>
-#include <spandsp/private/v29tx.h>
+#include <spandsp/private/modem_connect_tones.h>
+#include <spandsp/private/v8.h>
#include <spandsp/private/v17rx.h>
#include <spandsp/private/v17tx.h>
#include <spandsp/private/v22bis.h>
#include <spandsp/private/v27ter_rx.h>
#include <spandsp/private/v27ter_tx.h>
-#include <spandsp/private/modem_connect_tones.h>
+#include <spandsp/private/v29rx.h>
+#include <spandsp/private/v29tx.h>
+/*#include <spandsp/private/v32bis.h>*/
+/*#include <spandsp/private/v34.h>*/
#include <spandsp/private/at_interpreter.h>
#include <spandsp/private/fax_modems.h>
+#include <spandsp/private/image_translate.h>
+#include <spandsp/private/t4_t6_decode.h>
+#include <spandsp/private/t4_t6_encode.h>
+/*#include <spandsp/private/t81_t82_arith_coding.h>*/
+/*#include <spandsp/private/t85.h>*/
#include <spandsp/private/t4_rx.h>
#include <spandsp/private/t4_tx.h>
#include <spandsp/private/t30.h>
#include <spandsp/private/t38_gateway.h>
#include <spandsp/private/t38_terminal.h>
#include <spandsp/private/t31.h>
-#include <spandsp/private/v8.h>
+#include <spandsp/private/timezone.h>
#include <spandsp/private/v18.h>
#include <spandsp/private/v42.h>
#include <spandsp/private/v42bis.h>
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fast_convert.h,v 1.9 2009/10/03 04:37:25 steveu Exp $
*/
#if !defined(_SPANDSP_FAST_CONVERT_H_)
*/
#if defined(__CYGWIN__)
-#if !defined(__cplusplus)
+#if !defined(__cplusplus) && (__GNUC__ < 4)
/*
- * CYGWIN has lrint and lrintf functions, but they are slow and buggy:
+ * CYGWIN versions prior to 1.7.1 have lrint and lrintf functions, but
+ * they are slow and buggy:
* http://sourceware.org/ml/cygwin/2005-06/msg00153.html
* http://sourceware.org/ml/cygwin/2005-09/msg00047.html
- * The latest version of cygwin seems to have made no effort to fix this.
* These replacement functions (pulled from the Public Domain MinGW
* math.h header) replace the native versions.
*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax.h,v 1.39 2009/03/13 12:59:26 steveu Exp $
*/
/*! \file */
\return The number of samples unprocessed. This should only be non-zero if
the software has reached the end of the FAX call.
*/
-SPAN_DECLARE(int) fax_rx(fax_state_t *s, int16_t *amp, int len);
+SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len);
/*! Apply fake T.30 receive processing when a block of audio samples is missing (e.g due
to packet loss).
\return The number of samples unprocessed. This should only be non-zero if
the software has reached the end of the FAX call.
*/
-SPAN_DECLARE(int) fax_rx_fillin(fax_state_t *s, int len);
+SPAN_DECLARE_NONSTD(int) fax_rx_fillin(fax_state_t *s, int len);
/*! Apply T.30 transmit processing to generate a block of audio samples.
\brief Apply T.30 transmit processing to generate a block of audio samples.
\return The number of samples actually generated. This will be zero when
there is nothing to send.
*/
-SPAN_DECLARE(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len);
+SPAN_DECLARE_NONSTD(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len);
/*! Select whether silent audio will be sent when FAX transmit is idle.
\brief Select whether silent audio will be sent when FAX transmit is idle.
*/
SPAN_DECLARE(logging_state_t *) fax_get_logging_state(fax_state_t *s);
+/*! Restart a FAX context.
+ \brief Restart a FAX context.
+ \param s The FAX context.
+ \param calling_party TRUE if the context is for a calling party. FALSE if the
+ context is for an answering party.
+ \return 0 for OK, else -1. */
+SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party);
+
/*! Initialise a FAX context.
\brief Initialise a FAX context.
\param s The FAX context.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_modems.h,v 1.11 2009/04/26 12:55:23 steveu Exp $
*/
/*! \file */
#endif
/* N.B. the following are currently a work in progress */
-SPAN_DECLARE(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len);
-SPAN_DECLARE(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len);
-SPAN_DECLARE(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len);
-SPAN_DECLARE(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len);
-SPAN_DECLARE(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len);
-SPAN_DECLARE(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len);
+SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len);
+SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len);
+SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len);
+SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len);
+SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len);
+SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len);
SPAN_DECLARE(void) fax_modems_start_rx_modem(fax_modems_state_t *s, int which);
SPAN_DECLARE(void) fax_modems_set_tep_mode(fax_modems_state_t *s, int use_tep);
+SPAN_DECLARE(int) fax_modems_restart(fax_modems_state_t *s);
+
SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
int use_tep,
hdlc_frame_handler_t hdlc_accept,
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fir.h,v 1.13 2008/04/17 14:27:00 steveu Exp $
*/
/*! \page fir_page FIR filtering
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fsk.h,v 1.41 2009/11/02 13:25:20 steveu Exp $
*/
/*! \file */
\param len The number of samples to fake.
\return The number of samples unprocessed.
*/
-SPAN_DECLARE(int) fsk_rx_fillin(fsk_rx_state_t *s, int len);
+SPAN_DECLARE_NONSTD(int) fsk_rx_fillin(fsk_rx_state_t *s, int len);
SPAN_DECLARE(void) fsk_rx_set_put_bit(fsk_rx_state_t *s, put_bit_func_t put_bit, void *user_data);
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g168models.h,v 1.9 2008/08/29 09:28:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g711.h,v 1.19 2009/04/12 09:12:10 steveu Exp $
*/
/*! \file */
*/
/* Enable the trap as per the MIL-STD */
-//#define ULAW_ZEROTRAP
+//#define G711_ULAW_ZEROTRAP
/*! Bias for u-law encoding from linear. */
-#define ULAW_BIAS 0x84
+#define G711_ULAW_BIAS 0x84
/*! \brief Encode a linear sample to u-law
\param linear The sample to encode.
/* Get the sign and the magnitude of the value. */
if (linear >= 0)
{
- linear = ULAW_BIAS + linear;
+ linear = G711_ULAW_BIAS + linear;
mask = 0xFF;
}
else
{
- linear = ULAW_BIAS - linear;
+ linear = G711_ULAW_BIAS - linear;
mask = 0x7F;
}
u_val = (uint8_t) (0x7F ^ mask);
else
u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
-#ifdef ULAW_ZEROTRAP
+#if defined(G711_ULAW_ZEROTRAP)
/* Optional ITU trap */
if (u_val == 0)
u_val = 0x02;
* Extract and bias the quantization bits. Then
* shift up by the segment number and subtract out the bias.
*/
- t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
- return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
+ t = (((ulaw & 0x0F) << 3) + G711_ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
+ return (int16_t) ((ulaw & 0x80) ? (G711_ULAW_BIAS - t) : (t - G711_ULAW_BIAS));
}
/*- End of function --------------------------------------------------------*/
*/
/*! The A-law alternate mark inversion mask */
-#define ALAW_AMI_MASK 0x55
+#define G711_ALAW_AMI_MASK 0x55
/*! \brief Encode a linear sample to A-law
\param linear The sample to encode.
if (linear >= 0)
{
/* Sign (bit 7) bit = 1 */
- mask = ALAW_AMI_MASK | 0x80;
+ mask = G711_ALAW_AMI_MASK | 0x80;
}
else
{
/* Sign (bit 7) bit = 0 */
- mask = ALAW_AMI_MASK;
+ mask = G711_ALAW_AMI_MASK;
linear = -linear - 1;
}
int i;
int seg;
- alaw ^= ALAW_AMI_MASK;
+ alaw ^= G711_ALAW_AMI_MASK;
i = ((alaw & 0x0F) << 4);
seg = (((int) alaw & 0x70) >> 4);
if (seg)
***** Copyright (c) CMU 1993 *****
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
- *
- * $Id: g722.h,v 1.26 2009/04/12 09:12:10 steveu Exp $
*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g726.h,v 1.26 2009/04/12 09:12:10 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: gsm0610.h,v 1.21 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_GSM0610_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: hdlc.h,v 1.45 2009/06/02 16:03:56 steveu Exp $
*/
/*! \file */
*
* Based on a bit from here, a bit from there, eye of toad,
* ear of bat, etc - plus, of course, my own 2 cents.
- *
- * $Id: ima_adpcm.h,v 1.25 2009/04/11 18:11:19 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: logging.h,v 1.20 2009/02/10 17:44:18 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: lpc10.h,v 1.22 2009/04/11 18:11:19 steveu Exp $
*/
#if !defined(_SPANDSP_LPC10_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_connect_tones.h,v 1.24 2009/06/02 16:03:56 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_echo.h,v 1.14 2009/09/22 13:11:04 steveu Exp $
*/
/*! \file */
\param len The length of the canceller, in samples.
eturn The new canceller context, or NULL if the canceller could not be created.
*/
-SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_create(int len);
+SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len);
/*! Free a modem echo canceller context.
\param ec The echo canceller context.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: noise.h,v 1.17 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: oki_adpcm.h,v 1.24 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: playout.h,v 1.14 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_PLAYOUT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: plc.h,v 1.21 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: power_meter.h,v 1.19 2009/05/19 14:15:09 steveu Exp $
*/
#if !defined(_POWER_METER_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: adsi.h,v 1.4 2009/04/12 04:20:01 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: async.h,v 1.1 2008/11/30 10:17:31 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_ASYNC_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: at_interpreter.h,v 1.1 2008/11/30 05:43:37 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: awgn.h,v 1.1 2008/11/30 12:38:27 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_AWGN_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bell_r2_mf.h,v 1.2 2008/10/13 14:19:18 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_BELL_R2_MF_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bert.h,v 1.2 2009/04/14 16:04:54 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_BERT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bitstream.h,v 1.1.4.1 2009/12/28 12:20:47 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_BITSTREAM_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dtmf.h,v 1.1 2008/10/13 13:14:01 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_DTMF_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo.h,v 1.1 2009/09/22 13:11:04 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax.h,v 1.1 2008/10/13 13:14:01 steveu Exp $
*/
/*! \file */
{
/*! \brief The T.30 back-end */
t30_state_t t30;
-
+
/*! \brief The analogue modem front-end */
fax_modems_state_t modems;
+ /*! \brief V.8 */
+ //v8_state_t v8;
/*! \brief Error and flow logging control */
logging_state_t logging;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_modems.h,v 1.4 2009/09/04 14:38:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fsk.h,v 1.5 2009/04/01 13:22:40 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_FSK_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g711.h,v 1.2 2009/04/12 09:12:11 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_G711_H_)
***** Copyright (c) CMU 1993 *****
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
- *
- * $Id: g722.h,v 1.2 2009/04/12 09:12:11 steveu Exp $
*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g726.h,v 1.4 2009/04/12 09:12:11 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_G726_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: gsm0610.h,v 1.2 2008/11/15 14:27:29 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_GSM0610_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: hdlc.h,v 1.3 2009/02/12 12:38:39 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_HDLC_H_)
*
* Based on a bit from here, a bit from there, eye of toad,
* ear of bat, etc - plus, of course, my own 2 cents.
- *
- * $Id: ima_adpcm.h,v 1.1 2008/11/30 10:17:31 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_IMA_ADPCM_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: logging.h,v 1.1 2008/11/30 13:44:35 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_LOGGING_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: lpc10.h,v 1.3 2009/04/12 09:12:11 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_LPC10_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_connect_tones.h,v 1.3 2009/11/02 13:25:20 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_echo.h,v 1.1 2009/09/22 13:11:04 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: noise.h,v 1.1 2008/11/30 12:45:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: oki_adpcm.h,v 1.1 2008/11/30 10:17:31 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: queue.h,v 1.2 2009/01/31 08:48:11 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_QUEUE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: schedule.h,v 1.1 2008/11/30 05:43:37 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_SCHEDULE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: sig_tone.h,v 1.9 2010/03/11 14:22:30 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_SIG_TONE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: silence_gen.h,v 1.1 2009/04/12 03:29:58 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_SILENCE_GEN_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_rx.h,v 1.1 2008/11/30 10:17:31 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_SUPER_TONE_RX_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_tx.h,v 1.1 2008/11/30 10:22:19 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_SUPER_TONE_TX_H_)
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2, as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: swept_tone.h,v 1.1 2009/09/22 12:54:33 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_SWEPT_TONE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30.h,v 1.5.4.1 2009/12/19 09:47:56 steveu Exp $
*/
/*! \file */
*/
struct t30_state_s
{
- /* This must be kept the first thing in the structure, so it can be pointed
- to reliably as the structures change over time. */
/*! \brief T.4 context for reading or writing image data. */
- t4_state_t t4;
-
+ union
+ {
+ t4_state_t rx;
+ t4_state_t tx;
+ } t4;
/*! \brief The type of FAX operation currently in progress */
int operation_in_progress;
/*! \brief TRUE if behaving as the calling party */
int calling_party;
+ /*! \brief Internet aware FAX mode bit mask. */
+ int iaf;
+ /*! \brief A bit mask of the currently supported modem types. */
+ int supported_modems;
+ /*! \brief A bit mask of the currently supported image compression modes. */
+ int supported_compressions;
+ /*! \brief A bit mask of the currently supported image resolutions. */
+ int supported_resolutions;
+ /*! \brief A bit mask of the currently supported image sizes. */
+ int supported_image_sizes;
+ /*! \brief A bit mask of the currently supported T.30 special features. */
+ int supported_t30_features;
+ /*! \brief TRUE is ECM mode handling is enabled. */
+ int ecm_allowed;
+#if 0
+ /*! \brief TRUE if we are capable of retransmitting pages */
+ int retransmit_capable;
+#endif
+
/*! \brief The received DCS, formatted as an ASCII string, for inclusion
in the TIFF file. */
char rx_dcs_string[T30_MAX_DIS_DTC_DCS_LEN*3 + 1];
/*! \brief The text which will be used in FAX page header. No text results
in no header line. */
char header_info[T30_MAX_PAGE_HEADER_INFO + 1];
+#if 0
+ /*! \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;
+#endif
+
/*! \brief The information fields received. */
t30_exchanged_info_t rx_info;
/*! \brief The information fields to be transmitted. */
/*! \brief TRUE if a valid DIS has been received from the far end. */
int dis_received;
- /*! \brief A flag to indicate a message is in progress. */
- int in_message;
-
/*! \brief TRUE if the short training sequence should be used. */
int short_train;
int tx_stop_page;
/*! \brief The current completion status. */
int current_status;
- /*! \brief Internet aware FAX mode bit mask. */
- int iaf;
- /*! \brief A bit mask of the currently supported modem types. */
- int supported_modems;
- /*! \brief A bit mask of the currently supported image compression modes. */
- int supported_compressions;
- /*! \brief A bit mask of the currently supported image resolutions. */
- int supported_resolutions;
- /*! \brief A bit mask of the currently supported image sizes. */
- int supported_image_sizes;
- /*! \brief A bit mask of the currently supported T.30 special features. */
- int supported_t30_features;
- /*! \brief TRUE is ECM mode handling is enabled. */
- int ecm_allowed;
-
+
+#if 0
+ /*! \brief The number of RTP events */
+ int rtp_events;
+ /*! \brief The number of RTN events */
+ int rtn_events;
+#endif
+
/*! \brief the FCF2 field of the last PPS message we received. */
uint8_t last_pps_fcf2;
- /*! \brief The number of the first ECM frame which we do not currently received correctly. For
- a partial page received correctly, this will be one greater than the number of frames it
- contains. */
- int ecm_first_bad_frame;
+ /*! \brief TRUE if all frames of the current received ECM block are now OK */
+ int rx_ecm_block_ok;
/*! \brief A count of successfully received ECM frames, to assess progress as a basis for
deciding whether to continue error correction when PPRs keep repeating. */
int ecm_progress;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_dis_dtc_dcs_bits.h,v 1.1.4.1 2009/12/19 09:47:57 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t31.h,v 1.7 2009/02/12 12:38:39 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T31_H_)
typedef struct
{
fax_modems_state_t modems;
+ //v8_state_t v8;
/*! The transmit signal handler to be used when the current one has finished sending. */
span_tx_handler_t *next_tx_handler;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_core.h,v 1.4 2009/07/14 13:54:22 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T38_CORE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_non_ecm_buffer.h,v 1.2.4.1 2009/12/19 06:43:28 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T38_NON_ECM_BUFFER_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_terminal.h,v 1.2 2008/12/31 13:57:13 steveu Exp $
*/
/*! \file */
int32_t samples;
/*! \brief The value for samples at the next transmission point. */
int32_t next_tx_samples;
+ /*! \brief The current transmit timeout. */
+ //int32_t timeout_tx_samples;
/*! \brief The current receive timeout. */
int32_t timeout_rx_samples;
} t38_terminal_front_end_state_t;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_rx.h,v 1.6.2.8 2009/12/21 17:18:40 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T4_RX_H_)
/*! \brief The libtiff context for the current TIFF file */
TIFF *tiff_file;
- /*! \brief The number of pages in the current image file. */
- int pages_in_file;
-
/*! \brief The compression type for output to the TIFF file. */
int32_t output_compression;
/*! \brief The TIFF photometric setting for the current page. */
/*! \brief The TIFF G3 FAX options. */
int32_t output_t4_options;
+ /*! \brief The number of pages in the current image file. */
+ int pages_in_file;
+
/* "Background" information about the FAX, which can be stored in the image file. */
/*! \brief The vendor of the machine which produced the file. */
const char *vendor;
int stop_page;
} t4_tiff_state_t;
-typedef struct t4_t6_decode_state_s t4_t6_decode_state_t;
-
-/*!
- T.4 1D, T4 2D and T6 decompressor state.
-*/
-struct t4_t6_decode_state_s
-{
- /*! \brief Callback function to write a row of pixels to the image destination. */
- t4_row_write_handler_t row_write_handler;
- /*! \brief Opaque pointer passed to row_write_handler. */
- void *row_write_user_data;
-
- /*! \brief Incoming bit buffer for decompression. */
- uint32_t rx_bitstream;
- /*! \brief The number of bits currently in rx_bitstream. */
- int rx_bits;
- /*! \brief The number of bits to be skipped before trying to match the next code word. */
- int rx_skip_bits;
-
- /*! \brief This variable is used to count the consecutive EOLS we have seen. If it
- reaches six, this is the end of the image. It is initially set to -1 for
- 1D and 2D decoding, as an indicator that we must wait for the first EOL,
- before decoding any image data. */
- int consecutive_eols;
-
- /*! \brief The reference or starting changing element on the coding line. At the
- start of the coding line, a0 is set on an imaginary white changing element
- situated just before the first element on the line. During the coding of
- the coding line, the position of a0 is defined by the previous coding mode.
- (See T.4/4.2.1.3.2.). */
- int a0;
- /*! \brief The first changing element on the reference line to the right of a0 and of
- opposite colour to a0. */
- int b1;
- /*! \brief The length of the in-progress run of black or white. */
- int run_length;
- /*! \brief 2D horizontal mode control. */
- int black_white;
- /*! \brief TRUE if the current run is black */
- int its_black;
-
- /*! \brief The current step into the current row run-lengths buffer. */
- int a_cursor;
- /*! \brief The current step into the reference row run-lengths buffer. */
- int b_cursor;
-
- /*! \brief A pointer into the image buffer indicating where the last row begins */
- int last_row_starts_at;
-
- /*! \brief The current number of consecutive bad rows. */
- int curr_bad_row_run;
- /*! \brief The longest run of consecutive bad rows seen in the current page. */
- int longest_bad_row_run;
- /*! \brief The total number of bad rows in the current page. */
- int bad_rows;
-};
-
#endif
/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_tx.h,v 1.7.2.4 2009/12/21 17:18:40 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T4_TX_H_)
#define _SPANDSP_PRIVATE_T4_TX_H_
-typedef struct t4_t6_encode_state_s t4_t6_encode_state_t;
-
-/*!
- T.4 1D, T4 2D and T6 compressor state.
-*/
-struct t4_t6_encode_state_s
-{
- /*! \brief The minimum number of encoded bits per row. This is a timing thing
- for hardware FAX machines. */
- int min_bits_per_row;
- /*! \brief The current maximum contiguous rows that may be 2D encoded. */
- int max_rows_to_next_1d_row;
-
- /*! \brief The text which will be used in FAX page header. No text results
- in no header line. */
- const char *header_info;
-
- /*! \brief Number of rows left that can be 2D encoded, before a 1D encoded row
- must be used. */
- int rows_to_next_1d_row;
-
- /*! \brief The number of runs currently in the reference row. */
- int ref_steps;
-
- /*! \brief Pointer to the byte containing the next image bit to transmit. */
- int bit_pos;
- /*! \brief Pointer to the bit within the byte containing the next image bit to transmit. */
- int bit_ptr;
-
- /*! \brief Callback function to read a row of pixels from the image source. */
- t4_row_read_handler_t row_read_handler;
- /*! \brief Opaque pointer passed to row_read_handler. */
- void *row_read_user_data;
-};
-
/*!
T.4 FAX compression/decompression descriptor. This defines the working state
for a single instance of a T.4 FAX compression or decompression channel.
/*! \brief The time at which handling of the current page began. */
time_t page_start_time;
+ /*! \brief The text which will be used in FAX page header. No text results
+ in no header line. */
+ const char *header_info;
+ /*! \brief Optional per instance time zone for the FAX pager header timestamp. */
+ struct tz_s *tz;
+
/*! \brief The size of the compressed image on the line side, in bits. */
int line_image_size;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: time_scale.h,v 1.1 2008/11/15 14:27:29 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_TIME_SCALE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_detect.h,v 1.1 2008/11/30 10:17:31 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_TONE_DETECT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_generate.h,v 1.1 2008/11/30 10:17:31 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_TONE_GENERATE_H_)
/* Target length for the equalizer is about 63 taps, to deal with the worst stuff
in V.56bis. */
/*! The length of the equalizer buffer */
-#define V17_EQUALIZER_LEN 33
-
+//#define V17_EQUALIZER_LEN 33
+#define V17_EQUALIZER_LEN 17
/*! Samples before the target position in the equalizer buffer */
-#define V17_EQUALIZER_PRE_LEN 16
+//#define V17_EQUALIZER_PRE_LEN 16
+#define V17_EQUALIZER_PRE_LEN 8
/*! The number of taps in the pulse shaping/bandpass filter */
#define V17_RX_FILTER_STEPS 27
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17tx.h,v 1.2.4.1 2009/12/24 16:52:30 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v18.h,v 1.5 2009/11/04 15:52:06 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V18_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v22bis.h,v 1.12 2009/11/04 15:52:06 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V22BIS_H_)
#define V22BIS_TX_FILTER_STEPS 9
/*! The number of taps in the receive pulse shaping/bandpass filter */
-#define V22BIS_RX_FILTER_STEPS 37
+#define V22BIS_RX_FILTER_STEPS 27
/*! Segments of the training sequence on the receive side */
enum
struct
{
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
- float rrc_filter[2*V22BIS_RX_FILTER_STEPS];
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ int16_t rrc_filter[V22BIS_RX_FILTER_STEPS];
+#else
+ float rrc_filter[V22BIS_RX_FILTER_STEPS];
+#endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step;
/*! \brief The register for the data scrambler. */
- unsigned int scramble_reg;
+ uint32_t scramble_reg;
/*! \brief A counter for the number of consecutive bits of repeating pattern through
the scrambler. */
int scrambler_pattern_count;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_rx.h,v 1.2 2009/07/09 13:52:09 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V27TER_RX_H_)
/* Target length for the equalizer is about 43 taps for 4800bps and 32 taps for 2400bps
to deal with the worst stuff in V.56bis. */
-/*! Samples before the target position in the equalizer buffer */
-#define V27TER_EQUALIZER_PRE_LEN 16 /* This much before the real event */
-/*! Samples after the target position in the equalizer buffer */
-#define V27TER_EQUALIZER_POST_LEN 14 /* This much after the real event (must be even) */
+/*! The length of the equalizer buffer. Must be a power of 2 */
+#define V27TER_EQUALIZER_LEN 32
+/*! Samples before the target central position in the equalizer buffer */
+#define V27TER_EQUALIZER_PRE_LEN 16
/*! The number of taps in the 4800bps pulse shaping/bandpass filter */
#define V27TER_RX_4800_FILTER_STEPS 27
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
- /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_LEN];
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
- /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
- /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_LEN];
#else
/*! \brief The scaling factor accessed by the AGC algorithm. */
float agc_scaling;
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
- complexf_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ complexf_t eq_coeff[V27TER_EQUALIZER_LEN];
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
- complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
- complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ complexf_t eq_buf[V27TER_EQUALIZER_LEN];
#endif
/*! \brief Integration variable for damping the Gardner algorithm tests. */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_tx.h,v 1.3 2009/07/09 13:52:09 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V27TER_TX_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29rx.h,v 1.2 2009/07/09 13:52:09 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V29RX_H_)
/* Target length for the equalizer is about 63 taps, to deal with the worst stuff
in V.56bis. */
+/*! The length of the equalizer buffer */
+#define V29_EQUALIZER_LEN 33
/*! Samples before the target position in the equalizer buffer */
#define V29_EQUALIZER_PRE_LEN 16
-/*! Samples after the target position in the equalizer buffer */
-#define V29_EQUALIZER_POST_LEN 14
/*! The number of taps in the pulse shaping/bandpass filter */
#define V29_RX_FILTER_STEPS 27
int rrc_filter_step;
/*! \brief The register for the data scrambler. */
- unsigned int scramble_reg;
+ uint32_t scramble_reg;
/*! \brief The register for the training scrambler. */
uint8_t training_scramble_reg;
/*! \brief The current step in the table of CD constellation positions. */
/*! \brief The current delta factor for updating the equalizer coefficients. */
int16_t eq_delta;
/*! \brief The adaptive equalizer coefficients. */
- complexi16_t eq_coeff[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
+ complexi16_t eq_coeff[V29_EQUALIZER_LEN];
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
- complexi16_t eq_coeff_save[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
+ complexi16_t eq_coeff_save[V29_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
- complexi16_t eq_buf[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
+ complexi16_t eq_buf[V29_EQUALIZER_LEN];
/*! Low band edge filter for symbol sync. */
int32_t symbol_sync_low[2];
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
- complexf_t eq_coeff[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
+ complexf_t eq_coeff[V29_EQUALIZER_LEN];
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
- complexf_t eq_coeff_save[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
+ complexf_t eq_coeff_save[V29_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
- complexf_t eq_buf[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
+ complexf_t eq_buf[V29_EQUALIZER_LEN];
/*! Low band edge filter for symbol sync. */
float symbol_sync_low[2];
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29tx.h,v 1.2 2009/07/09 13:52:09 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V29TX_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42.h,v 1.2 2009/11/04 15:52:06 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V42_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42bis.h,v 1.1 2008/11/15 14:43:08 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V42BIS_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v8.h,v 1.3.4.1 2009/12/28 12:20:47 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_V8_H_)
struct v8_state_s
{
- /*! \brief TRUE if we are the calling modem */
+ /*! \brief TRUE if we are the calling party */
int calling_party;
+ /*! \brief A handler to process the V.8 signals */
v8_result_handler_t *result_handler;
+ /*! \brief An opaque pointer passed to result_handler */
void *result_handler_user_data;
/*! \brief The current state of the V.8 protocol */
modem_connect_tones_tx_state_t ansam_tx;
modem_connect_tones_rx_state_t ansam_rx;
- /*! \brief Modulation schemes available at this end. */
- unsigned int far_end_modulations;
-
v8_parms_t parms;
v8_parms_t result;
+ /*! \brief The number of modulation bytes to use when sending. */
+ int modulation_bytes;
+
/* V.8 data parsing */
uint32_t bit_stream;
int bit_cnt;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: queue.h,v 1.21 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: saturated.h,v 1.4 2009/02/05 12:21:36 steveu Exp $
*/
/*! \file */
{
#endif
+/* This is the same as saturate16(), but is here for historic reasons */
static __inline__ int16_t saturate(int32_t amp)
{
int16_t amp16;
}
/*- End of function --------------------------------------------------------*/
+static __inline__ int16_t saturate16(int32_t amp)
+{
+ int16_t amp16;
+
+ /* Hopefully this is optimised for the common case - not clipping */
+ amp16 = (int16_t) amp;
+ if (amp == amp16)
+ return amp16;
+ if (amp > INT16_MAX)
+ return INT16_MAX;
+ return INT16_MIN;
+}
+/*- End of function --------------------------------------------------------*/
+
/*! Saturate to 15 bits, rather than the usual 16 bits. This is often a useful function. */
static __inline__ int16_t saturate15(int32_t amp)
{
}
/*- End of function --------------------------------------------------------*/
+static __inline__ uint16_t saturateu16(int32_t amp)
+{
+ uint16_t amp16;
+
+ /* Hopefully this is optimised for the common case - not clipping */
+ amp16 = (uint16_t) amp;
+ if (amp == amp16)
+ return amp16;
+ if (amp > UINT16_MAX)
+ return UINT16_MAX;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ uint8_t saturateu8(int32_t amp)
+{
+ uint8_t amp8;
+
+ /* Hopefully this is optimised for the common case - not clipping */
+ amp8 = (uint8_t) amp;
+ if (amp == amp8)
+ return amp8;
+ if (amp > UINT8_MAX)
+ return UINT8_MAX;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
static __inline__ int16_t fsaturatef(float famp)
{
if (famp > (float) INT16_MAX)
static __inline__ int16_t saturated_add16(int16_t a, int16_t b)
{
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
__asm__ __volatile__(
" addw %2,%0;\n"
" jno 0f;\n"
: "cc"
);
return a;
+#elif defined(__GNUC__) && defined(__arm5__)
+ int16_t result;
+
+ __asm__ __volatile__(
+ " sadd16 %0,%1,%2;\n"
+ : "=r" (result)
+ : "0" (a), "ir" (b)
+ );
+ return result;
#else
return saturate((int32_t) a + (int32_t) b);
#endif
static __inline__ int32_t saturated_add32(int32_t a, int32_t b)
{
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
__asm__ __volatile__(
" addl %2,%0;\n"
" jno 0f;\n"
: "cc"
);
return a;
+#elif defined(__GNUC__) && defined(__arm5__)
+ int32_t result;
+
+ __asm__ __volatile__(
+ " qadd %0,%1,%2;\n"
+ : "=r" (result)
+ : "0" (a), "ir" (b)
+ );
+ return result;
#else
- uint32_t A;
+ int32_t sum;
- if (a < 0)
+ sum = a + b;
+ if ((a ^ b) >= 0)
{
- if (b >= 0)
- return a + b;
- /*endif*/
- A = (uint32_t) -(a + 1) + (uint32_t) -(b + 1);
- return (A >= INT32_MAX) ? INT32_MIN : -(int32_t) A - 2;
+ if ((sum ^ a) < 0)
+ sum = (a < 0) ? INT32_MIN : INT32_MAX;
}
- /*endif*/
- if (b <= 0)
- return a + b;
- /*endif*/
- A = (uint32_t) a + (uint32_t) b;
- return (A > INT32_MAX) ? INT32_MAX : A;
+ return sum;
#endif
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t saturated_sub16(int16_t a, int16_t b)
{
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+ __asm__ __volatile__(
+ " subw %2,%0;\n"
+ " jno 0f;\n"
+ " movw $0x8000,%0;\n"
+ " sbbw $0,%0;\n"
+ "0:"
+ : "=r" (a)
+ : "0" (a), "ir" (b)
+ : "cc"
+ );
+ return a;
+#elif defined(__GNUC__) && defined(__arm5__)
+ int16_t result;
+
+ __asm__ __volatile__(
+ " ssub16 %0,%1,%2;\n"
+ : "=r" (result)
+ : "0" (a), "ir" (b)
+ );
+ return result;
+#else
return saturate((int32_t) a - (int32_t) b);
+#endif
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int32_t saturated_sub32(int32_t a, int32_t b)
+{
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+ __asm__ __volatile__(
+ " subl %2,%0;\n"
+ " jno 0f;\n"
+ " movl $0x80000000,%0;\n"
+ " sbbl $0,%0;\n"
+ "0:"
+ : "=r" (a)
+ : "0" (a), "ir" (b)
+ : "cc"
+ );
+ return a;
+#elif defined(__GNUC__) && defined(__arm5__)
+ int32_t result;
+
+ __asm__ __volatile__(
+ " qsub %0,%1,%2;\n"
+ : "=r" (result)
+ : "0" (a), "ir" (b)
+ );
+ return result;
+#else
+ int32_t diff;
+
+ diff = a - b;
+ if ((a ^ b) < 0)
+ {
+ if ((diff ^ a) & INT32_MIN)
+ diff = (a < 0L) ? INT32_MIN : INT32_MAX;
+ }
+ return diff;
+#endif
}
/*- End of function --------------------------------------------------------*/
}
/*- End of function --------------------------------------------------------*/
-static __inline__ int32_t saturated_mul_16_32(int16_t a, int16_t b)
+static __inline__ int32_t saturated_mul16_32(int16_t a, int16_t b)
{
return ((int32_t) a*(int32_t) b) << 1;
}
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: schedule.h,v 1.20 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: sig_tone.h,v 1.23 2010/03/09 13:43:04 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: silence_gen.h,v 1.19 2009/09/04 14:38:47 steveu Exp $
*/
#if !defined(_SPANDSP_SILENCE_GEN_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_rx.h,v 1.21 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_SUPER_TONE_RX_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_tx.h,v 1.17 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_SUPER_TONE_TX_H_)
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2, as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: swept_tone.h,v 1.1 2009/09/22 12:54:33 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30.h,v 1.126.4.1 2009/12/19 09:47:56 steveu Exp $
*/
/*! \file */
T30_MODEM_V27TER,
T30_MODEM_V29,
T30_MODEM_V17,
+ T30_MODEM_V34HDX,
T30_MODEM_DONE
};
/*! Support the V.17 modem (14400, 12000, 9600 and 7200bps) for image transfer. */
T30_SUPPORT_V17 = 0x04,
/*! Support the V.34 modem (up to 33,600bps) for image transfer. */
- T30_SUPPORT_V34 = 0x08,
+ T30_SUPPORT_V34HDX = 0x08,
/*! Support the Internet aware FAX mode (no bit rate limit) for image transfer. */
T30_SUPPORT_IAF = 0x10
};
T30_SUPPORT_T4_2D_COMPRESSION = 0x04,
/*! T.6 2D compression */
T30_SUPPORT_T6_COMPRESSION = 0x08,
- /*! T.85 monochrome JBIG compression */
+ /*! T.85 monochrome JBIG compression, with fixed L0 */
T30_SUPPORT_T85_COMPRESSION = 0x10,
+ /*! T.85 monochrome JBIG compression, with variable L0 */
+ T30_SUPPORT_T85_L0_COMPRESSION = 0x20,
/*! T.43 colour JBIG compression */
- T30_SUPPORT_T43_COMPRESSION = 0x20,
+ T30_SUPPORT_T43_COMPRESSION = 0x40,
/*! T.45 run length colour compression */
- T30_SUPPORT_T45_COMPRESSION = 0x40,
+ T30_SUPPORT_T45_COMPRESSION = 0x80,
/*! T.81 + T.30 Annex E colour JPEG compression */
- T30_SUPPORT_T81_COMPRESSION = 0x80,
+ T30_SUPPORT_T81_COMPRESSION = 0x100,
/*! T.81 + T.30 Annex K colour sYCC-JPEG compression */
- T30_SUPPORT_SYCC_T81_COMPRESSION = 0x100,
+ T30_SUPPORT_SYCC_T81_COMPRESSION = 0x200,
/*! T.88 monochrome JBIG2 compression */
- T30_SUPPORT_T88_COMPRESSION = 0x200
+ T30_SUPPORT_T88_COMPRESSION = 0x400
};
enum
int longest_bad_row_run;
/*! \brief The number of HDLC frame retries, if error correcting mode is used. */
int error_correcting_mode_retries;
- /*! \brief Current status */
+ /*! \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)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_api.h,v 1.10 2009/04/12 09:12:10 steveu Exp $
*/
/*! \file */
\return A pointer to the password. */
SPAN_DECLARE(const char *) t30_get_rx_password(t30_state_t *s);
-/*! Set the transmitted ??? (i.e. the one we will send to the far
+/*! Set the transmitted TSA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Set the transmitted ??? associated with a T.30 context.
+ \brief Set the transmitted TSA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address, int len);
-/*! Get the received ??? (i.e. the one we will send to the far
+/*! Get the transmitted TSA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+ \brief Get the received TSA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return The length of the address. */
SPAN_DECLARE(size_t) t30_get_tx_tsa(t30_state_t *s, int *type, const char *address[]);
-/*! Get the received ??? (i.e. the one we will send to the far
- end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+/*! Get the received TSA associated with a T.30 context.
+ \brief Get the received TSA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return The length of the address. */
SPAN_DECLARE(size_t) t30_get_rx_tsa(t30_state_t *s, int *type, const char *address[]);
-/*! Set the transmitted ??? (i.e. the one we will send to the far
+/*! Set the transmitted IRA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Set the transmitted ??? associated with a T.30 context.
+ \brief Set the transmitted IRA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t30_set_tx_ira(t30_state_t *s, int type, const char *address, int len);
-/*! Get the received ??? (i.e. the one we will send to the far
+/*! Get the transmitted IRA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+ \brief Get the received IRA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return The length of the address. */
SPAN_DECLARE(size_t) t30_get_tx_ira(t30_state_t *s, int *type, const char *address[]);
-/*! Get the received ??? (i.e. the one we will send to the far
- end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+/*! Get the received IRA associated with a T.30 context.
+ \brief Get the received IRA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return The length of the address. */
SPAN_DECLARE(size_t) t30_get_rx_ira(t30_state_t *s, int *type, const char *address[]);
-/*! Set the transmitted ??? (i.e. the one we will send to the far
+/*! Set the transmitted CIA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Set the transmitted ??? associated with a T.30 context.
+ \brief Set the transmitted CIA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t30_set_tx_cia(t30_state_t *s, int type, const char *address, int len);
-/*! Get the received ??? (i.e. the one we will send to the far
+/*! Get the transmitted CIA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+ \brief Get the received CIA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return The length of the address. */
SPAN_DECLARE(size_t) t30_get_tx_cia(t30_state_t *s, int *type, const char *address[]);
-/*! Get the received ??? (i.e. the one we will send to the far
- end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+/*! Get the received CIA associated with a T.30 context.
+ \brief Get the received CIA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(size_t) t30_get_rx_cia(t30_state_t *s, int *type, const char *address[]);
-/*! Set the transmitted ??? (i.e. the one we will send to the far
+/*! Set the transmitted ISP (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Set the transmitted ??? associated with a T.30 context.
+ \brief Set the transmitted ISP associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t30_set_tx_isp(t30_state_t *s, int type, const char *address, int len);
-/*! Get the received ??? (i.e. the one we will send to the far
+/*! Get the transmitted ISP (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+ \brief Get the received ISP associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(size_t) t30_get_tx_isp(t30_state_t *s, int *type, const char *address[]);
-/*! Get the received ??? (i.e. the one we will send to the far
- end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+/*! Get the received ISP associated with a T.30 context.
+ \brief Get the received ISP associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(size_t) t30_get_rx_isp(t30_state_t *s, int *type, const char *address[]);
-/*! Set the transmitted ??? (i.e. the one we will send to the far
+/*! Set the transmitted CSA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Set the transmitted ??? associated with a T.30 context.
+ \brief Set the transmitted CSA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t30_set_tx_csa(t30_state_t *s, int type, const char *address, int len);
-/*! Get the received ??? (i.e. the one we will send to the far
+/*! Get the transmitted CSA (i.e. the one we will send to the far
end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+ \brief Get the received CSA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return The length of the address. */
SPAN_DECLARE(size_t) t30_get_tx_csa(t30_state_t *s, int *type, const char *address[]);
-/*! Get the received ??? (i.e. the one we will send to the far
- end) associated with a T.30 context.
- \brief Get the received ??? associated with a T.30 context.
+/*! Get the received CSA associated with a T.30 context.
+ \brief Get the received CSA associated with a T.30 context.
\param s The T.30 context.
\param type The type of address.
\param address A pointer to the address.
\return 0 for OK, else -1. */
SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *address[]);
+/*! Set page header extends or overlays the image mode.
+ \brief Set page header overlay mode.
+ \param s The T.30 context.
+ \param header_overlays_image TRUE for overlay, or FALSE for extend the page. */
+SPAN_DECLARE(int) t30_set_tx_page_header_overlays_image(t30_state_t *s, int header_overlays_image);
+
/*! Set the transmitted header information associated with a T.30 context.
\brief Set the transmitted header information associated with a T.30 context.
\param s The T.30 context.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t30_set_tx_page_header_info(t30_state_t *s, const char *info);
+/*! Set the transmitted header timestamp timezone associated with a T.30 context.
+ \brief Set the transmitted header timestamp timezone associated with a T.30 context.
+ \param s The T.30 context.
+ \param info A pointer to the POSIZ timezone string.
+ \return 0 for OK, else -1. */
+SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring);
+
/*! Get the header information associated with a T.30 context.
\brief Get the header information associated with a T.30 context.
\param s The T.30 context.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_fcf.h,v 1.18 2009/10/08 15:14:31 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_logging.h,v 1.4 2009/02/03 16:28:41 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t31.h,v 1.59 2009/03/13 12:59:26 steveu Exp $
*/
/*! \file */
\param amp The audio sample buffer.
\param len The number of samples in the buffer.
\return The number of samples unprocessed. */
-SPAN_DECLARE(int) t31_rx(t31_state_t *s, int16_t amp[], int len);
+SPAN_DECLARE_NONSTD(int) t31_rx(t31_state_t *s, int16_t amp[], int len);
/*! Fake processing of a missing block of received T.31 modem audio samples
(e.g due to packet loss).
\param s The T.31 modem context.
\param len The number of samples to fake.
\return The number of samples unprocessed. */
-SPAN_DECLARE(int) t31_rx_fillin(t31_state_t *s, int len);
+SPAN_DECLARE_NONSTD(int) t31_rx_fillin(t31_state_t *s, int len);
/*! Generate a block of T.31 modem audio samples.
\brief Generate a block of T.31 modem audio samples.
\param max_len The number of samples to be generated.
\return The number of samples actually generated.
*/
-SPAN_DECLARE(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len);
+SPAN_DECLARE_NONSTD(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len);
SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples);
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t35.h,v 1.15 2009/01/31 08:48:11 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_core.h,v 1.39 2009/07/14 13:54:22 steveu Exp $
*/
/*! \file */
/*! \brief Find the delay to allow for HDLC flags after sending an indicator
\param s The T.38 context.
- \param indicator The indicator to send.
+ \param indicator The indicator to check.
\return The delay to allow for initial HDLC flags after this indicator is sent. */
SPAN_DECLARE(int) t38_core_send_flags_delay(t38_core_state_t *s, int indicator);
+/*! \brief Find the delay to allow for modem training after sending an indicator
+ \param s The T.38 context.
+ \param indicator The indicator to check.
+ \return The delay to allow for modem training after this indicator is sent. */
+SPAN_DECLARE(int) t38_core_send_training_delay(t38_core_state_t *s, int indicator);
+
/*! \brief Send a data packet
\param s The T.38 context.
\param data_type The packet's data type.
\param len The length of the packet contents.
\param seq_no The packet sequence number.
\return 0 for OK, else -1. */
-SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_packet(t38_core_state_t *s, const uint8_t *buf, int len, uint16_t seq_no);
+SPAN_DECLARE(int) t38_core_rx_ifp_packet(t38_core_state_t *s, const uint8_t *buf, int len, uint16_t seq_no);
/*! Set the method to be used for data rate management, as per the T.38 spec.
\param s The T.38 context.
*/
SPAN_DECLARE(logging_state_t *) t38_core_get_logging_state(t38_core_state_t *s);
+/*! Restart a T.38 core context.
+ \brief Restart a T.38 core context.
+ \param s The T.38 context.
+ \return 0 for OK, else -1. */
+SPAN_DECLARE(int) t38_core_restart(t38_core_state_t *s);
+
/*! Initialise a T.38 core context.
\brief Initialise a T.38 core context.
\param s The T.38 context.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_gateway.h,v 1.63 2009/04/12 09:12:10 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_non_ecm_buffer.h,v 1.7.4.1 2009/12/19 06:43:28 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_terminal.h,v 1.41 2009/02/03 16:28:41 steveu Exp $
*/
/*! \file */
/* Make sure the HDLC frame buffers are big enough for ECM frames. */
#define T38_MAX_HDLC_LEN 260
+enum
+{
+ /*! This option enables the continuous streaming of FAX data, with no allowance for
+ FAX machine speeds. This is usually used with TCP/TPKT transmission of T.38 FAXes */
+ T38_TERMINAL_OPTION_NO_PACING = 0x01,
+ /*! This option enables the regular repeat transmission of indicator signals,
+ during periods when no FAX signal transmission occurs. */
+ T38_TERMINAL_OPTION_REGULAR_INDICATORS = 0x02,
+ /*! This option enables the regular repeat transmission of indicator signals for the
+ first 2s, during periods when no FAX signal transmission occurs. */
+ T38_TERMINAL_OPTION_2S_REPEATING_INDICATORS = 0x04
+};
+
typedef struct t38_terminal_state_s t38_terminal_state_t;
#if defined(__cplusplus)
SPAN_DECLARE(int) t38_terminal_send_timeout(t38_terminal_state_t *s, int samples);
-SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int without_pacing);
+/*! Set configuration options.
+ \brief Set configuration options.
+ \param s The T.38 context.
+ \param config A combinations of T38_TERMINAL_OPTION_* bits.
+*/
+SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int config);
/*! Select whether the time for talker echo protection tone will be allowed for when sending.
\brief Select whether TEP time will be allowed for.
*/
SPAN_DECLARE(logging_state_t *) t38_terminal_get_logging_state(t38_terminal_state_t *s);
+/*! \brief Reinitialise a termination mode T.38 context.
+ \param s The T.38 context.
+ \param calling_party TRUE if the context is for a calling party. FALSE if the
+ context is for an answering party.
+ \return 0 for OK, else -1. */
+SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s,
+ int calling_party);
+
/*! \brief Initialise a termination mode T.38 context.
\param s The T.38 context.
\param calling_party TRUE if the context is for a calling party. FALSE if the
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_rx.h,v 1.3.2.3 2009/12/21 17:18:40 steveu Exp $
*/
/*! \file */
T4_COMPRESSION_ITU_T4_2D = 2,
/*! T.6 2D compression */
T4_COMPRESSION_ITU_T6 = 3,
- /*! T.85 monochrome JBIG coding */
+ /*! T.85 monochrome JBIG coding with L0 fixed. */
T4_COMPRESSION_ITU_T85 = 4,
+ /*! T.85 monochrome JBIG coding with L0 variable. */
+ T4_COMPRESSION_ITU_T85_L0 = 5,
/*! T.43 colour JBIG coding */
- T4_COMPRESSION_ITU_T43 = 5,
+ T4_COMPRESSION_ITU_T43 = 6,
/*! T.45 run length colour compression */
- T4_COMPRESSION_ITU_T45 = 6,
+ T4_COMPRESSION_ITU_T45 = 7,
/*! T.81 + T.30 Annex E colour JPEG coding */
- T4_COMPRESSION_ITU_T81 = 7,
+ T4_COMPRESSION_ITU_T81 = 8,
/*! T.81 + T.30 Annex K colour sYCC-JPEG coding */
- T4_COMPRESSION_ITU_SYCC_T81 = 8
+ T4_COMPRESSION_ITU_SYCC_T81 = 9
} t4_image_compression_t;
/*! Supported X resolutions, in pixels per metre. */
\brief Get the current transfer statistics.
\param s The T.4 context.
\param t A pointer to a statistics structure. */
-SPAN_DECLARE(void) t4_get_transfer_statistics(t4_state_t *s, t4_stats_t *t);
+SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t);
/*! Get the short text name of an encoding format.
\brief Get the short text name of an encoding format.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_tx.h,v 1.2.2.3 2009/12/21 17:18:40 steveu Exp $
*/
/*! \file */
time specified by a remote receiving machine.
\param s The T.4 context.
\param bits The minimum number of bits per row. */
-SPAN_DECLARE(void) t4_tx_set_min_row_bits(t4_state_t *s, int bits);
+SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits);
/*! \brief Set the identity of the local machine, for inclusion in page headers.
\param s The T.4 context.
\param info A string, of up to 50 bytes, which will form the info field. */
SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info);
+/*! Set the time zone for the time stamp in page header lines. If this function is not used
+ the current time zone of the program's environment is used.
+ \brief Set the header timezone.
+ \param s The T.4 context.
+ \param info A POSIX timezone description string. */
+SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring);
+
/*! \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.
\return The page number, or -1 if there is an error. */
SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s);
+/*! Get the current image transfer statistics.
+ \brief Get the current transfer statistics.
+ \param s The T.4 context.
+ \param t A pointer to a statistics structure. */
+SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t);
+
#if defined(__cplusplus)
}
#endif
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: telephony.h,v 1.18.4.2 2009/12/21 18:38:06 steveu Exp $
*/
#if !defined(_SPANDSP_TELEPHONY_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: time_scale.h,v 1.20 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_TIME_SCALE_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: timing.h,v 1.14 2009/09/04 14:38:47 steveu Exp $
*/
#if !defined(_SPANDSP_TIMING_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_detect.h,v 1.45 2009/02/10 13:06:47 steveu Exp $
*/
#if !defined(_SPANDSP_TONE_DETECT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_generate.h,v 1.40 2010/05/22 13:20:18 steveu Exp $
*/
/*! \file */
int d4,
int repeat);
+/* For backwards compatibility */
+#define make_tone_gen_descriptor tone_gen_descriptor_init
+
SPAN_DECLARE(void) tone_gen_descriptor_free(tone_gen_descriptor_t *s);
SPAN_DECLARE_NONSTD(int) tone_gen(tone_gen_state_t *s, int16_t amp[], int max_samples);
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17rx.h,v 1.65 2009/07/09 13:52:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17tx.h,v 1.43.4.1 2009/12/24 16:52:30 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v18.h,v 1.6 2009/11/04 15:52:06 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v22bis.h,v 1.46 2009/11/04 15:52:06 steveu Exp $
*/
/*! \file */
\param s The modem context.
\param len The number of samples to fake.
\return The number of samples unprocessed. */
-SPAN_DECLARE(int) v22bis_rx_fillin(v22bis_state_t *s, int len);
+SPAN_DECLARE_NONSTD(int) v22bis_rx_fillin(v22bis_state_t *s, int len);
/*! Get a snapshot of the current equalizer coefficients.
\brief Get a snapshot of the current equalizer coefficients.
/*! Report the current operating bit rate of a V.22bis modem context.
\brief Report the current operating bit rate of a V.22bis modem context
\param s The modem context. */
-SPAN_DECLARE(int) v22bis_current_bit_rate(v22bis_state_t *s);
+SPAN_DECLARE(int) v22bis_get_current_bit_rate(v22bis_state_t *s);
/*! Initialise a V.22bis modem context. This must be called before the first
use of the context, to initialise its contents.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_rx.h,v 1.61 2009/07/09 13:52:09 steveu Exp $
*/
/*! \file */
\param len The number of samples to fake.
\return The number of samples unprocessed.
*/
-SPAN_DECLARE(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len);
+SPAN_DECLARE_NONSTD(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len);
/*! Get a snapshot of the current equalizer coefficients.
\brief Get a snapshot of the current equalizer coefficients.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_tx.h,v 1.43 2009/07/09 13:52:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29rx.h,v 1.72 2009/07/09 13:52:09 steveu Exp $
*/
/*! \file */
\param s The modem context.
\param len The number of samples to fake.
\return The number of samples unprocessed. */
-SPAN_DECLARE(int) v29_rx_fillin(v29_rx_state_t *s, int len);
+SPAN_DECLARE_NONSTD(int) v29_rx_fillin(v29_rx_state_t *s, int len);
/*! Get a snapshot of the current equalizer coefficients.
\brief Get a snapshot of the current equalizer coefficients.
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29tx.h,v 1.41 2009/07/09 13:52:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42.h,v 1.31 2009/11/04 15:52:06 steveu Exp $
*/
/*! \page v42_page V.42 modem error correction
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42bis.h,v 1.27 2009/04/11 18:11:19 steveu Exp $
*/
/*! \page v42bis_page V.42bis modem data compression
#if !defined(_SPANDSP_V42BIS_H_)
#define _SPANDSP_V42BIS_H_
-#define V42BIS_MAX_BITS 12
-#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
-#define V42BIS_TABLE_SIZE 5021 /* This should be a prime >(2^V42BIS_MAX_BITS) */
-#define V42BIS_MAX_STRING_SIZE 250
+#define V42BIS_MIN_STRING_SIZE 6
+#define V42BIS_MAX_STRING_SIZE 250
+#define V42BIS_MIN_DICTIONARY_SIZE 512
+#define V42BIS_MAX_BITS 12
+#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
+#define V42BIS_TABLE_SIZE 5021 /* This should be a prime >(2^V42BIS_MAX_BITS) */
enum
{
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v8.h,v 1.31.4.1 2009/12/28 12:20:47 steveu Exp $
*/
/*! \file */
V8_MOD_V17 = (1 << 0), /* V.17 half-duplex */
V8_MOD_V21 = (1 << 1), /* V.21 duplex */
V8_MOD_V22 = (1 << 2), /* V.22/V22.bis duplex */
- V8_MOD_V23HALF = (1 << 3), /* V.23 half-duplex */
+ V8_MOD_V23HDX = (1 << 3), /* V.23 half-duplex */
V8_MOD_V23 = (1 << 4), /* V.23 duplex */
V8_MOD_V26BIS = (1 << 5), /* V.23 duplex */
V8_MOD_V26TER = (1 << 6), /* V.23 duplex */
V8_MOD_V27TER = (1 << 7), /* V.23 duplex */
V8_MOD_V29 = (1 << 8), /* V.29 half-duplex */
V8_MOD_V32 = (1 << 9), /* V.32/V32.bis duplex */
- V8_MOD_V34HALF = (1 << 10), /* V.34 half-duplex */
+ V8_MOD_V34HDX = (1 << 10), /* V.34 half-duplex */
V8_MOD_V34 = (1 << 11), /* V.34 duplex */
V8_MOD_V90 = (1 << 12), /* V.90 duplex */
- V8_MOD_V92 = (1 << 13), /* V.92 duplex */
-
- V8_MOD_FAILED = (1 << 15) /* Indicates failure to negotiate */
+ V8_MOD_V92 = (1 << 13) /* V.92 duplex */
};
enum v8_protocol_e
V8_PSTN_PCM_MODEM_V91 = 0x04
};
+enum v8_status_e
+{
+ /*! V.8 negotiation is in progress. */
+ V8_STATUS_IN_PROGRESS = 0,
+ /*! V.8 has been offered by the other (calling) party. */
+ V8_STATUS_V8_OFFERED = 1,
+ /*! V.8 has been successfully negotiated. Note that this only means the V.8
+ message exchange has successfully completed. The actual exchanged parameters
+ must be checked, to see if the call can proceed properly. */
+ V8_STATUS_V8_CALL = 2,
+ /*! A non-V.8 is being received. */
+ V8_STATUS_NON_V8_CALL = 3,
+ /*! V.8 negotiation failed. */
+ V8_STATUS_FAILED = 4
+};
+
typedef struct v8_state_s v8_state_t;
struct v8_parms_s
{
+ int status;
int modem_connect_tone;
int call_function;
unsigned int modulations;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: vector_float.h,v 1.15 2009/01/31 08:48:11 steveu Exp $
*/
#if !defined(_SPANDSP_VECTOR_FLOAT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: vector_int.h,v 1.14 2009/01/31 08:48:11 steveu Exp $
*/
#if !defined(_SPANDSP_VECTOR_INT_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: version.h.in,v 1.3.4.1 2009/12/19 09:47:56 steveu Exp $
*/
#if !defined(_SPANDSP_VERSION_H_)
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20091228
-#define SPANDSP_RELEASE_TIME 123351
-#define SPANDSP_RELEASE_DATETIME_STRING "20091228 123351"
+#define SPANDSP_RELEASE_DATE 20100724
+#define SPANDSP_RELEASE_TIME 163333
+#define SPANDSP_RELEASE_DATETIME_STRING "20100724 163333"
#endif
/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: version.h.in,v 1.3.4.1 2009/12/19 09:47:56 steveu Exp $
*/
#if !defined(_SPANDSP_VERSION_H_)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_rx.c,v 1.33.4.1 2009/12/19 09:47:56 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_tx.c,v 1.30 2009/02/10 17:44:18 steveu Exp $
*/
/*! \file */
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2, as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: swept_tone.c,v 1.2 2009/09/23 16:02:59 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30.c,v 1.305.4.4 2009/12/23 14:23:49 steveu Exp $
*/
/*! \file */
#include "spandsp/v27ter_tx.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/t30.h"
#include "spandsp/t30_logging.h"
#include "spandsp/private/logging.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "spandsp/private/t30.h"
};
/*! These are internal assessments of received image quality, used to determine whether we
- continue, retrain, or abandon the call. */
+ continue, retrain, or abandon the call. This is only relevant to non-ECM operation. */
enum
{
T30_COPY_QUALITY_PERFECT = 0,
};
/*! There are high level indications of what is happening at any instant, to guide the cleanup
- process if the call is abandoned. */
+ continue, retrain, or abandoning of the call. */
enum
{
OPERATION_IN_PROGRESS_NONE = 0,
OPERATION_IN_PROGRESS_T4_RX,
- OPERATION_IN_PROGRESS_T4_TX
+ OPERATION_IN_PROGRESS_T4_TX,
+ OPERATION_IN_PROGRESS_POST_T4_RX,
+ OPERATION_IN_PROGRESS_POST_T4_TX
};
/* All timers specified in milliseconds */
switch (s->operation_in_progress)
{
case OPERATION_IN_PROGRESS_T4_TX:
- t4_tx_release(&s->t4);
+ t4_tx_release(&s->t4.tx);
+ s->operation_in_progress = OPERATION_IN_PROGRESS_POST_T4_TX;
break;
case OPERATION_IN_PROGRESS_T4_RX:
- t4_rx_release(&s->t4);
+ t4_rx_release(&s->t4.rx);
+ s->operation_in_progress = OPERATION_IN_PROGRESS_POST_T4_RX;
break;
}
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
return 0;
}
/*- End of function --------------------------------------------------------*/
static int tx_start_page(t30_state_t *s)
{
- if (t4_tx_start_page(&s->t4))
+ if (t4_tx_start_page(&s->t4.tx))
{
terminate_operation_in_progress(s);
return -1;
static int tx_end_page(t30_state_t *s)
{
s->retries = 0;
- if (t4_tx_end_page(&s->t4) == 0)
+ if (t4_tx_end_page(&s->t4.tx) == 0)
{
s->tx_page_number++;
s->ecm_block = 0;
{
int i;
- t4_rx_set_image_width(&s->t4, s->image_width);
- t4_rx_set_sub_address(&s->t4, s->rx_info.sub_address);
- t4_rx_set_dcs(&s->t4, s->rx_dcs_string);
- t4_rx_set_far_ident(&s->t4, s->rx_info.ident);
- t4_rx_set_vendor(&s->t4, s->vendor);
- t4_rx_set_model(&s->t4, s->model);
+ t4_rx_set_image_width(&s->t4.rx, s->image_width);
+ t4_rx_set_sub_address(&s->t4.rx, s->rx_info.sub_address);
+ t4_rx_set_dcs(&s->t4.rx, s->rx_dcs_string);
+ t4_rx_set_far_ident(&s->t4.rx, s->rx_info.ident);
+ t4_rx_set_vendor(&s->t4.rx, s->vendor);
+ t4_rx_set_model(&s->t4.rx, s->model);
- t4_rx_set_rx_encoding(&s->t4, s->line_encoding);
- t4_rx_set_x_resolution(&s->t4, s->x_resolution);
- t4_rx_set_y_resolution(&s->t4, s->y_resolution);
+ t4_rx_set_rx_encoding(&s->t4.rx, s->line_encoding);
+ t4_rx_set_x_resolution(&s->t4.rx, s->x_resolution);
+ t4_rx_set_y_resolution(&s->t4.rx, s->y_resolution);
- if (t4_rx_start_page(&s->t4))
+ if (t4_rx_start_page(&s->t4.rx))
return -1;
- /* Clear the buffer */
+ /* Clear the ECM buffer */
for (i = 0; i < 256; i++)
s->ecm_len[i] = -1;
s->ecm_block = 0;
static int rx_end_page(t30_state_t *s)
{
- if (t4_rx_end_page(&s->t4) == 0)
+ if (t4_rx_end_page(&s->t4.rx) == 0)
{
s->rx_page_number++;
s->ecm_block = 0;
}
/*- End of function --------------------------------------------------------*/
+static void report_rx_ecm_page_result(t30_state_t *s)
+{
+ t4_stats_t stats;
+
+ /* This is only used for ECM pages, as copy_quality() does a similar job for non-ECM
+ pages as a byproduct of assessing copy quality. */
+ t4_rx_get_transfer_statistics(&s->t4.rx, &stats);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Page no = %d\n", stats.pages_transferred);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Image size = %d x %d pixels\n", stats.width, stats.length);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Image resolution = %d/m x %d/m\n", stats.x_resolution, stats.y_resolution);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Compression = %s (%d)\n", t4_encoding_to_str(stats.encoding), stats.encoding);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Compressed image size = %d bytes\n", stats.line_image_size);
+}
+/*- End of function --------------------------------------------------------*/
+
static int copy_quality(t30_state_t *s)
{
t4_stats_t stats;
int quality;
- t4_get_transfer_statistics(&s->t4, &stats);
+ t4_rx_get_transfer_statistics(&s->t4.rx, &stats);
/* There is no specification for judging copy quality. However, we need to classify
it at three levels, to control what we do next: OK; tolerable, but retrain;
intolerable. */
<15% bad rows to be tolerable, but retrain
>15% bad rows to be intolerable
*/
+ /* This is called before the page is confirmed, so we need to add one to get the page
+ number right */
span_log(&s->logging, SPAN_LOG_FLOW, "Page no = %d\n", stats.pages_transferred + 1);
span_log(&s->logging, SPAN_LOG_FLOW, "Image size = %d x %d pixels\n", stats.width, stats.length);
span_log(&s->logging, SPAN_LOG_FLOW, "Image resolution = %d/m x %d/m\n", stats.x_resolution, stats.y_resolution);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Compression = %s (%d)\n", t4_encoding_to_str(stats.encoding), stats.encoding);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Compressed image size = %d bytes\n", stats.line_image_size);
span_log(&s->logging, SPAN_LOG_FLOW, "Bad rows = %d\n", stats.bad_rows);
span_log(&s->logging, SPAN_LOG_FLOW, "Longest bad row run = %d\n", stats.longest_bad_row_run);
/* Don't treat a page as perfect because it has zero bad rows out of zero total rows. A zero row
}
/*- End of function --------------------------------------------------------*/
+static void report_tx_result(t30_state_t *s, int result)
+{
+ t4_stats_t stats;
+
+ if (span_log_test(&s->logging, SPAN_LOG_FLOW))
+ {
+ t4_tx_get_transfer_statistics(&s->t4.tx, &stats);
+ span_log(&s->logging,
+ SPAN_LOG_FLOW,
+ "%s - delivered %d pages\n",
+ (result) ? "Success" : "Failure",
+ stats.pages_transferred);
+ }
+}
+/*- End of function --------------------------------------------------------*/
+
static void release_resources(t30_state_t *s)
{
if (s->tx_info.nsf)
int res;
int more;
- res = t4_tx_next_page_has_different_format(&s->t4);
+ res = t4_tx_next_page_has_different_format(&s->t4.tx);
if (res == 0)
{
span_log(&s->logging, SPAN_LOG_FLOW, "More pages to come with the same format\n");
if (res > 0)
{
span_log(&s->logging, SPAN_LOG_FLOW, "More pages to come with a different format\n");
- s->tx_start_page = t4_tx_get_current_page_in_file(&s->t4) + 1;
+ s->tx_start_page = t4_tx_get_current_page_in_file(&s->t4.tx) + 1;
return (s->local_interrupt_pending) ? T30_PRI_EOM : T30_EOM;
}
/* Call a user handler, if one is set, to check if another document is to be sent.
/* These frames contain a frame sequence number within the partial page (one octet) followed
by some image data. */
s->ecm_data[i][3] = (uint8_t) i;
- if ((len = t4_tx_get_chunk(&s->t4, &s->ecm_data[i][4], s->octets_per_ecm_frame)) < s->octets_per_ecm_frame)
+ if ((len = t4_tx_get_chunk(&s->t4.tx, &s->ecm_data[i][4], s->octets_per_ecm_frame)) < s->octets_per_ecm_frame)
{
/* The image is not big enough to fill the entire buffer */
/* We need to pad to a full frame, as most receivers expect that. */
/* We filled the entire buffer */
s->ecm_frames = 256;
span_log(&s->logging, SPAN_LOG_FLOW, "Partial page buffer full (%d per frame)\n", s->octets_per_ecm_frame);
- s->ecm_at_page_end = ((t4_tx_check_bit(&s->t4) & 2) != 0);
+ s->ecm_at_page_end = ((t4_tx_check_bit(&s->t4.tx) & 2) != 0);
return 256;
}
/*- End of function --------------------------------------------------------*/
-static int t30_ecm_commit_partial_page(t30_state_t *s)
-{
- int i;
- int image_ended;
-
- span_log(&s->logging, SPAN_LOG_FLOW, "Commiting partial page - block %d, %d frames\n", s->ecm_block, s->ecm_frames);
- image_ended = FALSE;
- for (i = 0; i < s->ecm_frames; i++)
- {
- if (t4_rx_put_chunk(&s->t4, s->ecm_data[i], s->ecm_len[i]))
- {
- /* This is the end of the document */
- /* Clear the buffer */
- for (i = 0; i < 256; i++)
- s->ecm_len[i] = -1;
- s->ecm_frames = -1;
- image_ended = TRUE;
- break;
- }
- }
- /* Clear the buffer */
- for (i = 0; i < 256; i++)
- s->ecm_len[i] = -1;
- s->ecm_block++;
- s->ecm_frames = -1;
- return (image_ended) ? -1 : 0;
-}
-/*- End of function --------------------------------------------------------*/
-
static int send_next_ecm_frame(t30_state_t *s)
{
int i;
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE);
if ((s->supported_compressions & T30_SUPPORT_T43_COMPRESSION))
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE);
-#if 0
if ((s->supported_compressions & T30_SUPPORT_T45_COMPRESSION))
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T45_CAPABLE);
if ((s->supported_compressions & T30_SUPPORT_T81_COMPRESSION))
if ((s->supported_compressions & T30_SUPPORT_SYCC_T81_COMPRESSION))
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SYCC_T81_CAPABLE);
if ((s->supported_compressions & T30_SUPPORT_T85_COMPRESSION))
+ {
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE);
- /* No T.85 optional L0. */
- //if ((s->supported_compressions & T30_SUPPORT_T85_L0_COMPRESSION))
- // set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE);
+ if ((s->supported_compressions & T30_SUPPORT_T85_L0_COMPRESSION))
+ set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE);
+ }
//if ((s->supported_compressions & T30_SUPPORT_T89_COMPRESSION))
// set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T89_CAPABLE);
-#endif
}
if ((s->supported_t30_features & T30_SUPPORT_FIELD_NOT_VALID))
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_FNV_CAPABLE);
/* No k > 4 */
if ((s->iaf & T30_IAF_MODE_CONTINUOUS_FLOW))
set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T38_FAX_CAPABLE);
- /* No T.89 profile */
+ /* No T.88/T.89 profile */
s->local_dis_dtc_len = 19;
//t30_decode_dis_dtc_dcs(s, s->local_dis_dtc_frame, s->local_dis_dtc_len);
return 0;
/* Select the compression to use. */
switch (s->line_encoding)
{
-#if 0
case T4_COMPRESSION_ITU_T85:
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE);
- //set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE);
+ clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE);
+ set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
+ break;
+ case T4_COMPRESSION_ITU_T85_L0:
+ set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE);
+ 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);
current page, though it is benign - fallback will only result in an excessive
minimum. */
min_row_bits = set_min_scan_time_code(s);
- t4_tx_set_min_row_bits(&s->t4, min_row_bits);
+ t4_tx_set_min_bits_per_row(&s->t4.tx, min_row_bits);
/* We need to rebuild the DCS message we will send. */
build_dcs(s);
return s->current_fallback;
span_log(&s->logging, SPAN_LOG_FLOW, "Disconnecting\n");
/* Make sure any FAX in progress is tidied up. If the tidying up has
already happened, repeating it here is harmless. */
- switch (s->operation_in_progress)
- {
- case OPERATION_IN_PROGRESS_T4_TX:
- t4_tx_release(&s->t4);
- break;
- case OPERATION_IN_PROGRESS_T4_RX:
- t4_rx_release(&s->t4);
- break;
- }
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
s->timer_t0_t1 = 0;
s->timer_t2_t4 = 0;
s->timer_t3 = 0;
return -1;
}
span_log(&s->logging, SPAN_LOG_FLOW, "Start sending document\n");
- if (t4_tx_init(&s->t4, s->tx_file, s->tx_start_page, s->tx_stop_page) == NULL)
+ if (t4_tx_init(&s->t4.tx, s->tx_file, s->tx_start_page, s->tx_stop_page) == NULL)
{
span_log(&s->logging, SPAN_LOG_WARNING, "Cannot open source TIFF file '%s'\n", s->tx_file);
s->current_status = T30_ERR_FILEERROR;
return -1;
}
s->operation_in_progress = OPERATION_IN_PROGRESS_T4_TX;
- t4_tx_get_pages_in_file(&s->t4);
- t4_tx_set_tx_encoding(&s->t4, s->line_encoding);
- t4_tx_set_local_ident(&s->t4, s->tx_info.ident);
- t4_tx_set_header_info(&s->t4, s->header_info);
+ t4_tx_get_pages_in_file(&s->t4.tx);
+ t4_tx_set_tx_encoding(&s->t4.tx, s->line_encoding);
+ t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident);
+ t4_tx_set_header_info(&s->t4.tx, s->header_info);
- s->x_resolution = t4_tx_get_x_resolution(&s->t4);
- s->y_resolution = t4_tx_get_y_resolution(&s->t4);
+ s->x_resolution = t4_tx_get_x_resolution(&s->t4.tx);
+ s->y_resolution = t4_tx_get_y_resolution(&s->t4.tx);
/* The minimum scan time to be used can't be evaluated until we know the Y resolution, and
must be evaluated before the minimum scan row bits can be evaluated. */
if ((min_row_bits = set_min_scan_time_code(s)) < 0)
{
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
return -1;
}
span_log(&s->logging, SPAN_LOG_FLOW, "Minimum bits per row will be %d\n", min_row_bits);
- t4_tx_set_min_row_bits(&s->t4, min_row_bits);
+ t4_tx_set_min_bits_per_row(&s->t4.tx, min_row_bits);
if (tx_start_page(s))
return -1;
- s->image_width = t4_tx_get_image_width(&s->t4);
+ s->image_width = t4_tx_get_image_width(&s->t4.tx);
if (s->error_correcting_mode)
{
if (get_partial_ecm_page(s) == 0)
static int restart_sending_document(t30_state_t *s)
{
- t4_tx_restart_page(&s->t4);
+ t4_tx_restart_page(&s->t4.tx);
s->retries = 0;
s->ecm_block = 0;
send_dcs_sequence(s, TRUE);
/* 256 octets per ECM frame */
s->octets_per_ecm_frame = 256;
/* Select the compression to use. */
-#if 0
- if (s->error_correcting_mode && (s->supported_compressions & T30_SUPPORT_T85_COMPRESSION) && test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE))
- {
- s->line_encoding = T4_COMPRESSION_ITU_T85;
+ if (s->error_correcting_mode
+ &&
+ (s->supported_compressions & T30_SUPPORT_T85_COMPRESSION)
+ &&
+ test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE))
+ {
+ if (s->supported_compressions & T30_SUPPORT_T85_L0_COMPRESSION
+ &&
+ test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE))
+ {
+ s->line_encoding = T4_COMPRESSION_ITU_T85_L0;
+ }
+ else
+ {
+ s->line_encoding = T4_COMPRESSION_ITU_T85;
+ }
}
- else if (s->error_correcting_mode && (s->supported_compressions & T30_SUPPORT_T6_COMPRESSION) && test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE))
-#else
- if (s->error_correcting_mode && (s->supported_compressions & T30_SUPPORT_T6_COMPRESSION) && test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE))
-#endif
+ else if (s->error_correcting_mode
+ &&
+ (s->supported_compressions & T30_SUPPORT_T6_COMPRESSION)
+ &&
+ test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE))
{
s->line_encoding = T4_COMPRESSION_ITU_T6;
}
- else if ((s->supported_compressions & T30_SUPPORT_T4_2D_COMPRESSION) && test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE))
+ else if ((s->supported_compressions & T30_SUPPORT_T4_2D_COMPRESSION)
+ &&
+ test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE))
{
s->line_encoding = T4_COMPRESSION_ITU_T4_2D;
}
s->image_width = widths[i][dcs_frame[5] & (DISBIT2 | DISBIT1)];
/* Check which compression we will use. */
-#if 0
if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_MODE))
- s->line_encoding = T4_COMPRESSION_ITU_T85;
+ {
+ if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_L0_MODE))
+ s->line_encoding = T4_COMPRESSION_ITU_T85_L0;
+ else
+ s->line_encoding = T4_COMPRESSION_ITU_T85;
+ }
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE))
-#else
- if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE))
-#endif
+ {
s->line_encoding = T4_COMPRESSION_ITU_T6;
+ }
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_2D_CODING))
+ {
s->line_encoding = T4_COMPRESSION_ITU_T4_2D;
+ }
else
+ {
s->line_encoding = T4_COMPRESSION_ITU_T4_1D;
- span_log(&s->logging, SPAN_LOG_FLOW, "Selected compression %d\n", s->line_encoding);
+ }
+ span_log(&s->logging, SPAN_LOG_FLOW, "Selected compression %s (%d)\n", t4_encoding_to_str(s->line_encoding), s->line_encoding);
if (!test_ctrl_bit(dcs_frame, T30_DCS_BIT_RECEIVE_FAX_DOCUMENT))
span_log(&s->logging, SPAN_LOG_PROTOCOL_WARNING, "Remote is not requesting receive in DCS\n");
send_dcn(s);
return -1;
}
- if (!s->in_message)
+ if (s->operation_in_progress != OPERATION_IN_PROGRESS_T4_RX)
{
- if (t4_rx_init(&s->t4, s->rx_file, s->output_encoding) == NULL)
+ if (t4_rx_init(&s->t4.rx, s->rx_file, s->output_encoding) == NULL)
{
span_log(&s->logging, SPAN_LOG_WARNING, "Cannot open target TIFF file '%s'\n", s->rx_file);
s->current_status = T30_ERR_FILEERROR;
}
/*- End of function --------------------------------------------------------*/
-static int send_deferred_pps_response(t30_state_t *s)
+static int send_response_to_pps(t30_state_t *s)
{
queue_phase(s, T30_PHASE_D_TX);
- if (s->ecm_first_bad_frame >= s->ecm_frames)
+ if (s->rx_ecm_block_ok)
{
- /* Everything was OK. We can accept the data and move on. */
- t30_ecm_commit_partial_page(s);
- switch (s->last_pps_fcf2)
- {
- case T30_NULL:
- /* We can confirm this partial page. */
- break;
- default:
- /* We can confirm the whole page. */
- s->next_rx_step = s->last_pps_fcf2;
- rx_end_page(s);
- if (s->phase_d_handler)
- s->phase_d_handler(s, s->phase_d_user_data, s->last_pps_fcf2);
- rx_start_page(s);
- break;
- }
set_state(s, T30_STATE_F_POST_RCP_MCF);
send_simple_frame(s, T30_MCF);
}
int i;
int j;
int frame_no;
+ int first_bad_frame;
+ int image_ended;
if (len < 7)
{
return -1;
}
s->last_pps_fcf2 = msg[3] & 0xFE;
- page = msg[4];
- block = msg[5];
/* The frames count is not well specified in T.30. In practice it seems it might be the
number of frames in the current block, or it might be the number of frames in the
than the actual size of the block. If we only accept the number when it exceeds
previous values, we should get the real number of frames in the block. */
frames = msg[6] + 1;
+ block = msg[5];
+ page = msg[4];
+
if (s->ecm_frames < 0)
{
/* First time. Take the number and believe in it. */
frames = 0;
}
}
- span_log(&s->logging, SPAN_LOG_FLOW, "Received PPS + %s - page %d, block %d, %d frames\n", t30_frametype(msg[3]), page, block, frames);
- if (page != s->rx_page_number)
- {
- span_log(&s->logging, SPAN_LOG_FLOW, "ECM rx page mismatch - expected %d, but received %d.\n", s->rx_page_number, page);
- }
- if (block != s->ecm_block)
+ span_log(&s->logging,
+ SPAN_LOG_FLOW,
+ "Received PPS + %s - page %d, block %d, %d frames\n",
+ t30_frametype(msg[3]),
+ page,
+ block,
+ frames);
+ /* Check that we have received the page and block we expected. If the far end missed
+ our last response, it might have repeated the previous chunk. */
+ if ((s->rx_page_number & 0xFF) != page || (s->ecm_block & 0xFF) != block)
{
- span_log(&s->logging, SPAN_LOG_FLOW, "ECM rx block mismatch - expected %d, but received %d.\n", s->ecm_block, block);
+ span_log(&s->logging,
+ SPAN_LOG_FLOW,
+ "ECM rx page/block mismatch - expected %d/%d, but received %d/%d.\n",
+ (s->rx_page_number & 0xFF),
+ (s->ecm_block & 0xFF),
+ page,
+ block);
+ /* Look for this being a repeat, because the other end missed the last response
+ we sent - which would have been a T30_MCF - If the block is for the previous
+ page, or the previous block of the current page, we can assume we have hit this
+ condition. */
+ if (((s->rx_page_number & 0xFF) == page && (s->ecm_block & 0xFF) == block)
+ ||
+ (((s->rx_page_number - 1) & 0xFF) == page && s->ecm_block == 0))
+ {
+ /* This must be a repeat of the last thing the far end sent, while we are expecting
+ the first transfer of a new block. */
+ span_log(&s->logging, SPAN_LOG_FLOW, "Looks like a repeat from the previous page/block - send MCF again.\n");
+ /* Clear the ECM buffer */
+ for (i = 0; i < 256; i++)
+ s->ecm_len[i] = -1;
+ s->ecm_frames = -1;
+ queue_phase(s, T30_PHASE_D_TX);
+ set_state(s, T30_STATE_F_POST_RCP_MCF);
+ send_simple_frame(s, T30_MCF);
+ }
+ else
+ {
+ /* Give up */
+ s->current_status = T30_ERR_RX_ECMPHD;
+ send_dcn(s);
+ }
+ return 0;
}
+
/* Build a bit map of which frames we now have stored OK */
- s->ecm_first_bad_frame = 256;
+ first_bad_frame = 256;
for (i = 0; i < 32; i++)
{
s->ecm_frame_map[i + 3] = 0;
if (s->ecm_len[frame_no] < 0)
{
s->ecm_frame_map[i + 3] |= (1 << j);
- if (frame_no < s->ecm_first_bad_frame)
- s->ecm_first_bad_frame = frame_no;
+ if (frame_no < first_bad_frame)
+ first_bad_frame = frame_no;
if (frame_no < s->ecm_frames)
s->error_correcting_mode_retries++;
}
}
}
- /* Are there any bad frames, or does our scan represent things being OK? */
+ s->rx_ecm_block_ok = (first_bad_frame >= s->ecm_frames);
+ if (s->rx_ecm_block_ok)
+ {
+ span_log(&s->logging, SPAN_LOG_FLOW, "Partial page OK - committing block %d, %d frames\n", s->ecm_block, s->ecm_frames);
+ image_ended = FALSE;
+ for (i = 0; i < s->ecm_frames; i++)
+ {
+ if (t4_rx_put_chunk(&s->t4.rx, s->ecm_data[i], s->ecm_len[i]))
+ {
+ /* This is the end of the document */
+ image_ended = TRUE;
+ break;
+ }
+ }
+ /* Clear the ECM buffer */
+ for (i = 0; i < 256; i++)
+ s->ecm_len[i] = -1;
+ s->ecm_block++;
+ s->ecm_frames = -1;
+
+ switch (s->last_pps_fcf2)
+ {
+ case T30_NULL:
+ /* We can accept only this partial page. */
+ break;
+ default:
+ /* We can accept and confirm the whole page. */
+ s->next_rx_step = s->last_pps_fcf2;
+ rx_end_page(s);
+ report_rx_ecm_page_result(s);
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, s->last_pps_fcf2);
+ rx_start_page(s);
+ break;
+ }
+ }
+
switch (s->last_pps_fcf2)
{
case T30_NULL:
}
else
{
- send_deferred_pps_response(s);
+ send_response_to_pps(s);
}
break;
default:
switch (fcf)
{
case T30_MPS:
- if (s->phase_d_handler)
- s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->next_rx_step = fcf;
queue_phase(s, T30_PHASE_D_TX);
switch (copy_quality(s))
case T30_COPY_QUALITY_PERFECT:
case T30_COPY_QUALITY_GOOD:
rx_end_page(s);
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
rx_start_page(s);
set_state(s, T30_STATE_III_Q_MCF);
send_simple_frame(s, T30_MCF);
break;
case T30_COPY_QUALITY_POOR:
rx_end_page(s);
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
rx_start_page(s);
set_state(s, T30_STATE_III_Q_RTP);
send_simple_frame(s, T30_RTP);
break;
case T30_COPY_QUALITY_BAD:
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
rx_start_page(s);
set_state(s, T30_STATE_III_Q_RTN);
send_simple_frame(s, T30_RTN);
}
break;
case T30_PRI_MPS:
- if (s->phase_d_handler)
- {
- s->phase_d_handler(s, s->phase_d_user_data, fcf);
- s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
- }
s->next_rx_step = fcf;
switch (copy_quality(s))
{
case T30_COPY_QUALITY_PERFECT:
case T30_COPY_QUALITY_GOOD:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_MCF);
break;
case T30_COPY_QUALITY_POOR:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_RTP);
break;
case T30_COPY_QUALITY_BAD:
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
set_state(s, T30_STATE_III_Q_RTN);
break;
}
break;
case T30_EOM:
case T30_EOS:
- if (s->phase_d_handler)
- s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->next_rx_step = fcf;
/* Return to phase B */
queue_phase(s, T30_PHASE_B_TX);
case T30_COPY_QUALITY_PERFECT:
case T30_COPY_QUALITY_GOOD:
rx_end_page(s);
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
rx_start_page(s);
set_state(s, T30_STATE_III_Q_MCF);
send_simple_frame(s, T30_MCF);
break;
case T30_COPY_QUALITY_POOR:
rx_end_page(s);
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
rx_start_page(s);
set_state(s, T30_STATE_III_Q_RTP);
send_simple_frame(s, T30_RTP);
break;
case T30_COPY_QUALITY_BAD:
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
rx_start_page(s);
set_state(s, T30_STATE_III_Q_RTN);
send_simple_frame(s, T30_RTN);
}
break;
case T30_PRI_EOM:
- if (s->phase_d_handler)
- {
- s->phase_d_handler(s, s->phase_d_user_data, fcf);
- s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
- }
s->next_rx_step = fcf;
switch (copy_quality(s))
{
case T30_COPY_QUALITY_PERFECT:
case T30_COPY_QUALITY_GOOD:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_MCF);
break;
case T30_COPY_QUALITY_POOR:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_RTP);
break;
case T30_COPY_QUALITY_BAD:
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
set_state(s, T30_STATE_III_Q_RTN);
break;
}
break;
case T30_EOP:
- if (s->phase_d_handler)
- s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->next_rx_step = fcf;
queue_phase(s, T30_PHASE_D_TX);
switch (copy_quality(s))
case T30_COPY_QUALITY_PERFECT:
case T30_COPY_QUALITY_GOOD:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_MCF);
send_simple_frame(s, T30_MCF);
break;
case T30_COPY_QUALITY_POOR:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_RTP);
send_simple_frame(s, T30_RTP);
break;
case T30_COPY_QUALITY_BAD:
+ if (s->phase_d_handler)
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
set_state(s, T30_STATE_III_Q_RTN);
send_simple_frame(s, T30_RTN);
break;
}
break;
case T30_PRI_EOP:
- if (s->phase_d_handler)
- {
- s->phase_d_handler(s, s->phase_d_user_data, fcf);
- s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
- }
s->next_rx_step = fcf;
switch (copy_quality(s))
{
case T30_COPY_QUALITY_PERFECT:
case T30_COPY_QUALITY_GOOD:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_MCF);
break;
case T30_COPY_QUALITY_POOR:
rx_end_page(s);
- t4_rx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- s->in_message = FALSE;
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
+ terminate_operation_in_progress(s);
set_state(s, T30_STATE_III_Q_RTP);
break;
case T30_COPY_QUALITY_BAD:
+ if (s->phase_d_handler)
+ {
+ s->phase_d_handler(s, s->phase_d_user_data, fcf);
+ s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
+ }
set_state(s, T30_STATE_III_Q_RTN);
break;
}
}
else
{
- send_deferred_pps_response(s);
+ /* Now we send the deferred response */
+ send_response_to_pps(s);
}
break;
case T30_CRP:
static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
{
- t4_stats_t stats;
uint8_t fcf;
fcf = msg[2] & 0xFE;
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ terminate_operation_in_progress(s);
+ report_tx_result(s, TRUE);
return_to_phase_b(s, FALSE);
break;
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
send_dcn(s);
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ report_tx_result(s, TRUE);
break;
}
break;
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
+ t4_tx_release(&s->t4.tx);
/* TODO: should go back to T, and resend */
return_to_phase_b(s, TRUE);
break;
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
+ t4_tx_release(&s->t4.tx);
send_dcn(s);
break;
}
static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int len)
{
- t4_stats_t stats;
uint8_t fcf;
fcf = msg[2] & 0xFE;
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ terminate_operation_in_progress(s);
+ report_tx_result(s, TRUE);
return_to_phase_b(s, FALSE);
break;
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
send_dcn(s);
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ report_tx_result(s, TRUE);
break;
}
}
static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len)
{
- t4_stats_t stats;
uint8_t fcf;
fcf = msg[2] & 0xFE;
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ terminate_operation_in_progress(s);
+ report_tx_result(s, TRUE);
return_to_phase_b(s, FALSE);
break;
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
send_dcn(s);
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ report_tx_result(s, TRUE);
break;
}
}
static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len)
{
- t4_stats_t stats;
uint8_t fcf;
fcf = msg[2] & 0xFE;
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ terminate_operation_in_progress(s);
+ report_tx_result(s, TRUE);
return_to_phase_b(s, FALSE);
break;
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
- t4_tx_release(&s->t4);
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
send_dcn(s);
- if (span_log_test(&s->logging, SPAN_LOG_FLOW))
- {
- t4_get_transfer_statistics(&s->t4, &stats);
- span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred);
- }
+ report_tx_result(s, TRUE);
break;
}
}
{
/* The training went OK */
s->short_train = TRUE;
- s->in_message = TRUE;
rx_start_page(s);
set_phase(s, T30_PHASE_B_TX);
set_state(s, T30_STATE_F_CFR);
break;
case T30_STATE_F_DOC_NON_ECM:
/* Document transfer */
- if (t4_rx_put_bit(&s->t4, bit))
+ if (t4_rx_put_bit(&s->t4.rx, bit))
{
/* That is the end of the document */
set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
{
t30_state_t *s;
+ if (byte < 0)
+ {
+ t30_non_ecm_rx_status(user_data, byte);
+ return;
+ }
s = (t30_state_t *) user_data;
switch (s->state)
{
break;
case T30_STATE_F_DOC_NON_ECM:
/* Document transfer */
- if (t4_rx_put_byte(&s->t4, (uint8_t) byte))
+ if (t4_rx_put_byte(&s->t4.rx, (uint8_t) byte))
{
/* That is the end of the document */
set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
break;
case T30_STATE_F_DOC_NON_ECM:
/* Document transfer */
- if (t4_rx_put_chunk(&s->t4, buf, len))
+ if (t4_rx_put_chunk(&s->t4.rx, buf, len))
{
/* That is the end of the document */
set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
break;
case T30_STATE_I:
/* Transferring real data. */
- bit = t4_tx_get_bit(&s->t4);
+ bit = t4_tx_get_bit(&s->t4.tx);
break;
case T30_STATE_D_POST_TCF:
case T30_STATE_II_Q:
break;
case T30_STATE_I:
/* Transferring real data. */
- byte = t4_tx_get_byte(&s->t4);
+ byte = t4_tx_get_byte(&s->t4.tx);
break;
case T30_STATE_D_POST_TCF:
case T30_STATE_II_Q:
break;
case T30_STATE_I:
/* Transferring real data. */
- len = t4_tx_get_chunk(&s->t4, buf, max_len);
+ len = t4_tx_get_chunk(&s->t4.tx, buf, max_len);
break;
case T30_STATE_D_POST_TCF:
case T30_STATE_II_Q:
t->bit_rate = fallback_sequence[s->current_fallback].bit_rate;
t->error_correcting_mode = s->error_correcting_mode;
t->error_correcting_mode_retries = s->error_correcting_mode_retries;
- t4_get_transfer_statistics(&s->t4, &stats);
+ switch (s->operation_in_progress)
+ {
+ case OPERATION_IN_PROGRESS_T4_TX:
+ case OPERATION_IN_PROGRESS_POST_T4_TX:
+ t4_tx_get_transfer_statistics(&s->t4.tx, &stats);
+ break;
+ case OPERATION_IN_PROGRESS_T4_RX:
+ case OPERATION_IN_PROGRESS_POST_T4_RX:
+ t4_rx_get_transfer_statistics(&s->t4.rx, &stats);
+ break;
+ default:
+ memset(&stats, 0, sizeof(stats));
+ break;
+ }
t->pages_tx = s->tx_page_number;
t->pages_rx = s->rx_page_number;
t->pages_in_file = stats.pages_in_file;
{
/* Make sure any FAX in progress is tidied up. If the tidying up has
already happened, repeating it here is harmless. */
- switch (s->operation_in_progress)
- {
- case OPERATION_IN_PROGRESS_T4_TX:
- t4_tx_release(&s->t4);
- break;
- case OPERATION_IN_PROGRESS_T4_RX:
- t4_rx_release(&s->t4);
- break;
- }
- s->operation_in_progress = OPERATION_IN_PROGRESS_NONE;
+ terminate_operation_in_progress(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_api.c,v 1.13.4.2 2009/12/19 14:18:13 steveu Exp $
*/
/*! \file */
#include "spandsp/v27ter_tx.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/t30.h"
#include "spandsp/t30_logging.h"
#include "spandsp/private/logging.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "spandsp/private/t30.h"
if (strlen(id) > T30_MAX_IDENT_LEN)
return -1;
strcpy(s->tx_info.ident, id);
- t4_tx_set_local_ident(&s->t4, s->tx_info.ident);
+ t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident);
return 0;
}
/*- End of function --------------------------------------------------------*/
}
/*- End of function --------------------------------------------------------*/
+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 --------------------------------------------------------*/
+
SPAN_DECLARE(int) t30_set_tx_page_header_info(t30_state_t *s, const char *info)
{
if (info == NULL)
if (strlen(info) > T30_MAX_PAGE_HEADER_INFO)
return -1;
strcpy(s->header_info, info);
- t4_tx_set_header_info(&s->t4, s->header_info);
+ t4_tx_set_header_info(&s->t4.tx, s->header_info);
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring)
+{
+ t4_tx_set_header_tz(&s->t4.tx, tzstring);
return 0;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_compressions)
{
- s->supported_compressions = supported_compressions;
+ int mask;
+
+ /* Mask out the ones we actually support today. */
+ mask = T30_SUPPORT_T4_1D_COMPRESSION
+ | T30_SUPPORT_T4_2D_COMPRESSION
+ | T30_SUPPORT_T6_COMPRESSION
+#if defined(SPANDSP_SUPPORT_T85)
+ | T30_SUPPORT_T85_COMPRESSION
+ | T30_SUPPORT_T85_L0_COMPRESSION;
+#else
+ | 0;
+#endif
+ s->supported_compressions = supported_compressions & mask;
t30_build_dis_or_dtc(s);
return 0;
}
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_local.h,v 1.2 2008/04/17 14:26:57 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t30_logging.c,v 1.12.4.2 2009/12/19 10:44:10 steveu Exp $
*/
/*! \file */
#include "spandsp/v27ter_tx.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/t30.h"
#include "spandsp/t30_logging.h"
#include "spandsp/private/logging.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "spandsp/private/t30.h"
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t31.c,v 1.155.4.1 2009/12/19 10:44:10 steveu Exp $
*/
/*! \file */
#include "spandsp/telephony.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
+#include "spandsp/bitstream.h"
#include "spandsp/dc_restore.h"
#include "spandsp/queue.h"
#include "spandsp/power_meter.h"
#include "spandsp/crc.h"
#include "spandsp/hdlc.h"
#include "spandsp/silence_gen.h"
+#include "spandsp/super_tone_rx.h"
#include "spandsp/fsk.h"
+#include "spandsp/modem_connect_tones.h"
+#include "spandsp/v8.h"
#include "spandsp/v29tx.h"
#include "spandsp/v29rx.h"
#include "spandsp/v27ter_tx.h"
#include "spandsp/v27ter_rx.h"
#include "spandsp/v17tx.h"
#include "spandsp/v17rx.h"
-#include "spandsp/super_tone_rx.h"
-#include "spandsp/modem_connect_tones.h"
+#if defined(SPANDSP_SUPPORT_V34)
+#include "spandsp/v34.h"
+#endif
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
#include "spandsp/t30.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/private/logging.h"
+#include "spandsp/private/bitstream.h"
#include "spandsp/private/t38_core.h"
#include "spandsp/private/silence_gen.h"
#include "spandsp/private/fsk.h"
+#include "spandsp/private/modem_connect_tones.h"
+#include "spandsp/private/v8.h"
+#if defined(SPANDSP_SUPPORT_V34)
+#include "spandsp/private/v34.h"
+#endif
#include "spandsp/private/v17tx.h"
#include "spandsp/private/v17rx.h"
#include "spandsp/private/v27ter_tx.h"
#include "spandsp/private/v27ter_rx.h"
#include "spandsp/private/v29tx.h"
#include "spandsp/private/v29rx.h"
-#include "spandsp/private/modem_connect_tones.h"
#include "spandsp/private/hdlc.h"
#include "spandsp/private/fax_modems.h"
#include "spandsp/private/at_interpreter.h"
with 0xFF it would appear some octets must have been missed before this one. */
if (len <= 0 || buf[0] != 0xFF)
fe->rx_data_missing = TRUE;
+ /*endif*/
}
- if (len > 0 && fe->hdlc_rx.len + len <= T31_T38_MAX_HDLC_LEN)
+ /*endif*/
+ if (len > 0)
{
- bit_reverse(fe->hdlc_rx.buf + fe->hdlc_rx.len, buf, len);
- fe->hdlc_rx.len += len;
+ if (fe->hdlc_rx.len + len <= T31_T38_MAX_HDLC_LEN)
+ {
+ bit_reverse(fe->hdlc_rx.buf + fe->hdlc_rx.len, buf, len);
+ fe->hdlc_rx.len += len;
+ }
+ else
+ {
+ fe->rx_data_missing = TRUE;
+ }
+ /*endif*/
}
+ /*endif*/
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
break;
case T38_FIELD_HDLC_FCS_OK:
/* The sender has incorrectly included data in this message. It is unclear what we should do
with it, to maximise tolerance of buggy implementations. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_FCS_OK messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
crc_itu16_append(fe->hdlc_rx.buf, fe->hdlc_rx.len);
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
}
+ /*endif*/
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
/* The sender has incorrectly included data in this message. We can safely ignore it, as the
bad FCS means we will throw away the whole message, anyway. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_FCS_BAD messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC bad (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
}
+ /*endif*/
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
}
/*- End of function --------------------------------------------------------*/
+static void v8_handler(void *user_data, v8_parms_t *result)
+{
+ t31_state_t *s;
+
+ s = (t31_state_t *) user_data;
+ span_log(&s->logging, SPAN_LOG_FLOW, "V.8 report received\n");
+}
+/*- End of function --------------------------------------------------------*/
+
static void hdlc_tx_underflow(void *user_data)
{
t31_state_t *s;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t31_rx(t31_state_t *s, int16_t amp[], int len)
+SPAN_DECLARE_NONSTD(int) t31_rx(t31_state_t *s, int16_t amp[], int len)
{
int i;
int32_t power;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t31_rx_fillin(t31_state_t *s, int len)
+SPAN_DECLARE_NONSTD(int) t31_rx_fillin(t31_state_t *s, int len)
{
/* To mitigate the effect of lost packets on a packet network we should
try to sustain the status quo. If there is no receive modem running, keep
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len)
+SPAN_DECLARE_NONSTD(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len)
{
int len;
t38_tx_packet_handler_t *tx_t38_packet_handler,
void *tx_t38_packet_user_data)
{
+ v8_parms_t v8_parms;
int alloced;
-
+
if (at_tx_handler == NULL || modem_control_handler == NULL)
return NULL;
non_ecm_get_bit,
tone_detected,
(void *) s);
+#if 0
+ v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR;
+ v8_parms.call_function = V8_CALL_T30_RX;
+ v8_parms.modulations = V8_MOD_V21
+#if 0
+ | V8_MOD_V34HALF
+#endif
+ | V8_MOD_V17
+ | V8_MOD_V29
+ | V8_MOD_V27TER;
+ v8_parms.protocol = V8_PROTOCOL_NONE;
+ v8_parms.pcm_modem_availability = 0;
+ v8_parms.pstn_access = 0;
+ v8_parms.nsf = -1;
+ v8_parms.t66 = -1;
+ v8_init(&s->audio.v8,
+ FALSE,
+ &v8_parms,
+ v8_handler,
+ s);
+
+#endif
power_meter_init(&(s->audio.rx_power), 4);
s->audio.last_sample = 0;
s->audio.silence_threshold_power = power_meter_level_dbm0(-36);
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t35.c,v 1.31 2009/05/16 03:34:45 steveu Exp $
*/
/*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_core.c,v 1.54 2009/10/09 14:53:57 steveu Exp $
*/
/*! \file */
case T38_DATA_V34_CC_1200:
return "v34-CC-1200";
case T38_DATA_V34_PRI_CH:
- return "v34-pri-vh";
+ return "v34-pri-ch";
case T38_DATA_V33_12000:
return "v33-12000";
case T38_DATA_V33_14400:
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_packet(t38_core_state_t *s, const uint8_t *buf, int len, uint16_t seq_no)
+SPAN_DECLARE(int) t38_core_rx_ifp_packet(t38_core_state_t *s, const uint8_t *buf, int len, uint16_t seq_no)
{
int i;
int t30_indicator;
uint8_t buf[100];
int len;
int delay;
+ int transmissions;
delay = 0;
/* Only send an indicator if it represents a change of state. */
+ /* If the 0x100 bit is set in indicator it will bypass this test, and force transmission */
if (s->current_tx_indicator != indicator)
{
/* Zero is a valid count, to suppress the transmission of indicators when the
transport means they are not needed - e.g. TPKT/TCP. */
+ transmissions = (indicator & 0x100) ? 1 : s->category_control[T38_PACKET_CATEGORY_INDICATOR];
+ indicator &= 0xFF;
if (s->category_control[T38_PACKET_CATEGORY_INDICATOR])
{
if ((len = t38_encode_indicator(s, buf, indicator)) < 0)
return len;
}
span_log(&s->logging, SPAN_LOG_FLOW, "Tx %5d: indicator %s\n", s->tx_seq_no, t38_indicator_to_str(indicator));
- s->tx_packet_handler(s, s->tx_packet_user_data, buf, len, s->category_control[T38_PACKET_CATEGORY_INDICATOR]);
+ s->tx_packet_handler(s, s->tx_packet_user_data, buf, len, transmissions);
s->tx_seq_no = (s->tx_seq_no + 1) & 0xFFFF;
delay = modem_startup_time[indicator].training;
if (s->allow_for_tep)
}
/*- End of function --------------------------------------------------------*/
+SPAN_DECLARE(int) t38_core_send_training_delay(t38_core_state_t *s, int indicator)
+{
+ return modem_startup_time[indicator].training;
+}
+/*- End of function --------------------------------------------------------*/
+
SPAN_DECLARE(int) t38_core_send_data(t38_core_state_t *s, int data_type, int field_type, const uint8_t field[], int field_len, int category)
{
t38_data_field_t field0;
}
/*- End of function --------------------------------------------------------*/
+SPAN_DECLARE(int) t38_core_restart(t38_core_state_t *s)
+{
+ /* Set the initial current receive states to something invalid, so the
+ first data received is seen as a change of state. */
+ s->current_rx_indicator = -1;
+ s->current_rx_data_type = -1;
+ s->current_rx_field_type = -1;
+
+ /* Set the initial current indicator state to something invalid, so the
+ first attempt to send an indicator will work. */
+ s->current_tx_indicator = -1;
+
+ /* We have no initial expectation of the received packet sequence number.
+ They most often start at 0 or 1 for a UDPTL transport, but random
+ starting numbers are possible. */
+ s->rx_expected_seq_no = -1;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
SPAN_DECLARE(t38_core_state_t *) t38_core_init(t38_core_state_t *s,
t38_rx_indicator_handler_t *rx_indicator_handler,
t38_rx_data_handler_t *rx_data_handler,
s->category_control[T38_PACKET_CATEGORY_IMAGE_DATA] = 1;
s->category_control[T38_PACKET_CATEGORY_IMAGE_DATA_END] = 1;
- /* Set the initial current receive states to something invalid, so the
- first data received is seen as a change of state. */
- s->current_rx_indicator = -1;
- s->current_rx_data_type = -1;
- s->current_rx_field_type = -1;
-
- /* Set the initial current indicator state to something invalid, so the
- first attempt to send an indicator will work. */
- s->current_tx_indicator = -1;
-
s->rx_indicator_handler = rx_indicator_handler;
s->rx_data_handler = rx_data_handler;
s->rx_missing_handler = rx_missing_handler;
s->tx_packet_handler = tx_packet_handler;
s->tx_packet_user_data = tx_packet_user_data;
- /* We have no initial expectation of the received packet sequence number.
- They most often start at 0 or 1 for a UDPTL transport, but random
- starting numbers are possible. */
- s->rx_expected_seq_no = -1;
+ t38_core_restart(s);
return s;
}
/*- End of function --------------------------------------------------------*/
#include "spandsp/modem_connect_tones.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/t30.h"
#include "spandsp/private/modem_connect_tones.h"
#include "spandsp/private/hdlc.h"
#include "spandsp/private/fax_modems.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "spandsp/private/t30.h"
s->audio.modems.rx_handler = handler;
s->audio.modems.rx_fillin_handler = fillin_handler;
}
+ /*endif*/
s->audio.base_rx_handler = handler;
s->audio.base_rx_fillin_handler = fillin_handler;
s->audio.modems.rx_user_data = user_data;
/*endswitch*/
if (expected < 0)
return;
+ /*endif*/
if (t->current_rx_indicator == expected)
return;
+ /*endif*/
if (expected_alt >= 0 && t->current_rx_indicator == expected_alt)
return;
+ /*endif*/
span_log(&s->logging,
SPAN_LOG_FLOW,
"Queuing missing indicator - %s\n",
with 0xFF it would appear some octets must have been missed before this one. */
if (len <= 0 || buf[0] != 0xFF)
s->core.hdlc_to_modem.buf[s->core.hdlc_to_modem.in].flags |= HDLC_FLAG_MISSING_DATA;
+ /*endif*/
hdlc_buf = &s->core.hdlc_to_modem.buf[s->core.hdlc_to_modem.in];
}
/*endif*/
/* Check if this data would overflow the buffer. */
- if (len <= 0 || hdlc_buf->len + len > T38_MAX_HDLC_LEN)
+ if (len <= 0)
break;
/*endif*/
+ if (hdlc_buf->len + len > T38_MAX_HDLC_LEN)
+ {
+ s->core.hdlc_to_modem.buf[s->core.hdlc_to_modem.in].flags |= HDLC_FLAG_MISSING_DATA;
+ break;
+ }
+ /*endif*/
hdlc_buf->contents = (data_type | FLAG_DATA);
bit_reverse(&hdlc_buf->buf[hdlc_buf->len], buf, len);
/* We need to send out the control messages as they are arriving. They are
queue_missing_indicator(s, data_type);
hdlc_buf = &s->core.hdlc_to_modem.buf[s->core.hdlc_to_modem.in];
}
+ /*endif*/
/* WORKAROUND: At least some Mediatrix boxes have a bug, where they can send this message at the
end of non-ECM data. We need to tolerate this. */
if (xx->current_rx_field_class == T38_FIELD_CLASS_NON_ECM)
queue_missing_indicator(s, data_type);
hdlc_buf = &s->core.hdlc_to_modem.buf[s->core.hdlc_to_modem.in];
}
+ /*endif*/
if (len > 0)
t38_non_ecm_buffer_inject(&s->core.non_ecm_to_modem, buf, len);
+ /*endif*/
xx->corrupt_current_frame[0] = FALSE;
break;
case T38_FIELD_T4_NON_ECM_SIG_END:
{
int octets;
- octets = s->core.ms_per_tx_chunk*bit_rate/(8*1000);
+ //octets = s->core.ms_per_tx_chunk*bit_rate/(8*1000);
+ octets = DEFAULT_MS_PER_TX_CHUNK*bit_rate/(8*1000);
if (octets < 1)
octets = 1;
/*endif*/
s->t38x.current_tx_data_type = T38_DATA_V17_14400;
break;
}
+ /*endswitch*/
break;
case T38_V27TER_RX:
set_octets_per_data_packet(s, s->core.fast_bit_rate);
s->t38x.current_tx_data_type = T38_DATA_V27TER_4800;
break;
}
+ /*endswitch*/
break;
case T38_V29_RX:
set_octets_per_data_packet(s, s->core.fast_bit_rate);
s->t38x.current_tx_data_type = T38_DATA_V29_9600;
break;
}
+ /*endswitch*/
break;
}
+ /*endswitch*/
return ind;
}
/*- End of function --------------------------------------------------------*/
s->core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_FAST_MODEM_SEEN;
else
s->core.samples_to_timeout = ms_to_samples(500);
+ /*endif*/
set_fast_packetisation(s);
}
+ /*endif*/
break;
case SIG_STATUS_TRAINING_FAILED:
break;
non_ecm_push_residue(s);
t38_core_send_indicator(&s->t38x.t38, T38_IND_NO_SIGNAL);
}
+ /*endif*/
restart_rx_modem(s);
break;
}
+ /*endswitch*/
break;
default:
span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected non-ECM special bit - %d!\n", status);
break;
}
+ /*endswitch*/
}
/*- End of function --------------------------------------------------------*/
/* There is a fractional octet in progress. We might as well send every last bit we can. */
s->data[s->data_ptr++] = (uint8_t) (s->bit_stream << (8 - s->bit_no));
}
+ /*endif*/
t38_core_send_data(&t->t38x.t38, t->t38x.current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, s->data, s->data_ptr, T38_PACKET_CATEGORY_IMAGE_DATA_END);
s->in_bits += s->bits_absorbed;
s->out_octets += s->data_ptr;
non_ecm_rx_status(user_data, bit);
return;
}
+ /*endif*/
t = (t38_gateway_state_t *) user_data;
s = &t->core.to_t38;
s->data[s->data_ptr++] = (uint8_t) s->bit_stream & 0xFF;
if (s->data_ptr >= s->octets_per_data_packet)
non_ecm_push(t);
+ /*endif*/
s->bit_no = 0;
}
+ /*endif*/
}
/*- End of function --------------------------------------------------------*/
non_ecm_rx_status(user_data, bit);
return;
}
+ /*endif*/
t = (t38_gateway_state_t *) user_data;
s = &t->core.to_t38;
end gateway (assuming the far end is a gateway) cannot play them out. */
non_ecm_push(t);
}
+ /*endif*/
return;
}
+ /*endif*/
s->bit_stream = (s->bit_stream << 1) | bit;
if (++s->bit_no >= 8)
{
s->data[s->data_ptr++] = (uint8_t) s->bit_stream & 0xFF;
if (s->data_ptr >= s->octets_per_data_packet)
non_ecm_push(t);
+ /*endif*/
s->bit_no = 0;
}
+ /*endif*/
}
/*- End of function --------------------------------------------------------*/
t38_core_send_indicator(&s->t38x.t38, T38_IND_NO_SIGNAL);
t->framing_ok_announced = FALSE;
}
+ /*endif*/
restart_rx_modem(s);
if (s->core.timed_mode == TIMED_MODE_TCF_PREDICTABLE_MODEM_START_BEGIN)
{
s->core.samples_to_timeout = ms_to_samples(75);
s->core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_PAST_V21_MODEM;
}
+ /*endif*/
break;
default:
span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected HDLC special bit - %d!\n", status);
break;
}
+ /*endswitch*/
}
/*- End of function --------------------------------------------------------*/
s->core.to_t38.in_bits = 0;
s->core.to_t38.out_octets = 0;
}
- span_log(&s->logging, SPAN_LOG_FLOW, "Restart rx modem - modem = %d, short train = %d, ECM = %d\n", s->core.fast_rx_modem, s->core.short_train, s->core.ecm_mode);
+ /*endif*/
+ span_log(&s->logging,
+ SPAN_LOG_FLOW,
+ "Restart rx modem - modem = %d, short train = %d, ECM = %d\n",
+ s->core.fast_rx_modem,
+ s->core.short_train,
+ s->core.ecm_mode);
hdlc_rx_init(&(s->audio.modems.hdlc_rx), FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, NULL, s);
s->audio.modems.rx_signal_present = FALSE;
put_bit_func = non_ecm_remove_fill_and_put_bit;
else
put_bit_func = non_ecm_put_bit;
+ /*endif*/
put_bit_user_data = (void *) s;
}
/*endif*/
amp[i] = dc_restore(&(s->audio.modems.dc_restore), amp[i]);
/*endfor*/
s->audio.modems.rx_handler(s->audio.modems.rx_user_data, amp, len);
- return 0;
+ return 0;
}
/*- End of function --------------------------------------------------------*/
update_rx_timing(s, len);
/* TODO: handle the modems properly */
s->audio.modems.rx_fillin_handler(s->audio.modems.rx_user_data, len);
- return 0;
+ return 0;
}
/*- End of function --------------------------------------------------------*/
s->core.to_t38.octets_per_data_packet = 1;
s->core.ecm_allowed = TRUE;
- s->core.ms_per_tx_chunk = DEFAULT_MS_PER_TX_CHUNK;
t38_non_ecm_buffer_init(&s->core.non_ecm_to_modem, FALSE, 0);
+ //s->core.ms_per_tx_chunk = DEFAULT_MS_PER_TX_CHUNK;
restart_rx_modem(s);
s->core.timed_mode = TIMED_MODE_STARTUP;
s->core.samples_to_timeout = 1;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_non_ecm_buffer.c,v 1.9.4.1 2009/12/19 06:43:28 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_terminal.c,v 1.129.4.2 2009/12/19 10:44:10 steveu Exp $
*/
/*! \file */
#include "spandsp/v17rx.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/t30.h"
#include "spandsp/t38_terminal.h"
#include "spandsp/private/logging.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "spandsp/private/t30.h"
#include "spandsp/private/t38_terminal.h"
/* Settings suitable for paced transmission over a UDP transport */
-#define MS_PER_TX_CHUNK 30
+#define DEFAULT_MS_PER_TX_CHUNK 30
#define INDICATOR_TX_COUNT 3
#define DATA_TX_COUNT 1
{
T38_CHUNKING_MERGE_FCS_WITH_DATA = 0x0001,
T38_CHUNKING_WHOLE_FRAMES = 0x0002,
- T38_CHUNKING_ALLOW_TEP_TIME = 0x0004
+ T38_CHUNKING_ALLOW_TEP_TIME = 0x0004,
+ T38_CHUNKING_SEND_REGULAR_INDICATORS = 0x0008,
+ T38_CHUNKING_SEND_2S_REGULAR_INDICATORS = 0x0010
};
enum
T38_TIMED_STEP_CED_3 = 0x32,
T38_TIMED_STEP_CNG = 0x40,
T38_TIMED_STEP_CNG_2 = 0x41,
- T38_TIMED_STEP_PAUSE = 0x50
+ T38_TIMED_STEP_PAUSE = 0x50,
+ T38_TIMED_STEP_NO_SIGNAL = 0x60
};
static __inline__ void front_end_status(t38_terminal_state_t *s, int status)
ones = 0;
stuffed++;
}
+ /*endif*/
}
else
{
ones = 0;
}
+ /*endif*/
bitstream >>= 1;
}
+ /*endfor*/
}
+ /*endfor*/
/* The total length of the frame is:
the number of bits in the body
+ the number of additional bits in the body due to stuffing
Lets just allow 3 bits for the CRC, which is the worst case. It
avoids calculating the real CRC, and the worst it can do is cause
a flag octet's worth of additional output.
- */
+ */
return stuffed + 16 + 3 + 16;
}
/*- End of function --------------------------------------------------------*/
ignore it. Its harmless. */
return 0;
}
+ /*endif*/
/* In termination mode we don't care very much about indicators telling us training
is starting. We only care about V.21 preamble starting, for timeout control, and
the actual data. */
{
hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, TRUE);
}
+ /*endif*/
fe->timeout_rx_samples = 0;
front_end_status(s, T30_FRONT_END_SIGNAL_ABSENT);
break;
span_log(&s->logging, SPAN_LOG_FLOW, "CM profile %d - %s\n", buf[0] - '0', t38_cm_profile_to_str(buf[0]));
else
span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for CM message - %d\n", len);
+ /*endif*/
//front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
break;
case T38_FIELD_JM_MESSAGE:
span_log(&s->logging, SPAN_LOG_FLOW, "JM - %s\n", t38_jm_to_str(buf, len));
else
span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for JM message - %d\n", len);
+ /*endif*/
//front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
break;
case T38_FIELD_CI_MESSAGE:
span_log(&s->logging, SPAN_LOG_FLOW, "CI 0x%X\n", buf[0]);
else
span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for CI message - %d\n", len);
+ /*endif*/
//front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
break;
default:
{
span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for V34rate message - %d\n", len);
}
+ /*endif*/
break;
default:
break;
if (fe->timeout_rx_samples == 0)
{
/* HDLC can just start without any signal indicator on some platforms, even when
- there is zero packet lost. Nasty, but true. Its a good idea to be tolerant of
+ there is zero packet loss. Nasty, but true. Its a good idea to be tolerant of
loss, though, so accepting a sudden start of HDLC data is the right thing to do. */
fake_rx_indicator(t, s, T38_IND_V21_PREAMBLE);
/* All real HDLC messages in the FAX world start with 0xFF. If this one is not starting
with 0xFF it would appear some octets must have been missed before this one. */
if (len <= 0 || buf[0] != 0xFF)
fe->rx_data_missing = TRUE;
+ /*endif*/
}
- if (len > 0 && fe->hdlc_rx.len + len <= T38_MAX_HDLC_LEN)
+ /*endif*/
+ if (len > 0)
{
- bit_reverse(fe->hdlc_rx.buf + fe->hdlc_rx.len, buf, len);
- fe->hdlc_rx.len += len;
+ if (fe->hdlc_rx.len + len <= T38_MAX_HDLC_LEN)
+ {
+ bit_reverse(fe->hdlc_rx.buf + fe->hdlc_rx.len, buf, len);
+ fe->hdlc_rx.len += len;
+ }
+ else
+ {
+ fe->rx_data_missing = TRUE;
+ }
+ /*endif*/
}
+ /*endif*/
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
break;
case T38_FIELD_HDLC_FCS_OK:
/* The sender has incorrectly included data in this message. It is unclear what we should do
with it, to maximise tolerance of buggy implementations. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_FCS_OK messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC OK (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
}
+ /*endif*/
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
/* The sender has incorrectly included data in this message. We can safely ignore it, as the
bad FCS means we will throw away the whole message, anyway. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_FCS_BAD messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC bad (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
}
+ /*endif*/
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
/* The sender has incorrectly included data in this message. It is unclear what we should do
with it, to maximise tolerance of buggy implementations. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_FCS_OK_SIG_END messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, TRUE);
}
+ /*endif*/
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
/* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
/* The sender has incorrectly included data in this message. We can safely ignore it, as the
bad FCS means we will throw away the whole message, anyway. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_FCS_BAD_SIG_END messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, TRUE);
}
+ /*endif*/
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
/* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
/* The sender has incorrectly included data in this message, but there seems nothing meaningful
it could be. There could not be an FCS good/bad report beyond this. */
}
+ /*endif*/
/* Some T.38 implementations send multiple T38_FIELD_HDLC_SIG_END messages, in IFP packets with
incrementing sequence numbers, which are actually repeats. They get through to this point because
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
fe->rx_data_missing = FALSE;
front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
}
+ /*endif*/
/* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
fake_rx_indicator(t, s, T38_IND_NO_SIGNAL);
break;
t30_non_ecm_put_bit(&s->t30, SIG_STATUS_TRAINING_SUCCEEDED);
fe->rx_signal_present = TRUE;
}
+ /*endif*/
if (len > 0)
{
bit_reverse(buf2, buf, len);
t30_non_ecm_put_chunk(&s->t30, buf2, len);
}
+ /*endif*/
fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
break;
case T38_FIELD_T4_NON_ECM_SIG_END:
t30_non_ecm_put_bit(&s->t30, SIG_STATUS_TRAINING_SUCCEEDED);
fe->rx_signal_present = TRUE;
}
+ /*endif*/
bit_reverse(buf2, buf, len);
t30_non_ecm_put_chunk(&s->t30, buf2, len);
}
+ /*endif*/
/* WORKAROUND: At least some Mediatrix boxes have a bug, where they can send HDLC signal end where
they should send non-ECM signal end. It is possible they also do the opposite.
We need to tolerate this, so we use the generic receive complete
indication, rather than the specific non-ECM carrier down. */
front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
}
+ /*endif*/
fe->rx_signal_present = FALSE;
/* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
fake_rx_indicator(t, s, T38_IND_NO_SIGNAL);
s->t38_fe.hdlc_tx.len = len;
s->t38_fe.hdlc_tx.ptr = 0;
}
+ /*endif*/
}
/*- End of function --------------------------------------------------------*/
{
if (s->t38_fe.ms_per_tx_chunk == 0 || s->t38_fe.tx_bit_rate == 0)
return 0;
+ /*endif*/
return bits*1000000/s->t38_fe.tx_bit_rate;
}
/*- End of function --------------------------------------------------------*/
/* Make sure we have a positive number (i.e. we didn't truncate to zero). */
if (s->t38_fe.octets_per_data_packet < 1)
s->t38_fe.octets_per_data_packet = 1;
+ /*endif*/
}
else
{
s->t38_fe.octets_per_data_packet = MAX_OCTETS_PER_UNPACED_CHUNK;
}
+ /*endif*/
+}
+/*- End of function --------------------------------------------------------*/
+
+static int set_no_signal(t38_terminal_state_t *s)
+{
+ int delay;
+
+ if ((s->t38_fe.chunking_modes & T38_CHUNKING_SEND_REGULAR_INDICATORS))
+ {
+ t38_core_send_indicator(&s->t38_fe.t38, 0x100 | T38_IND_NO_SIGNAL);
+ s->t38_fe.timed_step = T38_TIMED_STEP_NO_SIGNAL;
+#if 0
+ if ((s->t38_fe.chunking_modes & T38_CHUNKING_SEND_2S_REGULAR_INDICATORS))
+ s->t38_fe.timeout_tx_samples = s->t38_fe.next_tx_samples + us_to_samples(2000000);
+ else
+ s->t38_fe.timeout_tx_samples = 0;
+ /*endif*/
+#endif
+ return s->t38_fe.ms_per_tx_chunk*1000;
+ }
+ /*endif*/
+ delay = t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL);
+ s->t38_fe.timed_step = T38_TIMED_STEP_NONE;
+ return delay;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int stream_no_signal(t38_terminal_state_t *s)
+{
+ t38_core_send_indicator(&s->t38_fe.t38, 0x100 | T38_IND_NO_SIGNAL);
+#if 0
+ if (s->t38_fe.timeout_tx_samples && s->t38_fe.next_tx_samples >= s->t38_fe.timeout_tx_samples)
+ s->t38_fe.timed_step = T38_TIMED_STEP_NONE;
+ /*endif*/
+#endif
+ return s->t38_fe.ms_per_tx_chunk*1000;
}
/*- End of function --------------------------------------------------------*/
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL);
else
delay = 75000;
+ /*endif*/
fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_2;
+#if 0
+ fe->timeout_tx_samples = fe->next_tx_samples
+ + us_to_samples(t38_core_send_training_delay(&fe->t38, fe->next_tx_indicator));
+#endif
fe->next_tx_samples = fe->samples;
break;
case T38_TIMED_STEP_NON_ECM_MODEM_2:
/* Switch on a fast modem, and give the training time to complete */
+#if 0
+ if ((s->t38_fe.chunking_modes & T38_CHUNKING_SEND_REGULAR_INDICATORS))
+ {
+ delay = t38_core_send_indicator(&fe->t38, 0x100 | fe->next_tx_indicator);
+ if (fe->next_tx_samples >= fe->timeout_tx_samples)
+ fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_3;
+ /*endif*/
+ return fe->ms_per_tx_chunk*1000;
+ }
+ /*endif*/
+#endif
delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator);
fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_3;
break;
len = t30_non_ecm_get_chunk(&s->t30, buf, fe->octets_per_data_packet);
if (len > 0)
bit_reverse(buf, buf, len);
+ /*endif*/
if (len < fe->octets_per_data_packet)
{
/* That's the end of the image data. */
delay = 0;
break;
}
+ /*endif*/
}
+ /*endif*/
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA);
delay = bits_to_us(s, 8*len);
break;
delay = bits_to_us(s, 8*len);
if (s->t38_fe.ms_per_tx_chunk)
delay += 60000;
+ /*endif*/
front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE);
break;
}
+ /*endif*/
memset(buf, 0, len);
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA);
delay = bits_to_us(s, 8*len);
case T38_TIMED_STEP_NON_ECM_MODEM_5:
/* This should not be needed, since the message above indicates the end of the signal, but it
seems like it can improve compatibility with quirky implementations. */
- delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL);
- fe->timed_step = T38_TIMED_STEP_NONE;
- return delay;
+ return set_no_signal(s);
}
+ /*endswitch*/
}
+ /*endfor*/
return delay;
}
/*- End of function --------------------------------------------------------*/
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL);
else
delay = 75000;
+ /*endif*/
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_2;
+#if 0
+ fe->timeout_tx_samples = fe->next_tx_samples
+ + us_to_samples(t38_core_send_training_delay(&fe->t38, fe->next_tx_indicator))
+ + us_to_samples(t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator))
+ + us_to_samples(delay);
+#endif
fe->next_tx_samples = fe->samples;
break;
case T38_TIMED_STEP_HDLC_MODEM_2:
/* Send HDLC preambling */
- delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator);
- delay += t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator);
+#if 0
+ if ((s->t38_fe.chunking_modes & T38_CHUNKING_SEND_REGULAR_INDICATORS))
+ {
+ delay = t38_core_send_indicator(&fe->t38, 0x100 | fe->next_tx_indicator);
+ if (fe->next_tx_samples >= fe->timeout_tx_samples)
+ fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
+ /*endif*/
+ return fe->ms_per_tx_chunk*1000;
+ }
+ /*endif*/
+#endif
+ delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator)
+ + t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator);
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
break;
case T38_TIMED_STEP_HDLC_MODEM_3:
delay = bits_to_us(s, i*8 + fe->hdlc_tx.extra_bits);
if (s->t38_fe.ms_per_tx_chunk)
delay += 100000;
+ /*endif*/
front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE);
}
else
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
delay = bits_to_us(s, i*8 + fe->hdlc_tx.extra_bits);
}
+ /*endif*/
break;
}
+ /*endif*/
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &fe->hdlc_tx.buf[fe->hdlc_tx.ptr], i, category);
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_4;
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &fe->hdlc_tx.buf[fe->hdlc_tx.ptr], i, category);
fe->hdlc_tx.ptr += i;
}
+ /*endif*/
delay = bits_to_us(s, i*8);
break;
case T38_TIMED_STEP_HDLC_MODEM_4:
delay = bits_to_us(s, fe->hdlc_tx.extra_bits);
if (s->t38_fe.ms_per_tx_chunk)
delay += 100000;
+ /*endif*/
front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE);
break;
}
+ /*endif*/
if (fe->hdlc_tx.len == 0)
{
/* Now, how did we get here? We have finished a frame, but have no new frame to
send, and no end of transmission condition. */
span_log(&s->logging, SPAN_LOG_FLOW, "No new frame or end transmission condition.\n");
}
+ /*endif*/
/* Finish the current frame off, and prepare for the next one. */
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category);
case T38_TIMED_STEP_HDLC_MODEM_5:
/* Note that some boxes do not like us sending a T38_FIELD_HDLC_SIG_END at this point.
A T38_IND_NO_SIGNAL should always be OK. */
- delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL);
- fe->timed_step = T38_TIMED_STEP_NONE;
- return delay;
+ return set_no_signal(s);
}
+ /*endswitch*/
}
+ /*endfor*/
return delay;
}
/*- End of function --------------------------------------------------------*/
front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE);
return 0;
}
+ /*endswitch*/
}
+ /*endfor*/
return delay;
}
/*- End of function --------------------------------------------------------*/
fe->current_tx_data_type = T38_DATA_NONE;
return delay;
}
+ /*endswitch*/
}
+ /*endfor*/
return delay;
}
/*- End of function --------------------------------------------------------*/
fe = &s->t38_fe;
if (fe->current_rx_type == T30_MODEM_DONE || fe->current_tx_type == T30_MODEM_DONE)
return TRUE;
+ /*endif*/
fe->samples += samples;
t30_timer_update(&s->t30, samples);
fe->timeout_rx_samples = 0;
front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
}
+ /*endif*/
if (fe->timed_step == T38_TIMED_STEP_NONE)
return FALSE;
+ /*endif*/
/* Wait until the right time comes along, unless we are working in "no delays" mode, while talking to an
IAF terminal. */
if (fe->ms_per_tx_chunk && fe->samples < fe->next_tx_samples)
return FALSE;
+ /*endif*/
/* Its time to send something */
delay = 0;
- switch (fe->timed_step & 0xFFF0)
+ switch ((fe->timed_step & 0xFFF0))
{
case T38_TIMED_STEP_NON_ECM_MODEM:
delay = stream_non_ecm(s);
fe->timed_step = T38_TIMED_STEP_NONE;
front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE);
break;
+ case T38_TIMED_STEP_NO_SIGNAL:
+ delay = stream_no_signal(s);
+ break;
}
+ /*endswitch*/
fe->next_tx_samples += us_to_samples(delay);
return FALSE;
}
fe->timed_step = (use_hdlc) ? T38_TIMED_STEP_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
if (fe->next_tx_samples < fe->samples)
fe->next_tx_samples = fe->samples;
+ /*endif*/
}
else
{
/* Start the fast streaming transmission process. */
}
+ /*endif*/
}
/*- End of function --------------------------------------------------------*/
span_log(&s->logging, SPAN_LOG_FLOW, "Set tx type %d\n", type);
if (fe->current_tx_type == type)
return;
+ /*endif*/
set_octets_per_data_packet(s, bit_rate);
switch (type)
/* If a "no signal" indicator is waiting to be played out, don't disturb it. */
if (fe->timed_step != T38_TIMED_STEP_NON_ECM_MODEM_5 && fe->timed_step != T38_TIMED_STEP_HDLC_MODEM_5)
fe->timed_step = T38_TIMED_STEP_NONE;
+ /*endif*/
fe->current_tx_data_type = T38_DATA_NONE;
break;
case T30_MODEM_PAUSE:
fe->current_tx_data_type = T38_DATA_V27TER_4800;
break;
}
+ /*endswitch*/
start_tx(fe, use_hdlc);
break;
case T30_MODEM_V29:
fe->current_tx_data_type = T38_DATA_V29_9600;
break;
}
+ /*endswitch*/
start_tx(fe, use_hdlc);
break;
case T30_MODEM_V17:
fe->current_tx_data_type = T38_DATA_V17_14400;
break;
}
+ /*endswitch*/
start_tx(fe, use_hdlc);
break;
case T30_MODEM_DONE:
fe->current_tx_data_type = T38_DATA_NONE;
break;
}
+ /*endswitch*/
fe->current_tx_type = type;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int without_pacing)
+SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int config)
{
- if (without_pacing)
+ if ((config & T38_TERMINAL_OPTION_NO_PACING))
{
/* Continuous streaming mode, as used for TPKT over TCP transport */
/* Inhibit indicator packets */
t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_IMAGE_DATA, 1);
t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_IMAGE_DATA_END, 1);
s->t38_fe.ms_per_tx_chunk = 0;
+ s->t38_fe.chunking_modes &= ~T38_CHUNKING_SEND_REGULAR_INDICATORS;
}
else
{
t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_CONTROL_DATA_END, DATA_END_TX_COUNT);
t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_IMAGE_DATA, DATA_TX_COUNT);
t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_IMAGE_DATA_END, DATA_END_TX_COUNT);
- s->t38_fe.ms_per_tx_chunk = MS_PER_TX_CHUNK;
+ s->t38_fe.ms_per_tx_chunk = DEFAULT_MS_PER_TX_CHUNK;
+ if ((config & (T38_TERMINAL_OPTION_REGULAR_INDICATORS | T38_TERMINAL_OPTION_2S_REPEATING_INDICATORS)))
+ s->t38_fe.chunking_modes |= T38_CHUNKING_SEND_REGULAR_INDICATORS;
+ else
+ s->t38_fe.chunking_modes &= ~T38_CHUNKING_SEND_REGULAR_INDICATORS;
+ /*endif*/
+ if ((config & T38_TERMINAL_OPTION_2S_REPEATING_INDICATORS))
+ s->t38_fe.chunking_modes |= T38_CHUNKING_SEND_2S_REGULAR_INDICATORS;
+ else
+ s->t38_fe.chunking_modes &= ~T38_CHUNKING_SEND_2S_REGULAR_INDICATORS;
+ /*endif*/
}
+ /*endif*/
set_octets_per_data_packet(s, 300);
}
/*- End of function --------------------------------------------------------*/
s->t38_fe.chunking_modes |= T38_CHUNKING_ALLOW_TEP_TIME;
else
s->t38_fe.chunking_modes &= ~T38_CHUNKING_ALLOW_TEP_TIME;
+ /*endif*/
t38_set_tep_handling(&s->t38_fe.t38, use_tep);
}
/*- End of function --------------------------------------------------------*/
s->t38_fe.iaf |= T30_IAF_MODE_NO_FILL_BITS;
else
s->t38_fe.iaf &= ~T30_IAF_MODE_NO_FILL_BITS;
+ /*endif*/
t30_set_iaf_mode(&s->t30, s->t38_fe.iaf);
}
/*- End of function --------------------------------------------------------*/
}
/*- End of function --------------------------------------------------------*/
+static int t38_terminal_t38_fe_restart(t38_terminal_state_t *t)
+{
+ t38_terminal_front_end_state_t *s;
+
+ s = &t->t38_fe;
+ t38_core_restart(&s->t38);
+
+ s->rx_signal_present = FALSE;
+ s->timed_step = T38_TIMED_STEP_NONE;
+ //s->iaf = T30_IAF_MODE_T37 | T30_IAF_MODE_T38;
+ s->iaf = T30_IAF_MODE_T38;
+
+ s->current_tx_data_type = T38_DATA_NONE;
+ s->next_tx_samples = 0;
+
+ s->hdlc_tx.ptr = 0;
+
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
static int t38_terminal_t38_fe_init(t38_terminal_state_t *t,
t38_tx_packet_handler_t *tx_packet_handler,
void *tx_packet_user_data)
}
/*- End of function --------------------------------------------------------*/
+SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s,
+ int calling_party)
+{
+ t38_terminal_t38_fe_restart(s);
+ t30_restart(&s->t30);
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s,
int calling_party,
t38_tx_packet_handler_t *tx_packet_handler,
{
if (tx_packet_handler == NULL)
return NULL;
+ /*endif*/
if (s == NULL)
{
if ((s = (t38_terminal_state_t *) malloc(sizeof(*s))) == NULL)
return NULL;
+ /*endif*/
}
+ /*endif*/
memset(s, 0, sizeof(*s));
span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&s->logging, "T.38T");
t38_terminal_t38_fe_init(s, tx_packet_handler, tx_packet_user_data);
- t38_terminal_set_config(s, FALSE);
+ t38_terminal_set_config(s, 0);
t30_init(&s->t30,
calling_party,
/*
* SpanDSP - a series of DSP components for telephony
*
- * t4_rx.c - ITU T.4 FAX receive processing
+ * t4_rx.c - ITU T.4 FAX image receive processing
*
* Written by Steve Underwood <steveu@coppice.org>
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_rx.c,v 1.12.2.8 2009/12/21 17:18:39 steveu Exp $
*/
/*
#include "spandsp/async.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/version.h"
#include "spandsp/private/logging.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
/*! The number of EOLs to check at the end of a T.6 page */
#define EOLS_TO_END_T6_RX_PAGE 2
+#include "t4_t6_decode_states.h"
+
#if defined(T4_STATE_DEBUGGING)
static void STATE_TRACE(const char *format, ...)
{
#define STATE_TRACE(...) /**/
#endif
-/*! T.4 run length table entry */
-typedef struct
-{
- /*! Length of T.4 code, in bits */
- uint16_t length;
- /*! T.4 code */
- uint16_t code;
- /*! Run length, in bits */
- int16_t run_length;
-} t4_run_table_entry_t;
-
-#include "t4_t6_decode_states.h"
-
#if defined(HAVE_LIBTIFF)
static int set_tiff_directory_info(t4_state_t *s)
{
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(void) t4_get_transfer_statistics(t4_state_t *s, t4_stats_t *t)
+SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t)
{
t->pages_transferred = s->current_page - s->tiff.start_page;
t->pages_in_file = s->tiff.pages_in_file;
{
switch (encoding)
{
+ case T4_COMPRESSION_NONE:
+ return "None";
case T4_COMPRESSION_ITU_T4_1D:
return "T.4 1-D";
case T4_COMPRESSION_ITU_T4_2D:
return "T.4 2-D";
case T4_COMPRESSION_ITU_T6:
return "T.6";
+ case T4_COMPRESSION_ITU_T85:
+ return "T.85";
+ case T4_COMPRESSION_ITU_T85_L0:
+ return "T.85(L0)";
+ case T4_COMPRESSION_ITU_T43:
+ return "T.43";
+ case T4_COMPRESSION_ITU_T45:
+ return "T.45";
+ case T4_COMPRESSION_ITU_T81:
+ return "T.81";
+ case T4_COMPRESSION_ITU_SYCC_T81:
+ return "sYCC T.81";
}
return "???";
}
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_t6_decode_states.h,v 1.1.2.4 2009/12/19 10:21:43 steveu Exp $
*/
/* Legitimate runs of zero bits which are the tail end of one code
/*
* SpanDSP - a series of DSP components for telephony
*
- * t4_tx.c - ITU T.4 FAX transmit processing
+ * t4_tx.c - ITU T.4 FAX image transmit processing
*
* Written by Steve Underwood <steveu@coppice.org>
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_tx.c,v 1.13.2.9 2009/12/21 17:18:40 steveu Exp $
*/
/*
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/async.h"
+#include "spandsp/timezone.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
-#include "spandsp/version.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/t81_t82_arith_coding.h"
+#include "spandsp/t85.h"
+#endif
+#include "spandsp/t4_t6_decode.h"
+#include "spandsp/t4_t6_encode.h"
#include "spandsp/private/logging.h"
+#if defined(SPANDSP_SUPPORT_T85)
+#include "spandsp/private/t81_t82_arith_coding.h"
+#include "spandsp/private/t85.h"
+#endif
+#include "spandsp/private/t4_t6_decode.h"
+#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
};
time(&now);
- tm = *localtime(&now);
+ if (s->tz)
+ tz_localtime(s->tz, &tm, now);
+ else
+ tm = *localtime(&now);
snprintf(header,
132,
" %2d-%s-%d %02d:%02d %-50s %-21s p.%d",
tm.tm_year + 1900,
tm.tm_hour,
tm.tm_min,
- s->t4_t6_tx.header_info,
- s->tiff.local_ident,
+ s->header_info,
+ (s->tiff.local_ident) ? s->tiff.local_ident : "",
s->current_page + 1);
}
/*- End of function --------------------------------------------------------*/
s->min_row_bits = INT_MAX;
s->max_row_bits = 0;
- if (s->t4_t6_tx.header_info && s->t4_t6_tx.header_info[0])
+ if (s->header_info && s->header_info[0])
{
if (t4_tx_put_fax_header(s))
return -1;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(void) t4_tx_set_min_row_bits(t4_state_t *s, int bits)
+SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits)
{
s->t4_t6_tx.min_bits_per_row = bits;
}
SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info)
{
- s->t4_t6_tx.header_info = (info && info[0]) ? info : NULL;
+ s->header_info = (info && info[0]) ? info : NULL;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring)
+{
+ s->tz = tz_init(s->tz, tzstring);
}
/*- End of function --------------------------------------------------------*/
return s->current_page;
}
/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t)
+{
+ t->pages_transferred = s->current_page - s->tiff.start_page;
+ t->pages_in_file = s->tiff.pages_in_file;
+ t->width = s->image_width;
+ t->length = s->image_length;
+ t->bad_rows = s->t4_t6_rx.bad_rows;
+ t->longest_bad_row_run = s->t4_t6_rx.longest_bad_row_run;
+ t->x_resolution = s->x_resolution;
+ t->y_resolution = s->y_resolution;
+ t->encoding = s->line_encoding;
+ t->line_image_size = s->line_image_size/8;
+}
+/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: testcpuid.c,v 1.13 2009/01/05 13:48:31 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: time_scale.c,v 1.30 2009/02/10 13:06:47 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_detect.c,v 1.53 2009/04/12 09:12:10 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_generate.c,v 1.56 2010/05/23 14:02:21 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17_v32bis_rx_constellation_maps.h,v 1.1.4.1 2009/12/24 16:52:30 steveu Exp $
*/
/* The following table maps the 8 soft-decisions associated with every possible point in the
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17_v32bis_tx_constellation_maps.h,v 1.1.4.1 2009/12/24 16:52:30 steveu Exp $
*/
#if defined(SPANDSP_USE_FIXED_POINTx)
cvec_circular_lmsf(s->eq_buf, s->eq_coeff, V17_EQUALIZER_LEN, s->eq_step, &err);
}
#endif
+/*- End of function --------------------------------------------------------*/
static int descramble(v17_rx_state_t *s, int in_bit)
{
#endif
}
s->last_sample = 0;
- span_log(&s->logging, SPAN_LOG_FLOW, "Phase rates %f %f\n", dds_frequencyf(s->carrier_phase_rate), dds_frequencyf(s->carrier_phase_rate_save));
span_log(&s->logging, SPAN_LOG_FLOW, "Gains %f %f\n", s->agc_scaling_save, s->agc_scaling);
+ span_log(&s->logging, SPAN_LOG_FLOW, "Phase rates %f %f\n", dds_frequencyf(s->carrier_phase_rate), dds_frequencyf(s->carrier_phase_rate_save));
/* Initialise the working data for symbol timing synchronisation */
#if defined(SPANDSP_USE_FIXED_POINTx)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17tx.c,v 1.75.4.1 2009/12/24 16:52:30 steveu Exp $
*/
/*! \file */
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
#include "spandsp/async.h"
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
/* 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)
- memset(s->rrc_filter, 0, sizeof(s->rrc_filter));
+ cvec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#else
cvec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#endif
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v18.c,v 1.12 2009/11/04 15:52:06 steveu Exp $
*/
/*! \file */
{"##9", 'Z'},
{"##0", ' '},
#if defined(WIN32)
- {"#*1", 'X'}, // (Note 1) 111 1011
- {"#*2", 'X'}, // (Note 1) 111 1100
- {"#*3", 'X'}, // (Note 1) 111 1101
- {"#*4", 'X'}, // (Note 1) 101 1011
- {"#*5", 'X'}, // (Note 1) 101 1100
- {"#*6", 'X'}, // (Note 1) 101 1101
+ {"#*1", 'X'}, // (Note 1) 111 1011
+ {"#*2", 'X'}, // (Note 1) 111 1100
+ {"#*3", 'X'}, // (Note 1) 111 1101
+ {"#*4", 'X'}, // (Note 1) 101 1011
+ {"#*5", 'X'}, // (Note 1) 101 1100
+ {"#*6", 'X'}, // (Note 1) 101 1101
#else
- {"#*1", 'æ'}, // (Note 1) 111 1011
- {"#*2", 'ø'}, // (Note 1) 111 1100
- {"#*3", 'Ã¥'}, // (Note 1) 111 1101
- {"#*4", 'Æ'}, // (Note 1) 101 1011
- {"#*5", 'Ø'}, // (Note 1) 101 1100
- {"#*6", 'Ã…'}, // (Note 1) 101 1101
+ {"#*1", 0xE6}, // (Note 1) 111 1011
+ {"#*2", 0xF8}, // (Note 1) 111 1100
+ {"#*3", 0xE5}, // (Note 1) 111 1101
+ {"#*4", 0xC6}, // (Note 1) 101 1011
+ {"#*5", 0xD8}, // (Note 1) 101 1100
+ {"#*6", 0xC5}, // (Note 1) 101 1101
#endif
{"#0", '?'},
{"#1", 'c'},
"", /* $ */
"**5", /* % */
"**1", /* & >> + */
- "", /* \92 */
+ "", /* 0x92 */
"**6", /* ( */
"**7", /* ) */
"#9", /* _ >> . */
"###8", /* X */
"##*9", /* Y */
"##9", /* Z */
- "#*4", /* Æ (National code) */
- "#*5", /* Ø (National code) */
- "#*6", /* Ã… (National code) */
+ "#*4", /* 0xC6 (National code) */
+ "#*5", /* 0xD8 (National code) */
+ "#*6", /* 0xC5 (National code) */
"", /* ^ */
"0", /* _ >> SPACE */
- "", /* \92 */
+ "", /* 0x92 */
"*1", /* a */
"1", /* b */
"#1", /* c */
"#8", /* x */
"*9", /* y */
"9", /* z */
- "#*1", /* æ (National code) */
- "#*2", /* ø (National code) */
- "#*3", /* å (National code) */
+ "#*1", /* 0xE6 (National code) */
+ "#*2", /* 0xF8 (National code) */
+ "#*3", /* 0xE5 (National code) */
"0", /* ~ >> SPACE */
"*0" /* DEL >> BACK SPACE */
};
s = (v18_state_t *) user_data;
if ((ch = queue_read_byte(&s->queue.queue)) >= 0)
- {
- int space;
- int cont;
- space = queue_free_space(&s->queue.queue);
- cont = queue_contents(&s->queue.queue);
return ch;
- }
if (s->tx_signal_on)
{
/* The FSK should now be switched off. */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v22bis_rx.c,v 1.69 2009/11/04 15:52:06 steveu Exp $
*/
/*! \file */
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
#include "spandsp/async.h"
#include "spandsp/power_meter.h"
#include "spandsp/arctan2.h"
SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int len)
{
int i;
- int j;
int step;
complexf_t z;
complexf_t zz;
/* Complex bandpass filter the signal, using a pair of FIRs, and RRC coeffs shifted
to centre at 1200Hz or 2400Hz. The filters support 12 fractional phase shifts, to
permit signal extraction very close to the middle of a symbol. */
- s->rx.rrc_filter[s->rx.rrc_filter_step] =
- s->rx.rrc_filter[s->rx.rrc_filter_step + V22BIS_RX_FILTER_STEPS] = amp[i];
+ s->rx.rrc_filter[s->rx.rrc_filter_step] = amp[i];
if (++s->rx.rrc_filter_step >= V22BIS_RX_FILTER_STEPS)
s->rx.rrc_filter_step = 0;
own transmitted signal suppressed. */
if (s->calling_party)
{
- ii = rx_pulseshaper_2400_re[6][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
- for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
- ii += rx_pulseshaper_2400_re[6][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+#if defined(SPANDSP_USE_FIXED_POINT)
+ ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#else
+ ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#endif
}
else
{
- ii = rx_pulseshaper_1200_re[6][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
- for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
- ii += rx_pulseshaper_1200_re[6][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+#if defined(SPANDSP_USE_FIXED_POINT)
+ ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#else
+ ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#endif
}
power = power_meter_update(&(s->rx.rx_power), (int16_t) ii);
if (s->rx.signal_present)
s->rx.eq_put_step += PULSESHAPER_COEFF_SETS*40/(3*2);
if (s->calling_party)
{
- ii = rx_pulseshaper_2400_re[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
- qq = rx_pulseshaper_2400_im[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
- for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
- {
- ii += rx_pulseshaper_2400_re[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
- qq += rx_pulseshaper_2400_im[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
- }
+#if defined(SPANDSP_USE_FIXED_POINT)
+ ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+ qq = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#else
+ ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+ qq = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#endif
}
else
{
- ii = rx_pulseshaper_1200_re[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
- qq = rx_pulseshaper_1200_im[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
- for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
- {
- ii += rx_pulseshaper_1200_re[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
- qq += rx_pulseshaper_1200_im[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
- }
+#if defined(SPANDSP_USE_FIXED_POINT)
+ ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+ qq = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#else
+ ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+ qq = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step);
+#endif
}
sample.re = ii*s->rx.agc_scaling;
sample.im = qq*s->rx.agc_scaling;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) v22bis_rx_fillin(v22bis_state_t *s, int len)
+SPAN_DECLARE_NONSTD(int) v22bis_rx_fillin(v22bis_state_t *s, int len)
{
int i;
int v22bis_rx_restart(v22bis_state_t *s)
{
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ vec_zeroi16(s->rx.rrc_filter, sizeof(s->rx.rrc_filter)/sizeof(s->rx.rrc_filter[0]));
+#else
vec_zerof(s->rx.rrc_filter, sizeof(s->rx.rrc_filter)/sizeof(s->rx.rrc_filter[0]));
+#endif
s->rx.rrc_filter_step = 0;
s->rx.scramble_reg = 0;
s->rx.scrambler_pattern_count = 0;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v22bis_tx.c,v 1.64 2009/11/04 15:52:06 steveu Exp $
*/
/*! \file */
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
#include "spandsp/async.h"
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
/* Now create and modulate the carrier */
z = dds_complexf(&(s->tx.carrier_phase), s->tx.carrier_phase_rate);
famp = (x.re*z.re - x.im*z.im)*s->tx.gain;
- if (s->tx.guard_phase_rate && (s->tx.rrc_filter[s->tx.rrc_filter_step].re != 0.0f || s->tx.rrc_filter[i + s->tx.rrc_filter_step].im != 0.0f))
+ if (s->tx.guard_phase_rate && (s->tx.rrc_filter[s->tx.rrc_filter_step].re != 0.0f || s->tx.rrc_filter[s->tx.rrc_filter_step].im != 0.0f))
{
/* Add the guard tone */
famp += dds_modf(&(s->tx.guard_phase), s->tx.guard_phase_rate, s->tx.guard_level, 0);
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) v22bis_current_bit_rate(v22bis_state_t *s)
+SPAN_DECLARE(int) v22bis_get_current_bit_rate(v22bis_state_t *s)
{
return s->negotiated_bit_rate;
}
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_rx.c,v 1.131 2009/07/08 15:11:09 steveu Exp $
*/
/*! \file */
/*! The length of training segment 6, in symbols */
#define V27TER_TRAINING_SEG_6_LEN 8
-/*! The length of the equalizer buffer */
-#define V27TER_EQUALIZER_LEN (V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN)
-
enum
{
TRAINING_STAGE_NORMAL_OPERATION = 0,
/* Start with an equalizer based on everything being perfect. */
#if defined(SPANDSP_USE_FIXED_POINTx)
cvec_zeroi16(s->eq_coeff, V27TER_EQUALIZER_LEN);
- s->eq_coeff[V27TER_EQUALIZER_PRE_LEN] = complex_seti16(1.414f*FP_FACTOR, 0);
+ s->eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1] = complex_seti16(1.414f*FP_FACTOR, 0);
cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_LEN);
s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN);
#else
cvec_zerof(s->eq_coeff, V27TER_EQUALIZER_LEN);
- s->eq_coeff[V27TER_EQUALIZER_PRE_LEN] = complex_setf(1.414f, 0.0f);
+ s->eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1] = complex_setf(1.414f, 0.0f);
cvec_zerof(s->eq_buf, V27TER_EQUALIZER_LEN);
s->eq_delta = EQUALIZER_DELTA/V27TER_EQUALIZER_LEN;
#endif
/* This routine adapts the position of the half baud samples entering the equalizer. */
/* Perform a Gardner test for baud alignment */
- p = s->eq_buf[(s->eq_step - 3) & V27TER_EQUALIZER_LEN].re
- - s->eq_buf[(s->eq_step - 1) & V27TER_EQUALIZER_LEN].re;
- p *= s->eq_buf[(s->eq_step - 2) & V27TER_EQUALIZER_LEN].re;
+ p = s->eq_buf[(s->eq_step - 3) & (V27TER_EQUALIZER_LEN - 1)].re
+ - s->eq_buf[(s->eq_step - 1) & (V27TER_EQUALIZER_LEN - 1)].re;
+ p *= s->eq_buf[(s->eq_step - 2) & (V27TER_EQUALIZER_LEN - 1)].re;
- q = s->eq_buf[(s->eq_step - 3) & V27TER_EQUALIZER_LEN].im
- - s->eq_buf[(s->eq_step - 1) & V27TER_EQUALIZER_LEN].im;
- q *= s->eq_buf[(s->eq_step - 2) & V27TER_EQUALIZER_LEN].im;
+ q = s->eq_buf[(s->eq_step - 3) & (V27TER_EQUALIZER_LEN - 1)].im
+ - s->eq_buf[(s->eq_step - 1) & (V27TER_EQUALIZER_LEN - 1)].im;
+ q *= s->eq_buf[(s->eq_step - 2) & (V27TER_EQUALIZER_LEN - 1)].im;
s->gardner_integrate += (p + q > 0.0f) ? s->gardner_step : -s->gardner_step;
#if defined(SPANDSP_USE_FIXED_POINTx)
z1.re = z.re/(float) FP_FACTOR;
z1.im = z.im/(float) FP_FACTOR;
- zz = complex_subf(&z, target);
+ zz.re = target->re;
+ zz.im = target->im;
zz = complex_subf(&z1, &zz);
s->training_error += powerf(&zz);
#else
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len)
+SPAN_DECLARE_NONSTD(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len)
{
int i;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_tx.c,v 1.76 2009/06/02 16:03:56 steveu Exp $
*/
/*! \file */
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
#include "spandsp/async.h"
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
return -1;
s->bit_rate = bit_rate;
#if defined(SPANDSP_USE_FIXED_POINT)
- memset(s->rrc_filter, 0, sizeof(s->rrc_filter));
+ cvec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#else
cvec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#endif
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29rx.c,v 1.167.4.5 2009/12/28 12:20:47 steveu Exp $
*/
/*! \file */
/*! The length of training segment 4, in symbols */
#define V29_TRAINING_SEG_4_LEN 48
-/*! The length of the equalizer buffer */
-#define V29_EQUALIZER_LEN (V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN)
-
enum
{
TRAINING_STAGE_NORMAL_OPERATION = 0,
/* Start with an equalizer based on everything being perfect */
#if defined(SPANDSP_USE_FIXED_POINT)
cvec_zeroi16(s->eq_coeff, V29_EQUALIZER_LEN);
- s->eq_coeff[V29_EQUALIZER_POST_LEN] = complex_seti16(3*FP_FACTOR, 0*FP_FACTOR);
+ s->eq_coeff[V29_EQUALIZER_PRE_LEN] = complex_seti16(3*FP_FACTOR, 0*FP_FACTOR);
cvec_zeroi16(s->eq_buf, V29_EQUALIZER_LEN);
s->eq_delta = 32768.0f*EQUALIZER_DELTA/V29_EQUALIZER_LEN;
#else
cvec_zerof(s->eq_coeff, V29_EQUALIZER_LEN);
- s->eq_coeff[V29_EQUALIZER_POST_LEN] = complex_setf(3.0f, 0.0f);
+ s->eq_coeff[V29_EQUALIZER_PRE_LEN] = complex_setf(3.0f, 0.0f);
cvec_zerof(s->eq_buf, V29_EQUALIZER_LEN);
s->eq_delta = EQUALIZER_DELTA/V29_EQUALIZER_LEN;
#endif
bit &= 1;
/* Descramble the bit */
- out_bit = (bit ^ (s->scramble_reg >> 17) ^ (s->scramble_reg >> 22)) & 1;
+ out_bit = (bit ^ (s->scramble_reg >> (18 - 1)) ^ (s->scramble_reg >> (23 - 1))) & 1;
s->scramble_reg = (s->scramble_reg << 1) | bit;
/* We need to strip the last part of the training - the test period of all 1s -
Passband Timing Recovery in an All-Digital Modem Receiver
IEEE TRANSACTIONS ON COMMUNICATIONS, VOL. COM-26, NO. 5, MAY 1978 */
- /* This is slightly rearranged for figure 3b of the Godard paper, as this saves a couple of
+ /* This is slightly rearranged from figure 3b of the Godard paper, as this saves a couple of
maths operations */
#if defined(SPANDSP_USE_FIXED_POINT)
/* TODO: The scalings used here need more thorough evaluation, to see if overflows are possible. */
s->symbol_sync_dc_filter[0] = v;
/* A little integration will now filter away much of the HF noise */
s->baud_phase -= p;
- if (abs(s->baud_phase) > 30*FP_FACTOR)
+ v = labs(s->baud_phase);
+ if (v > 30*FP_FACTOR)
{
- if (s->baud_phase > 0)
- i = (s->baud_phase > 1000*FP_FACTOR) ? 5 : 1;
- else
- i = (s->baud_phase < -1000*FP_FACTOR) ? -5 : -1;
+ i = (v > 1000*FP_FACTOR) ? 5 : 1;
+ if (s->baud_phase < 0)
+ i = -i;
//printf("v = %10.5f %5d - %f %f %d %d\n", v, i, p, s->baud_phase, s->total_baud_timing_correction);
s->eq_put_step += i;
s->total_baud_timing_correction += i;
s->symbol_sync_dc_filter[0] = v;
/* A little integration will now filter away much of the HF noise */
s->baud_phase -= p;
- if (fabsf(s->baud_phase) > 30.0f)
+ v = fabsf(s->baud_phase);
+ if (v > 30.0f)
{
- if (s->baud_phase > 0.0f)
- i = (s->baud_phase > 1000.0f) ? 5 : 1;
- else
- i = (s->baud_phase < -1000.0f) ? -5 : -1;
+ i = (v > 1000.0f) ? 5 : 1;
+ if (s->baud_phase < 0.0f)
+ i = -i;
//printf("v = %10.5f %5d - %f %f %d %d\n", v, i, p, s->baud_phase, s->total_baud_timing_correction);
s->eq_put_step += i;
s->total_baud_timing_correction += i;
pair of filters. This results in a properly bandpass filtered complex
signal, which can be brought directly to baseband by complex mixing.
No further filtering, to remove mixer harmonics, is needed. */
- step = -s->eq_put_step;
- if (step > RX_PULSESHAPER_COEFF_SETS - 1)
- step = RX_PULSESHAPER_COEFF_SETS - 1;
s->eq_put_step += RX_PULSESHAPER_COEFF_SETS*10/(3*2);
#if defined(SPANDSP_USE_FIXED_POINT)
v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V29_RX_FILTER_STEPS, s->rrc_filter_step);
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) v29_rx_fillin(v29_rx_state_t *s, int len)
+SPAN_DECLARE_NONSTD(int) v29_rx_fillin(v29_rx_state_t *s, int len)
{
int i;
if (s->old_train)
{
s->carrier_phase_rate = s->carrier_phase_rate_save;
- s->agc_scaling = s->agc_scaling_save;
equalizer_restore(s);
+ s->agc_scaling = s->agc_scaling_save;
}
else
{
s->carrier_phase_rate = dds_phase_ratef(CARRIER_NOMINAL_FREQ);
+ equalizer_reset(s);
#if defined(SPANDSP_USE_FIXED_POINT)
s->agc_scaling_save = 0;
s->agc_scaling = (float) FP_FACTOR*32768.0f*0.0017f/RX_PULSESHAPER_GAIN;
s->agc_scaling_save = 0.0f;
s->agc_scaling = 0.0017f/RX_PULSESHAPER_GAIN;
#endif
- equalizer_reset(s);
}
#if defined(SPANDSP_USE_FIXED_POINT)
s->carrier_track_i = 8000;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29tx.c,v 1.89 2009/06/02 16:03:56 steveu Exp $
*/
/*! \file */
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
#include "spandsp/async.h"
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
s->in_training = TRUE;
bit = 1;
}
- out_bit = (bit ^ (s->scramble_reg >> 17) ^ (s->scramble_reg >> 22)) & 1;
+ out_bit = (bit ^ (s->scramble_reg >> (18 - 1)) ^ (s->scramble_reg >> (23 - 1))) & 1;
s->scramble_reg = (s->scramble_reg << 1) | out_bit;
return out_bit;
}
return -1;
}
#if defined(SPANDSP_USE_FIXED_POINT)
- memset(s->rrc_filter, 0, sizeof(s->rrc_filter));
+ cvec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#else
cvec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#endif
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29tx_constellation_maps.h,v 1.2 2008/09/04 14:40:05 steveu Exp $
*/
#if defined(SPANDSP_USE_FIXED_POINT)
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42.c,v 1.51 2009/11/04 15:52:06 steveu Exp $
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42bis.c,v 1.37 2009/02/10 13:06:47 steveu Exp $
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED.
#define V42BIS_N5 (V42BIS_N4 + V42BIS_N6) /* Index number of first dictionary entry used to store a string */
#define V42BIS_N6 3 /* Number of control codewords */
+/* V.42bis/9.2 */
+#define V42BIS_ESC_STEP 51
+
/* Control code words in compressed mode */
enum
{
{
octet = buf[ptr++];
ss->string_code = octet + V42BIS_N6;
- if (ss->transparent)
+ if (octet == ss->escape_code)
+ {
+ push_compressed_octet(ss, ss->escape_code);
+ ss->escape_code += V42BIS_ESC_STEP;
+ push_compressed_octet(ss, V42BIS_EID);
+ }
+ else
+ {
push_compressed_octet(ss, octet);
+ }
ss->first = FALSE;
}
while (ptr < len)
printf("Going compressed\n");
/* 7.8.1 Transition to compressed mode */
/* Switch out of transparent now, between codes. We need to send the octet which did not
- match, just before switching. */
+ match, just before switching. */
if (octet == ss->escape_code)
{
- push_compressed_octet(ss, ss->escape_code++);
+ push_compressed_octet(ss, ss->escape_code);
+ ss->escape_code += V42BIS_ESC_STEP;
push_compressed_octet(ss, V42BIS_EID);
}
else
{
push_compressed_octet(ss, octet);
}
- push_compressed_octet(ss, ss->escape_code++);
+ push_compressed_octet(ss, ss->escape_code);
+ ss->escape_code += V42BIS_ESC_STEP;
push_compressed_octet(ss, V42BIS_ECM);
ss->transparent = FALSE;
}
{
if (octet == ss->escape_code)
{
- push_compressed_octet(ss, ss->escape_code++);
+ push_compressed_octet(ss, ss->escape_code);
+ ss->escape_code += V42BIS_ESC_STEP;
push_compressed_octet(ss, V42BIS_EID);
}
else
for (;;)
{
/* Fill up the bit buffer. */
- while (ss->input_bit_count < 32 - 8 && ptr < len)
+ while (ss->input_bit_count < (32 - 8) && ptr < len)
{
ss->input_bit_count += 8;
ss->input_bit_buffer |= (uint32_t) buf[ptr++] << (32 - ss->input_bit_count);
if (ss->escaped)
{
ss->escaped = FALSE;
- if (code == V42BIS_ECM)
+ switch (code)
{
+ case V42BIS_ECM:
printf("Hit V42BIS_ECM\n");
ss->transparent = FALSE;
code_len = ss->v42bis_parm_c2;
- }
- else if (code == V42BIS_EID)
- {
+ break;
+ case V42BIS_EID:
printf("Hit V42BIS_EID\n");
- ss->output_buf[ss->output_octet_count++] = ss->escape_code - 1;
+ ss->output_buf[ss->output_octet_count++] = ss->escape_code;
+ ss->escape_code += V42BIS_ESC_STEP;
if (ss->output_octet_count >= ss->max_len - s->v42bis_parm_n7)
{
ss->handler(ss->user_data, ss->output_buf, ss->output_octet_count);
ss->output_octet_count = 0;
}
- }
- else if (code == V42BIS_RESET)
- {
+ break;
+ case V42BIS_RESET:
printf("Hit V42BIS_RESET\n");
- }
- else
- {
+ break;
+ default:
printf("Hit V42BIS_???? - %" PRIu32 "\n", code);
+ break;
}
}
else if (code == ss->escape_code)
{
- ss->escape_code++;
ss->escaped = TRUE;
}
else
ss->octet = code - V42BIS_N6;
/* Output the decoded string. */
this_length = V42BIS_MAX_STRING_SIZE - (int) (string - decode_buf);
+ for (i = 0; i < this_length; i++)
+ {
+ if (string[i] == ss->escape_code)
+ ss->escape_code += V42BIS_ESC_STEP;
+ }
memcpy(ss->output_buf + ss->output_octet_count, string, this_length);
ss->output_octet_count += this_length;
if (ss->output_octet_count >= ss->max_len - s->v42bis_parm_n7)
{
int i;
- if (negotiated_p1 < 512 || negotiated_p1 > 65535)
+ if (negotiated_p1 < V42BIS_MIN_DICTIONARY_SIZE || negotiated_p1 > 65535)
return NULL;
- if (negotiated_p2 < 6 || negotiated_p2 > V42BIS_MAX_STRING_SIZE)
+ if (negotiated_p2 < V42BIS_MIN_STRING_SIZE || negotiated_p2 > V42BIS_MAX_STRING_SIZE)
return NULL;
if (s == NULL)
{
s->decompress.dict[i].parent_code = (uint16_t) i;
s->compress.string_code = 0xFFFFFFFF;
s->compress.latest_code = 0xFFFFFFFF;
-
+ s->compress.transparent = TRUE;
+ s->compress.first = TRUE;
+
s->decompress.last_old_code = 0xFFFFFFFF;
s->decompress.last_extra_octet = -1;
+ s->decompress.transparent = TRUE;
+ s->compress.first = TRUE;
s->compress.compression_mode = V42BIS_COMPRESSION_MODE_DYNAMIC;
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v8.c,v 1.42.4.3 2009/12/28 12:20:47 steveu Exp $
*/
/*! \file */
case V8_CALL_V_SERIES:
return "V series modem data";
case V8_CALL_FUNCTION_EXTENSION:
- return "Call function is in extention octet";
+ return "Call function is in extension octet";
}
return "???";
}
return "V.21 duplex";
case V8_MOD_V22:
return "V.22/V.22bis duplex";
- case V8_MOD_V23HALF:
+ case V8_MOD_V23HDX:
return "V.23 half-duplex";
case V8_MOD_V23:
return "V.23 duplex";
return "V.29 half-duplex";
case V8_MOD_V32:
return "V.32/V.32bis duplex";
- case V8_MOD_V34HALF:
+ case V8_MOD_V34HDX:
return "V.34 half-duplex";
case V8_MOD_V34:
return "V.34 duplex";
return "V.90 duplex";
case V8_MOD_V92:
return "V.92 duplex";
- case V8_MOD_FAILED:
- return "negotiation failed";
}
return "???";
}
}
/*- End of function --------------------------------------------------------*/
+static int report_event(v8_state_t *s)
+{
+ if (s->result_handler)
+ s->result_handler(s->result_handler_user_data, &s->result);
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
static const uint8_t *process_call_function(v8_state_t *s, const uint8_t *p)
{
s->result.call_function = (*p >> 5) & 0x07;
static const uint8_t *process_modulation_mode(v8_state_t *s, const uint8_t *p)
{
- unsigned int far_end_modulations;
+ unsigned int modulations;
- /* Modulation mode octet */
- far_end_modulations = 0;
+ /* Modulation mode octets */
+ /* We must record the number of bytes of modulation information, so a resulting
+ JM can be made to have the same number (V.8/8.2.3) */
+ modulations = 0;
+ s->modulation_bytes = 1;
if (*p & 0x80)
- far_end_modulations |= V8_MOD_V34HALF;
+ modulations |= V8_MOD_V34HDX;
if (*p & 0x40)
- far_end_modulations |= V8_MOD_V34;
+ modulations |= V8_MOD_V34;
if (*p & 0x20)
- far_end_modulations |= V8_MOD_V90;
+ modulations |= V8_MOD_V90;
+ ++p;
/* Check for an extension octet */
- if ((*++p & 0x38) == 0x10)
+ if ((*p & 0x38) == 0x10)
{
+ s->modulation_bytes++;
if (*p & 0x80)
- far_end_modulations |= V8_MOD_V27TER;
+ modulations |= V8_MOD_V27TER;
if (*p & 0x40)
- far_end_modulations |= V8_MOD_V29;
+ modulations |= V8_MOD_V29;
if (*p & 0x04)
- far_end_modulations |= V8_MOD_V17;
+ modulations |= V8_MOD_V17;
if (*p & 0x02)
- far_end_modulations |= V8_MOD_V22;
+ modulations |= V8_MOD_V22;
if (*p & 0x01)
- far_end_modulations |= V8_MOD_V32;
+ modulations |= V8_MOD_V32;
+ ++p;
/* Check for an extension octet */
- if ((*++p & 0x38) == 0x10)
+ if ((*p & 0x38) == 0x10)
{
+ s->modulation_bytes++;
if (*p & 0x80)
- far_end_modulations |= V8_MOD_V21;
+ modulations |= V8_MOD_V21;
if (*p & 0x40)
- far_end_modulations |= V8_MOD_V23HALF;
+ modulations |= V8_MOD_V23HDX;
if (*p & 0x04)
- far_end_modulations |= V8_MOD_V23;
+ modulations |= V8_MOD_V23;
if (*p & 0x02)
- far_end_modulations |= V8_MOD_V26BIS;
+ modulations |= V8_MOD_V26BIS;
if (*p & 0x01)
- far_end_modulations |= V8_MOD_V26TER;
+ modulations |= V8_MOD_V26TER;
+ ++p;
}
}
- s->far_end_modulations =
- s->result.modulations = far_end_modulations;
- v8_log_supported_modulations(s, far_end_modulations);
- return ++p;
+ s->result.modulations = modulations;
+ v8_log_supported_modulations(s, modulations);
+ return p;
}
/*- End of function --------------------------------------------------------*/
static const uint8_t *process_protocols(v8_state_t *s, const uint8_t *p)
{
s->result.protocol = (*p >> 5) & 0x07;
- span_log(&s->logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, "%s\n", v8_protocol_to_str(s->result.protocol));
+ span_log(&s->logging, SPAN_LOG_FLOW, "%s\n", v8_protocol_to_str(s->result.protocol));
return ++p;
}
/*- End of function --------------------------------------------------------*/
static const uint8_t *process_pstn_access(v8_state_t *s, const uint8_t *p)
{
s->result.pstn_access = (*p >> 5) & 0x07;
- span_log(&s->logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, "%s\n", v8_pstn_access_to_str(s->result.pstn_access));
+ span_log(&s->logging, SPAN_LOG_FLOW, "%s\n", v8_pstn_access_to_str(s->result.pstn_access));
return ++p;
}
/*- End of function --------------------------------------------------------*/
static const uint8_t *process_non_standard_facilities(v8_state_t *s, const uint8_t *p)
{
s->result.nsf = (*p >> 5) & 0x07;
- span_log(&s->logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, "%s\n", v8_nsf_to_str(s->result.nsf));
+ span_log(&s->logging, SPAN_LOG_FLOW, "%s\n", v8_nsf_to_str(s->result.nsf));
return p;
}
/*- End of function --------------------------------------------------------*/
static const uint8_t *process_pcm_modem_availability(v8_state_t *s, const uint8_t *p)
{
s->result.pcm_modem_availability = (*p >> 5) & 0x07;
- span_log(&s->logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, "%s\n", v8_pcm_modem_availability_to_str(s->result.pcm_modem_availability));
+ span_log(&s->logging, SPAN_LOG_FLOW, "%s\n", v8_pcm_modem_availability_to_str(s->result.pcm_modem_availability));
return ++p;
}
/*- End of function --------------------------------------------------------*/
static const uint8_t *process_t66(v8_state_t *s, const uint8_t *p)
{
s->result.t66 = (*p >> 5) & 0x07;
- span_log(&s->logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, "%s\n", v8_t66_to_str(s->result.t66));
+ span_log(&s->logging, SPAN_LOG_FLOW, "%s\n", v8_t66_to_str(s->result.t66));
return ++p;
}
/*- End of function --------------------------------------------------------*/
{
int val;
unsigned int offered_modulations;
+ int bytes;
- offered_modulations = s->parms.modulations & s->far_end_modulations;
-
/* Send a CM, or a JM as appropriate */
v8_put_preamble(s);
v8_put_byte(s, V8_CM_JM_SYNC_OCTET);
v8_put_byte(s, (s->result.call_function << 5) | V8_CALL_FUNCTION_TAG);
/* Supported modulations */
+ offered_modulations = s->result.modulations;
+ bytes = 0;
val = 0x05;
if (offered_modulations & V8_MOD_V90)
val |= 0x20;
if (offered_modulations & V8_MOD_V34)
val |= 0x40;
v8_put_byte(s, val);
-
- val = 0x10;
- if (offered_modulations & V8_MOD_V32)
- val |= 0x01;
- if (offered_modulations & V8_MOD_V22)
- val |= 0x02;
- if (offered_modulations & V8_MOD_V17)
- val |= 0x04;
- if (offered_modulations & V8_MOD_V29)
- val |= 0x40;
- if (offered_modulations & V8_MOD_V27TER)
- val |= 0x80;
- v8_put_byte(s, val);
-
- val = 0x10;
- if (offered_modulations & V8_MOD_V26TER)
- val |= 0x01;
- if (offered_modulations & V8_MOD_V26BIS)
- val |= 0x02;
- if (offered_modulations & V8_MOD_V23)
- val |= 0x04;
- if (offered_modulations & V8_MOD_V23HALF)
- val |= 0x40;
- if (offered_modulations & V8_MOD_V21)
- val |= 0x80;
- v8_put_byte(s, val);
+ if (++bytes < s->modulation_bytes)
+ {
+ val = 0x10;
+ if (offered_modulations & V8_MOD_V32)
+ val |= 0x01;
+ if (offered_modulations & V8_MOD_V22)
+ val |= 0x02;
+ if (offered_modulations & V8_MOD_V17)
+ val |= 0x04;
+ if (offered_modulations & V8_MOD_V29)
+ val |= 0x40;
+ if (offered_modulations & V8_MOD_V27TER)
+ val |= 0x80;
+ v8_put_byte(s, val);
+ }
+ if (++bytes < s->modulation_bytes)
+ {
+ val = 0x10;
+ if (offered_modulations & V8_MOD_V26TER)
+ val |= 0x01;
+ if (offered_modulations & V8_MOD_V26BIS)
+ val |= 0x02;
+ if (offered_modulations & V8_MOD_V23)
+ val |= 0x04;
+ if (offered_modulations & V8_MOD_V23HDX)
+ val |= 0x40;
+ if (offered_modulations & V8_MOD_V21)
+ val |= 0x80;
+ v8_put_byte(s, val);
+ }
if (s->parms.protocol)
v8_put_byte(s, (s->parms.protocol << 5) | V8_PROTOCOLS_TAG);
- if (s->parms.pcm_modem_availability)
- v8_put_byte(s, (s->parms.pcm_modem_availability << 5) | V8_PCM_MODEM_AVAILABILITY_TAG);
if (s->parms.pstn_access)
v8_put_byte(s, (s->parms.pstn_access << 5) | V8_PSTN_ACCESS_TAG);
+ if (s->parms.pcm_modem_availability)
+ v8_put_byte(s, (s->parms.pcm_modem_availability << 5) | V8_PCM_MODEM_AVAILABILITY_TAG);
if (s->parms.t66 >= 0)
v8_put_byte(s, (s->parms.t66 << 5) | V8_T66_TAG);
-
/* No NSF */
//v8_put_byte(s, (0 << 5) | V8_NSF_TAG);
}
tone == MODEM_CONNECT_TONES_ANSAM_PR)
{
/* Set the Te interval. The spec. says 500ms is the minimum,
- but gives reasons why 1 second is a better value. */
+ but gives reasons why 1 second is a better value (V.8/8.1.1). */
s->state = V8_HEARD_ANSAM;
s->ci_timer = ms_to_samples(1000);
}
indicating V.8 startup, we are not going to do V.8 processing. */
span_log(&s->logging, SPAN_LOG_FLOW, "Non-V.8 modem connect tone detected\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, &s->result);
+ s->result.status = V8_STATUS_NON_V8_CALL;
+ report_event(s);
}
}
/*- End of function --------------------------------------------------------*/
handle_modem_connect_tone(s, tone);
break;
}
- if (queue_empty(s->tx_queue))
+ if (!s->fsk_tx_on)
{
s->state = V8_CI_OFF;
s->ci_timer = ms_to_samples(500);
/* The spec says we should give up now. */
span_log(&s->logging, SPAN_LOG_FLOW, "Timeout waiting for modem connect tone\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, NULL);
+ s->result.status = V8_STATUS_FAILED;
+ report_event(s);
}
else
{
/* Timeout */
span_log(&s->logging, SPAN_LOG_FLOW, "Timeout waiting for JM\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, NULL);
+ s->result.status = V8_STATUS_FAILED;
+ report_event(s);
}
if (queue_contents(s->tx_queue) < 10)
{
break;
case V8_CJ_ON:
residual_samples = fsk_rx(&s->v21rx, amp, len);
- if (queue_empty(s->tx_queue))
+ if (!s->fsk_tx_on)
{
+#if 0
s->negotiation_timer = ms_to_samples(75);
s->state = V8_SIGC;
}
case V8_SIGC:
if ((s->negotiation_timer -= len) <= 0)
{
+#endif
/* The V.8 negotiation has succeeded. */
span_log(&s->logging, SPAN_LOG_FLOW, "Negotiation succeeded\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, &s->result);
+ s->result.status = V8_STATUS_V8_CALL;
+ report_event(s);
}
break;
case V8_CM_WAIT:
{
span_log(&s->logging, SPAN_LOG_FLOW, "CM recognised\n");
- /* TODO: negotiate if the call function is acceptable */
+ s->result.status = V8_STATUS_V8_OFFERED;
+ report_event(s);
/* Stop sending ANSam or ANSam/ and send JM instead */
fsk_tx_init(&s->v21tx, &preset_fsk_specs[FSK_V21CH2], get_bit, s);
/* Timeout */
span_log(&s->logging, SPAN_LOG_FLOW, "Timeout waiting for CM\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, NULL);
+ s->result.status = V8_STATUS_FAILED;
+ report_event(s);
}
break;
case V8_JM_ON:
/* Timeout */
span_log(&s->logging, SPAN_LOG_FLOW, "Timeout waiting for CJ\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, NULL);
+ s->result.status = V8_STATUS_FAILED;
+ report_event(s);
break;
}
if (queue_contents(s->tx_queue) < 10)
}
break;
case V8_SIGA:
- if ((s->negotiation_timer -= len) <= 0)
+ if (!s->fsk_tx_on)
+ //if ((s->negotiation_timer -= len) <= 0)
{
/* The V.8 negotiation has succeeded. */
span_log(&s->logging, SPAN_LOG_FLOW, "Negotiation succeeded\n");
s->state = V8_PARKED;
- if (s->result_handler)
- s->result_handler(s->result_handler_user_data, &s->result);
+ s->result.status = V8_STATUS_V8_CALL;
+ report_event(s);
}
break;
case V8_PARKED:
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) v8_restart(v8_state_t *s,
- int calling_party,
- v8_parms_t *parms)
+SPAN_DECLARE(int) v8_restart(v8_state_t *s, int calling_party, v8_parms_t *parms)
{
memcpy(&s->parms, parms, sizeof(s->parms));
memset(&s->result, 0, sizeof(s->result));
+ s->result.status = V8_STATUS_IN_PROGRESS;
+ s->result.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
+ s->result.modulations = s->parms.modulations;
s->result.call_function = s->parms.call_function;
s->result.nsf = -1;
s->result.t66 = -1;
+ s->modulation_bytes = 3;
+
s->ci_timer = 0;
if (calling_party)
{
s->negotiation_timer = ms_to_samples(200 + 5000);
s->modem_connect_tone_tx_on = ms_to_samples(75) + 1;
}
- s->result.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
if ((s->tx_queue = queue_init(NULL, 1024, 0)) == NULL)
return -1;
s->result_handler_user_data = user_data;
v8_restart(s, calling_party, parms);
-
- memcpy(&s->parms, parms, sizeof(s->parms));
-
- s->result.call_function = s->parms.call_function;
- s->result.nsf = -1;
- s->result.t66 = -1;
-
- s->ci_timer = 0;
- if (calling_party)
- {
- s->calling_party = TRUE;
- s->state = V8_WAIT_1S;
- s->negotiation_timer = ms_to_samples(1000);
- s->ci_count = 0;
- modem_connect_tones_rx_init(&s->ansam_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
- fsk_tx_init(&s->v21tx, &preset_fsk_specs[FSK_V21CH1], get_bit, s);
- }
- else
- {
- /* Send the ANSam or ANSam/ tone */
- s->calling_party = FALSE;
- modem_connect_tones_tx_init(&s->ansam_tx, s->parms.modem_connect_tone);
-
- v8_decode_init(s);
- s->state = V8_CM_WAIT;
- s->negotiation_timer = ms_to_samples(200 + 5000);
- s->modem_connect_tone_tx_on = ms_to_samples(75) + 1;
- }
- s->result.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
-
- if ((s->tx_queue = queue_init(NULL, 1024, 0)) == NULL)
- return NULL;
return s;
}
/*- End of function --------------------------------------------------------*/
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: vector_float.c,v 1.22 2009/07/12 09:23:09 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: vector_int.c,v 1.26.4.1 2009/12/28 11:54:59 steveu Exp $
*/
/*! \file */
## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.3 2008/07/10 12:44:54 steveu Exp $
SUBDIRS = itu etsi
## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.4 2008/07/10 12:44:54 steveu Exp $
SUBDIRS = fax
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.4 2009/02/25 17:52:51 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: generate_etsi_300_242_pages.c,v 1.5 2009/03/23 14:34:13 steveu Exp $
*/
/*! \file */
static int create_diago1_page(TIFF *tiff_file)
{
- uint8_t image_buffer[1728/8];
+ uint8_t image_buffer[1728/8 + 1];
int row;
/* ETSI ETS 300 242 B.5.1 One dimensional coding test chart - the DIAGO1 page. */
static int create_diago2_page(TIFF *tiff_file)
{
- uint8_t image_buffer[1728/8];
+ uint8_t image_buffer[1728/8 + 1];
int row;
/* ETSI ETS 300 242 B.5.1 One dimensional coding test chart - the DIAGO2 page. */
static int create_duration1_page(TIFF *tiff_file)
{
- uint8_t image_buffer[1728/8];
+ uint8_t image_buffer[1728/8 + 1];
int row;
int i;
static int create_error_page(TIFF *tiff_file)
{
- uint8_t image_buffer[1728/8];
+ uint8_t image_buffer[1728/8 + 1];
int row;
int start_pixel;
int i;
## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.3 2008/05/03 10:26:15 steveu Exp $
SUBDIRS = fax
## You should have received a copy of the GNU General Public License
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.5 2009/02/25 17:52:52 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
MAINTAINERCLEANFILES = Makefile.in
-nobase_data_DATA = itutests.tif \
- ${ITU_TEST_PAGES} \
+nobase_data_DATA = 100pages.tif \
dithered.tif \
- 100pages.tif \
+ itutests.tif \
+ ${ITU_TEST_PAGES} \
${MIXED_SIZE_PAGES} \
- mixed_size_pages.tif
+ mixed_size_pages.tif \
+ striped.tif
noinst_PROGRAMS = generate_dithered_tif \
- generate_sized_pages
+ generate_sized_pages \
+ generate_striped_pages
generate_dithered_tif_SOURCES = generate_dithered_tif.c
generate_dithered_tif_LDADD = -ltiff
generate_sized_pages_SOURCES = generate_sized_pages.c
generate_sized_pages_LDADD = -ltiff
+generate_striped_pages_SOURCES = generate_striped_pages.c
+generate_striped_pages_LDADD = -ltiff
+
clean:
rm -f *.tif *.g3
.pbm.g3:
${PBM2G3} $*.pbm >$*.g3
-
+
dithered.tif: generate_dithered_tif$(EXEEXT)
./generate_dithered_tif$(EXEEXT)
mixed_size_pages.tif: ${MIXED_SIZE_PAGES}
$(TIFFCP) ${MIXED_SIZE_PAGES} $@
+
+striped.tif: generate_striped_pages$(EXEEXT)
+ ./generate_striped_pages$(EXEEXT)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: generate_dithered_tif.c,v 1.2 2008/07/10 13:34:01 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: generate_sized_pages.c,v 1.3 2009/03/01 12:39:02 steveu Exp $
*/
/*! \file */
## You should have received a copy of the GNU Lesser General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.1 2008/05/03 07:30:19 steveu Exp $
SUBDIRS =
EXTRA_DIST = dam9_lpc55.wav \
dam9.wav \
+ lenna-colour.tif \
short_nb_voice.wav \
short_wb_voice.wav
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-## $Id: Makefile.am,v 1.117 2009/09/22 13:11:04 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
noinst_DATA = sound_c1_8k.wav sound_c3_8k.wav
EXTRA_DIST = regression_tests.sh \
+ tsb85_extra_tests.sh \
v42bis_tests.sh \
fax_tests.sh \
tsb85_tests.sh \
bell_mf_tx_tests \
bert_tests \
bit_operations_tests \
+ bitstream_tests \
complex_tests \
complex_vector_float_tests \
complex_vector_int_tests \
gsm0610_tests \
hdlc_tests \
ima_adpcm_tests \
+ image_translate_tests \
line_model_tests \
logging_tests \
lpc10_tests \
r2_mf_rx_tests \
r2_mf_tx_tests \
rfc2198_sim_tests \
+ saturated_tests \
schedule_tests \
sig_tone_tests \
super_tone_rx_tests \
swept_tone_tests \
t4_tests \
t31_tests \
+ t38_decode \
t38_core_tests \
t38_gateway_tests \
t38_gateway_to_terminal_tests \
t38_terminal_tests \
t38_terminal_to_gateway_tests \
time_scale_tests \
+ timezone_tests \
tone_detect_tests \
tone_generate_tests \
tsb85_tests \
fax_utils.h \
line_model_monitor.h \
media_monitor.h \
- modem_monitor.h
+ modem_monitor.h \
+ pcap_parse.h \
+ udptl.h
adsi_tests_SOURCES = adsi_tests.c
adsi_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
bit_operations_tests_SOURCES = bit_operations_tests.c
bit_operations_tests_LDADD = $(LIBDIR) -lspandsp
+bitstream_tests_SOURCES = bitstream_tests.c
+bitstream_tests_LDADD = $(LIBDIR) -lspandsp
+
complex_tests_SOURCES = complex_tests.c
complex_tests_LDADD = $(LIBDIR) -lspandsp
ima_adpcm_tests_SOURCES = ima_adpcm_tests.c
ima_adpcm_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
+image_translate_tests_SOURCES = image_translate_tests.c
+image_translate_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
+
line_model_tests_SOURCES = line_model_tests.c
line_model_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
rfc2198_sim_tests_SOURCES = rfc2198_sim_tests.c media_monitor.cpp
rfc2198_sim_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
+saturated_tests_SOURCES = saturated_tests.c
+saturated_tests_LDADD = $(LIBDIR) -lspandsp
+
schedule_tests_SOURCES = schedule_tests.c
schedule_tests_LDADD = $(LIBDIR) -lspandsp
t38_core_tests_SOURCES = t38_core_tests.c
t38_core_tests_LDADD = $(LIBDIR) -lspandsp
+t38_decode_SOURCES = t38_decode.c fax_utils.c pcap_parse.c udptl.c
+t38_decode_LDADD = $(LIBDIR) -lspandsp -lpcap
+
t38_gateway_tests_SOURCES = t38_gateway_tests.c fax_utils.c media_monitor.cpp
t38_gateway_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
time_scale_tests_SOURCES = time_scale_tests.c
time_scale_tests_LDADD = $(LIBDIR) -lspandsp
+timezone_tests_SOURCES = timezone_tests.c
+timezone_tests_LDADD = $(LIBDIR) -lspandsp
+
tone_detect_tests_SOURCES = tone_detect_tests.c
tone_detect_tests_LDADD = $(LIBDIR) -lspandsp
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: adsi_tests.c,v 1.57 2009/05/30 15:23:13 steveu Exp $
*/
/*! \page adsi_tests_page ADSI tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: async_tests.c,v 1.19 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: at_interpreter_tests.c,v 1.24 2009/10/09 14:53:57 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: awgn_tests.c,v 1.18 2008/11/30 12:38:27 steveu Exp $
*/
/*! \page awgn_tests_page AWGN tests
/* Some simple sanity tests for the Gaussian noise generation routines */
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
{
int i;
int j;
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bell_mf_rx_tests.c,v 1.16 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bell_mf_tx_tests.c,v 1.15 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bert_tests.c,v 1.28 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: bit_operations_tests.c,v 1.14 2008/05/13 13:17:25 steveu Exp $
*/
/*! \page bit_operations_tests_page Bit operations tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_tests.c,v 1.2 2009/01/28 03:41:27 steveu Exp $
*/
/*! \page complex_tests_page Complex arithmetic tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_vector_float_tests.c,v 1.3 2009/04/26 07:00:39 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: complex_vector_int_tests.c,v 1.2 2009/04/26 07:00:39 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: crc_tests.c,v 1.6 2008/05/13 13:17:25 steveu Exp $
*/
/*! \file */
int main(int argc, char *argv[])
{
int i;
+ int j;
int len;
+ uint16_t crc16a;
+ uint16_t crc16b;
- printf("HDLC module tests\n");
+ printf("CRC module tests\n");
/* TODO: This doesn't check every function in the module */
}
printf("Test passed.\n\n");
+ printf("Testing the CRC-16 byte by byte and bit by bit routines\n");
+ for (i = 0; i < 100; i++)
+ {
+ ref_len = cook_up_msg(buf);
+ crc16a = 0xFFFF;
+ crc16a = crc_itu16_calc(buf, ref_len, crc16a);
+
+ crc16b = 0xFFFF;
+ for (j = 0; j < ref_len; j++)
+ crc16b = crc_itu16_bits(buf[j], 8, crc16b);
+ if (crc16a != crc16b)
+ {
+ printf("CRC-16 failure\n");
+ exit(2);
+ }
+ }
+ printf("Test passed.\n\n");
+
printf("Testing the CRC-32 routines\n");
for (i = 0; i < 100; i++)
{
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dc_restore_tests.c,v 1.24 2008/11/30 12:38:27 steveu Exp $
*/
/*! \page dc_restore_tests_page DC restoration tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dds_tests.c,v 1.26 2009/06/02 14:55:36 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dtmf_rx_tests.c,v 1.45 2009/05/30 15:23:13 steveu Exp $
*/
/*
int callback_roll;
int step;
+int max_forward_twist;
+int max_reverse_twist;
+
int use_dialtone_filter = FALSE;
char *decode_test_file = NULL;
awgn_state_t noise_source;
dtmf_state = dtmf_rx_init(NULL, NULL, NULL);
- if (use_dialtone_filter)
- dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
+ if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0)
+ dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99);
/* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
which has no meaning here. */
dtmf_rx_state_t *dtmf_state;
dtmf_state = dtmf_rx_init(NULL, NULL, NULL);
- if (use_dialtone_filter)
- dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
+ if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0)
+ dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99);
/* The remainder of the Mitel tape is the talk-off test */
/* Here we use the Bellcore test tapes (much tougher), in six
tone_gen_state_t dial_tone;
dtmf_state = dtmf_rx_init(NULL, NULL, NULL);
- if (use_dialtone_filter)
- dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
+ if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0)
+ dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99);
/* Test dial tone tolerance */
printf("Test: Dial tone tolerance.\n");
callback_ok = TRUE;
callback_roll = 0;
dtmf_state = dtmf_rx_init(NULL, digit_delivery, (void *) 0x12345678);
- if (use_dialtone_filter)
- dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
+ if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0)
+ dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99);
+
my_dtmf_gen_init(0.0f, DEFAULT_DTMF_TX_LEVEL, 0.0f, DEFAULT_DTMF_TX_LEVEL, DEFAULT_DTMF_TX_ON_TIME, DEFAULT_DTMF_TX_OFF_TIME);
for (i = 1; i < 10; i++)
{
callback_roll = 0;
dtmf_rx_init(dtmf_state, NULL, NULL);
dtmf_rx_set_realtime_callback(dtmf_state, digit_status, (void *) 0x12345678);
- if (use_dialtone_filter)
- dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
+ if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0)
+ dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99);
+
my_dtmf_gen_init(0.0f, DEFAULT_DTMF_TX_LEVEL, 0.0f, DEFAULT_DTMF_TX_LEVEL, DEFAULT_DTMF_TX_ON_TIME, DEFAULT_DTMF_TX_OFF_TIME);
step = 0;
for (i = 1; i < 10; i++)
int total;
dtmf_state = dtmf_rx_init(NULL, NULL, NULL);
- if (use_dialtone_filter)
- dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
+ if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0)
+ dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99);
/* We will decode the audio from a file. */
use_dialtone_filter = FALSE;
channel_codec = MUNGE_CODEC_NONE;
decode_test_file = NULL;
- while ((opt = getopt(argc, argv, "c:d:f")) != -1)
+ max_forward_twist = -1;
+ max_reverse_twist = -1;
+ while ((opt = getopt(argc, argv, "c:d:F:fR:")) != -1)
{
switch (opt)
{
case 'd':
decode_test_file = optarg;
break;
+ case 'F':
+ max_forward_twist = atoi(optarg);
+ break;
case 'f':
use_dialtone_filter = TRUE;
break;
+ case 'R':
+ max_reverse_twist = atoi(optarg);
+ break;
default:
//usage();
exit(2);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: dtmf_tx_tests.c,v 1.23 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo_monitor.cpp,v 1.13 2008/09/08 16:10:41 steveu Exp $
*/
#ifdef HAVE_CONFIG_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo_monitor.h,v 1.12 2008/04/26 13:39:16 steveu Exp $
*/
/*! \page echo_monitor_page Echo canceller performance monitoring
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: echo_tests.c,v 1.39 2009/05/30 15:23:13 steveu Exp $
*/
/*! \page echo_can_tests_page Line echo cancellation for voice tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_decode.c,v 1.58 2009/11/02 13:25:20 steveu Exp $
*/
/*! \page fax_decode_page FAX decoder
int error_correcting_mode = FALSE;
int current_fallback = 0;
+static void decode_20digit_msg(const uint8_t *pkt, int len)
+{
+ int p;
+ int k;
+ char msg[T30_MAX_IDENT_LEN + 1];
+
+ if (len > T30_MAX_IDENT_LEN + 3)
+ {
+ fprintf(stderr, "XXX %d %d\n", len, T30_MAX_IDENT_LEN + 1);
+ msg[0] = '\0';
+ return;
+ }
+ pkt += 2;
+ p = len - 2;
+ /* Strip trailing spaces */
+ while (p > 1 && pkt[p - 1] == ' ')
+ p--;
+ /* The string is actually backwards in the message */
+ k = 0;
+ while (p > 1)
+ msg[k++] = pkt[--p];
+ msg[k] = '\0';
+ fprintf(stderr, "%s is: \"%s\"\n", t30_frametype(pkt[0]), msg);
+}
+/*- End of function --------------------------------------------------------*/
+
static void print_frame(const char *io, const uint8_t *fr, int frlen)
{
int i;
type = fr[2] & 0xFE;
if (type == T30_DIS || type == T30_DTC || type == T30_DCS)
t30_decode_dis_dtc_dcs(&t30_dummy, fr, frlen);
+ if (type == T30_CSI || type == T30_TSI || type == T30_PWD || type == T30_SEP || type == T30_SUB || type == T30_SID)
+ decode_20digit_msg(fr, frlen);
if (type == T30_NSF || type == T30_NSS || type == T30_NSC)
{
if (t35_decode(&fr[3], frlen - 3, &country, &vendor, &model))
{
t4_stats_t stats;
int i;
- int j;
- int k;
if (!t4_up)
return;
{
for (i = 0; i < 256; i++)
{
- for (j = 0; j < ecm_len[i]; j++)
- {
- for (k = 0; k < 8; k++)
- t4_rx_put_bit(&t4_state, (ecm_data[i][j] >> k) & 1);
- }
- fprintf(stderr, "%d", (ecm_len[i] < 0) ? 0 : 1);
+ if (ecm_len[i] > 0)
+ t4_rx_put_chunk(&t4_state, ecm_data[i], ecm_len[i]);
+ fprintf(stderr, "%d", (ecm_len[i] <= 0) ? 0 : 1);
}
fprintf(stderr, "\n");
}
t4_rx_end_page(&t4_state);
- t4_get_transfer_statistics(&t4_state, &stats);
+ t4_rx_get_transfer_statistics(&t4_state, &stats);
fprintf(stderr, "Pages = %d\n", stats.pages_transferred);
fprintf(stderr, "Image size = %dx%d\n", stats.width, stats.length);
fprintf(stderr, "Image resolution = %dx%d\n", stats.x_resolution, stats.y_resolution);
}
if (info.samplerate != SAMPLE_RATE)
{
- printf(" Unexpected sample rate in audio file '%s'\n", filename);
+ fprintf(stderr, " Unexpected sample rate in audio file '%s'\n", filename);
exit(2);
}
if (info.channels != 1)
{
- printf(" Unexpected number of channels in audio file '%s'\n", filename);
+ fprintf(stderr, " Unexpected number of channels in audio file '%s'\n", filename);
exit(2);
}
/*
* SpanDSP - a series of DSP components for telephony
*
- * faxtester_tests.c
+ * fax_tester.c
*
* Written by Steve Underwood <steveu@coppice.org>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1,
- * as published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_tester.c,v 1.23 2009/11/02 13:25:20 steveu Exp $
*/
/*! \file */
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1,
- * as published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_tester.h,v 1.9 2008/09/12 14:41:55 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_tests.c,v 1.102 2009/05/30 15:23:13 steveu Exp $
*/
/*! \page fax_tests_page FAX tests
float signal_scaling;
time_t start_time;
time_t end_time;
+ int scan_line_time;
char *page_header_info;
int opt;
t30_state_t *t30;
use_page_limits = FALSE;
signal_level = 0;
noise_level = -99;
+ scan_line_time = 0;
supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
- while ((opt = getopt(argc, argv, "ehH:i:I:lm:n:prRs:tTw:")) != -1)
+ while ((opt = getopt(argc, argv, "ehH:i:I:lm:n:prRs:S:tTw:")) != -1)
{
switch (opt)
{
case 's':
signal_level = atoi(optarg);
break;
+ case 'S':
+ scan_line_time = atoi(optarg);
+ break;
case 't':
use_tep = TRUE;
break;
| T30_SUPPORT_SUB_ADDRESSING);
if ((mc->chan & 1))
- t30_set_minimum_scan_line_time(t30, 40);
+ t30_set_minimum_scan_line_time(t30, scan_line_time);
t30_set_supported_image_sizes(t30,
T30_SUPPORT_US_LETTER_LENGTH
| T30_SUPPORT_US_LEGAL_LENGTH
| T30_SUPPORT_600_1200_RESOLUTION);
t30_set_supported_modems(t30, supported_modems);
if (use_ecm)
+#if defined(SPANDSP_SUPPORT_T85)
+ t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
+#else
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+#endif
if ((mc->chan & 1))
{
if (polled_mode)
logging = t30_get_logging_state(t30);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
span_log_set_tag(logging, mc->tag);
- span_log_set_level(&t30->t4.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
- span_log_set_tag(&t30->t4.logging, mc->tag);
-
+ if ((j & 1))
+ {
+ span_log_set_level(&t30->t4.rx.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
+ span_log_set_tag(&t30->t4.rx.logging, mc->tag);
+ }
+ else
+ {
+ span_log_set_level(&t30->t4.tx.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
+ span_log_set_tag(&t30->t4.tx.logging, mc->tag);
+ }
logging = fax_get_logging_state(mc->fax);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
span_log_set_tag(logging, mc->tag);
-#!/bin/bash
+#!/bin/sh
#
# spandsp fax tests
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: fax_tests.sh,v 1.5 2008/03/30 18:33:31 steveu Exp $
-#
run_fax_test()
{
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_utils.c,v 1.3.4.1 2009/12/19 09:47:57 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
t30_stats_t t;
t30_get_transfer_statistics(s, &t);
- printf("%s: bit rate %d\n", tag, t.bit_rate);
- printf("%s: ECM %s\n", tag, (t.error_correcting_mode) ? "on" : "off");
printf("%s: tx pages %d, rx pages %d\n", tag, t.pages_tx, t.pages_rx);
printf("%s: pages in the file %d\n", tag, t.pages_in_file);
+ printf("%s: compression type %s (%d)\n", tag, t4_encoding_to_str(t.encoding), t.encoding);
+ printf("%s: compressed image size %d bytes\n", tag, t.image_size);
printf("%s: image size %d pels x %d pels\n", tag, t.width, t.length);
printf("%s: image resolution %d pels/m x %d pels/m\n", tag, t.x_resolution, t.y_resolution);
+ printf("%s: bit rate %d\n", tag, t.bit_rate);
+ printf("%s: ECM %s\n", tag, (t.error_correcting_mode) ? "on" : "off");
printf("%s: bad rows %d, longest bad row run %d\n", tag, t.bad_rows, t.longest_bad_row_run);
printf("%s: bad ECM frames %d\n", tag, t.error_correcting_mode_retries);
- printf("%s: compression type %d\n", tag, t.encoding);
- printf("%s: image size %d bytes\n", tag, t.image_size);
+ //printf("%s: RTP events %d. RTN events %d\n", tag, t.rtp_events, t.rtn_events);
#if defined(WITH_SPANDSP_INTERNALS)
printf("%s: bits per row - min %d, max %d\n", tag, s->t4.min_row_bits, s->t4.max_row_bits);
#endif
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fax_utils.h,v 1.1 2009/02/20 12:34:20 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: fsk_tests.c,v 1.59 2009/11/02 13:25:20 steveu Exp $
*/
/*! \page fsk_tests_page FSK modem tests
modem_under_test_2 = FSK_V21CH2;
log_audio = FALSE;
modems_set = 0;
- while ((opt = getopt(argc, argv, "c:dlm:nr:s:")) != -1)
+ while ((opt = getopt(argc, argv, "c:d:lm:nr:s:")) != -1)
{
switch (opt)
{
bert_set_report(&caller_bert, 100000, reporter, (void *) (intptr_t) 1);
bert_init(&answerer_bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20);
bert_set_report(&answerer_bert, 100000, reporter, (void *) (intptr_t) 2);
- if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, line_model_no, (float) noise_level, channel_codec, rbs_pattern)) == NULL)
+ if ((model = both_ways_line_model_init(line_model_no,
+ (float) noise_level,
+ -15.0f,
+ -15.0f,
+ line_model_no,
+ (float) noise_level,
+ -15.0f,
+ -15.0f,
+ channel_codec,
+ rbs_pattern)) == NULL)
{
fprintf(stderr, " Failed to create line model\n");
exit(2);
fsk_rx_set_modem_status_handler(caller_rx, rx_status, (void *) &caller_rx);
}
noise_level++;
- if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, line_model_no, noise_level, channel_codec, 0)) == NULL)
+ if ((model = both_ways_line_model_init(line_model_no,
+ (float) noise_level,
+ line_model_no,
+ -15.0f,
+ -15.0f,
+ noise_level,
+ channel_codec,
+ -15.0f,
+ -15.0f,
+ 0)) == NULL)
{
fprintf(stderr, " Failed to create line model\n");
exit(2);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g1050_tests.c,v 1.18 2009/05/30 15:23:13 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g168_tests.c,v 1.20 2009/05/30 15:23:13 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g711_tests.c,v 1.17 2009/05/30 15:23:13 steveu Exp $
*/
/*! \page g711_tests_page A-law and u-law conversion tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g722_tests.c,v 1.32 2009/06/02 14:55:36 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: g726_tests.c,v 1.33 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: gsm0610_tests.c,v 1.25 2009/05/30 15:23:13 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: hdlc_tests.c,v 1.48 2008/11/30 05:43:37 steveu Exp $
*/
/*! \file */
{
char buf[1024];
int bit;
+ int num;
hdlc_rx_state_t rx;
FILE *in;
hdlc_rx_init(&rx, FALSE, TRUE, 2, decode_handler, NULL);
while (fgets(buf, 1024, in))
{
- if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1)
+ if (sscanf(buf, "Rx bit %d - %d", &num, &bit) == 2)
{
+ //printf("Rx bit %d - %d\n", num, bit);
+ //printf("Rx bit %d\n", bit);
hdlc_rx_put_bit(&rx, bit);
}
}
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: ima_adpcm_tests.c,v 1.36 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: line_model_monitor.cpp,v 1.5 2008/09/08 16:10:41 steveu Exp $
*/
#ifdef HAVE_CONFIG_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: line_model_monitor.h,v 1.7 2008/04/26 13:39:17 steveu Exp $
*/
/*! \page line_model_monitor_page Telephone line model monitoring
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: line_model_tests.c,v 1.28 2009/09/23 16:02:59 steveu Exp $
*/
/*! \page line_model_tests_page Telephony line model tests
awgn_state_t noise1;
awgn_state_t noise2;
- if ((model = both_ways_line_model_init(line_model_no, -50, line_model_no + 1, -35, channel_codec, rbs_pattern)) == NULL)
+ if ((model = both_ways_line_model_init(line_model_no,
+ -50,
+ -15.0f,
+ -15.0f,
+ line_model_no + 1,
+ -35,
+ -15.0f,
+ -15.0f,
+ channel_codec,
+ rbs_pattern)) == NULL)
{
fprintf(stderr, " Failed to create line model\n");
exit(2);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: logging_tests.c,v 1.16 2009/02/12 12:38:39 steveu Exp $
*/
/*! \page logging_tests_page Logging tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: lpc10_tests.c,v 1.24 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: make_g168_css.c,v 1.18 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page makecss_page CSS construction for G.168 testing
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: media_monitor.cpp,v 1.5 2008/09/08 16:10:41 steveu Exp $
*/
#ifdef HAVE_CONFIG_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: media_monitor.h,v 1.6 2008/04/26 13:39:17 steveu Exp $
*/
/*! \page media_monitor_page IP streaming media performance monitoring
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_connect_tones_tests.c,v 1.32 2009/11/02 15:04:15 steveu Exp $
*/
/*! \page modem_connect_tones_tests_page Modem connect tones tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_echo_tests.c,v 1.32 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page modem_echo_can_tests_page Line echo cancellation for modems tests
line_model_no = atoi(argv[1]);
}
time(&now);
- ctx = modem_echo_can_create(256);
+ ctx = modem_echo_can_init(256);
awgn_init_dbm0(&far_noise_source, 7162534, -50.0f);
signal_load(&local_css, "sound_c1_8k.wav");
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_monitor.cpp,v 1.17 2008/09/04 14:40:05 steveu Exp $
*/
#ifdef HAVE_CONFIG_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: modem_monitor.h,v 1.16 2008/09/03 13:41:42 steveu Exp $
*/
/*! \page constel_page Modem performance monitoring
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: noise_tests.c,v 1.18 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page noise_tests_page Noise generator tests
--- /dev/null
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * pcap_parse.c
+ *
+ * Written by Steve Underwood <steveu@coppice.org>
+ *
+ * Copyright (C) 2009 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 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.
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <pcap.h>
+#include <netinet/in.h>
+#include <netinet/udp.h>
+#if defined(__HPUX) || defined(__CYGWIN) || defined(__FreeBSD__)
+#include <netinet/in_systm.h>
+#endif
+#include <netinet/ip.h>
+#ifndef __CYGWIN
+#include <netinet/ip6.h>
+#endif
+#include <string.h>
+
+#include <pcap.h>
+#include <netinet/in.h>
+#include <netinet/udp.h>
+#include <time.h>
+
+#include "udptl.h"
+#include "spandsp.h"
+#include "pcap_parse.h"
+
+#if defined(__HPUX) || defined(__DARWIN) || defined(__CYGWIN) || defined(__FreeBSD__)
+
+struct iphdr
+{
+#ifdef _HPUX_LI
+ unsigned int ihl:4;
+ unsigned int version:4;
+#else
+ unsigned int version:4;
+ unsigned int ihl:4;
+#endif
+ uint8_t tos;
+ uint16_t tot_len;
+ uint16_t id;
+ uint16_t frag_off;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t check;
+ uint32_t saddr;
+ uint32_t daddr;
+ /*The options start here. */
+};
+
+#endif
+
+/* We define our own structures for Ethernet Header and IPv6 Header as they are not available on CYGWIN.
+ * We only need the fields, which are necessary to determine the type of the next header.
+ * we could also define our own structures for UDP and IPv4. We currently use the structures
+ * made available by the platform, as we had no problems to get them on all supported platforms.
+ */
+
+typedef struct _ether_hdr
+{
+ char ether_dst[6];
+ char ether_src[6];
+ u_int16_t ether_type; /* we only need the type, so we can determine, if the next header is IPv4 or IPv6 */
+} ether_hdr;
+
+typedef struct _ipv6_hdr
+{
+ char dontcare[6];
+ u_int8_t nxt_header; /* we only need the next header, so we can determine, if the next header is UDP or not */
+ char dontcare2[33];
+} ipv6_hdr;
+
+char errbuf[PCAP_ERRBUF_SIZE];
+
+int pcap_scan_pkts(const char *file,
+ uint32_t src_addr,
+ uint16_t src_port,
+ uint32_t dest_addr,
+ uint16_t dest_port,
+ pcap_timing_update_handler_t *timing_update_handler,
+ pcap_packet_handler_t *packet_handler,
+ void *user_data)
+{
+ pcap_t *pcap;
+ struct pcap_pkthdr *pkthdr;
+ uint8_t *pktdata;
+ const uint8_t *body;
+ int body_len;
+ int total_pkts;
+ uint32_t pktlen;
+ ether_hdr *ethhdr;
+ struct iphdr *iphdr;
+ ipv6_hdr *ip6hdr;
+ struct udphdr *udphdr;
+
+ total_pkts = 0;
+ if ((pcap = pcap_open_offline(file, errbuf)) == NULL)
+ {
+ fprintf(stderr, "Can't open PCAP file '%s'\n", file);
+ return -1;
+ }
+ pkthdr = NULL;
+ pktdata = NULL;
+#if defined(HAVE_PCAP_NEXT_EX)
+ while (pcap_next_ex(pcap, &pkthdr, (const uint8_t **) &pktdata) == 1)
+ {
+#else
+ if ((pkthdr = (struct pcap_pkthdr *) malloc(sizeof(*pkthdr))) == NULL)
+ {
+ fprintf(stderr, "Can't allocate memory for pcap pkthdr\n");
+ return -1;
+ }
+ while ((pktdata = (uint8_t *) pcap_next(pcap, pkthdr)) != NULL)
+ {
+#endif
+ ethhdr = (ether_hdr *) pktdata;
+ if (ntohs(ethhdr->ether_type) != 0x0800 /* IPv4 */
+ &&
+ ntohs(ethhdr->ether_type) != 0x86dd) /* IPv6 */
+ {
+ continue;
+ }
+ iphdr = (struct iphdr *) ((uint8_t *) ethhdr + sizeof(*ethhdr));
+ if (iphdr && iphdr->version == 6)
+ {
+ /* ipv6 */
+ pktlen = (uint32_t) pkthdr->len - sizeof(*ethhdr) - sizeof(*ip6hdr);
+ ip6hdr = (ipv6_hdr *) (void *) iphdr;
+ if (ip6hdr->nxt_header != IPPROTO_UDP)
+ continue;
+ udphdr = (struct udphdr *) ((uint8_t *) ip6hdr + sizeof(*ip6hdr));
+ }
+ else
+ {
+ /* ipv4 */
+ if (iphdr->protocol != IPPROTO_UDP)
+ continue;
+#if defined(__DARWIN) || defined(__CYGWIN) || defined(__FreeBSD__)
+ udphdr = (struct udphdr *) ((uint8_t *) iphdr + (iphdr->ihl << 2) + 4);
+ pktlen = (uint32_t) ntohs(udphdr->uh_ulen);
+#elif defined ( __HPUX)
+ udphdr = (struct udphdr *) ((uint8_t *) iphdr + (iphdr->ihl << 2));
+ pktlen = (uint32_t) pkthdr->len - sizeof(*ethhdr) - sizeof(*iphdr);
+#else
+ udphdr = (struct udphdr *) ((uint8_t *) iphdr + (iphdr->ihl << 2));
+ pktlen = (uint32_t) ntohs(udphdr->len);
+#endif
+ }
+ timing_update_handler(user_data, &pkthdr->ts);
+ if (src_addr && ntohl(iphdr->saddr) != src_addr)
+ continue;
+ if (src_port && ntohs(udphdr->source) != src_port)
+ continue;
+ if (dest_addr && ntohl(iphdr->daddr) != dest_addr)
+ continue;
+ if (dest_port && ntohs(udphdr->dest) != dest_port)
+ continue;
+
+ body = (const uint8_t *) udphdr;
+ body += sizeof(udphdr);
+ body_len = pktlen - sizeof(udphdr);
+ packet_handler(user_data, body, body_len);
+
+ total_pkts++;
+ }
+ fprintf(stderr, "In pcap %s, npkts %d\n", file, total_pkts);
+ pcap_close(pcap);
+
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
--- /dev/null
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * pcap_parse.h
+ *
+ * Written by Steve Underwood <steveu@coppice.org>
+ *
+ * Copyright (C) 2009 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*! \file */
+
+#if !defined(_SPANDSP_PCAP_PARSE_H_)
+#define _SPANDSP_PCAP_PARSE_H_
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+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,
+ uint32_t dest_addr,
+ uint16_t dest_port,
+ pcap_timing_update_handler_t *timing_update_handler,
+ pcap_packet_handler_t *packet_handler,
+ void *user_data);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: playout_tests.c,v 1.29 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page playout_tests_page Playout (jitter buffering) tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: plc_tests.c,v 1.26 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page plc_tests_page Packet loss concealment tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: power_meter_tests.c,v 1.24 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page power_meter_tests_page Power meter tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: queue_tests.c,v 1.13 2009/04/11 17:43:04 steveu Exp $
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
if (monitored_queue_write_msg(buf, MSG_LEN) != MSG_LEN)
break;
}
- printf("Full at chunk %d (expected %u)\n", i, BUF_LEN/(MSG_LEN + sizeof(uint16_t)) + 1);
+ printf("Full at chunk %d (expected %lu)\n", i, (unsigned long int) BUF_LEN/(MSG_LEN + sizeof(uint16_t)) + 1);
if (i != BUF_LEN/(MSG_LEN + sizeof(uint16_t)) + 1)
tests_failed();
if ((len = monitored_queue_write_msg(buf, 5)) == 5)
}
printf("Free space = %d (%d)\n", queue_free_space(queue), BUF_LEN - (total_in - total_out));
display_queue_pointers();
- printf("Full at chunk %d (expected %u)\n", i, BUF_LEN/(MSG_LEN + sizeof(uint16_t)));
+ printf("Full at chunk %d (expected %lu)\n", i, (unsigned long int) BUF_LEN/(MSG_LEN + sizeof(uint16_t)));
if (i != BUF_LEN/(MSG_LEN + sizeof(uint16_t)))
tests_failed();
display_queue_pointers();
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: r2_mf_rx_tests.c,v 1.14 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: r2_mf_tx_tests.c,v 1.16 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: regression_tests.sh,v 1.59 2009/09/22 13:28:18 steveu Exp $
-#
ITUTESTS_TIF=../test-data/itu/fax/itutests.tif
MIXEDSIZES_TIF=../test-data/itu/fax/mixed_size_pages.tif
RETVAL=$?
if [ $RETVAL != 0 ]
then
- echo fax_tests failed!
+ echo fax_tests mixed-sizes failed!
exit $RETVAL
fi
# Now use tiffcmp to check the results. It will return non-zero if any page images differ. The -t
RETVAL=$?
if [ $RETVAL != 0 ]
then
- echo fax_tests failed!
+ echo fax_tests mixed-sizes failed!
exit $RETVAL
fi
echo fax_tests completed OK
fi
echo ima_adpcm_tests completed OK
+./image_translate_tests >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+ echo image_translate_tests failed!
+ exit $RETVAL
+fi
+echo image_translate_tests completed OK
+
./logging_tests >$STDOUT_DEST 2>$STDERR_DEST
RETVAL=$?
if [ $RETVAL != 0 ]
#fi
#echo rfc2198_sim_tests completed OK
+./saturated_tests >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+ echo saturated_tests failed!
+ exit $RETVAL
+fi
+echo saturated_tests completed OK
+
./schedule_tests >$STDOUT_DEST 2>$STDERR_DEST
RETVAL=$?
if [ $RETVAL != 0 ]
fi
echo t4_tests completed OK
+#rm -f t4_t6_tests_receive.tif
+#./t4_t6_tests >$STDOUT_DEST 2>$STDERR_DEST
+#RETVAL=$?
+#if [ $RETVAL != 0 ]
+#then
+# echo t4_t6_tests failed!
+# exit $RETVAL
+#fi
+#echo t4_t6_tests completed OK
+#rm -f t81_t82_arith_coding_tests_receive.tif
+#./t4_tests >$STDOUT_DEST 2>$STDERR_DEST
+#RETVAL=$?
+#if [ $RETVAL != 0 ]
+#then
+# echo t81_t82_arith_coding_tests failed!
+# exit $RETVAL
+#fi
+#echo t81_t82_arith_coding_tests completed OK
+echo t81_t82_arith_coding_tests not enabled
+
+#rm -f t85_tests_receive.tif
+#./t4_tests >$STDOUT_DEST 2>$STDERR_DEST
+#RETVAL=$?
+#if [ $RETVAL != 0 ]
+#then
+# echo t85_tests failed!
+# exit $RETVAL
+#fi
+#echo t85_tests completed OK
+echo t85_tests not enabled
+
#./time_scale_tests >$STDOUT_DEST 2>$STDERR_DEST
#RETVAL=$?
#if [ $RETVAL != 0 ]
#echo time_scale_tests completed OK
echo time_scale_tests not enabled
+./timezone_tests >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+ echo timezone_tests failed!
+ exit $RETVAL
+fi
+echo timezone_tests completed OK
+
#./tone_detect_tests >$STDOUT_DEST 2>$STDERR_DEST
#RETVAL=$?
#if [ $RETVAL != 0 ]
fi
echo v29_tests completed OK
+#./v32bis_tests -b 14400 -s -42 -n -66 >$STDOUT_DEST 2>$STDERR_DEST
+#RETVAL=$?
+#if [ $RETVAL != 0 ]
+#then
+# echo v32bis_tests failed!
+# exit $RETVAL
+#fi
+#echo v32bis_tests completed OK
+
#./v42_tests >$STDOUT_DEST 2>$STDERR_DEST
#RETVAL=$?
#if [ $RETVAL != 0 ]
#echo v42_tests completed OK
echo v42_tests not enabled
-./v42bis_tests.sh >/dev/null
-RETVAL=$?
-if [ $RETVAL != 0 ]
-then
- echo v42bis_tests failed!
- exit $RETVAL
-fi
-echo v42bis_tests completed OK
+#./v42bis_tests.sh >/dev/null
+#RETVAL=$?
+#if [ $RETVAL != 0 ]
+#then
+# echo v42bis_tests failed!
+# exit $RETVAL
+#fi
+#echo v42bis_tests completed OK
+echo v42bis_tests not enabled
./v8_tests >$STDOUT_DEST 2>$STDERR_DEST
RETVAL=$?
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: rfc2198_sim_tests.c,v 1.7 2009/05/30 15:23:14 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: schedule_tests.c,v 1.20 2008/11/30 05:43:37 steveu Exp $
*/
/*! \page schedule_tests_page Event scheduler tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: sig_tone_tests.c,v 1.32 2010/03/11 14:22:30 steveu Exp $
*/
/*! \file */
#endif
#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <memory.h>
#include <sndfile.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_rx_tests.c,v 1.33 2009/06/02 14:55:36 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: super_tone_tx_tests.c,v 1.26 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: swept_tone_tests.c,v 1.2 2009/09/22 13:28:18 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t31_tests.c,v 1.72 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
EXCHANGE("ATH0\r", "\r\nOK\r\n")
};
+static const struct command_response_s v34_fax_send_test_seq[] =
+{
+ EXCHANGE("ATE0\r", "ATE0\r\r\nOK\r\n"),
+ EXCHANGE("AT+A8E=3,,\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+FCLASS=1.0\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+F34=14,4,2\r", "\r\nOK\r\n"),
+ EXCHANGE("ATD123456789\r", "\r\n+A8A:1\r\nOK\r\n"),
+ EXCHANGE("AT+A8M=8185D490\r", "\r\n+A8M:8185D490\r\nOK\r\n"),
+ EXCHANGE("ATO\r", "\r\n+A8J:1\r\n+F34=14,2\r\nCONNECT\r\n"),
+ //<DIS frame data>
+ RESPONSE("\x10\x6B\x10\x7D\x10\x6F" "\xFF\x13\x80\x00\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\x78\x57\x10\x03"), // For audio FAXing
+ //RESPONSE("\x10\x6B\x10\x7D\x10\x6F" ""\xFF\x13\x80\x04\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\xE4\xE7\x10\x03"), // For T.38 FAXing
+ //<DCS frame data>
+ //<CFR frame data>
+ EXCHANGE("\xFF\x13\x83\x01\xC6\x80\x80\x80\x80\x01\xFD\x13\x10\x03", "\xFF\x13\x84\xEA\x7D\x10\x03"),
+ EXCHANGE("\x10\x04", "\x10\x04\x10\x7D"),
+ //<FCD frames>
+ EXCHANGE("\x10\x6B", "\x10\x6B\x10\x79\x10\x6F"),
+ //<PPS-MPS frame>
+ //<FCD frames>
+ //<PPS-EOP frame>
+ EXCHANGE("\x10\x03", "\xFF\x13\x8C\xA2\xF1\x10\x03"),
+ //<DCN frame>
+ EXCHANGE("\xFF\x13\xFB\x10\x03\x10\x04", "\r\nOK\r\n"),
+ EXCHANGE("ATH\r", "\r\nOK\r\n")
+};
+
+static const struct command_response_s v34_fax_receive_test_seq[] =
+{
+ EXCHANGE("ATE0\r", "ATE0\r\r\nOK\r\n"),
+ EXCHANGE("AT+A8E=,2,\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+FCLASS=1.0\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+F34=10\r", "\r\nOK\r\n"),
+ RESPONSE("\r\nRING\r\n"),
+ EXCHANGE("ATA\r", "\r\n+A8M:8185D490\r\nOK\r\n"),
+ EXCHANGE("AT+A8M=8185D490;O\r", "\r\n+A8J:1\r\n+F34:10,1\r\nCONNECT\r\n"),
+ RESPONSE("\x10<ctrl>\x10<p224>\x10<C12>"),
+ EXCHANGE("ATH\r", "\r\nOK\r\n")
+};
+
+static const struct command_response_s v34_fax_receive_a_test_seq[] =
+{
+ EXCHANGE("ATE0\r", "ATE0\r\r\nOK\r\n"),
+ EXCHANGE("AT+A8E=,3,\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+FCLASS=1.0\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+F34=10\r", "\r\nOK\r\n"),
+ RESPONSE("\r\nRING\r\n"),
+ EXCHANGE("ATA\r", "\r\n+A8C:1\r\n+A8C:1\r\n"),
+ EXCHANGE("X", "\r\nOK\r\n"),
+ EXCHANGE("AT+A8E=,2,\r", "\r\n+A8M:8185D490\r\nOK\r\n"),
+ EXCHANGE("AT+A8M=8185D490\r", "\r\n+A8J:1\r\n+F34:10,1\r\nCONNECT\r\n"),
+ RESPONSE("\x10<ctrl>\x10<p224>\x10<C12>"),
+ EXCHANGE("ATH\r", "\r\nOK\r\n")
+};
+
+static const struct command_response_s v34_fax_receive_b_test_seq[] =
+{
+ EXCHANGE("ATE0\r", "ATE0\r\r\nOK\r\n"),
+ EXCHANGE("AT+A8E=,3,\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+FCLASS=1.0\r", "\r\nOK\r\n"),
+ EXCHANGE("AT+F34=10\r", "\r\nOK\r\n"),
+ RESPONSE("\r\nRING\r\n"),
+ EXCHANGE("ATA\r", "\r\nA8I:81\r\n"),
+ RESPONSE("A8I:81\r\n"),
+ EXCHANGE("X", "\r\nOK\r\n"),
+ EXCHANGE("AT+A8E=,2,\r", "\r\n+A8M:8185D490\r\nOK\r\n")
+};
+
char *decode_test_file = NULL;
int countdown = 0;
int command_response_test_step = -1;
for (i = 0; i < response_buf_ptr; i++)
printf("%02x ", response_buf[i] & 0xFF);
printf("\n");
-printf("Match %d against %d\n", response_buf_ptr, fax_test_seq[test_seq_ptr].len_response);
+ printf("Match %d against %d\n", response_buf_ptr, fax_test_seq[test_seq_ptr].len_response);
if (response_buf_ptr >= fax_test_seq[test_seq_ptr].len_response
&&
memcmp(fax_test_seq[test_seq_ptr].response, response_buf, fax_test_seq[test_seq_ptr].len_response) == 0)
span_log_set_tag(logging, "T.31");
t38_core = t31_get_t38_core_state(t31_state);
- span_log_set_level(&t38_core->logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
- span_log_set_tag(&t38_core->logging, "T.31");
+ 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.31");
span_log_set_level(&t31_state->at_state.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(&t31_state->at_state.logging, "T.31");
if (fax_rx(fax_state, t31_amp, SAMPLES_PER_CHUNK))
break;
- span_log_bump_samples(&fax_state->logging, SAMPLES_PER_CHUNK);
- span_log_bump_samples(&t30->logging, SAMPLES_PER_CHUNK);
+ logging = fax_get_logging_state(fax_state);
+ span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
+ logging = t30_get_logging_state(t30);
+ span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
+ logging = t31_get_logging_state(t31_state);
+ span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
if (log_audio)
{
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_core_tests.c,v 1.16 2009/07/14 13:54:22 steveu Exp $
*/
/*! \file */
--- /dev/null
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * pcap-parse.c
+ *
+ * Written by Steve Underwood <steveu@coppice.org>
+ *
+ * Copyright (C) 2009 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 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.
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <time.h>
+#if !defined(_WIN32)
+#include <unistd.h>
+#endif
+
+#include "udptl.h"
+#include "spandsp.h"
+
+#include "fax_utils.h"
+#include "pcap_parse.h"
+
+#define INPUT_FILE_NAME "t38.pcap"
+#define OUTPUT_FILE_NAME "t38pcap.tif"
+
+t38_terminal_state_t *t38_state;
+
+static int phase_b_handler(t30_state_t *s, void *user_data, int result)
+{
+ int i;
+ char tag[20];
+
+ i = (int) (intptr_t) user_data;
+ snprintf(tag, sizeof(tag), "%c: Phase B", i);
+ printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
+ log_rx_parameters(s, tag);
+ return T30_ERR_OK;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int phase_d_handler(t30_state_t *s, void *user_data, int result)
+{
+ int i;
+ char tag[20];
+
+ i = (int) (intptr_t) user_data;
+ snprintf(tag, sizeof(tag), "%c: Phase 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);
+ return T30_ERR_OK;
+}
+/*- End of function --------------------------------------------------------*/
+
+static void phase_e_handler(t30_state_t *s, void *user_data, int result)
+{
+ int i;
+ t30_stats_t t;
+ char tag[20];
+
+ i = (int) (intptr_t) user_data;
+ snprintf(tag, sizeof(tag), "%c: Phase E", i);
+ printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
+ log_transfer_statistics(s, tag);
+ log_tx_parameters(s, tag);
+ log_rx_parameters(s, tag);
+ t30_get_transfer_statistics(s, &t);
+}
+/*- End of function --------------------------------------------------------*/
+
+static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
+{
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int timing_update(void *user_data, struct timeval *ts)
+{
+ t30_state_t *t30;
+ t38_core_state_t *t38_core;
+ logging_state_t *logging;
+ int samples;
+ static int64_t current = 0;
+ int64_t when;
+ int64_t diff;
+
+ when = ts->tv_sec*1000000LL + ts->tv_usec;
+ if (current == 0)
+ current = when;
+
+ diff = when - current;
+ samples = diff/125LL;
+ if (samples > 0)
+ {
+ logging = t38_terminal_get_logging_state(t38_state);
+ span_log_bump_samples(logging, samples);
+ t38_core = t38_terminal_get_t38_core_state(t38_state);
+ logging = t38_core_get_logging_state(t38_core);
+ span_log_bump_samples(logging, samples);
+ t30 = t38_terminal_get_t30_state(t38_state);
+ logging = t30_get_logging_state(t30);
+ span_log_bump_samples(logging, samples);
+
+ t38_terminal_send_timeout(t38_state, samples);
+ current = when;
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int ifp_handler(void *user_data, const uint8_t msg[], int len, int seq_no)
+{
+ t38_core_state_t *t38_core;
+ int i;
+
+ 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;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int process_packet(void *user_data, const uint8_t *pkt, int len)
+{
+ static udptl_state_t *state = NULL;
+
+ if (state == NULL)
+ state = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, ifp_handler, NULL);
+
+ udptl_rx_packet(state, pkt, len);
+ return 0;
+}
+/*- 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 use_ecm;
+ int use_tep;
+ int options;
+ int supported_modems;
+ int fill_removal;
+ int opt;
+ uint32_t src_addr;
+ uint16_t src_port;
+ uint32_t dest_addr;
+ uint16_t dest_port;
+
+
+ use_ecm = FALSE;
+ t38_version = 1;
+ input_file_name = INPUT_FILE_NAME;
+ fill_removal = FALSE;
+ use_tep = FALSE;
+ supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
+ src_addr = 0;
+ src_port = 0;
+ dest_addr = 0;
+ dest_port = 0;
+ while ((opt = getopt(argc, argv, "D:d:eFi:m:S:s:tv:")) != -1)
+ {
+ switch (opt)
+ {
+ case 'D':
+ dest_addr = atoi(optarg);
+ break;
+ case 'd':
+ dest_port = atoi(optarg);
+ break;
+ case 'e':
+ use_ecm = TRUE;
+ break;
+ case 'F':
+ fill_removal = TRUE;
+ break;
+ case 'i':
+ input_file_name = optarg;
+ break;
+ case 'm':
+ supported_modems = atoi(optarg);
+ break;
+ case 'S':
+ src_addr = atoi(optarg);
+ break;
+ case 's':
+ src_port = atoi(optarg);
+ break;
+ case 't':
+ use_tep = TRUE;
+ break;
+ case 'v':
+ t38_version = atoi(optarg);
+ break;
+ default:
+ //usage();
+ exit(2);
+ break;
+ }
+ }
+
+ if ((t38_state = t38_terminal_init(NULL, FALSE, tx_packet_handler, NULL)) == NULL)
+ {
+ 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);
+
+ 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_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");
+
+ 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);
+
+ if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, timing_update, process_packet, NULL))
+ exit(2);
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_gateway_tests.c,v 1.82.4.1 2009/12/19 09:47:57 steveu Exp $
*/
/*! \file */
#define INPUT_FILE_NAME "../test-data/itu/fax/itutests.tif"
#define OUTPUT_FILE_NAME "t38.tif"
#define OUTPUT_FILE_NAME_WAVE "t38_gateway.wav"
-#define OUTPUT_FILE_NAME_T30A "t38_gateway_t30a.wav"
-#define OUTPUT_FILE_NAME_T38A "t38_gateway_t38a.wav"
-#define OUTPUT_FILE_NAME_T30B "t38_gateway_t30b.wav"
-#define OUTPUT_FILE_NAME_T38B "t38_gateway_t38b.wav"
fax_state_t *fax_state_a;
t38_gateway_state_t *t38_state_a;
const char *input_file_name;
int i;
int seq_no;
- int model_no;
- int speed_pattern_no;
+ int g1050_model_no;
+ int g1050_speed_pattern_no;
double tx_when;
double rx_when;
int supported_modems;
int fill_removal;
int use_gui;
int opt;
+ int drop_frame;
+ int drop_frame_rate;
t38_stats_t stats;
fax_state_t *fax;
t30_state_t *t30;
t38_version = 1;
input_file_name = INPUT_FILE_NAME;
simulate_incrementing_repeats = FALSE;
- model_no = 0;
- speed_pattern_no = 1;
+ g1050_model_no = 0;
+ g1050_speed_pattern_no = 1;
fill_removal = FALSE;
use_gui = FALSE;
use_tep = FALSE;
feedback_audio = FALSE;
use_transmit_on_idle = TRUE;
supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
- while ((opt = getopt(argc, argv, "efFgi:Ilm:M:s:tv:")) != -1)
+ drop_frame = 0;
+ drop_frame_rate = 0;
+ while ((opt = getopt(argc, argv, "D:efFgi:Ilm:M:s:tv:")) != -1)
{
switch (opt)
{
+ case 'D':
+ drop_frame_rate =
+ drop_frame = atoi(optarg);
+ break;
case 'e':
use_ecm = TRUE;
break;
supported_modems = atoi(optarg);
break;
case 'M':
- model_no = optarg[0] - 'A' + 1;
+ g1050_model_no = optarg[0] - 'A' + 1;
break;
case 's':
- speed_pattern_no = atoi(optarg);
+ g1050_speed_pattern_no = atoi(optarg);
break;
case 't':
use_tep = TRUE;
memset(silence, 0, sizeof(silence));
srand48(0x1234567);
- if ((path_a_to_b = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_a_to_b = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
}
- if ((path_b_to_a = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_b_to_a = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
t30_amp_a[i] += t38_amp_hist_a[hist_ptr][i] >> 1;
memcpy(t38_amp_hist_a[hist_ptr], t38_amp_a, sizeof(int16_t)*SAMPLES_PER_CHUNK);
}
- if (t38_gateway_rx(t38_state_a, t30_amp_a, t30_len_a))
- break;
+ if (drop_frame_rate && --drop_frame == 0)
+ {
+ drop_frame = drop_frame_rate;
+ if (t38_gateway_rx_fillin(t38_state_a, t30_len_a))
+ break;
+ }
+ else
+ {
+ if (t38_gateway_rx(t38_state_a, t30_amp_a, t30_len_a))
+ break;
+ }
t38_len_a = t38_gateway_tx(t38_state_a, t38_amp_a, SAMPLES_PER_CHUNK);
if (!use_transmit_on_idle)
t30_amp_b[i] += t38_amp_hist_b[hist_ptr][i] >> 1;
memcpy(t38_amp_hist_b[hist_ptr], t38_amp_b, sizeof(int16_t)*SAMPLES_PER_CHUNK);
}
- if (t38_gateway_rx(t38_state_b, t30_amp_b, t30_len_b))
- break;
+ if (drop_frame_rate && --drop_frame == 0)
+ {
+ drop_frame = drop_frame_rate;
+ if (t38_gateway_rx_fillin(t38_state_b, t30_len_b))
+ break;
+ }
+ else
+ {
+ if (t38_gateway_rx(t38_state_b, t30_amp_b, t30_len_b))
+ break;
+ }
t38_len_b = t38_gateway_tx(t38_state_b, t38_amp_b, SAMPLES_PER_CHUNK);
if (!use_transmit_on_idle)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_gateway_to_terminal_tests.c,v 1.66.4.1 2009/12/19 09:47:57 steveu Exp $
*/
/*! \file */
int simulate_incrementing_repeats = FALSE;
+int t38_version;
+int use_ecm;
+int use_tep;
+int use_transmit_on_idle;
+int supported_modems;
+int use_gui;
+int g1050_model_no;
+int g1050_speed_pattern_no;
+
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
int i;
}
/*- End of function --------------------------------------------------------*/
+static int decode_test(const char *decode_test_file)
+{
+ int16_t t38_amp_a[SAMPLES_PER_CHUNK];
+ int16_t t30_amp_a[SAMPLES_PER_CHUNK];
+ SNDFILE *wave_handle;
+ t30_state_t *t30;
+ t38_core_state_t *t38_core;
+ logging_state_t *logging;
+ int t38_len_a;
+ int t30_len_a;
+ int msg_len;
+ uint8_t msg[1024];
+ int seq_no;
+ double tx_when;
+ double rx_when;
+
+ printf("Decode test data file '%s'\n", decode_test_file);
+
+ if ((wave_handle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
+ {
+ fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
+ exit(2);
+ }
+
+ srand48(0x1234567);
+ if ((path_a_to_b = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
+ {
+ fprintf(stderr, "Failed to start IP network path model\n");
+ exit(2);
+ }
+ if ((path_b_to_a = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
+ {
+ fprintf(stderr, "Failed to start IP network path model\n");
+ exit(2);
+ }
+
+ memset(t30_amp_a, 0, sizeof(t30_amp_a));
+
+ if ((t38_state_a = t38_gateway_init(NULL, tx_packet_handler_a, t38_state_b)) == NULL)
+ {
+ fprintf(stderr, "Cannot start the T.38 channel\n");
+ exit(2);
+ }
+ t38_core = t38_gateway_get_t38_core_state(t38_state_a);
+ t38_gateway_set_transmit_on_idle(t38_state_a, use_transmit_on_idle);
+ t38_set_t38_version(t38_core, t38_version);
+ t38_gateway_set_ecm_capability(t38_state_a, use_ecm);
+
+ logging = t38_gateway_get_logging_state(t38_state_a);
+ span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+ span_log_set_tag(logging, "T.38-A");
+
+ 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-A");
+
+ logging = &t38_state_a->audio.modems.v17_rx.logging;
+ span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+ span_log_set_tag(logging, "V.17-A");
+
+ memset(t38_amp_a, 0, sizeof(t38_amp_a));
+
+ if ((t38_state_b = t38_terminal_init(NULL, FALSE, tx_packet_handler_b, t38_state_a)) == NULL)
+ {
+ fprintf(stderr, "Cannot start the T.38 channel\n");
+ exit(2);
+ }
+ t30 = t38_terminal_get_t30_state(t38_state_b);
+ t38_core = t38_terminal_get_t38_core_state(t38_state_b);
+ t38_set_t38_version(t38_core, t38_version);
+
+ logging = t38_terminal_get_logging_state(t38_state_b);
+ span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+ span_log_set_tag(logging, "T.38-B");
+
+ 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-B");
+
+ 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-B");
+
+ t30_set_supported_modems(t30, supported_modems);
+ t30_set_tx_ident(t30, "22222222");
+ t30_set_rx_file(t30, OUTPUT_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, use_ecm);
+ if (use_ecm)
+ t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+
+#if defined(ENABLE_GUI)
+ if (use_gui)
+ start_media_monitor();
+#endif
+ for (;;)
+ {
+ t30_len_a = sf_readf_short(wave_handle, t30_amp_a, SAMPLES_PER_CHUNK);
+
+ logging = t38_gateway_get_logging_state(t38_state_a);
+ span_log_bump_samples(logging, t30_len_a);
+ t38_core = t38_gateway_get_t38_core_state(t38_state_a);
+ logging = t38_core_get_logging_state(t38_core);
+ span_log_bump_samples(logging, t30_len_a);
+ logging = &t38_state_a->audio.modems.v17_rx.logging;
+ span_log_bump_samples(logging, t30_len_a);
+
+ logging = t38_terminal_get_logging_state(t38_state_b);
+ span_log_bump_samples(logging, t30_len_a);
+ t38_core = t38_terminal_get_t38_core_state(t38_state_b);
+ logging = t38_core_get_logging_state(t38_core);
+ span_log_bump_samples(logging, t30_len_a);
+
+ t30 = t38_terminal_get_t30_state(t38_state_b);
+ logging = t30_get_logging_state(t30);
+ span_log_bump_samples(logging, t30_len_a);
+
+ t38_terminal_send_timeout(t38_state_b, t30_len_a);
+
+ if (t38_gateway_rx(t38_state_a, t30_amp_a, t30_len_a))
+ break;
+
+ t38_len_a = t38_gateway_tx(t38_state_a, t38_amp_a, t30_len_a);
+ if (!use_transmit_on_idle)
+ {
+ if (t38_len_a < SAMPLES_PER_CHUNK)
+ {
+ memset(t38_amp_a + t38_len_a, 0, sizeof(int16_t)*(t30_len_a - t38_len_a));
+ t38_len_a = t30_len_a;
+ }
+ }
+
+ when += (float) t30_len_a/(float) SAMPLE_RATE;
+
+ while ((msg_len = g1050_get(path_a_to_b, msg, 1024, when, &seq_no, &tx_when, &rx_when)) >= 0)
+ {
+#if defined(ENABLE_GUI)
+ if (use_gui)
+ media_monitor_rx(seq_no, tx_when, rx_when);
+#endif
+ t38_core = t38_terminal_get_t38_core_state(t38_state_b);
+ t38_core_rx_ifp_packet(t38_core, msg, msg_len, seq_no);
+ }
+ while ((msg_len = g1050_get(path_b_to_a, msg, 1024, when, &seq_no, &tx_when, &rx_when)) >= 0)
+ {
+#if defined(ENABLE_GUI)
+ if (use_gui)
+ media_monitor_rx(seq_no, tx_when, rx_when);
+#endif
+ t38_core = t38_gateway_get_t38_core_state(t38_state_a);
+ t38_core_rx_ifp_packet(t38_core, msg, msg_len, seq_no);
+ }
+
+ if (done[0] && done[1])
+ break;
+#if defined(ENABLE_GUI)
+ if (use_gui)
+ media_monitor_update_display();
+#endif
+ }
+ t38_gateway_release(t38_state_a);
+ t38_terminal_release(t38_state_b);
+ if (sf_close(wave_handle) != 0)
+ {
+ fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
+ exit(2);
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
int main(int argc, char *argv[])
{
int16_t t38_amp_a[SAMPLES_PER_CHUNK];
uint8_t msg[1024];
int log_audio;
int outframes;
- int t38_version;
- int use_ecm;
- int use_tep;
int feedback_audio;
- int use_transmit_on_idle;
SNDFILE *wave_handle;
const char *input_file_name;
int i;
int seq_no;
- int model_no;
- int speed_pattern_no;
double tx_when;
double rx_when;
- int supported_modems;
- int use_gui;
int opt;
t30_state_t *t30;
t38_core_state_t *t38_core;
logging_state_t *logging;
+ char *decode_test_file;
log_audio = FALSE;
t38_version = 1;
use_ecm = FALSE;
input_file_name = INPUT_FILE_NAME;
simulate_incrementing_repeats = FALSE;
- model_no = 0;
- speed_pattern_no = 1;
+ g1050_model_no = 0;
+ g1050_speed_pattern_no = 1;
use_gui = FALSE;
use_tep = FALSE;
feedback_audio = FALSE;
use_transmit_on_idle = TRUE;
supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
- while ((opt = getopt(argc, argv, "efgi:Ilm:M:s:tv:")) != -1)
+ decode_test_file = NULL;
+ while ((opt = getopt(argc, argv, "d:efgi:Ilm:M:s:tv:")) != -1)
{
switch (opt)
{
+ case 'd':
+ decode_test_file = optarg;
+ break;
case 'e':
use_ecm = TRUE;
break;
supported_modems = atoi(optarg);
break;
case 'M':
- model_no = optarg[0] - 'A' + 1;
+ g1050_model_no = optarg[0] - 'A' + 1;
break;
case 's':
- speed_pattern_no = atoi(optarg);
+ g1050_speed_pattern_no = atoi(optarg);
break;
case 't':
use_tep = TRUE;
if (use_ecm)
printf("Using ECM\n");
+ if (decode_test_file)
+ {
+ decode_test(decode_test_file);
+ return 0;
+ }
+
wave_handle = NULL;
if (log_audio)
{
}
srand48(0x1234567);
- if ((path_a_to_b = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_a_to_b = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
}
- if ((path_b_to_a = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_b_to_a = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38-A");
+ logging = &t38_state_a->audio.modems.v17_rx.logging;
+ span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+ span_log_set_tag(logging, "V.17-A");
+
memset(t38_amp_a, 0, sizeof(t38_amp_a));
if ((t38_state_b = t38_terminal_init(NULL, FALSE, tx_packet_handler_b, t38_state_a)) == NULL)
t30 = fax_get_t30_state(fax_state_a);
logging = t30_get_logging_state(t30);
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
+
logging = t38_gateway_get_logging_state(t38_state_a);
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
t38_core = t38_gateway_get_t38_core_state(t38_state_a);
logging = t38_core_get_logging_state(t38_core);
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
+ logging = &t38_state_a->audio.modems.v17_rx.logging;
+ span_log_bump_samples(logging, t30_len_a);
+
logging = t38_terminal_get_logging_state(t38_state_b);
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
t38_core = t38_terminal_get_t38_core_state(t38_state_b);
#endif
}
fax_release(fax_state_a);
+ t38_gateway_release(t38_state_a);
t38_terminal_release(t38_state_b);
if (log_audio)
{
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_non_ecm_buffer_tests.c,v 1.5.4.1 2009/12/19 06:43:28 steveu Exp $
*/
/*! \file */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_terminal_tests.c,v 1.67.4.1 2009/12/19 09:47:57 steveu Exp $
*/
/*! \file */
int t38_version;
int seq_no;
int use_ecm;
- int without_pacing;
+ int options;
int use_tep;
- int model_no;
- int speed_pattern_no;
+ int g1050_model_no;
+ int g1050_speed_pattern_no;
const char *input_file_name;
double tx_when;
double rx_when;
logging_state_t *logging;
t38_version = 1;
- without_pacing = FALSE;
+ options = 0;
use_tep = FALSE;
input_file_name = INPUT_FILE_NAME;
use_ecm = FALSE;
simulate_incrementing_repeats = FALSE;
- model_no = 0;
- speed_pattern_no = 1;
+ g1050_model_no = 0;
+ g1050_speed_pattern_no = 1;
use_gui = FALSE;
supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
- while ((opt = getopt(argc, argv, "efgi:Im:M:ps:tv:")) != -1)
+ while ((opt = getopt(argc, argv, "efgi:Im:M:o:s:tv:")) != -1)
{
switch (opt)
{
supported_modems = atoi(optarg);
break;
case 'M':
- model_no = optarg[0] - 'A' + 1;
+ g1050_model_no = optarg[0] - 'A' + 1;
break;
- case 'p':
- without_pacing = TRUE;
+ case 'o':
+ options = atoi(optarg);
break;
case 's':
- speed_pattern_no = atoi(optarg);
+ g1050_speed_pattern_no = atoi(optarg);
break;
case 't':
use_tep = TRUE;
printf("Using ECM\n");
srand48(0x1234567);
- if ((path_a_to_b = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_a_to_b = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
}
- if ((path_b_to_a = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_b_to_a = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
t30 = t38_terminal_get_t30_state(t38_state_a);
t38_core = t38_terminal_get_t38_core_state(t38_state_a);
t38_set_t38_version(t38_core, t38_version);
- t38_terminal_set_config(t38_state_a, without_pacing);
+ t38_terminal_set_config(t38_state_a, options);
t38_terminal_set_tep_mode(t38_state_a, use_tep);
logging = t38_terminal_get_logging_state(t38_state_a);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
t30_set_ecm_capability(t30, use_ecm);
if (use_ecm)
- t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+ t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
if ((t38_state_b = t38_terminal_init(NULL, FALSE, tx_packet_handler_b, t38_state_a)) == NULL)
{
t30 = t38_terminal_get_t30_state(t38_state_b);
t38_core = t38_terminal_get_t38_core_state(t38_state_b);
t38_set_t38_version(t38_core, t38_version);
- t38_terminal_set_config(t38_state_b, without_pacing);
+ t38_terminal_set_config(t38_state_b, options);
t38_terminal_set_tep_mode(t38_state_b, use_tep);
logging = t38_terminal_get_logging_state(t38_state_b);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'B');
t30_set_ecm_capability(t30, use_ecm);
if (use_ecm)
- t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+ t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
#if defined(ENABLE_GUI)
if (use_gui)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t38_terminal_to_gateway_tests.c,v 1.65.4.1 2009/12/19 09:47:57 steveu Exp $
*/
/*! \file */
const char *input_file_name;
int i;
int seq_no;
- int model_no;
- int speed_pattern_no;
+ int g1050_model_no;
+ int g1050_speed_pattern_no;
double tx_when;
double rx_when;
int use_gui;
use_ecm = FALSE;
input_file_name = INPUT_FILE_NAME;
simulate_incrementing_repeats = FALSE;
- model_no = 0;
- speed_pattern_no = 1;
+ g1050_model_no = 0;
+ g1050_speed_pattern_no = 1;
use_gui = FALSE;
use_tep = FALSE;
feedback_audio = FALSE;
supported_modems = atoi(optarg);
break;
case 'M':
- model_no = optarg[0] - 'A' + 1;
+ g1050_model_no = optarg[0] - 'A' + 1;
break;
case 's':
- speed_pattern_no = atoi(optarg);
+ g1050_speed_pattern_no = atoi(optarg);
break;
case 't':
use_tep = TRUE;
}
srand48(0x1234567);
- if ((path_a_to_b = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_a_to_b = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
}
- if ((path_b_to_a = g1050_init(model_no, speed_pattern_no, 100, 33)) == NULL)
+ if ((path_b_to_a = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: t4_tests.c,v 1.69.4.1 2009/12/19 09:47:57 steveu Exp $
*/
/*! \file */
/* Line end codes to V(0) H(7,0). */
};
+int rows_written = 0;
+int rows_read = 0;
+
static void dump_image_as_xxx(t4_state_t *state)
{
uint8_t *s;
for (j = 0; j < state->bytes_per_row; j++)
{
for (k = 0; k < 8; k++)
- {
printf((state->image_buffer[i*state->bytes_per_row + j] & (0x80 >> k)) ? "X" : " ");
- }
}
printf("\n");
}
{
t4_stats_t stats;
- t4_get_transfer_statistics(s, &stats);
+ t4_rx_get_transfer_statistics(s, &stats);
printf("Pages = %d\n", stats.pages_transferred);
+ printf("Compression = %s\n", t4_encoding_to_str(stats.encoding));
+ printf("Compressed size = %d\n", stats.line_image_size);
printf("Image size = %d pels x %d pels\n", stats.width, stats.length);
printf("Image resolution = %d pels/m x %d pels/m\n", stats.x_resolution, stats.y_resolution);
printf("Bad rows = %d\n", stats.bad_rows);
int i;
int j;
const char *s;
- static int row = 0;
/* Send the test pattern. */
- s = t4_test_patterns[row++];
- if (row >= 16)
+ if (rows_read >= 16)
return 0;
+ s = t4_test_patterns[rows_read++];
memset(buf, 0, len);
for (i = 0; i < len; i++)
{
}
}
if (*s)
- printf("Oops - '%c' at end of row %d\n", *s, row);
+ printf("Oops - '%c' at end of row %d\n", *s, rows_read);
return len;
}
/*- End of function --------------------------------------------------------*/
int i;
int j;
const char *s;
- static int row = 0;
uint8_t ref[8192];
/* Verify that what is received matches the test pattern. */
if (len == 0)
return 0;
- s = t4_test_patterns[row++];
- if (row >= 16)
- row = 0;
+ s = t4_test_patterns[rows_written++];
memset(ref, 0, len);
for (i = 0; i < len; i++)
{
}
}
if (*s)
- printf("Oops - '%c' at end of row %d\n", *s, row);
+ printf("Oops - '%c' at end of row %d\n", *s, rows_written);
if (memcmp(buf, ref, len))
{
- printf("Test failed at row %d\n", row);
+ printf("Test failed at row %d\n", rows_written);
exit(2);
}
- return len;
+ return 0;
}
/*- End of function --------------------------------------------------------*/
eol_zeros = 11;
eol_ones = (page_ended == T4_COMPRESSION_ITU_T4_2D) ? 2 : 1;
expected_eols = (page_ended == T4_COMPRESSION_ITU_T6) ? 2 : 6;
- return FALSE;
+ return 0;
}
/* Monitor whether the EOLs are there in the correct amount */
T4_COMPRESSION_ITU_T4_1D,
T4_COMPRESSION_ITU_T4_2D,
T4_COMPRESSION_ITU_T6,
- //T4_COMPRESSION_ITU_T85,
+#if defined(SPANDSP_SUPPORT_T85)
+ T4_COMPRESSION_ITU_T85,
+ T4_COMPRESSION_ITU_T85_L0,
+#endif
//T4_COMPRESSION_ITU_T43,
//T4_COMPRESSION_ITU_T45,
//T4_COMPRESSION_ITU_T81,
- //T4_COMPRESSION_ITU_SYCC_T81
+ //T4_COMPRESSION_ITU_SYCC_T81,
+ -1
};
int sends;
int page_no;
int compression;
int compression_step;
int add_page_headers;
+ int overlay_page_headers;
int min_row_bits;
int restart_pages;
int block_size;
uint8_t block[1024];
const char *in_file_name;
const char *decode_file_name;
+ const char *page_header_tz;
int opt;
int i;
int bit_error_rate;
compression = -1;
compression_step = 0;
add_page_headers = FALSE;
+ overlay_page_headers = FALSE;
restart_pages = FALSE;
in_file_name = IN_FILE_NAME;
decode_file_name = NULL;
+ page_header_tz = NULL;
/* Use a non-zero default minimum row length to ensure we test the consecutive EOLs part
properly. */
min_row_bits = 50;
- block_size = 0;
+ block_size = 1;
bit_error_rate = 0;
dump_as_xxx = FALSE;
- while ((opt = getopt(argc, argv, "126b:d:ehri:m:x")) != -1)
+ while ((opt = getopt(argc, argv, "1268b:d:ehHri:m:t:x")) != -1)
{
switch (opt)
{
compression = T4_COMPRESSION_ITU_T6;
compression_step = -1;
break;
+#if defined(SPANDSP_SUPPORT_T85)
+ case '8':
+ compression = T4_COMPRESSION_ITU_T85;
+ compression_step = -1;
+ break;
+#endif
case 'b':
block_size = atoi(optarg);
if (block_size > 1024)
break;
case 'h':
add_page_headers = TRUE;
+ overlay_page_headers = FALSE;
+ break;
+ case 'H':
+ add_page_headers = TRUE;
+ overlay_page_headers = TRUE;
break;
case 'r':
restart_pages = TRUE;
case 'm':
min_row_bits = atoi(optarg);
break;
+ case 't':
+ page_header_tz = optarg;
+ break;
case 'x':
dump_as_xxx = TRUE;
break;
printf("Failed to init T.4 rx\n");
exit(2);
}
- span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
+ span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_rx_encoding(&receive_state, compression);
t4_rx_set_x_resolution(&receive_state, T4_X_RESOLUTION_R8);
//t4_rx_set_y_resolution(&receive_state, T4_Y_RESOLUTION_FINE);
break;
}
}
+ else if (strlen(buf) > 2 && sscanf(buf, "T.30 Rx: %x %x", (unsigned int *) &bit, (unsigned int *) &bit) == 2)
+ {
+ /* Useful for breaking up ECM logs */
+ if (pkt_no != last_pkt_no + 1)
+ printf("Packet %u\n", pkt_no);
+ last_pkt_no = pkt_no;
+ for (i = 0; i < 256; i++)
+ {
+ if (sscanf(&buf[22 + 3*i], "%x", (unsigned int *) &bit) != 1)
+ break;
+ bit = bit_reverse8(bit);
+ if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
+ break;
+ }
+ }
+ else if (sscanf(buf, "%04x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
+ {
+ for (i = 0; i < 16; i++)
+ {
+ if (sscanf(&buf[6 + 3*i], "%x", (unsigned int *) &bit) != 1)
+ break;
+ bit = bit_reverse8(bit);
+ if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
+ break;
+ }
+ }
else if (sscanf(buf, "%08x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
{
for (i = 0; i < 16; i++)
printf("Failed to init T.4 tx\n");
exit(2);
}
- span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
+ span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_tx_set_row_read_handler(&send_state, row_read_handler, NULL);
- t4_tx_set_min_row_bits(&send_state, min_row_bits);
+ t4_tx_set_min_bits_per_row(&send_state, min_row_bits);
t4_tx_set_local_ident(&send_state, "111 2222 3333");
/* Receive end puts TIFF to a function. */
printf("Failed to init T.4 rx\n");
exit(2);
}
- span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
+ span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_row_write_handler(&receive_state, row_write_handler, NULL);
t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state));
t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state));
if (compression_step >= 0)
{
compression = compression_sequence[compression_step++];
- if (compression_step > 3)
+ if (compression < 0)
break;
}
t4_tx_set_tx_encoding(&send_state, compression);
t4_rx_set_rx_encoding(&receive_state, compression);
+ rows_read = 0;
+ rows_written = 0;
if (t4_tx_start_page(&send_state))
break;
- t4_rx_start_page(&receive_state);
- do
+ if (t4_rx_start_page(&receive_state))
+ break;
+ switch (block_size)
{
- bit = t4_tx_get_bit(&send_state);
- if (bit == SIG_STATUS_END_OF_DATA)
+ case 0:
+ do
{
- if (++end_marks > 50)
+ bit = t4_tx_get_bit(&send_state);
+ if (bit == SIG_STATUS_END_OF_DATA)
{
- printf("Receiver missed the end of page mark\n");
- tests_failed++;
- break;
+ if (++end_marks > 50)
+ {
+ printf("Receiver missed the end of page mark\n");
+ tests_failed++;
+ break;
+ }
+ }
+ end_of_page = t4_rx_put_bit(&receive_state, bit & 1);
+ }
+ while (!end_of_page);
+ break;
+ case 1:
+ do
+ {
+ bit = t4_tx_get_byte(&send_state);
+ if ((bit & 0x100))
+ {
+ if (++end_marks > 50)
+ {
+ printf("Receiver missed the end of page mark\n");
+ tests_failed++;
+ break;
+ }
}
+ end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
}
- end_of_page = t4_rx_put_bit(&receive_state, bit & 1);
+ while (!end_of_page);
+ if ((t4_tx_get_byte(&send_state) & 0x100) == 0)
+ {
+ printf("Page ended, but source is not reporting end of data\n");
+ tests_failed++;
+ }
+ break;
+ default:
+ do
+ {
+ bit = t4_tx_get_chunk(&send_state, block, block_size);
+ if (bit > 0)
+ end_of_page = t4_rx_put_chunk(&receive_state, block, bit);
+ if (bit < block_size)
+ {
+ if (++end_marks > 50)
+ {
+ printf("Receiver missed the end of page mark\n");
+ tests_failed++;
+ break;
+ }
+ }
+ }
+ while (!end_of_page);
+ break;
}
- while (!end_of_page);
+ display_page_stats(&receive_state);
t4_tx_end_page(&send_state);
t4_rx_end_page(&receive_state);
+ if (rows_read != (15 + 1) || rows_written != (15 + 1))
+ {
+ printf("Test failed: %d rows read, %d rows written\n", rows_read, rows_written);
+ exit(2);
+ }
if (compression_step < 0)
break;
}
printf("Failed to init T.4 send\n");
exit(2);
}
- span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
- t4_tx_set_min_row_bits(&send_state, min_row_bits);
+ span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
+ t4_tx_set_min_bits_per_row(&send_state, min_row_bits);
t4_tx_set_local_ident(&send_state, "111 2222 3333");
/* Receive end puts TIFF to a new file. */
printf("Failed to init T.4 rx for '%s'\n", OUT_FILE_NAME);
exit(2);
}
- span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
+ span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state));
t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state));
t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state));
t4_tx_set_header_info(&send_state, "Header");
else
t4_tx_set_header_info(&send_state, NULL);
+ if (page_header_tz && page_header_tz[0])
+ t4_tx_set_header_tz(&send_state, page_header_tz);
+ //t4_tx_set_header_overlays_image(&send_state, overlay_page_headers);
if (restart_pages && (sends & 1))
{
/* Use restart, to send the page a second time */
if (compression_step >= 0)
{
compression = compression_sequence[compression_step++];
- if (compression_step > 2)
+ if (compression < 0)
+ {
compression_step = 0;
+ compression = compression_sequence[compression_step++];
+ }
}
t4_tx_set_tx_encoding(&send_state, compression);
t4_rx_set_rx_encoding(&receive_state, compression);
t4_rx_start_page(&receive_state);
detect_page_end(-1000000, compression);
page_ended = FALSE;
- if (block_size == 0)
+ switch (block_size)
{
+ case 0:
for (;;)
{
bit = t4_tx_get_bit(&send_state);
{
t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
}
- }
- else if (block_size == 1)
- {
+ break;
+ case 1:
do
{
bit = t4_tx_get_byte(&send_state);
end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
}
while (!end_of_page);
- }
- else
- {
+ if ((t4_tx_get_byte(&send_state) & 0x100) == 0)
+ {
+ printf("Page ended, but source is not reporting end of data\n");
+ tests_failed++;
+ }
+ break;
+ default:
do
{
bit = t4_tx_get_chunk(&send_state, block, block_size);
}
}
while (!end_of_page);
+ break;
}
if (dump_as_xxx)
dump_image_as_xxx(&receive_state);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: testadsi.c,v 1.23 2009/05/30 15:23:14 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: testfax.c,v 1.33 2009/05/30 15:23:14 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: time_scale_tests.c,v 1.24 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page time_scale_tests_page Time scaling tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_detect_tests.c,v 1.12 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page tone_detect_tests_page Tone detection tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tone_generate_tests.c,v 1.23 2010/05/22 13:20:18 steveu Exp $
*/
/*! \page tone_generate_tests_page Tone generation tests
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: tsb85_tests.c,v 1.32 2009/05/30 15:23:14 steveu Exp $
*/
/*! \file */
while (*t)
{
/* Skip white space */
- while (isspace(*t))
+ while (isspace((int) *t))
t++;
/* If we find ... we allow arbitrary addition info beyond this point in the message */
if (t[0] == '.' && t[1] == '.' && t[2] == '.')
{
return -i;
}
- else if (isxdigit(*t))
+ else if (isxdigit((int) *t))
{
- for ( ; isxdigit(*t); t++)
+ for ( ; isxdigit((int) *t); t++)
{
x = *t;
if (x >= 'a')
{
/* There is a mask following the byte */
mask[i] = 0;
- for (t++; isxdigit(*t); t++)
+ for (t++; isxdigit((int) *t); t++)
{
x = *t;
if (x >= 'a')
mask[i] = (mask[i] << 4) | x;
}
}
- if (*t && !isspace(*t))
+ if (*t && !isspace((int) *t))
{
/* Bad string */
return 0;
t = bad_rows;
while (*t)
{
- while (isspace(*t))
+ while (isspace((int) *t))
t++;
if (sscanf(t, "%d", &list[x]) < 1)
break;
x++;
- while (isdigit(*t))
+ while (isdigit((int) *t))
t++;
if (*t == ',')
t++;
int compression_type;
int timer;
int len;
- t4_state_t t4_state;
+ t4_state_t t4_tx_state;
t30_state_t *t30;
if (s->cur == NULL)
/* A non-ECM page */
min_row_bits = (min_bits) ? atoi((const char *) min_bits) : 0;
sprintf(path, "%s/%s", image_path, (const char *) value);
- if (t4_tx_init(&t4_state, path, -1, -1) == NULL)
+ if (t4_tx_init(&t4_tx_state, path, -1, -1) == NULL)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n");
printf("Test failed\n");
exit(2);
}
- t4_tx_set_min_row_bits(&t4_state, min_row_bits);
- t4_tx_set_header_info(&t4_state, NULL);
+ t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits);
+ t4_tx_set_header_info(&t4_tx_state, NULL);
compression_type = T4_COMPRESSION_ITU_T4_1D;
if (compression)
{
else if (strcasecmp((const char *) compression, "T.6") == 0)
compression_type = T4_COMPRESSION_ITU_T6;
}
- t4_tx_set_tx_encoding(&t4_state, compression_type);
- if (t4_tx_start_page(&t4_state))
+ t4_tx_set_tx_encoding(&t4_tx_state, compression_type);
+ if (t4_tx_start_page(&t4_tx_state))
{
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n");
printf("Test failed\n");
exit(2);
}
- len = t4_tx_get_chunk(&t4_state, image, sizeof(image));
+ len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image));
if (bad_rows)
{
span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n");
corrupt_image(s, image, len, (const char *) bad_rows);
}
- t4_tx_release(&t4_state);
+ t4_tx_release(&t4_tx_state);
span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM image is %d bytes\n", len);
faxtester_set_non_ecm_image_buffer(s, image, len);
}
ecm_frame_size = (frame_size) ? atoi((const char *) frame_size) : 64;
i = (crc_error) ? atoi((const char *) crc_error) : -1;
sprintf(path, "%s/%s", image_path, (const char *) value);
- if (t4_tx_init(&t4_state, path, -1, -1) == NULL)
+ if (t4_tx_init(&t4_tx_state, path, -1, -1) == NULL)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n");
printf("Test failed\n");
exit(2);
}
- t4_tx_set_min_row_bits(&t4_state, min_row_bits);
- t4_tx_set_header_info(&t4_state, NULL);
+ t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits);
+ t4_tx_set_header_info(&t4_tx_state, NULL);
compression_type = T4_COMPRESSION_ITU_T4_1D;
if (compression)
{
else if (strcasecmp((const char *) compression, "T.6") == 0)
compression_type = T4_COMPRESSION_ITU_T6;
}
- t4_tx_set_tx_encoding(&t4_state, compression_type);
- if (t4_tx_start_page(&t4_state))
+ t4_tx_set_tx_encoding(&t4_tx_state, compression_type);
+ if (t4_tx_start_page(&t4_tx_state))
{
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n");
printf("Test failed\n");
exit(2);
}
/*endif*/
- len = t4_tx_get_chunk(&t4_state, image, sizeof(image));
+ len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image));
if (bad_rows)
{
span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n");
corrupt_image(s, image, len, (const char *) bad_rows);
}
/*endif*/
- t4_tx_release(&t4_state);
+ t4_tx_release(&t4_tx_state);
span_log(&s->logging, SPAN_LOG_FLOW, "ECM image is %d bytes\n", len);
faxtester_set_ecm_image_buffer(s, image, len, ecm_block, ecm_frame_size, i);
}
int main(int argc, char *argv[])
{
+ const char *xml_file_name;
const char *test_name;
+ int opt;
- //string_test();
+#if 0
+ string_test();
+#endif
+ xml_file_name = "../spandsp/tsb85.xml";
test_name = "MRGN01";
- if (argc > 1)
- test_name = argv[1];
+ while ((opt = getopt(argc, argv, "x:")) != -1)
+ {
+ switch (opt)
+ {
+ case 'x':
+ xml_file_name = optarg;
+ break;
+ default:
+ //usage();
+ exit(2);
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc > 0)
+ test_name = argv[0];
strcpy(image_path, ".");
faxtester_init(&state, TRUE);
memset(&expected_rx_info, 0, sizeof(expected_rx_info));
span_log_set_level(&state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
span_log_set_tag(&state.logging, "B");
- get_test_set(&state, "../spandsp/tsb85.xml", test_name);
+ get_test_set(&state, xml_file_name, test_name);
printf("Done\n");
return 0;
}
-#!/bin/bash
+#!/bin/sh
#
# spandsp fax tests
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: tsb85_tests.sh,v 1.8 2009/05/24 07:18:36 steveu Exp $
-#
run_tsb85_test()
{
--- /dev/null
+//#define UDPTL_DEBUG
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * udptl.c
+ *
+ * Written by Steve Underwood <steveu@coppice.org>
+ *
+ * Copyright (C) 2009 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <inttypes.h>
+#include <memory.h>
+
+#include "udptl.h"
+
+#define FALSE 0
+#define TRUE (!FALSE)
+
+static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue)
+{
+ if (*len >= limit)
+ return -1;
+ if ((buf[*len] & 0x80) == 0)
+ {
+ *pvalue = buf[(*len)++];
+ return 0;
+ }
+ if ((buf[*len] & 0x40) == 0)
+ {
+ if (*len >= limit - 1)
+ return -1;
+ *pvalue = (buf[(*len)++] & 0x3F) << 8;
+ *pvalue |= buf[(*len)++];
+ return 0;
+ }
+ *pvalue = (buf[(*len)++] & 0x3F) << 14;
+ /* Indicate we have a fragment */
+ return 1;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int decode_open_type(const uint8_t *buf, int limit, int *len, const uint8_t ** p_object, int *p_num_octets)
+{
+ int octet_cnt;
+ int octet_idx;
+ int stat;
+ int i;
+ const uint8_t **pbuf;
+
+ for (octet_idx = 0, *p_num_octets = 0;; octet_idx += octet_cnt)
+ {
+ if ((stat = decode_length(buf, limit, len, &octet_cnt)) < 0)
+ return -1;
+ if (octet_cnt > 0)
+ {
+ *p_num_octets += octet_cnt;
+
+ pbuf = &p_object[octet_idx];
+ i = 0;
+ /* Make sure the buffer contains at least the number of bits requested */
+ if ((*len + octet_cnt) > limit)
+ return -1;
+
+ *pbuf = &buf[*len];
+ *len += octet_cnt;
+ }
+ if (stat == 0)
+ break;
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int encode_length(uint8_t *buf, int *len, int value)
+{
+ int multiplier;
+
+ if (value < 0x80)
+ {
+ /* 1 octet */
+ buf[(*len)++] = value;
+ return value;
+ }
+ if (value < 0x4000)
+ {
+ /* 2 octets */
+ /* Set the first bit of the first octet */
+ buf[(*len)++] = ((0x8000 | value) >> 8) & 0xFF;
+ buf[(*len)++] = value & 0xFF;
+ return value;
+ }
+ /* Fragmentation */
+ multiplier = (value < 0x10000) ? (value >> 14) : 4;
+ /* Set the first 2 bits of the octet */
+ buf[(*len)++] = 0xC0 | multiplier;
+ return multiplier << 14;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int encode_open_type(uint8_t *buf, int *len, const uint8_t *data, int num_octets)
+{
+ int enclen;
+ int octet_idx;
+ uint8_t zero_byte;
+
+ /* If open type is of zero length, add a single zero byte (10.1) */
+ if (num_octets == 0)
+ {
+ zero_byte = 0;
+ data = &zero_byte;
+ num_octets = 1;
+ }
+ /* Encode the open type */
+ for (octet_idx = 0;; num_octets -= enclen, octet_idx += enclen)
+ {
+ if ((enclen = encode_length(buf, len, num_octets)) < 0)
+ return -1;
+ if (enclen > 0)
+ {
+ memcpy(&buf[*len], &data[octet_idx], enclen);
+ *len += enclen;
+ }
+ if (enclen >= num_octets)
+ break;
+ }
+
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
+{
+ int stat;
+ int stat2;
+ int i;
+ int j;
+ int k;
+ int l;
+ int m;
+ int x;
+ int limit;
+ int which;
+ int ptr;
+ int count;
+ int total_count;
+ int seq_no;
+ const uint8_t *msg;
+ const uint8_t *data;
+ int msg_len;
+ int repaired[16];
+ const uint8_t *bufs[16];
+ int lengths[16];
+ int span;
+ int entries;
+
+ ptr = 0;
+ /* Decode seq_number */
+ if (ptr + 2 > len)
+ return -1;
+ seq_no = (buf[0] << 8) | buf[1];
+ ptr += 2;
+ /* Break out the primary packet */
+ if ((stat = decode_open_type(buf, len, &ptr, &msg, &msg_len)) != 0)
+ return -1;
+ /* Decode error_recovery */
+ if (ptr + 1 > len)
+ return -1;
+ /* Our buffers cannot tolerate overlength packets */
+ if (msg_len > LOCAL_FAX_MAX_DATAGRAM)
+ return -1;
+ /* Update any missed slots in the buffer */
+ for (i = s->rx_seq_no; seq_no > i; i++)
+ {
+ x = i & UDPTL_BUF_MASK;
+ s->rx[x].buf_len = -1;
+ s->rx[x].fec_len[0] = 0;
+ s->rx[x].fec_span = 0;
+ s->rx[x].fec_entries = 0;
+ }
+ /* Save the new packet. Pure redundancy mode won't use this, but some systems will switch
+ into FEC mode after sending some redundant packets. */
+ x = seq_no & UDPTL_BUF_MASK;
+ memcpy(s->rx[x].buf, msg, msg_len);
+ s->rx[x].buf_len = msg_len;
+ s->rx[x].fec_len[0] = 0;
+ s->rx[x].fec_span = 0;
+ s->rx[x].fec_entries = 0;
+ if ((buf[ptr++] & 0x80) == 0)
+ {
+ /* Secondary packet mode for error recovery */
+ /* We might have the packet we want, but we need to check through
+ the redundant stuff, and verify the integrity of the UDPTL.
+ This greatly reduces our chances of accepting garbage. */
+ total_count = 0;
+ do
+ {
+ if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0)
+ return -1;
+ for (i = 0; i < count; i++)
+ {
+ if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0)
+ return -1;
+ }
+ total_count += count;
+ }
+ while (stat2 > 0);
+ /* We should now be exactly at the end of the packet. If not, this is a fault. */
+ if (ptr != len)
+ return -1;
+ if (seq_no > s->rx_seq_no)
+ {
+ /* We received a later packet than we expected, so we need to check if we can fill in the gap from the
+ secondary packets. */
+ /* Step through in reverse order, so we go oldest to newest */
+ for (i = total_count; i > 0; i--)
+ {
+ if (seq_no - i >= s->rx_seq_no)
+ {
+ /* This one wasn't seen before */
+ /* Decode the secondary packet */
+#if defined(UDPTL_DEBUG)
+ fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]);
+#endif
+ /* Save the new packet. Redundancy mode won't use this, but some systems will switch into
+ FEC mode after sending some redundant packets, and this may then be important. */
+ x = (seq_no - i) & UDPTL_BUF_MASK;
+ memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
+ s->rx[x].buf_len = lengths[i - 1];
+ s->rx[x].fec_len[0] = 0;
+ s->rx[x].fec_span = 0;
+ s->rx[x].fec_entries = 0;
+ if (s->rx_packet_handler(s->user_data, bufs[i - 1], lengths[i - 1], seq_no - i) < 0)
+ fprintf(stderr, "Bad IFP\n");
+ }
+ }
+ }
+ }
+ else
+ {
+ /* FEC mode for error recovery */
+
+ /* Decode the FEC packets */
+ /* The span is defined as an unconstrained integer, but will never be more
+ than a small value. */
+ if (ptr + 2 > len)
+ return -1;
+ if (buf[ptr++] != 1)
+ return -1;
+ span = buf[ptr++];
+
+ x = seq_no & UDPTL_BUF_MASK;
+
+ s->rx[x].fec_span = span;
+
+ memset(repaired, 0, sizeof(repaired));
+ repaired[x] = TRUE;
+
+ /* The number of entries is defined as a length, but will only ever be a small
+ value. Treat it as such. */
+ if (ptr + 1 > len)
+ return -1;
+ entries = buf[ptr++];
+ s->rx[x].fec_entries = entries;
+
+ /* Decode the elements */
+ for (i = 0; i < entries; i++)
+ {
+ if ((stat = decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i])) != 0)
+ return -1;
+ if (s->rx[x].fec_len[i] > LOCAL_FAX_MAX_DATAGRAM)
+ return -1;
+
+ /* Save the new FEC data */
+ memcpy(s->rx[x].fec[i], data, s->rx[x].fec_len[i]);
+#if 0
+ fprintf(stderr, "FEC: ");
+ for (j = 0; j < s->rx[x].fec_len[i]; j++)
+ fprintf(stderr, "%02X ", data[j]);
+ fprintf(stderr, "\n");
+#endif
+ }
+ /* We should now be exactly at the end of the packet. If not, this is a fault. */
+ if (ptr != len)
+ return -1;
+ /* See if we can reconstruct anything which is missing */
+ /* TODO: this does not comprehensively hunt back and repair everything that is possible */
+ for (l = x; l != ((x - (16 - span * entries)) & UDPTL_BUF_MASK); l = (l - 1) & UDPTL_BUF_MASK)
+ {
+ if (s->rx[l].fec_len[0] <= 0)
+ continue;
+ for (m = 0; m < s->rx[l].fec_entries; m++)
+ {
+ limit = (l + m) & UDPTL_BUF_MASK;
+ for (which = -1, k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit;
+ k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
+ {
+ if (s->rx[k].buf_len <= 0)
+ which = (which == -1) ? k : -2;
+ }
+ if (which >= 0)
+ {
+ /* Repairable */
+ for (j = 0; j < s->rx[l].fec_len[m]; j++)
+ {
+ s->rx[which].buf[j] = s->rx[l].fec[m][j];
+ for (k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit;
+ k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
+ s->rx[which].buf[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0;
+ }
+ s->rx[which].buf_len = s->rx[l].fec_len[m];
+ repaired[which] = TRUE;
+ }
+ }
+ }
+ /* Now play any new packets forwards in time */
+ for (l = (x + 1) & UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) & UDPTL_BUF_MASK, j++)
+ {
+ if (repaired[l])
+ {
+#if defined(UDPTL_DEBUG)
+ fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
+#endif
+ if (s->rx_packet_handler(s->user_data, s->rx[l].buf, s->rx[l].buf_len, j) < 0)
+ fprintf(stderr, "Bad IFP\n");
+ }
+ }
+ }
+ /* If packets are received out of sequence, we may have already processed this packet from the error
+ recovery information in a packet already received. */
+ if (seq_no >= s->rx_seq_no)
+ {
+ /* Decode the primary packet */
+#if defined(UDPTL_DEBUG)
+ fprintf(stderr, "Primary packet %d, len %d\n", seq_no, msg_len);
+#endif
+ if (s->rx_packet_handler(s->user_data, msg, msg_len, seq_no) < 0)
+ fprintf(stderr, "Bad IFP\n");
+ }
+
+ s->rx_seq_no = (seq_no + 1) & 0xFFFF;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len)
+{
+ uint8_t fec[LOCAL_FAX_MAX_DATAGRAM];
+ int i;
+ int j;
+ int seq;
+ int entry;
+ int entries;
+ int span;
+ int m;
+ int len;
+ int limit;
+ int high_tide;
+
+ /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
+ maximum length. */
+ if (msg_len < 1 || msg_len > LOCAL_FAX_MAX_DATAGRAM)
+ return -1;
+ seq = s->tx_seq_no & 0xFFFF;
+
+ /* Map the sequence number to an entry in the circular buffer */
+ entry = seq & UDPTL_BUF_MASK;
+
+ /* We save the message in a circular buffer, for generating FEC or
+ redundancy sets later on. */
+ s->tx[entry].buf_len = msg_len;
+ memcpy(s->tx[entry].buf, msg, msg_len);
+
+ /* Build the UDPTL packet */
+
+ len = 0;
+ /* Encode the sequence number */
+ buf[len++] = (seq >> 8) & 0xFF;
+ buf[len++] = seq & 0xFF;
+
+ /* Encode the primary packet */
+ if (encode_open_type(buf, &len, msg, msg_len) < 0)
+ return -1;
+
+ /* Encode the appropriate type of error recovery information */
+ switch (s->error_correction_scheme)
+ {
+ case UDPTL_ERROR_CORRECTION_NONE:
+ /* Encode the error recovery type */
+ buf[len++] = 0x00;
+ /* The number of entries will always be zero, so it is pointless allowing
+ for the fragmented case here. */
+ if (encode_length(buf, &len, 0) < 0)
+ return -1;
+ break;
+ case UDPTL_ERROR_CORRECTION_REDUNDANCY:
+ /* Encode the error recovery type */
+ buf[len++] = 0x00;
+ if (s->tx_seq_no > s->error_correction_entries)
+ entries = s->error_correction_entries;
+ else
+ entries = s->tx_seq_no;
+ /* The number of entries will always be small, so it is pointless allowing
+ for the fragmented case here. */
+ if (encode_length(buf, &len, entries) < 0)
+ return -1;
+ /* Encode the elements */
+ for (i = 0; i < entries; i++)
+ {
+ j = (entry - i - 1) & UDPTL_BUF_MASK;
+ if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0)
+ return -1;
+ }
+ break;
+ case UDPTL_ERROR_CORRECTION_FEC:
+ span = s->error_correction_span;
+ entries = s->error_correction_entries;
+ if (seq < s->error_correction_span * s->error_correction_entries)
+ {
+ /* In the initial stages, wind up the FEC smoothly */
+ entries = seq / s->error_correction_span;
+ if (seq < s->error_correction_span)
+ span = 0;
+ }
+ /* Encode the error recovery type */
+ buf[len++] = 0x80;
+ /* Span is defined as an inconstrained integer, which it dumb. It will only
+ ever be a small value. Treat it as such. */
+ buf[len++] = 1;
+ buf[len++] = span;
+ /* The number of entries is defined as a length, but will only ever be a small
+ value. Treat it as such. */
+ buf[len++] = entries;
+ for (m = 0; m < entries; m++)
+ {
+ /* Make an XOR'ed entry the maximum length */
+ limit = (entry + m) & UDPTL_BUF_MASK;
+ high_tide = 0;
+ for (i = (limit - span * entries) & UDPTL_BUF_MASK; i != limit; i = (i + entries) & UDPTL_BUF_MASK)
+ {
+ if (high_tide < s->tx[i].buf_len)
+ {
+ for (j = 0; j < high_tide; j++)
+ fec[j] ^= s->tx[i].buf[j];
+ for (; j < s->tx[i].buf_len; j++)
+ fec[j] = s->tx[i].buf[j];
+ high_tide = s->tx[i].buf_len;
+ }
+ else
+ {
+ for (j = 0; j < s->tx[i].buf_len; j++)
+ fec[j] ^= s->tx[i].buf[j];
+ }
+ }
+ if (encode_open_type(buf, &len, fec, high_tide) < 0)
+ return -1;
+ }
+ break;
+ }
+
+ if (s->verbose)
+ fprintf(stderr, "\n");
+ s->tx_seq_no++;
+ return len;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_set_error_correction(udptl_state_t *s, int ec_scheme, int span, int entries)
+{
+ switch (ec_scheme)
+ {
+ case UDPTL_ERROR_CORRECTION_FEC:
+ case UDPTL_ERROR_CORRECTION_REDUNDANCY:
+ case UDPTL_ERROR_CORRECTION_NONE:
+ s->error_correction_scheme = ec_scheme;
+ break;
+ case -1:
+ /* Just don't change the scheme */
+ break;
+ default:
+ return -1;
+ }
+ if (span >= 0)
+ s->error_correction_span = span;
+ if (entries >= 0)
+ s->error_correction_entries = entries;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_get_error_correction(udptl_state_t *s, int *ec_scheme, int *span, int *entries)
+{
+ if (ec_scheme)
+ *ec_scheme = s->error_correction_scheme;
+ if (span)
+ *span = s->error_correction_span;
+ if (entries)
+ *entries = s->error_correction_entries;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram)
+{
+ s->local_max_datagram_size = max_datagram;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_get_local_max_datagram(udptl_state_t *s)
+{
+ return s->local_max_datagram_size;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram)
+{
+ s->far_max_datagram_size = max_datagram;
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_get_far_max_datagram(udptl_state_t *s)
+{
+ return s->far_max_datagram_size;
+}
+/*- End of function --------------------------------------------------------*/
+
+udptl_state_t *udptl_init(udptl_state_t *s, int ec_scheme, int span, int entries, udptl_rx_packet_handler_t rx_packet_handler, void *user_data)
+{
+ int i;
+
+ if (rx_packet_handler == NULL)
+ return NULL;
+
+ if (s == NULL)
+ {
+ if ((s = (udptl_state_t *) malloc(sizeof(*s))) == NULL)
+ return NULL;
+ }
+ memset(s, 0, sizeof(*s));
+
+ s->error_correction_scheme = ec_scheme;
+ s->error_correction_span = span;
+ s->error_correction_entries = entries;
+
+ s->far_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
+ s->local_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
+
+ memset(&s->rx, 0, sizeof(s->rx));
+ memset(&s->tx, 0, sizeof(s->tx));
+ for (i = 0; i <= UDPTL_BUF_MASK; i++)
+ {
+ s->rx[i].buf_len = -1;
+ s->tx[i].buf_len = -1;
+ }
+
+ s->rx_packet_handler = rx_packet_handler;
+ s->user_data = user_data;
+
+ return s;
+}
+/*- End of function --------------------------------------------------------*/
+
+int udptl_release(udptl_state_t *s)
+{
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
--- /dev/null
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * udptl.c
+ *
+ * Written by Steve Underwood <steveu@coppice.org>
+ *
+ * Copyright (C) 2009 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#if !defined(_SPANDSP_UDPTL_H_)
+#define _SPANDSP_UDPTL_H_
+
+#define LOCAL_FAX_MAX_DATAGRAM 400
+#define LOCAL_FAX_MAX_FEC_PACKETS 5
+
+#define UDPTL_BUF_MASK 15
+
+typedef int (udptl_rx_packet_handler_t) (void *user_data, const uint8_t msg[], int len, int seq_no);
+
+typedef struct
+{
+ int buf_len;
+ uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
+} udptl_fec_tx_buffer_t;
+
+typedef struct
+{
+ int buf_len;
+ uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
+ int fec_len[LOCAL_FAX_MAX_FEC_PACKETS];
+ uint8_t fec[LOCAL_FAX_MAX_FEC_PACKETS][LOCAL_FAX_MAX_DATAGRAM];
+ int fec_span;
+ int fec_entries;
+} udptl_fec_rx_buffer_t;
+
+struct udptl_state_s
+{
+ udptl_rx_packet_handler_t *rx_packet_handler;
+ void *user_data;
+
+ /*! This option indicates the error correction scheme used in transmitted UDPTL
+ packets. */
+ int error_correction_scheme;
+
+ /*! This option indicates the number of error correction entries transmitted in
+ UDPTL packets. */
+ int error_correction_entries;
+
+ /*! This option indicates the span of the error correction entries in transmitted
+ UDPTL packets (FEC only). */
+ int error_correction_span;
+
+ /*! This option indicates the maximum size of a datagram that can be accepted by
+ the remote device. */
+ int far_max_datagram_size;
+
+ /*! This option indicates the maximum size of a datagram that we are prepared to
+ accept. */
+ int local_max_datagram_size;
+
+ int verbose;
+
+ int tx_seq_no;
+ int rx_seq_no;
+ int rx_expected_seq_no;
+
+ udptl_fec_tx_buffer_t tx[UDPTL_BUF_MASK + 1];
+ udptl_fec_rx_buffer_t rx[UDPTL_BUF_MASK + 1];
+};
+
+enum
+{
+ UDPTL_ERROR_CORRECTION_NONE,
+ UDPTL_ERROR_CORRECTION_FEC,
+ UDPTL_ERROR_CORRECTION_REDUNDANCY
+};
+
+typedef struct udptl_state_s udptl_state_t;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*! \brief Process an arriving UDPTL packet.
+ \param s The UDPTL context.
+ \param buf The UDPTL packet buffer.
+ \param len The length of the packet.
+ \return 0 for OK. */
+int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len);
+
+/*! \brief Construct a UDPTL packet, ready for transmission.
+ \param s The UDPTL context.
+ \param buf The UDPTL packet buffer.
+ \param msg The primary packet.
+ \param len The length of the primary packet.
+ \return The length of the constructed UDPTL packet. */
+int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len);
+
+/*! \brief Change the error correction settings of a UDPTL context.
+ \param s The UDPTL context.
+ \param ec_scheme One of the optional error correction schemes.
+ \param span The packet span over which error correction should be applied.
+ \param entries The number of error correction entries to include in packets.
+ \return 0 for OK. */
+int udptl_set_error_correction(udptl_state_t *s, int ec_scheme, int span, int entries);
+
+/*! \brief Check the error correction settings of a UDPTL context.
+ \param s The UDPTL context.
+ \param ec_scheme One of the optional error correction schemes.
+ \param span The packet span over which error correction is being applied.
+ \param entries The number of error correction being included in packets.
+ \return 0 for OK. */
+int udptl_get_error_correction(udptl_state_t *s, int *ec_scheme, int *span, int *entries);
+
+int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram);
+
+int udptl_get_local_max_datagram(udptl_state_t *s);
+
+int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram);
+
+int udptl_get_far_max_datagram(udptl_state_t *s);
+
+/*! \brief Initialise a UDPTL context.
+ \param s The UDPTL context.
+ \param ec_scheme One of the optional error correction schemes.
+ \param span The packet span over which error correction should be applied.
+ \param entries The number of error correction entries to include in packets.
+ \param rx_packet_handler The callback function, used to report arriving IFP packets.
+ \param user_data An opaque pointer supplied to rx_packet_handler.
+ \return A pointer to the UDPTL context, or NULL if there was a problem. */
+udptl_state_t *udptl_init(udptl_state_t *s, int ec_scheme, int span, int entries, udptl_rx_packet_handler_t rx_packet_handler, void *user_data);
+
+/*! \brief Release a UDPTL context.
+ \param s The UDPTL context.
+ \return 0 for OK. */
+int udptl_release(udptl_state_t *s);
+
+#if defined(__cplusplus)
+}
+#endif
+#endif
+/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v17_tests.c,v 1.104 2009/07/09 13:52:09 steveu Exp $
*/
/*! \page v17_tests_page V.17 modem tests
#include <unistd.h>
#include <string.h>
#include <sndfile.h>
+#include <signal.h>
+#if defined(HAVE_FENV_H)
+#include <fenv.h>
+#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
}
/*- End of function --------------------------------------------------------*/
+#if defined(HAVE_FENV_H)
+static void sigfpe_handler(int sig_num, siginfo_t *info, void *data)
+{
+ switch (sig_num)
+ {
+ case SIGFPE:
+ switch (info->si_code)
+ {
+ case FPE_INTDIV:
+ fprintf(stderr, "integer divide by zero at %p\n", info->si_addr);
+ break;
+ case FPE_INTOVF:
+ fprintf(stderr, "integer overflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTDIV:
+ fprintf(stderr, "FP divide by zero at %p\n", info->si_addr);
+ break;
+ case FPE_FLTOVF:
+ fprintf(stderr, "FP overflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTUND:
+ fprintf(stderr, "FP underflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTRES:
+ fprintf(stderr, "FP inexact result at %p\n", info->si_addr);
+ break;
+ case FPE_FLTINV:
+ fprintf(stderr, "FP invalid operation at %p\n", info->si_addr);
+ break;
+ case FPE_FLTSUB:
+ fprintf(stderr, "subscript out of range at %p\n", info->si_addr);
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "Unexpected signal %d\n", sig_num);
+ break;
+ }
+ exit(2);
+}
+/*- End of function --------------------------------------------------------*/
+
+static void fpe_trap_setup(void)
+{
+ struct sigaction trap;
+
+ sigemptyset(&trap.sa_mask);
+ trap.sa_flags = SA_SIGINFO;
+ trap.sa_sigaction = sigfpe_handler;
+
+ sigaction(SIGFPE, &trap, NULL);
+ //feenableexcept(FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);
+ //feenableexcept(FE_ALL_EXCEPT);
+ feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
int main(int argc, char *argv[])
{
v17_rx_state_t *rx;
{
case 'b':
test_bps = atoi(optarg);
- if (test_bps != 14400 && test_bps != 12000 && test_bps != 9600 && test_bps != 7200)
+ if (test_bps != 14400
+ &&
+ test_bps != 12000
+ &&
+ test_bps != 9600
+ &&
+ test_bps != 7200
+ &&
+ test_bps != 4800)
{
+ /* 4800 is an extension of V.17, to provide full coverage of the V.32bis modes */
fprintf(stderr, "Invalid bit rate specified\n");
exit(2);
}
inhandle = NULL;
outhandle = NULL;
+#if defined(HAVE_FENV_H)
+ fpe_trap_setup();
+#endif
+
if (log_audio)
{
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
printf("Restarting on zero output\n");
/* Push a little silence through, to ensure all the data bits get out of the buffers */
- memset(amp, 0, BLOCK_LEN*sizeof(int16_t));
+ vec_zeroi16(amp, BLOCK_LEN);
v17_rx(rx, amp, BLOCK_LEN);
/* Note that we might get a few bad bits as the carrier shuts down. */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v18_tests.c,v 1.8 2009/05/30 15:23:14 steveu Exp $
*/
/*! \page v18_tests_page V.18 tests
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v22bis_tests.c,v 1.63 2009/07/09 13:52:09 steveu Exp $
*/
/*! \page v22bis_tests_page V.22bis modem tests
switch (bit)
{
case SIG_STATUS_TRAINING_SUCCEEDED:
- bit_rate = v22bis_current_bit_rate(s->v22bis);
+ bit_rate = v22bis_get_current_bit_rate(s->v22bis);
printf("Negotiated bit rate: %d\n", bit_rate);
len = v22bis_rx_equalizer_state(s->v22bis, &coeffs);
printf("Equalizer:\n");
int signal_level;
int log_audio;
int channel_codec;
+ int rbs_pattern;
int opt;
channel_codec = MUNGE_CODEC_NONE;
+ rbs_pattern = 0;
test_bps = 2400;
line_model_no = 0;
decode_test_file = NULL;
signal_level = -13;
bits_per_test = 50000;
log_audio = FALSE;
- while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:s:")) != -1)
+ while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:r:s:")) != -1)
{
switch (opt)
{
case 'n':
noise_level = atoi(optarg);
break;
+ case 'r':
+ rbs_pattern = atoi(optarg);
+ break;
case 's':
signal_level = atoi(optarg);
break;
endpoint[1].qam_monitor = qam_monitor_init(6.0f, "Answering modem");
}
#endif
- if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, line_model_no, (float) noise_level, channel_codec, 0)) == NULL)
+ if ((model = both_ways_line_model_init(line_model_no,
+ (float) noise_level,
+ -15.0f,
+ -15.0f,
+ line_model_no,
+ (float) noise_level,
+ -15.0f,
+ -15.0f,
+ channel_codec,
+ rbs_pattern)) == NULL)
{
fprintf(stderr, " Failed to create line model\n");
exit(2);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v27ter_tests.c,v 1.106 2009/07/09 13:52:09 steveu Exp $
*/
/*! \page v27ter_tests_page V.27ter modem tests
#include <unistd.h>
#include <string.h>
#include <sndfile.h>
+#include <signal.h>
+#if defined(HAVE_FENV_H)
+#include <fenv.h>
+#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
}
/*- End of function --------------------------------------------------------*/
+#if defined(HAVE_FENV_H)
+static void sigfpe_handler(int sig_num, siginfo_t *info, void *data)
+{
+ switch (sig_num)
+ {
+ case SIGFPE:
+ switch (info->si_code)
+ {
+ case FPE_INTDIV:
+ fprintf(stderr, "integer divide by zero at %p\n", info->si_addr);
+ break;
+ case FPE_INTOVF:
+ fprintf(stderr, "integer overflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTDIV:
+ fprintf(stderr, "FP divide by zero at %p\n", info->si_addr);
+ break;
+ case FPE_FLTOVF:
+ fprintf(stderr, "FP overflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTUND:
+ fprintf(stderr, "FP underflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTRES:
+ fprintf(stderr, "FP inexact result at %p\n", info->si_addr);
+ break;
+ case FPE_FLTINV:
+ fprintf(stderr, "FP invalid operation at %p\n", info->si_addr);
+ break;
+ case FPE_FLTSUB:
+ fprintf(stderr, "subscript out of range at %p\n", info->si_addr);
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "Unexpected signal %d\n", sig_num);
+ break;
+ }
+ exit(2);
+}
+/*- End of function --------------------------------------------------------*/
+
+static void fpe_trap_setup(void)
+{
+ struct sigaction trap;
+
+ sigemptyset(&trap.sa_mask);
+ trap.sa_flags = SA_SIGINFO;
+ trap.sa_sigaction = sigfpe_handler;
+
+ sigaction(SIGFPE, &trap, NULL);
+ //feenableexcept(FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);
+ //feenableexcept(FE_ALL_EXCEPT);
+ feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
int main(int argc, char *argv[])
{
v27ter_rx_state_t *rx;
inhandle = NULL;
outhandle = NULL;
+#if defined(HAVE_FENV_H)
+ fpe_trap_setup();
+#endif
+
if (log_audio)
{
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
printf("Restarting on zero output\n");
/* Push a little silence through, to ensure all the data bits get out of the buffers */
- memset(amp, 0, BLOCK_LEN*sizeof(int16_t));
+ vec_zeroi16(amp, BLOCK_LEN);
v27ter_rx(rx, amp, BLOCK_LEN);
v27ter_rx(rx, amp, BLOCK_LEN);
v27ter_rx(rx, amp, BLOCK_LEN);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v29_tests.c,v 1.120 2009/07/09 13:52:09 steveu Exp $
*/
/*! \page v29_tests_page V.29 modem tests
#include <unistd.h>
#include <string.h>
#include <sndfile.h>
+#include <signal.h>
+#if defined(HAVE_FENV_H)
+#include <fenv.h>
+#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
}
/*- End of function --------------------------------------------------------*/
+#if defined(HAVE_FENV_H)
+static void sigfpe_handler(int sig_num, siginfo_t *info, void *data)
+{
+ switch (sig_num)
+ {
+ case SIGFPE:
+ switch (info->si_code)
+ {
+ case FPE_INTDIV:
+ fprintf(stderr, "integer divide by zero at %p\n", info->si_addr);
+ break;
+ case FPE_INTOVF:
+ fprintf(stderr, "integer overflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTDIV:
+ fprintf(stderr, "FP divide by zero at %p\n", info->si_addr);
+ break;
+ case FPE_FLTOVF:
+ fprintf(stderr, "FP overflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTUND:
+ fprintf(stderr, "FP underflow at %p\n", info->si_addr);
+ break;
+ case FPE_FLTRES:
+ fprintf(stderr, "FP inexact result at %p\n", info->si_addr);
+ break;
+ case FPE_FLTINV:
+ fprintf(stderr, "FP invalid operation at %p\n", info->si_addr);
+ break;
+ case FPE_FLTSUB:
+ fprintf(stderr, "subscript out of range at %p\n", info->si_addr);
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "Unexpected signal %d\n", sig_num);
+ break;
+ }
+ exit(2);
+}
+/*- End of function --------------------------------------------------------*/
+
+static void fpe_trap_setup(void)
+{
+ struct sigaction trap;
+
+ sigemptyset(&trap.sa_mask);
+ trap.sa_flags = SA_SIGINFO;
+ trap.sa_sigaction = sigfpe_handler;
+
+ sigaction(SIGFPE, &trap, NULL);
+ //feenableexcept(FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);
+ //feenableexcept(FE_ALL_EXCEPT);
+ feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
int main(int argc, char *argv[])
{
v29_rx_state_t *rx;
inhandle = NULL;
outhandle = NULL;
+#if defined(HAVE_FENV_H)
+ fpe_trap_setup();
+#endif
+
if (log_audio)
{
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
if (samples == 0)
{
/* Push a little silence through, to ensure all the data bits get out of the buffers */
- memset(amp, 0, BLOCK_LEN*sizeof(int16_t));
+ vec_zeroi16(amp, BLOCK_LEN);
v29_rx(rx, amp, BLOCK_LEN);
/* Note that we might get a few bad bits as the carrier shuts down. */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42_tests.c,v 1.28 2008/11/30 10:17:31 steveu Exp $
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v42bis_tests.c,v 1.24 2008/11/15 14:43:08 steveu Exp $
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: v42bis_tests.sh,v 1.5 2008/05/03 09:34:26 steveu Exp $
-#
BASE=../test-data/itu/v56ter
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: v8_tests.c,v 1.36.4.1 2009/12/28 12:32:53 steveu Exp $
*/
/*! \page v8_tests_page V.8 tests
int negotiations_ok = 0;
+#if 0
static int select_modulation(int mask)
{
/* Select the fastest data modem available */
if (mask & V8_MOD_V90)
return V8_MOD_V90;
+ /*endif*/
if (mask & V8_MOD_V34)
return V8_MOD_V34;
+ /*endif*/
if (mask & V8_MOD_V32)
return V8_MOD_V32;
+ /*endif*/
if (mask & V8_MOD_V23)
return V8_MOD_V23;
+ /*endif*/
if (mask & V8_MOD_V21)
return V8_MOD_V21;
- return V8_MOD_FAILED;
+ /*endif*/
+ return -1;
}
/*- End of function --------------------------------------------------------*/
+#endif
static void handler(void *user_data, v8_parms_t *result)
{
const char *s;
s = (const char *) user_data;
-
- if (result == NULL)
+
+ printf("%s ", s);
+ switch (result->status)
{
- printf("%s V.8 negotiation failed\n", s);
+ case V8_STATUS_IN_PROGRESS:
+ printf("V.8 negotiation in progress\n");
+ return;
+ break;
+ case V8_STATUS_V8_OFFERED:
+ printf("V.8 offered by the other party\n");
+ break;
+ case V8_STATUS_V8_CALL:
+ printf("V.8 call negotiation successful\n");
+ break;
+ case V8_STATUS_NON_V8_CALL:
+ printf("Non-V.8 call negotiation successful\n");
+ break;
+ case V8_STATUS_FAILED:
+ printf("V.8 call negotiation failed\n");
return;
+ default:
+ printf("Unexpected V.8 status %d\n", result->status);
+ break;
}
- if (result->modem_connect_tone == MODEM_CONNECT_TONES_ANSAM
- ||
- result->modem_connect_tone == MODEM_CONNECT_TONES_ANSAM_PR
- ||
- result->modem_connect_tone == MODEM_CONNECT_TONES_NONE)
+ /*endswitch*/
+
+ printf(" Modem connect tone '%s' (%d)\n", modem_connect_tone_to_str(result->modem_connect_tone), result->modem_connect_tone);
+ printf(" Call function '%s' (%d)\n", v8_call_function_to_str(result->call_function), result->call_function);
+ printf(" Far end modulations 0x%X\n", result->modulations);
+ printf(" Protocol '%s' (%d)\n", v8_protocol_to_str(result->protocol), result->protocol);
+ printf(" PSTN access '%s' (%d)\n", v8_pstn_access_to_str(result->pstn_access), result->pstn_access);
+ printf(" PCM modem availability '%s' (%d)\n", v8_pcm_modem_availability_to_str(result->pcm_modem_availability), result->pcm_modem_availability);
+ if (result->t66 >= 0)
+ printf(" T.66 '%s' (%d)\n", v8_t66_to_str(result->t66), result->t66);
+ /*endif*/
+ if (result->nsf >= 0)
+ printf(" NSF %d\n", result->nsf);
+ /*endif*/
+
+ switch (result->status)
{
- printf("%s V.8 negotiation result:\n", s);
- printf(" Modem connect tone '%s' (%d)\n", modem_connect_tone_to_str(result->modem_connect_tone), result->modem_connect_tone);
- printf(" Call function '%s' (%d)\n", v8_call_function_to_str(result->call_function), result->call_function);
- printf(" Far end modulations 0x%X\n", result->modulations);
- printf(" Protocol '%s' (%d)\n", v8_protocol_to_str(result->protocol), result->protocol);
- printf(" PSTN access '%s' (%d)\n", v8_pstn_access_to_str(result->pstn_access), result->pstn_access);
- printf(" PCM modem availability '%s' (%d)\n", v8_pcm_modem_availability_to_str(result->pcm_modem_availability), result->pcm_modem_availability);
- if (result->t66 >= 0)
- printf(" T.66 '%s' (%d)\n", v8_t66_to_str(result->t66), result->t66);
- if (result->nsf >= 0)
- printf(" NSF %d\n", result->nsf);
+ case V8_STATUS_V8_OFFERED:
+ /* Edit the result information appropriately */
+ //result->call_function = V8_CALL_T30_TX;
+ result->modulations &= (V8_MOD_V17
+ | V8_MOD_V21
+ //| V8_MOD_V22
+ //| V8_MOD_V23HDX
+ //| V8_MOD_V23
+ //| V8_MOD_V26BIS
+ //| V8_MOD_V26TER
+ | V8_MOD_V27TER
+ | V8_MOD_V29
+ //| V8_MOD_V32
+ | V8_MOD_V34HDX
+ //| V8_MOD_V34
+ //| V8_MOD_V90
+ | V8_MOD_V92);
+ break;
+ case V8_STATUS_V8_CALL:
if (result->call_function == V8_CALL_V_SERIES
&&
result->protocol == V8_PROTOCOL_LAPM_V42)
{
negotiations_ok++;
}
+ /*endif*/
+ break;
+ case V8_STATUS_NON_V8_CALL:
+ negotiations_ok = 42;
+ break;
}
- else
- {
- printf("%s V.8 negotiation result:\n", s);
- printf(" Modem connect tone '%s' (%d)\n", modem_connect_tone_to_str(result->modem_connect_tone), result->modem_connect_tone);
- }
+ /*endswitch*/
}
/*- End of function --------------------------------------------------------*/
caller_available_modulations = V8_MOD_V17
| V8_MOD_V21
| V8_MOD_V22
- | V8_MOD_V23HALF
+ | V8_MOD_V23HDX
| V8_MOD_V23
| V8_MOD_V26BIS
| V8_MOD_V26TER
| V8_MOD_V27TER
| V8_MOD_V29
| V8_MOD_V32
- | V8_MOD_V34HALF
+ | V8_MOD_V34HDX
| V8_MOD_V34
| V8_MOD_V90
| V8_MOD_V92;
answerer_available_modulations = V8_MOD_V17
| V8_MOD_V21
| V8_MOD_V22
- | V8_MOD_V23HALF
+ | V8_MOD_V23HDX
| V8_MOD_V23
| V8_MOD_V26BIS
| V8_MOD_V26TER
| V8_MOD_V27TER
| V8_MOD_V29
| V8_MOD_V32
- | V8_MOD_V34HALF
+ | V8_MOD_V34HDX
| V8_MOD_V34
| V8_MOD_V90
| V8_MOD_V92;
samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
if (samples < SAMPLES_PER_CHUNK)
{
- memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+ vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
samples = SAMPLES_PER_CHUNK;
}
+ /*endif*/
span_log_bump_samples(caller_logging, samples);
remnant = v8_rx(v8_answerer, amp, samples);
for (i = 0; i < samples; i++)
out_amp[2*i] = amp[i];
-
+ /*endfor*/
+
samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
if (samples < SAMPLES_PER_CHUNK)
{
- memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+ vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
samples = SAMPLES_PER_CHUNK;
}
+ /*endif*/
span_log_bump_samples(answerer_logging, samples);
if (v8_rx(v8_caller, amp, samples) && remnant)
break;
+ /*endif*/
for (i = 0; i < samples; i++)
out_amp[2*i + 1] = amp[i];
+ /*endfor*/
- outframes = sf_writef_short(outhandle, out_amp, samples);
- if (outframes != samples)
+ if (outhandle)
{
- fprintf(stderr, " Error writing audio file\n");
- exit(2);
+ outframes = sf_writef_short(outhandle, out_amp, samples);
+ if (outframes != samples)
+ {
+ fprintf(stderr, " Error writing audio file\n");
+ exit(2);
+ }
+ /*endif*/
}
+ /*endif*/
}
+ /*endfor*/
v8_free(v8_caller);
v8_free(v8_answerer);
printf("Tests failed.\n");
exit(2);
}
+ /*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
answerer_available_modulations = V8_MOD_V17
| V8_MOD_V21
| V8_MOD_V22
- | V8_MOD_V23HALF
+ | V8_MOD_V23HDX
| V8_MOD_V23
| V8_MOD_V26BIS
| V8_MOD_V26TER
| V8_MOD_V27TER
| V8_MOD_V29
| V8_MOD_V32
- | V8_MOD_V34HALF
+ | V8_MOD_V34HDX
| V8_MOD_V34
| V8_MOD_V90
| V8_MOD_V92;
samples = silence_gen(non_v8_caller_tx, amp, SAMPLES_PER_CHUNK);
if (samples < SAMPLES_PER_CHUNK)
{
- memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+ vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
samples = SAMPLES_PER_CHUNK;
}
+ /*endif*/
remnant = v8_rx(v8_answerer, amp, samples);
if (remnant)
break;
+ /*endif*/
for (i = 0; i < samples; i++)
out_amp[2*i] = amp[i];
-
+ /*endfor*/
+
samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
if (samples < SAMPLES_PER_CHUNK)
{
- memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+ vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
samples = SAMPLES_PER_CHUNK;
}
+ /*endif*/
span_log_bump_samples(answerer_logging, samples);
modem_connect_tones_rx(non_v8_caller_rx, amp, samples);
if ((tone = modem_connect_tones_rx_get(non_v8_caller_rx)) != MODEM_CONNECT_TONES_NONE)
printf("Detected %s (%d)\n", modem_connect_tone_to_str(tone), tone);
if (tone == MODEM_CONNECT_TONES_ANSAM_PR)
negotiations_ok++;
+ /*endif*/
}
+ /*endif*/
for (i = 0; i < samples; i++)
out_amp[2*i + 1] = amp[i];
+ /*endfor*/
- outframes = sf_writef_short(outhandle, out_amp, samples);
- if (outframes != samples)
+ if (outhandle)
{
- fprintf(stderr, " Error writing audio file\n");
- exit(2);
+ outframes = sf_writef_short(outhandle, out_amp, samples);
+ if (outframes != samples)
+ {
+ fprintf(stderr, " Error writing audio file\n");
+ exit(2);
+ }
+ /*endif*/
}
+ /*endif*/
}
+ /*endfor*/
silence_gen_free(non_v8_caller_tx);
modem_connect_tones_rx_free(non_v8_caller_rx);
v8_free(v8_answerer);
printf("Tests failed.\n");
exit(2);
}
+ /*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
caller_available_modulations = V8_MOD_V17
| V8_MOD_V21
| V8_MOD_V22
- | V8_MOD_V23HALF
+ | V8_MOD_V23HDX
| V8_MOD_V23
| V8_MOD_V26BIS
| V8_MOD_V26TER
| V8_MOD_V27TER
| V8_MOD_V29
| V8_MOD_V32
- | V8_MOD_V34HALF
+ | V8_MOD_V34HDX
| V8_MOD_V34
| V8_MOD_V90
| V8_MOD_V92;
samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
if (samples < SAMPLES_PER_CHUNK)
{
- memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+ vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
samples = SAMPLES_PER_CHUNK;
}
+ /*endif*/
span_log_bump_samples(caller_logging, samples);
for (i = 0; i < samples; i++)
out_amp[2*i] = amp[i];
-
+ /*endfor*/
+
samples = modem_connect_tones_tx(non_v8_answerer_tx, amp, SAMPLES_PER_CHUNK);
if (samples < SAMPLES_PER_CHUNK)
{
- memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+ vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
samples = SAMPLES_PER_CHUNK;
}
+ /*endif*/
if (v8_rx(v8_caller, amp, samples))
break;
+ /*endif*/
for (i = 0; i < samples; i++)
out_amp[2*i + 1] = amp[i];
+ /*endfor*/
- outframes = sf_writef_short(outhandle, out_amp, samples);
- if (outframes != samples)
+ if (outhandle)
{
- fprintf(stderr, " Error writing audio file\n");
- exit(2);
+ outframes = sf_writef_short(outhandle, out_amp, samples);
+ if (outframes != samples)
+ {
+ fprintf(stderr, " Error writing audio file\n");
+ exit(2);
+ }
+ /*endif*/
}
+ /*endif*/
}
+ /*endfor*/
v8_free(v8_caller);
modem_connect_tones_tx_free(non_v8_answerer_tx);
-#if 0
- if (negotiations_ok != 1)
+ if (negotiations_ok != 42)
{
printf("Tests failed.\n");
exit(2);
}
-#endif
+ /*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
SNDFILE *inhandle;
SNDFILE *outhandle;
int opt;
+ int log_audio;
char *decode_test_file;
v8_state_t *v8_caller;
v8_state_t *v8_answerer;
logging_state_t *logging;
decode_test_file = NULL;
- while ((opt = getopt(argc, argv, "d:")) != -1)
+ log_audio = FALSE;
+ while ((opt = getopt(argc, argv, "d:l")) != -1)
{
switch (opt)
{
case 'd':
decode_test_file = optarg;
break;
+ case 'l':
+ log_audio = TRUE;
+ break;
default:
//usage();
exit(2);
}
}
- caller_available_modulations = V8_MOD_V17
- | V8_MOD_V21
- | V8_MOD_V22
- | V8_MOD_V23HALF
- | V8_MOD_V23
- | V8_MOD_V26BIS
- | V8_MOD_V26TER
- | V8_MOD_V27TER
- | V8_MOD_V29
- | V8_MOD_V32
- | V8_MOD_V34HALF
- | V8_MOD_V34
- | V8_MOD_V90
- | V8_MOD_V92;
- answerer_available_modulations = V8_MOD_V17
- | V8_MOD_V21
- | V8_MOD_V22
- | V8_MOD_V23HALF
- | V8_MOD_V23
- | V8_MOD_V26BIS
- | V8_MOD_V26TER
- | V8_MOD_V27TER
- | V8_MOD_V29
- | V8_MOD_V32
- | V8_MOD_V34HALF
- | V8_MOD_V34
- | V8_MOD_V90
- | V8_MOD_V92;
-
- if (decode_test_file == NULL)
+ if (decode_test_file)
{
- if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
- {
- fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
- exit(2);
- }
+ caller_available_modulations = V8_MOD_V17
+ | V8_MOD_V21
+ | V8_MOD_V22
+ | V8_MOD_V23HDX
+ | V8_MOD_V23
+ | V8_MOD_V26BIS
+ | V8_MOD_V26TER
+ | V8_MOD_V27TER
+ | V8_MOD_V29
+ | V8_MOD_V32
+ | V8_MOD_V34HDX
+ | V8_MOD_V34
+ | V8_MOD_V90
+ | V8_MOD_V92;
+ answerer_available_modulations = V8_MOD_V17
+ | V8_MOD_V21
+ | V8_MOD_V22
+ | V8_MOD_V23HDX
+ | V8_MOD_V23
+ | V8_MOD_V26BIS
+ | V8_MOD_V26TER
+ | V8_MOD_V27TER
+ | V8_MOD_V29
+ | V8_MOD_V32
+ | V8_MOD_V34HDX
+ | V8_MOD_V34
+ | V8_MOD_V90
+ | V8_MOD_V92;
- printf("Test 1: V.8 terminal calls V.8 terminal\n");
- v8_calls_v8_tests(outhandle);
-
- printf("Test 2: non-V.8 terminal calls V.8 terminal\n");
- non_v8_calls_v8_tests(outhandle);
-
- printf("Test 3: V.8 terminal calls non-V.8 terminal\n");
- v8_calls_non_v8_tests(outhandle);
-
- if (sf_close(outhandle))
- {
- fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
- exit(2);
- }
-
- printf("Tests passed.\n");
- }
- else
- {
printf("Decode file '%s'\n", decode_test_file);
v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
v8_call_parms.call_function = V8_CALL_V_SERIES;
}
/*endif*/
}
- return 0;
+ else
+ {
+ outhandle = NULL;
+ if (log_audio)
+ {
+ if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
+ {
+ fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
+ exit(2);
+ }
+ /*endif*/
+ }
+ /*endif*/
+
+ printf("Test 1: V.8 terminal calls V.8 terminal\n");
+ v8_calls_v8_tests(outhandle);
+
+ printf("Test 2: non-V.8 terminal calls V.8 terminal\n");
+ non_v8_calls_v8_tests(outhandle);
+
+ printf("Test 3: V.8 terminal calls non-V.8 terminal\n");
+ v8_calls_non_v8_tests(outhandle);
+
+ if (outhandle)
+ {
+ if (sf_close(outhandle))
+ {
+ fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
+ exit(2);
+ }
+ /*endif*/
+ }
+ /*endif*/
+
+ printf("Tests passed.\n");
+ }
+ return 0;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: vector_float_tests.c,v 1.13 2009/04/26 07:00:39 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: vector_int_tests.c,v 1.11 2009/04/26 07:00:39 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: unpack_g722_data.sh,v 1.5 2008/05/03 07:55:04 steveu Exp $
-#
ITUDATA="../../../T-REC-G.722-198703-I!AppII!ZPF-E.zip"
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: unpack_g726_data.sh,v 1.6 2008/05/03 07:55:04 steveu Exp $
-#
ITUDATA="../../../T-REC-G.726-199103-I!AppII!SOFT-ZST-E.zip"
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: unpack_gsm0610_data.sh,v 1.7 2008/05/03 10:59:44 steveu Exp $
-#
# The ETSI distribution file extracts to 5 ZIP files, called DISK1.ZIP to DISK5.ZIP
# These were originally the contents of 5 floppy disks. Disks 1 to 3 contain data
# to make the .EXE files actually executable.
chmod 755 *.EXE
./FR_HOM_A.EXE >/dev/null
+ RETVAL=$?
+ if [ $RETVAL != 0 ]
+ then
+ echo Cannot run ./FR_HOM_A.EXE
+ exit $RETVAL
+ fi
./FR_SYN_A.EXE >/dev/null
+ RETVAL=$?
+ if [ $RETVAL != 0 ]
+ then
+ echo Cannot run ./FR_HOM_A.EXE
+ exit $RETVAL
+ fi
./FR_A.EXE >/dev/null
+ RETVAL=$?
+ if [ $RETVAL != 0 ]
+ then
+ echo Cannot run ./FR_HOM_A.EXE
+ exit $RETVAL
+ fi
./FR_HOM_U.EXE >/dev/null
+ RETVAL=$?
+ if [ $RETVAL != 0 ]
+ then
+ echo Cannot run ./FR_HOM_A.EXE
+ exit $RETVAL
+ fi
./FR_SYN_U.EXE >/dev/null
+ RETVAL=$?
+ if [ $RETVAL != 0 ]
+ then
+ echo Cannot run ./FR_HOM_A.EXE
+ exit $RETVAL
+ fi
./FR_U.EXE >/dev/null
+ RETVAL=$?
+ if [ $RETVAL != 0 ]
+ then
+ echo Cannot run ./FR_HOM_A.EXE
+ exit $RETVAL
+ fi
rm -rf READ_FRA.TXT
fi
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id: unpack_v56ter_data.sh,v 1.5 2008/05/03 07:55:04 steveu Exp $
-#
ITUDATA="../../../T-REC-V.56ter-199608-I!!ZPF-E.zip"