diff --git a/.gitignore b/.gitignore index 766adfb371..514e756904 100644 --- a/.gitignore +++ b/.gitignore @@ -36,13 +36,16 @@ *.xz *.bz2 *.tbz2 +*.deb *.swp +*.serial aclocal.m4 autom4te.cache config.cache configure.lineno config.log config.status +test-driver core.* TAGS *.2010.log @@ -151,7 +154,8 @@ Release/ /src/mod/applications/mod_osp/Makefile.in /src/mod/applications/mod_rss/Makefile /src/mod/applications/mod_snipe_hunt/Makefile -/src/mod/codecs/mod_com_g729/ +/src/mod/codecs/mod_com_g729/Makefile +/src/mod/codecs/mod_com_g729/Makefile.in /src/mod/codecs/mod_dahdi_codec/Makefile /src/mod/dialplans/mod_dialplan_directory/Makefile /src/mod/formats/mod_shell_stream/Makefile @@ -168,8 +172,6 @@ Release/ BuildLog.htm -Win32/ -win32/ !/libs/win32/ !/libs/speex/win32/ !/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/ diff --git a/Freeswitch.2010.express.sln b/Freeswitch.2010.express.sln index 4749470674..e554a13076 100644 --- a/Freeswitch.2010.express.sln +++ b/Freeswitch.2010.express.sln @@ -38,6 +38,11 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_console", "src\mod\loggers\mod_console\mod_console.2010.vcxproj", "{1C453396-D912-4213-89FD-9B489162B7B5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_xml_rpc", "src\mod\xml_int\mod_xml_rpc\mod_xml_rpc.2010.vcxproj", "{CBEC7225-0C21-4DA8-978E-1F158F8AD950}" + ProjectSection(ProjectDependencies) = postProject + {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6} = {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6} + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} + {329A6FA0-0FCC-4435-A950-E670AEFA9838} = {329A6FA0-0FCC-4435-A950-E670AEFA9838} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_rss", "src\mod\applications\mod_rss\mod_rss.2010.vcxproj", "{B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4}" EndProject @@ -221,6 +226,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libs\spandsp\src\libspandsp.2010.vcxproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" ProjectSection(ProjectDependencies) = postProject {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspeex", "libs\speex\win32\VS2008\libspeex\libspeex.vcxproj", "{E972C52F-9E85-4D65-B19C-031E511E9DB4}" @@ -338,6 +344,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gennmtab", "libs\win32\xmlr EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_math_fixed_tables", "libs\spandsp\src\msvc\make_math_fixed_tables.2010.vcxproj", "{9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_cielab_luts", "libs\spandsp\src\msvc\make_cielab_luts.2010.vcxproj", "{85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -2067,6 +2075,17 @@ Global {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}.Release|Win32.Build.0 = All|Win32 {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}.Release|x64.ActiveCfg = All|Win32 {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6}.Release|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.Build.0 = All|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln index d620087405..4148d2ddc5 100644 --- a/Freeswitch.2010.sln +++ b/Freeswitch.2010.sln @@ -570,6 +570,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_math_fixed_tables", "l EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcbt", "libs\win32\libcbt\libcbt.2010.vcxproj", "{77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_cielab_luts", "libs\spandsp\src\msvc\make_cielab_luts.2010.vcxproj", "{85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -3791,6 +3793,23 @@ Global {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}.Release|x64.Build.0 = Release|x64 {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}.Release|x64 Setup.ActiveCfg = Release|Win32 {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}.Release|x86 Setup.ActiveCfg = Release|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x64 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x86 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x86 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x86 Setup.ActiveCfg = All|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3907,6 +3926,7 @@ Global {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {9D04A840-CE18-4FF5-A6D3-0A2BB92FF2E6} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC} {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000} {ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000} diff --git a/Freeswitch.2012.sln b/Freeswitch.2012.sln index 7e2d13e128..346914e690 100644 --- a/Freeswitch.2012.sln +++ b/Freeswitch.2012.sln @@ -575,6 +575,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_math_fixed_tables", "l EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcbt", "libs\win32\libcbt\libcbt.2012.vcxproj", "{77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_cielab_luts", "libs\spandsp\src\msvc\make_cielab_luts.2012.vcxproj", "{85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -3801,6 +3803,23 @@ Global {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}.Release|x64.Build.0 = Release|x64 {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}.Release|x64 Setup.ActiveCfg = Release|Win32 {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9}.Release|x86 Setup.ActiveCfg = Release|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x64 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.All|x86 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x64 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Debug|x86 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|Win32.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64.Build.0 = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x64 Setup.ActiveCfg = All|Win32 + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981}.Release|x86 Setup.ActiveCfg = All|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3915,8 +3934,9 @@ Global {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {C13CC324-0032-4492-9A30-310A6BD64FF5} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} - {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {2386B892-35F5-46CF-A0F0-10394D2FBF9B} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {77BC1DD2-C9A1-44D7-BFFA-1320370CACB9} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC} {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000} {ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000} diff --git a/Makefile.am b/Makefile.am index 145733e636..91d949b359 100644 --- a/Makefile.am +++ b/Makefile.am @@ -291,6 +291,7 @@ libfreeswitch_la_SOURCES = \ libs/libnatpmp/natpmp.c \ libs/libnatpmp/getgateway.c\ libs/spandsp/src/plc.c \ + libs/spandsp/src/alloc.c \ libs/spandsp/src/bit_operations.c if ENABLE_CPP diff --git a/acinclude.m4 b/acinclude.m4 index aeba17b5c3..58b5500a80 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -6,6 +6,7 @@ m4_include([build/config/ac_gcc_archflag.m4]) m4_include([build/config/ac_gcc_x86_cpuid.m4]) m4_include([build/config/ax_lib_mysql.m4]) m4_include([build/config/ax_check_java.m4]) +m4_include([build/config/uuid.m4]) m4_include([build/config/erlang.m4]) m4_include([build/config/odbc.m4]) m4_include([build/config/sched_setaffinity.m4]) diff --git a/build/config/uuid.m4 b/build/config/uuid.m4 new file mode 100644 index 0000000000..7f37c23c66 --- /dev/null +++ b/build/config/uuid.m4 @@ -0,0 +1,17 @@ +AC_DEFUN([CHECK_LIBUUID], + [ + PKG_CHECK_MODULES([LIBUUID], [uuid >= 1.41.2], + [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) + if test "$LIBUUID_FOUND" = "no" ; then + PKG_CHECK_MODULES([LIBUUID], [uuid], + [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) + if test "$LIBUUID_FOUND" = "no" ; then + AC_MSG_WARN([libuuid development package highly recommended!]) + else + LIBUUID_INCLUDEDIR=$(pkg-config --variable=includedir uuid) + LIBUUID_CFLAGS+=" -I$LIBUUID_INCLUDEDIR/uuid " + fi + fi + AC_SUBST([LIBUUID_CFLAGS]) + AC_SUBST([LIBUUID_LIBS]) + ]) diff --git a/build/modules.conf.in b/build/modules.conf.in index 81ae32f4c2..d60b1211ef 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -26,10 +26,14 @@ applications/mod_httapi #applications/mod_lcr #applications/mod_memcache #applications/mod_mongo +#applications/mod_mp4 #applications/mod_nibblebill +#applications/mod_oreka #applications/mod_osp +#applications/mod_rad_auth #applications/mod_redis #applications/mod_rss +#applications/mod_sonar applications/mod_sms #applications/mod_snapshot #applications/mod_snipe_hunt @@ -63,17 +67,20 @@ codecs/mod_h26x codecs/mod_vp8 #codecs/mod_ilbc #codecs/mod_isac +#codecs/mod_mp4v #codecs/mod_opus #codecs/mod_sangoma_codec #codecs/mod_silk #codecs/mod_siren codecs/mod_speex +#codecs/mod_theora dialplans/mod_dialplan_asterisk #dialplans/mod_dialplan_directory dialplans/mod_dialplan_xml #directories/mod_ldap #endpoints/mod_alsa #endpoints/mod_dingaling +#endpoints/mod_gsmopen #endpoints/mod_h323 #endpoints/mod_html5 #endpoints/mod_khomp @@ -81,9 +88,10 @@ endpoints/mod_loopback #endpoints/mod_opal #endpoints/mod_portaudio #endpoints/mod_rtmp -#endpoints/mod_skinny +endpoints/mod_skinny #endpoints/mod_skypopen endpoints/mod_sofia +#endpoints/mod_unicall event_handlers/mod_cdr_csv #event_handlers/mod_cdr_mongodb #event_handlers/mod_cdr_pg_csv @@ -92,6 +100,7 @@ event_handlers/mod_cdr_sqlite #event_handlers/mod_event_multicast event_handlers/mod_event_socket #event_handlers/mod_event_zmq +#event_handlers/mod_json_cdr #event_handlers/mod_radius_cdr #event_handlers/mod_rayo #event_handlers/mod_snmp @@ -117,10 +126,13 @@ loggers/mod_syslog #say/mod_say_de say/mod_say_en #say/mod_say_es +#say/mod_say_fa #say/mod_say_fr #say/mod_say_he +#say/mod_say_hr #say/mod_say_hu #say/mod_say_it +#say/mod_say_ja #say/mod_say_nl #say/mod_say_pl #say/mod_say_pt @@ -140,4 +152,4 @@ xml_int/mod_xml_scgi #../../libs/openzap/mod_openzap ## Experimental Modules (don't cry if they're broken) -#../../contrib/mod/xml_int/mod_xml_odbc +#../../contrib/mod/xml_int/mod_xml_odbc \ No newline at end of file diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/acl.conf.xml b/conf/rayo/autoload_configs/acl.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/acl.conf.xml rename to conf/rayo/autoload_configs/acl.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/cdr_csv.conf.xml b/conf/rayo/autoload_configs/cdr_csv.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/cdr_csv.conf.xml rename to conf/rayo/autoload_configs/cdr_csv.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/conference.conf.xml b/conf/rayo/autoload_configs/conference.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/conference.conf.xml rename to conf/rayo/autoload_configs/conference.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/console.conf.xml b/conf/rayo/autoload_configs/console.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/console.conf.xml rename to conf/rayo/autoload_configs/console.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/distributor.conf.xml b/conf/rayo/autoload_configs/distributor.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/distributor.conf.xml rename to conf/rayo/autoload_configs/distributor.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/event_socket.conf.xml b/conf/rayo/autoload_configs/event_socket.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/event_socket.conf.xml rename to conf/rayo/autoload_configs/event_socket.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/hash.conf.xml b/conf/rayo/autoload_configs/hash.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/hash.conf.xml rename to conf/rayo/autoload_configs/hash.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/http_cache.conf.xml b/conf/rayo/autoload_configs/http_cache.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/http_cache.conf.xml rename to conf/rayo/autoload_configs/http_cache.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/local_stream.conf.xml b/conf/rayo/autoload_configs/local_stream.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/local_stream.conf.xml rename to conf/rayo/autoload_configs/local_stream.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/logfile.conf.xml b/conf/rayo/autoload_configs/logfile.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/logfile.conf.xml rename to conf/rayo/autoload_configs/logfile.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/lua.conf.xml b/conf/rayo/autoload_configs/lua.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/lua.conf.xml rename to conf/rayo/autoload_configs/lua.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/memcache.conf.xml b/conf/rayo/autoload_configs/memcache.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/memcache.conf.xml rename to conf/rayo/autoload_configs/memcache.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/modules.conf.xml b/conf/rayo/autoload_configs/modules.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/modules.conf.xml rename to conf/rayo/autoload_configs/modules.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/pocketsphinx.conf.xml b/conf/rayo/autoload_configs/pocketsphinx.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/pocketsphinx.conf.xml rename to conf/rayo/autoload_configs/pocketsphinx.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/post_load_modules.conf.xml b/conf/rayo/autoload_configs/post_load_modules.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/post_load_modules.conf.xml rename to conf/rayo/autoload_configs/post_load_modules.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/presence_map.conf.xml b/conf/rayo/autoload_configs/presence_map.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/presence_map.conf.xml rename to conf/rayo/autoload_configs/presence_map.conf.xml diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml new file mode 100644 index 0000000000..248fd47ccf --- /dev/null +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/shout.conf.xml b/conf/rayo/autoload_configs/shout.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/shout.conf.xml rename to conf/rayo/autoload_configs/shout.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/sofia.conf.xml b/conf/rayo/autoload_configs/sofia.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/sofia.conf.xml rename to conf/rayo/autoload_configs/sofia.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/spandsp.conf.xml b/conf/rayo/autoload_configs/spandsp.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/spandsp.conf.xml rename to conf/rayo/autoload_configs/spandsp.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/ssml.conf.xml b/conf/rayo/autoload_configs/ssml.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/ssml.conf.xml rename to conf/rayo/autoload_configs/ssml.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/switch.conf.xml b/conf/rayo/autoload_configs/switch.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/switch.conf.xml rename to conf/rayo/autoload_configs/switch.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/timezones.conf.xml b/conf/rayo/autoload_configs/timezones.conf.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/autoload_configs/timezones.conf.xml rename to conf/rayo/autoload_configs/timezones.conf.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/cacert.pem b/conf/rayo/cacert.pem similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/cacert.pem rename to conf/rayo/cacert.pem diff --git a/src/mod/event_handlers/mod_rayo/conf/dialplan/public.xml b/conf/rayo/dialplan/public.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/dialplan/public.xml rename to conf/rayo/dialplan/public.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default.xml b/conf/rayo/directory/default.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default.xml rename to conf/rayo/directory/default.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/usera.xml b/conf/rayo/directory/default/usera.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/usera.xml rename to conf/rayo/directory/default/usera.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/userb.xml b/conf/rayo/directory/default/userb.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/userb.xml rename to conf/rayo/directory/default/userb.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/userc.xml b/conf/rayo/directory/default/userc.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/userc.xml rename to conf/rayo/directory/default/userc.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/directory/default/userd.xml b/conf/rayo/directory/default/userd.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/directory/default/userd.xml rename to conf/rayo/directory/default/userd.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/freeswitch.xml b/conf/rayo/freeswitch.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/freeswitch.xml rename to conf/rayo/freeswitch.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/de.xml b/conf/rayo/lang/de/de.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/de.xml rename to conf/rayo/lang/de/de.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/demo/demo.xml b/conf/rayo/lang/de/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/demo/demo.xml rename to conf/rayo/lang/de/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/vm/sounds.xml b/conf/rayo/lang/de/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/vm/sounds.xml rename to conf/rayo/lang/de/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/de/vm/tts.xml b/conf/rayo/lang/de/vm/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/de/vm/tts.xml rename to conf/rayo/lang/de/vm/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo-ivr.xml b/conf/rayo/lang/en/demo/demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo-ivr.xml rename to conf/rayo/lang/en/demo/demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo.xml b/conf/rayo/lang/en/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/demo.xml rename to conf/rayo/lang/en/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/funnies.xml b/conf/rayo/lang/en/demo/funnies.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/funnies.xml rename to conf/rayo/lang/en/demo/funnies.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/demo/new-demo-ivr.xml b/conf/rayo/lang/en/demo/new-demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/demo/new-demo-ivr.xml rename to conf/rayo/lang/en/demo/new-demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/dir/sounds.xml b/conf/rayo/lang/en/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/dir/sounds.xml rename to conf/rayo/lang/en/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/dir/tts.xml b/conf/rayo/lang/en/dir/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/dir/tts.xml rename to conf/rayo/lang/en/dir/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/en.xml b/conf/rayo/lang/en/en.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/en.xml rename to conf/rayo/lang/en/en.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/ivr/sounds.xml b/conf/rayo/lang/en/ivr/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/ivr/sounds.xml rename to conf/rayo/lang/en/ivr/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/vm/sounds.xml b/conf/rayo/lang/en/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/vm/sounds.xml rename to conf/rayo/lang/en/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/vm/tts.xml b/conf/rayo/lang/en/vm/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/vm/tts.xml rename to conf/rayo/lang/en/vm/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/en/vm/voicemail_ivr.xml b/conf/rayo/lang/en/vm/voicemail_ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/en/vm/voicemail_ivr.xml rename to conf/rayo/lang/en/vm/voicemail_ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-ES.xml b/conf/rayo/lang/es/demo/demo-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-ES.xml rename to conf/rayo/lang/es/demo/demo-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-MX.xml b/conf/rayo/lang/es/demo/demo-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-es-MX.xml rename to conf/rayo/lang/es/demo/demo-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-ES.xml b/conf/rayo/lang/es/demo/demo-ivr-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-ES.xml rename to conf/rayo/lang/es/demo/demo-ivr-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-MX.xml b/conf/rayo/lang/es/demo/demo-ivr-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/demo/demo-ivr-es-MX.xml rename to conf/rayo/lang/es/demo/demo-ivr-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-ES.xml b/conf/rayo/lang/es/dir/sounds-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-ES.xml rename to conf/rayo/lang/es/dir/sounds-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-MX.xml b/conf/rayo/lang/es/dir/sounds-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/sounds-es-MX.xml rename to conf/rayo/lang/es/dir/sounds-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-ES.xml b/conf/rayo/lang/es/dir/tts-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-ES.xml rename to conf/rayo/lang/es/dir/tts-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-MX.xml b/conf/rayo/lang/es/dir/tts-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/dir/tts-es-MX.xml rename to conf/rayo/lang/es/dir/tts-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/es_ES.xml b/conf/rayo/lang/es/es_ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/es_ES.xml rename to conf/rayo/lang/es/es_ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/es_MX.xml b/conf/rayo/lang/es/es_MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/es_MX.xml rename to conf/rayo/lang/es/es_MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-ES.xml b/conf/rayo/lang/es/vm/sounds-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-ES.xml rename to conf/rayo/lang/es/vm/sounds-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-MX.xml b/conf/rayo/lang/es/vm/sounds-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/sounds-es-MX.xml rename to conf/rayo/lang/es/vm/sounds-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-ES.xml b/conf/rayo/lang/es/vm/tts-es-ES.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-ES.xml rename to conf/rayo/lang/es/vm/tts-es-ES.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-MX.xml b/conf/rayo/lang/es/vm/tts-es-MX.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/es/vm/tts-es-MX.xml rename to conf/rayo/lang/es/vm/tts-es-MX.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/demo/demo.xml b/conf/rayo/lang/fr/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/demo/demo.xml rename to conf/rayo/lang/fr/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/sounds.xml b/conf/rayo/lang/fr/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/sounds.xml rename to conf/rayo/lang/fr/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/tts.xml b/conf/rayo/lang/fr/dir/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/dir/tts.xml rename to conf/rayo/lang/fr/dir/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/fr.xml b/conf/rayo/lang/fr/fr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/fr.xml rename to conf/rayo/lang/fr/fr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/fr/vm/sounds.xml b/conf/rayo/lang/fr/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/fr/vm/sounds.xml rename to conf/rayo/lang/fr/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo-ivr.xml b/conf/rayo/lang/he/demo/demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo-ivr.xml rename to conf/rayo/lang/he/demo/demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo.xml b/conf/rayo/lang/he/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/demo/demo.xml rename to conf/rayo/lang/he/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/dir/sounds.xml b/conf/rayo/lang/he/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/dir/sounds.xml rename to conf/rayo/lang/he/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/he.xml b/conf/rayo/lang/he/he.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/he.xml rename to conf/rayo/lang/he/he.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/he/vm/sounds.xml b/conf/rayo/lang/he/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/he/vm/sounds.xml rename to conf/rayo/lang/he/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-BR.xml b/conf/rayo/lang/pt/demo/demo-ivr-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-BR.xml rename to conf/rayo/lang/pt/demo/demo-ivr-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-PT.xml b/conf/rayo/lang/pt/demo/demo-ivr-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-ivr-pt-PT.xml rename to conf/rayo/lang/pt/demo/demo-ivr-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-BR.xml b/conf/rayo/lang/pt/demo/demo-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-BR.xml rename to conf/rayo/lang/pt/demo/demo-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-PT.xml b/conf/rayo/lang/pt/demo/demo-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/demo/demo-pt-PT.xml rename to conf/rayo/lang/pt/demo/demo-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-BR.xml b/conf/rayo/lang/pt/dir/sounds-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-BR.xml rename to conf/rayo/lang/pt/dir/sounds-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-PT.xml b/conf/rayo/lang/pt/dir/sounds-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/sounds-pt-PT.xml rename to conf/rayo/lang/pt/dir/sounds-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-BR.xml b/conf/rayo/lang/pt/dir/tts-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-BR.xml rename to conf/rayo/lang/pt/dir/tts-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-PT.xml b/conf/rayo/lang/pt/dir/tts-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/dir/tts-pt-PT.xml rename to conf/rayo/lang/pt/dir/tts-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_BR.xml b/conf/rayo/lang/pt/pt_BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_BR.xml rename to conf/rayo/lang/pt/pt_BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_PT.xml b/conf/rayo/lang/pt/pt_PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/pt_PT.xml rename to conf/rayo/lang/pt/pt_PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-BR.xml b/conf/rayo/lang/pt/vm/sounds-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-BR.xml rename to conf/rayo/lang/pt/vm/sounds-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-PT.xml b/conf/rayo/lang/pt/vm/sounds-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/sounds-pt-PT.xml rename to conf/rayo/lang/pt/vm/sounds-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-BR.xml b/conf/rayo/lang/pt/vm/tts-pt-BR.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-BR.xml rename to conf/rayo/lang/pt/vm/tts-pt-BR.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-PT.xml b/conf/rayo/lang/pt/vm/tts-pt-PT.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/pt/vm/tts-pt-PT.xml rename to conf/rayo/lang/pt/vm/tts-pt-PT.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo-ivr.xml b/conf/rayo/lang/ru/demo/demo-ivr.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo-ivr.xml rename to conf/rayo/lang/ru/demo/demo-ivr.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo.xml b/conf/rayo/lang/ru/demo/demo.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/demo/demo.xml rename to conf/rayo/lang/ru/demo/demo.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/sounds.xml b/conf/rayo/lang/ru/dir/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/sounds.xml rename to conf/rayo/lang/ru/dir/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/tts.xml b/conf/rayo/lang/ru/dir/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/dir/tts.xml rename to conf/rayo/lang/ru/dir/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/ru.xml b/conf/rayo/lang/ru/ru.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/ru.xml rename to conf/rayo/lang/ru/ru.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/sounds.xml b/conf/rayo/lang/ru/vm/sounds.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/sounds.xml rename to conf/rayo/lang/ru/vm/sounds.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/tts.xml b/conf/rayo/lang/ru/vm/tts.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/lang/ru/vm/tts.xml rename to conf/rayo/lang/ru/vm/tts.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/mime.types b/conf/rayo/mime.types similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/mime.types rename to conf/rayo/mime.types diff --git a/src/mod/event_handlers/mod_rayo/conf/sip_profiles/external.xml b/conf/rayo/sip_profiles/external.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/sip_profiles/external.xml rename to conf/rayo/sip_profiles/external.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/sip_profiles/external/example.xml b/conf/rayo/sip_profiles/external/example.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/sip_profiles/external/example.xml rename to conf/rayo/sip_profiles/external/example.xml diff --git a/src/mod/event_handlers/mod_rayo/conf/vars.xml b/conf/rayo/vars.xml similarity index 100% rename from src/mod/event_handlers/mod_rayo/conf/vars.xml rename to conf/rayo/vars.xml diff --git a/conf/vanilla/autoload_configs/lua.conf.xml b/conf/vanilla/autoload_configs/lua.conf.xml index 1eb594f0b5..f50307ea89 100644 --- a/conf/vanilla/autoload_configs/lua.conf.xml +++ b/conf/vanilla/autoload_configs/lua.conf.xml @@ -26,5 +26,7 @@ --> + + diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml index 9f4168f803..0ca6bc5b34 100644 --- a/conf/vanilla/autoload_configs/modules.conf.xml +++ b/conf/vanilla/autoload_configs/modules.conf.xml @@ -48,7 +48,7 @@ - + diff --git a/conf/vanilla/lang/en/vm/sounds.xml b/conf/vanilla/lang/en/vm/sounds.xml index fdef472a5b..fae8acefaa 100644 --- a/conf/vanilla/lang/en/vm/sounds.xml +++ b/conf/vanilla/lang/en/vm/sounds.xml @@ -334,12 +334,15 @@ - + + + + - + diff --git a/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml new file mode 100644 index 0000000000..cbde87ca5a --- /dev/null +++ b/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index df838406d1..c813d99c67 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -178,6 +178,10 @@ + + + + @@ -311,6 +315,10 @@ + + + + diff --git a/configure.in b/configure.in index fd52b959ff..7ee37860a8 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.5.3b], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.5.5b], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [5]) -AC_SUBST(SWITCH_VERSION_MICRO, [3b]) +AC_SUBST(SWITCH_VERSION_MICRO, [5b]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) @@ -405,6 +405,10 @@ if test "x$enable_core_odbc_support" != "xno"; then AC_CHECK_LIB([odbc], [SQLDisconnect],, AC_MSG_ERROR([no usable libodbc; please install unixodbc devel package or equivalent])) fi +CHECK_LIBUUID +SWITCH_AM_LDFLAGS="$LIBUUID_LIBS $SWITCH_AM_LDFLAGS" +SWITCH_AM_CFLAGS="$LIBUUID_CFLAGS $SWITCH_AM_CFLAGS" + AC_ARG_ENABLE(core-pgsql-support, [AS_HELP_STRING([--enable-core-pgsql-support], [Compile with PGSQL Support])],,[enable_core_pgsql_support="no"]) @@ -414,7 +418,7 @@ AC_PATH_PROG([PG_CONFIG], [pg_config], [no]) if test "$PG_CONFIG" != "no"; then AC_MSG_CHECKING([for PostgreSQL libraries]) POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" - POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags` -L`$PG_CONFIG --libdir` -lpq" + POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags|sed 's/ -Wl,--as-needed//g'` -L`$PG_CONFIG --libdir` -lpq" POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.[0-9]+#\1#'` POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL [0-9]+.([0-9]+).[0-9]+#\1#'` diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index 473bae5539..5843872904 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -179,7 +179,7 @@ Build-Depends: # bootstrapping automake (>= 1.9), autoconf, libtool, # core build - dpkg-dev (>= 1.15.8.12), gcc (>= 4:4.4.5) , g++ (>= 4:4.4.5), + dpkg-dev (>= 1.15.8.12), gcc (>= 4:4.4.5), g++ (>= 4:4.4.5), libc6-dev (>= 2.11.3), make (>= 3.81), wget, pkg-config, # configure options diff --git a/debian/control-modules b/debian/control-modules index 188f17ff96..ec291c71b6 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -227,9 +227,9 @@ Description: Voicemail detection This module detects voicemail beeps at any frequency in O(1) time. Module: applications/mod_voicemail -Depends: mail-transport-agent Description: Voicemail This module provides a voicemail system. +Depends: mail-transport-agent Module: applications/mod_voicemail_ivr Description: Voicemail IVR @@ -490,6 +490,10 @@ Module: event_handlers/mod_radius_cdr Description: mod_radius_cdr Adds mod_radius_cdr. +Module: event_handlers/mod_rayo +Description: mod_rayo + Adds mod_rayo. + Module: event_handlers/mod_snmp Description: mod_snmp Adds mod_snmp. @@ -523,6 +527,10 @@ Description: mod_sndfile Adds mod_sndfile. Build-Depends: libflac-dev, libogg-dev, libvorbis-dev +Module: formats/mod_ssml +Description: mod_ssml + Adds mod_ssml. + Module: formats/mod_tone_stream Description: mod_tone_stream Adds mod_tone_stream. diff --git a/debian/freeswitch-mod-managed.install.tmpl b/debian/freeswitch-mod-managed.install.tmpl new file mode 100644 index 0000000000..fb30d673f8 --- /dev/null +++ b/debian/freeswitch-mod-managed.install.tmpl @@ -0,0 +1 @@ +/usr/lib/freeswitch/mod/FreeSWITCH.Managed.dll diff --git a/debian/freeswitch-mod-spidermonkey.install.tmpl b/debian/freeswitch-mod-spidermonkey.install.tmpl new file mode 100644 index 0000000000..cb98d43c5d --- /dev/null +++ b/debian/freeswitch-mod-spidermonkey.install.tmpl @@ -0,0 +1,5 @@ +/usr/lib/freeswitch/mod/mod_spidermonkey_core_db.so +/usr/lib/freeswitch/mod/mod_spidermonkey_curl.so +/usr/lib/freeswitch/mod/mod_spidermonkey_odbc.so +/usr/lib/freeswitch/mod/mod_spidermonkey_socket.so +/usr/lib/freeswitch/mod/mod_spidermonkey_teletone.so diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches new file mode 100644 index 0000000000..e839ff128d --- /dev/null +++ b/docs/SubmittingPatches @@ -0,0 +1,117 @@ +How to Contribute Patches to FreeSWITCH +======================================= + +Download the Source Code +------------------------ + + git clone git://git.freeswitch.org/freeswitch.git + cd freeswitch + +Create Your Patch +----------------- + + # create a topic/feature branch in your local repository + git checkout -b myfeature + + # make your change + emacs . + + # commit the results locally; see below for how to write a good + # commit message + git commit -va + + # create more commits as needed such that each commit represents a + # logically separate change + #while true; do emacs .; git commit -va; done + + # create patch files + git format-patch origin/master..HEAD + + # you'll now have a number of *.patch files in your current + # directory + + # navigate to the FreeSWITCH JIRA + chromium http://jira.freeswitch.org/ + + # create an account in JIRA and create a new issue; + # attach the patch file(s) you created to the issue + +Writing a Good Commit Message +----------------------------- + +Your commit message consists of two parts: the subject and the body. + +The subject is like the subject in an email message. It should be +short -- typically less than 50 characters -- and it should concisely +describe the purpose or effect of your change. + +If you're having a difficult time writing a short subject for your +commit, perhaps your commit should be broken into smaller separate +commits. + +The commit body can be longer and can consist of multiple paragraphs. +The text of the body should be hard wrapped to 68-72 characters. + +When writing the commit body, describe in detail the problem that your +commit aims to solve, how your commit solves the problem, and any +changes in behavior that result from your change, such as new +variables, command flags, or breaks in backward compatibility. + +Your commit message should be written in the present tense in +imperative style. Your message should talk about what the patch +*does*, not what you *did* to write it. + +The commit subject is the first line of your commit message, then +there is an empty line, then your commit body starts. A good commit +message might look like this: + +> Add frobinator support to mod_sofia +> +> Without proper frobinator support users had to make multiple calls +> to shell scripts to do the sort of frobbing needed in high call +> volume environments. +> +> With this change, we now link to libfrob and support the IETF +> draft-cross-voip-frobbing API. +> +> After appropriate amounts of frobbing have been done, a new variable +> `frobbing_done` is set in the caller's channel. +> +> FS-XXXX --resolve + +Patches Related to JIRA Issues +------------------------------ + +When your patch is related to an issue logged in JIRA, add the +identifier for the issue (e.g. FS-XXXX) to the body of your commit +message at the beginning of a line, typically the last line or just +before "Signed-off-by:" and "Thanks-to:" lines. This helps our JIRA +bot do useful things by relating the commit to the issue. + +If you believe your patch resolves the issue in question, follow the +issue number with a space and the "--resolve" directive as in the +example above. + +Where to Go for Help +-------------------- + +If you have any questions or run into any roadblocks please reach out +to us. You can send an email to our development mailing list: + +> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev + +Note that while you're free to send a patch to that list for questions +or for review, patches sent to the mailing list will not be considered +for inclusion. Patches that you want included in FreeSWITCH must be +submitted to JIRA. + +You can also reach us on freenode.net at: + +> #freeswitch-dev + +Finally, feel free to join us in our weekly conference call. Many of +the core developers are often on the call and you'll have an +opportunity at the beginning or end of the call to ask your questions: + +> http://wiki.freeswitch.org/wiki/Weekly_Conference_Call + diff --git a/freeswitch.spec b/freeswitch.spec index 0e638daf66..1454aa6779 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -116,14 +116,14 @@ Source2: http://files.freeswitch.org/downloads/libs/flite-1.5.1-current.tar.bz2 Source3: http://files.freeswitch.org/downloads/libs/lame-3.97.tar.gz Source4: http://files.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz Source5: http://files.freeswitch.org/downloads/libs/mpg123-1.13.2.tar.gz -Source6: http://files.freeswitch.org/downloads/libs/openldap-2.4.11.tar.gz -Source7: http://files.freeswitch.org/downloads/libs/pocketsphinx-0.7.tar.gz -Source8: http://files.freeswitch.org/downloads/libs/soundtouch-1.6.0.tar.gz -Source9: http://files.freeswitch.org/downloads/libs/sphinxbase-0.7.tar.gz -Source10: http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz -Source11: http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz -Source12: http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz -Source13: http://files.freeswitch.org/downloads/libs/opus-0.9.0.tar.gz +#Source6: http://files.freeswitch.org/downloads/libs/openldap-2.4.11.tar.gz +Source6: http://files.freeswitch.org/downloads/libs/pocketsphinx-0.7.tar.gz +Source7: http://files.freeswitch.org/downloads/libs/soundtouch-1.6.0.tar.gz +Source8: http://files.freeswitch.org/downloads/libs/sphinxbase-0.7.tar.gz +Source9: http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz +Source10: http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz +Source11: http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz +Source12: http://files.freeswitch.org/downloads/libs/opus-0.9.0.tar.gz Prefix: %{prefix} @@ -137,7 +137,7 @@ Prefix: %{prefix} #BuildRequires: openldap2-devel BuildRequires: lzo-devel %else -BuildRequires: openldap-devel +#BuildRequires: openldap-devel %endif BuildRequires: autoconf BuildRequires: automake @@ -182,7 +182,7 @@ Requires: ncurses Requires: openssl Requires: unixODBC Requires: libjpeg -Requires: openldap +#Requires: openldap Requires: db4 Requires: gdbm Requires: zlib @@ -700,6 +700,14 @@ Requires: %{name} = %{version}-%{release} %description codec-isac iSAC Codec support for FreeSWITCH open source telephony platform +%package codec-vp8 +Summary: vp8 Codec support for FreeSWITCH open source telephony platform +Group: System/Libraries +Requires: %{name} = %{version}-%{release} + +%description codec-vp8 +iSAC Codec support for FreeSWITCH open source telephony platform + %package codec-mp4v Summary: MP4V Video Codec support for FreeSWITCH open source telephony platform Group: System/Libraries @@ -770,13 +778,13 @@ Theora Video Codec support for FreeSWITCH open source telephony platform. # FreeSWITCH Directory Modules ###################################################################################################################### -%package directory-ldap -Summary: LDAP Directory support for FreeSWITCH open source telephony platform -Group: System/Libraries -Requires: %{name} = %{version}-%{release} +#%package directory-ldap +#Summary: LDAP Directory support for FreeSWITCH open source telephony platform +#Group: System/Libraries +#Requires: %{name} = %{version}-%{release} -%description directory-ldap -LDAP Directory support for FreeSWITCH open source telephony platform. +#%description directory-ldap +#LDAP Directory support for FreeSWITCH open source telephony platform. ###################################################################################################################### # FreeSWITCH Endpoint Modules @@ -1266,7 +1274,6 @@ cp %{SOURCE9} libs/ cp %{SOURCE10} libs/ cp %{SOURCE11} libs/ cp %{SOURCE12} libs/ -cp %{SOURCE13} libs/ ###################################################################################################################### # @@ -1329,7 +1336,7 @@ ASR_TTS_MODULES="asr_tts/mod_flite asr_tts/mod_pocketsphinx asr_tts/mod_tts_comm ###################################################################################################################### CODECS_MODULES="codecs/mod_amr codecs/mod_amrwb codecs/mod_bv codecs/mod_celt codecs/mod_codec2 codecs/mod_g723_1 \ codecs/mod_g729 codecs/mod_h26x codecs/mod_ilbc codecs/mod_isac codecs/mod_mp4v codecs/mod_opus codecs/mod_silk \ - codecs/mod_siren codecs/mod_speex codecs/mod_theora " + codecs/mod_siren codecs/mod_speex codecs/mod_theora codecs/mod_vp8" # %if %{build_sng_tc} CODECS_MODULES+="codecs/mod_sangoma_codec" @@ -2040,6 +2047,10 @@ fi %defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_mp4v.so* +%files codec-vp8 +%defattr(-,freeswitch,daemon) +%{MODINSTDIR}/mod_vp8.so* + %files codec-opus %defattr(-,freeswitch,daemon) %{MODINSTDIR}/mod_opus.so* @@ -2072,9 +2083,9 @@ fi # ###################################################################################################################### -%files directory-ldap -%defattr(-,freeswitch,daemon) -%{MODINSTDIR}/mod_theora.so* +#%files directory-ldap +#%defattr(-,freeswitch,daemon) +#%{MODINSTDIR}/mod_theora.so* ###################################################################################################################### # @@ -2374,7 +2385,9 @@ fi # ###################################################################################################################### %changelog -* Thu June 19 2013 - krice@freeswitch.org +* Thu Jun 28 2013 - krice@freeswitch.org +- Add module for VP8 +* Thu Jun 19 2013 - krice@freeswitch.org - tweak files included for vanilla configs * Thu Sep 19 2012 - krice@freeswitch.org - Add support for Spanish and Portugese say language modules diff --git a/fscomm/conf/freeswitch.serial b/fscomm/conf/freeswitch.serial deleted file mode 100644 index 1ed5449607..0000000000 Binary files a/fscomm/conf/freeswitch.serial and /dev/null differ diff --git a/htdocs/portal/assets/js/fsportal.js b/htdocs/portal/assets/js/fsportal.js index 32c3b24703..d002cac4d1 100644 --- a/htdocs/portal/assets/js/fsportal.js +++ b/htdocs/portal/assets/js/fsportal.js @@ -154,6 +154,12 @@ App.ShowSaysRoute = Ember.Route.extend({ } }); +App.ShowNatMapsRoute = Ember.Route.extend({ + setupController: function(controller) { + App.showNatMapsController.load(); + } +}); + App.ShowChatsRoute = Ember.Route.extend({ setupController: function(controller) { App.showChatsController.load(); @@ -203,6 +209,7 @@ App.Router.map(function(){ this.route("showAliases"); this.route("showCompletes"); this.route("showManagements"); + this.route("showNatMaps"); this.route("showSays"); this.route("showChats"); this.route("showInterfaces"); @@ -256,6 +263,10 @@ App.callsController = Ember.ArrayController.create({ }); }, + delete: function(uuid) { + var obj = this.content.findProperty("uuid", uuid); + if (obj) this.content.removeObject(obj);// else alert(uuid); + }, dump: function(uuid) { var obj = this.content.findProperty("uuid", uuid); console.log(obj.getProperties(["uuid", "cid_num"])); @@ -550,6 +561,23 @@ App.showManagementsController = Ember.ArrayController.create({ } }); +App.showNatMapsController = Ember.ArrayController.create({ + content: [], + init: function(){ + }, + load: function() { + var me = this; + $.getJSON("/txtapi/show?nat_map%20as%20json", function(data){ + me.set('total', data.row_count); + me.content.clear(); + if (data.row_count == 0) return; + + me.pushObjects(data.rows); + + }); + } +}); + App.showSaysController = Ember.ArrayController.create({ content: [], init: function(){ @@ -687,10 +715,17 @@ App.usersController = Ember.ArrayController.create({ }); App.initialize(); - +var global_debug_event = false; +var global_background_job = false; function eventCallback(data) { console.log(data["Event-Name"]); + + if (global_debug_event || + (global_background_job && data["Event-Name"] == "BACKGROUND_JOB")) { + console.log(data); + } + if (data["Event-Name"] == "CHANNEL_CREATE") { var channel = { uuid: data["Unique-ID"], @@ -700,8 +735,47 @@ function eventCallback(data) { direction: data["Call-Direction"] } App.channelsController.pushObject(App.Channel.create(channel)); + + var x = $('#auto_update_calls')[0]; + if (typeof x != "undefined" && x.checked) { + return; + } + + App.callsController.pushObject(App.Call.create(channel)); } else if (data["Event-Name"] == "CHANNEL_HANGUP_COMPLETE") { App.channelsController.delete(data["Unique-ID"]); + + var x = $('#auto_update_calls')[0]; + if (typeof x != "undefined" && x.checked) { + return; + } + + App.callsController.delete(data["Unique-ID"]); + } else if (data["Event-Name"] == "CHANNEL_BRIDGE") { + var x = $('#auto_update_calls')[0]; + if (typeof x != "undefined" && x.checked) { + return; + } + + App.callsController.delete(data["Unique-ID"]); + App.callsController.delete(data["Other-Leg-Unique-ID"]); + + var call = { + uuid: data["Unique-ID"], + b_uuid: data["Other-Leg-Unique-ID"], + cid_num: data["Caller-Caller-ID-Number"], + b_cid_num: data["Other-Leg-Caller-ID-Number"], + dest: data["Caller-Destination-Number"], + b_dest: data["Other-Leg-Destination-Number"], + callstate: data["Channel-Call-State"], + b_callstate: data["Channel-Call-State"], + direction: data["Call-Direction"], + b_direction: data["Other-Leg-Direction"], + created: data["Caller-Channel-Created-Time"] + }; + + App.callsController.pushObject(App.Call.create(call)); + } else if (data["Event-Name"] == "CHANNEL_CALLSTATE") { var obj = App.channelsController.content.findProperty("uuid", data["Unique-ID"]); if (obj) { @@ -711,3 +785,34 @@ function eventCallback(data) { } } +// execute api +function api(cmdstr) +{ + cmdarr = cmdstr.split(" "); + cmd = cmdarr.shift(); + arg = escape(cmdarr.join(" ")); + arg = arg ? "?" + arg : ""; + url = "/txtapi/" + cmd + arg; + $.get(url, function(data){ + console.log(data); + }); + return url; +} + +//execute bgapi +function bgapi(cmd) +{ + if (!global_background_job) { + socket.send("event json BACKGROUND_JOB"); + global_background_job = true; + } + api("bgapi " + cmd); +} + +// subscribe event +function event(e) +{ + cmd = "event json " + e; + socket.send(cmd); + return cmd; +} diff --git a/htdocs/portal/assets/js/ie-console.js b/htdocs/portal/assets/js/ie-console.js new file mode 100644 index 0000000000..60f73cceec --- /dev/null +++ b/htdocs/portal/assets/js/ie-console.js @@ -0,0 +1,19 @@ +// var ie_console_alertFallback = true; +// var ie_console_divFallback = true; + +if (typeof console === "undefined" || typeof console.log === "undefined") { + console = {}; + + if (typeof ie_console_divFallback != "undefined") { + console.log = function(msg) { + $('#ie_console_debug_div').append(msg); + $('#ie_console_debug_div').append("
"); + } + } else if (typeof ie_console_alertFallback != "undefined" ) { + console.log = function(msg) { + alert(msg); + }; + } else { + console.log = function() {}; + } +} diff --git a/htdocs/portal/index.html b/htdocs/portal/index.html index 47270e6814..351b09590e 100644 --- a/htdocs/portal/index.html +++ b/htdocs/portal/index.html @@ -357,6 +357,28 @@ + + @@ -687,6 +770,7 @@ $('#ws-status').html('Socket Connected').css("color", "green"); // socket.send("event json all"); socket.send("event json CHANNEL_CREATE"); + socket.send("event json CHANNEL_BRIDGE"); socket.send("event json CHANNEL_HANGUP_COMPLETE"); socket.send("event json CHANNEL_CALLSTATE"); } @@ -694,7 +778,6 @@ socket.onmessage =function(msg) { // console.log(msg.data); var data = JSON.parse(msg.data); - console.log(data["Event-Name"]); eventCallback(data); } diff --git a/libs/.gitignore b/libs/.gitignore index 093c5bdf10..8fca0c8c42 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -238,16 +238,48 @@ opal /ldns/Makefile /ldns/packaging/ldns-config /libcodec2/src/c2dec +/libcodec2/src/c2demo /libcodec2/src/c2enc /libcodec2/src/c2sim +/libcodec2/src/codebook.c +/libcodec2/src/codebookd.c +/libcodec2/src/codebookdt.c +/libcodec2/src/codebookge.c +/libcodec2/src/codebookjnd.c +/libcodec2/src/codebookjvm.c +/libcodec2/src/codebookvqanssi.c +/libcodec2/src/fdmdv_demod +/libcodec2/src/fdmdv_get_test_bits +/libcodec2/src/fdmdv_interleave +/libcodec2/src/fdmdv_mod +/libcodec2/src/fdmdv_put_test_bits +/libcodec2/src/generate_codebook +/libcodec2/src/genlspdtcb +/libcodec2/unittest/create_interleaver +/libcodec2/unittest/de /libcodec2/unittest/extract +/libcodec2/unittest/genampdata /libcodec2/unittest/genlsp +/libcodec2/unittest/genphdata /libcodec2/unittest/genres +/libcodec2/unittest/lspsync +/libcodec2/unittest/polar2rect +/libcodec2/unittest/pre +/libcodec2/unittest/scalarlsptest +/libcodec2/unittest/t48_8 /libcodec2/unittest/tcodec2 +/libcodec2/unittest/tfdmdv +/libcodec2/unittest/tfifo /libcodec2/unittest/tinterp +/libcodec2/unittest/tlspsens /libcodec2/unittest/tnlp +/libcodec2/unittest/tprede /libcodec2/unittest/tquant +/libcodec2/unittest/vq_train_jvm /libcodec2/unittest/vqtrain +/libcodec2/unittest/vqtrainjnd +/libcodec2/unittest/vqtrainph +/libcodec2/unittest/vqtrainsp /libdingaling/build/compile /libdingaling/Makefile /libdingaling/Makefile.in @@ -355,6 +387,11 @@ opal /libwebsockets/compile /libwebsockets/test-server/Makefile /libwebsockets/test-server/Makefile.in +/libwebsockets/test-server/libwebsockets-test-client +/libwebsockets/test-server/libwebsockets-test-fraggle +/libwebsockets/test-server/libwebsockets-test-ping +/libwebsockets/test-server/libwebsockets-test-server +/libwebsockets/test-server/libwebsockets-test-server-extpoll /mongo-cxx-driver-v*/ /mpg123/ /libmpg123/ @@ -558,11 +595,13 @@ opal /spandsp/src/Makefile.in /spandsp/src/make_math_fixed_tables /spandsp/src/make_modem_filter +/spandsp/src/make_t43_gray_code_tables /spandsp/src/math_fixed_tables.h /spandsp/src/msvc/All/BuildLog make_at_dictionary.htm /spandsp/src/msvc/All/BuildLog make_modem_filter.htm /spandsp/src/spandsp.h /spandsp/src/stamp-h1 +/spandsp/src/t43_gray_code_tables.h /spandsp/src/v17_v32bis_rx_fixed_rrc.h /spandsp/src/v17_v32bis_rx_floating_rrc.h /spandsp/src/v17_v32bis_tx_fixed_rrc.h @@ -923,9 +962,12 @@ opal /sipcc/Makefile /sipcc/Makefile.in -/yaml/ +/yaml/Makefile /yaml/config.h +/yaml/include/Makefile +/yaml/src/Makefile /yaml/stamp-h1 +/yaml/tests/Makefile /yaml/tests/example-deconstructor /yaml/tests/example-deconstructor-alt /yaml/tests/example-reformatter @@ -935,6 +977,7 @@ opal /yaml/tests/run-loader /yaml/tests/run-parser /yaml/tests/run-scanner + /zeromq-*/ /jpeg-8d/ diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 0e6521908c..05286ecc49 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -57,6 +57,7 @@ typedef struct { int debug; const char *console_fnkeys[12]; char loglevel[128]; + int log_uuid; int quiet; int batch_mode; char prompt_color[12]; @@ -595,6 +596,7 @@ static const char *usage_str = " -i, --interrupt Allow Control-c to interrupt\n" " -x, --execute=command Execute Command and Exit\n" " -l, --loglevel=command Log Level\n" + " -U, --log-uuid Include UUID in log output\n" " -q, --quiet Disable logging\n" " -r, --retry Retry connection on failure\n" " -R, --reconnect Reconnect if disconnected\n" @@ -745,10 +747,14 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) if (aok) { if (feature_level) clear_line(); if(!(global_profile->batch_mode)) { - printf("%s%s", colors[level], handle->last_event->body); + printf("%s", colors[level]); + } + if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { + printf("%s ", userdata); + } + printf("%s", handle->last_event->body); + if(!(global_profile->batch_mode)) { if (!feature_level) printf("%s", ESL_SEQ_DEFAULT_COLOR); - } else { - printf("%s", handle->last_event->body); } if (feature_level) redisplay(); } @@ -757,6 +763,10 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) if(!(global_profile->batch_mode)) { SetConsoleTextAttribute(hStdout, colors[level]); } + if (global_profile->log_uuid && !esl_strlen_zero(userdata)) { + WriteFile(hStdout, userdata, (DWORD)strlen(userdata), &outbytes, NULL); + WriteFile(hStdout, " ", (DWORD)strlen(" "), &outbytes, NULL); + } WriteFile(hStdout, handle->last_event->body, len, &outbytes, NULL); if(!(global_profile->batch_mode)) { SetConsoleTextAttribute(hStdout, wOldColorAttrs); @@ -1191,7 +1201,7 @@ static void read_config(const char *dft_cfile, const char *cfile) { if (strcmp(cur_cat, cfg.category)) { esl_set_string(cur_cat, cfg.category); esl_set_string(profiles[pcount].name, cur_cat); - esl_set_string(profiles[pcount].host, "localhost"); + esl_set_string(profiles[pcount].host, "127.0.0.1"); esl_set_string(profiles[pcount].pass, "ClueCon"); profiles[pcount].port = 8021; set_fn_keys(&profiles[pcount]); @@ -1221,6 +1231,8 @@ static void read_config(const char *dft_cfile, const char *cfile) { } } else if(!strcasecmp(var, "loglevel")) { esl_set_string(profiles[pcount-1].loglevel, val); + } else if(!strcasecmp(var, "log-uuid")) { + profiles[pcount-1].log_uuid = esl_true(val); } else if(!strcasecmp(var, "quiet")) { profiles[pcount-1].quiet = esl_true(val); } else if(!strcasecmp(var, "prompt-color")) { @@ -1282,6 +1294,7 @@ int main(int argc, char *argv[]) {"debug", 1, 0, 'd'}, {"execute", 1, 0, 'x'}, {"loglevel", 1, 0, 'l'}, + {"log-uuid", 0, 0, 'U'}, {"quiet", 0, 0, 'q'}, {"batchmode", 0, 0, 'b'}, {"retry", 0, 0, 'r'}, @@ -1303,6 +1316,7 @@ int main(int argc, char *argv[]) int argv_exec = 0; char argv_command[1024] = ""; char argv_loglevel[128] = ""; + int argv_log_uuid = 0; int argv_quiet = 0; int argv_batch = 0; int loops = 2, reconnect = 0, timeout = 0; @@ -1340,7 +1354,7 @@ int main(int argc, char *argv[]) esl_global_set_default_logger(6); /* default debug level to 6 (info) */ for(;;) { int option_index = 0; - opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:t:qrRhib?n", options, &option_index); + opt = getopt_long(argc, argv, "H:P:S:u:p:d:x:l:Ut:qrRhib?n", options, &option_index); if (opt == -1) break; switch (opt) { case 'H': @@ -1383,6 +1397,9 @@ int main(int argc, char *argv[]) case 'l': esl_set_string(argv_loglevel, optarg); break; + case 'U': + argv_log_uuid = 1; + break; case 'q': argv_quiet = 1; break; @@ -1445,6 +1462,9 @@ int main(int argc, char *argv[]) esl_set_string(profile->loglevel, argv_loglevel); profile->quiet = 0; } + if (argv_log_uuid) { + profile->log_uuid = 1; + } esl_log(ESL_LOG_DEBUG, "Using profile %s [%s]\n", profile->name, profile->host); esl_set_string(prompt_color, profile->prompt_color); esl_set_string(input_text_color, profile->input_text_color); diff --git a/libs/esl/java/esl_wrap.cpp b/libs/esl/java/esl_wrap.cpp index 0550231dde..c5c4fa60c2 100644 --- a/libs/esl/java/esl_wrap.cpp +++ b/libs/esl/java/esl_wrap.cpp @@ -634,7 +634,70 @@ SWIGEXPORT jstring JNICALL Java_org_freeswitch_esl_eslJNI_ESLevent_1nextHeader(J } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2, jstring jarg3, jstring jarg4) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + arg2 = (int)jarg2; + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + *(ESLconnection **)&jresult = result; + if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4); + return jresult; +} + + +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2, jstring jarg3) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + arg2 = (int)jarg2; + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + *(ESLconnection **)&jresult = result; + if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + return jresult; +} + + +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4) { jlong jresult = 0 ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -674,7 +737,7 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SW } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_13(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3) { jlong jresult = 0 ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -707,7 +770,7 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SW } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jint jarg1) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_14(JNIEnv *jenv, jclass jcls, jint jarg1) { jlong jresult = 0 ; int arg1 ; ESLconnection *result = 0 ; diff --git a/libs/esl/java/org/freeswitch/esl/ESLconnection.java b/libs/esl/java/org/freeswitch/esl/ESLconnection.java index 588cefcc99..a45613473d 100644 --- a/libs/esl/java/org/freeswitch/esl/ESLconnection.java +++ b/libs/esl/java/org/freeswitch/esl/ESLconnection.java @@ -33,16 +33,24 @@ public class ESLconnection { swigCPtr = 0; } - public ESLconnection(String host, String port, String user, String password) { + public ESLconnection(String host, int port, String user, String password) { this(eslJNI.new_ESLconnection__SWIG_0(host, port, user, password), true); } - public ESLconnection(String host, String port, String password) { + public ESLconnection(String host, int port, String password) { this(eslJNI.new_ESLconnection__SWIG_1(host, port, password), true); } + public ESLconnection(String host, String port, String user, String password) { + this(eslJNI.new_ESLconnection__SWIG_2(host, port, user, password), true); + } + + public ESLconnection(String host, String port, String password) { + this(eslJNI.new_ESLconnection__SWIG_3(host, port, password), true); + } + public ESLconnection(int socket) { - this(eslJNI.new_ESLconnection__SWIG_2(socket), true); + this(eslJNI.new_ESLconnection__SWIG_4(socket), true); } public int socketDescriptor() { diff --git a/libs/esl/java/org/freeswitch/esl/eslJNI.java b/libs/esl/java/org/freeswitch/esl/eslJNI.java index ff3744e9df..e7da6f5fdf 100644 --- a/libs/esl/java/org/freeswitch/esl/eslJNI.java +++ b/libs/esl/java/org/freeswitch/esl/eslJNI.java @@ -31,9 +31,11 @@ class eslJNI { public final static native boolean ESLevent_delHeader(long jarg1, ESLevent jarg1_, String jarg2); public final static native String ESLevent_firstHeader(long jarg1, ESLevent jarg1_); public final static native String ESLevent_nextHeader(long jarg1, ESLevent jarg1_); - public final static native long new_ESLconnection__SWIG_0(String jarg1, String jarg2, String jarg3, String jarg4); - public final static native long new_ESLconnection__SWIG_1(String jarg1, String jarg2, String jarg3); - public final static native long new_ESLconnection__SWIG_2(int jarg1); + public final static native long new_ESLconnection__SWIG_0(String jarg1, int jarg2, String jarg3, String jarg4); + public final static native long new_ESLconnection__SWIG_1(String jarg1, int jarg2, String jarg3); + public final static native long new_ESLconnection__SWIG_2(String jarg1, String jarg2, String jarg3, String jarg4); + public final static native long new_ESLconnection__SWIG_3(String jarg1, String jarg2, String jarg3); + public final static native long new_ESLconnection__SWIG_4(int jarg1); public final static native void delete_ESLconnection(long jarg1); public final static native int ESLconnection_socketDescriptor(long jarg1, ESLconnection jarg1_); public final static native int ESLconnection_connected(long jarg1, ESLconnection jarg1_); diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp index 9420f853bb..9dac86544d 100644 --- a/libs/esl/lua/esl_wrap.cpp +++ b/libs/esl/lua/esl_wrap.cpp @@ -2231,6 +2231,63 @@ static const char *swig_ESLevent_base_names[] = {0}; static swig_lua_class _wrap_class_ESLevent = { "ESLevent", &SWIGTYPE_p_ESLevent,_wrap_new_ESLevent, swig_delete_ESLevent, swig_ESLevent_methods, swig_ESLevent_attributes, swig_ESLevent_bases, swig_ESLevent_base_names }; static int _wrap_new_ESLconnection__SWIG_0(lua_State* L) { + int SWIG_arg = -1; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + SWIG_check_num_args("ESLconnection",4,4) + if(!lua_isstring(L,1)) SWIG_fail_arg("ESLconnection",1,"char const *"); + if(!lua_isnumber(L,2)) SWIG_fail_arg("ESLconnection",2,"int const"); + if(!lua_isstring(L,3)) SWIG_fail_arg("ESLconnection",3,"char const *"); + if(!lua_isstring(L,4)) SWIG_fail_arg("ESLconnection",4,"char const *"); + arg1 = (char *)lua_tostring(L, 1); + arg2 = (int const)lua_tonumber(L, 2); + arg3 = (char *)lua_tostring(L, 3); + arg4 = (char *)lua_tostring(L, 4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + SWIG_arg=0; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLconnection,1); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_new_ESLconnection__SWIG_1(lua_State* L) { + int SWIG_arg = -1; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + SWIG_check_num_args("ESLconnection",3,3) + if(!lua_isstring(L,1)) SWIG_fail_arg("ESLconnection",1,"char const *"); + if(!lua_isnumber(L,2)) SWIG_fail_arg("ESLconnection",2,"int const"); + if(!lua_isstring(L,3)) SWIG_fail_arg("ESLconnection",3,"char const *"); + arg1 = (char *)lua_tostring(L, 1); + arg2 = (int const)lua_tonumber(L, 2); + arg3 = (char *)lua_tostring(L, 3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + SWIG_arg=0; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLconnection,1); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_new_ESLconnection__SWIG_2(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2260,7 +2317,7 @@ fail: } -static int _wrap_new_ESLconnection__SWIG_1(lua_State* L) { +static int _wrap_new_ESLconnection__SWIG_3(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2287,7 +2344,7 @@ fail: } -static int _wrap_new_ESLconnection__SWIG_2(lua_State* L) { +static int _wrap_new_ESLconnection__SWIG_4(lua_State* L) { int SWIG_arg = -1; int arg1 ; ESLconnection *result = 0 ; @@ -2321,7 +2378,26 @@ static int _wrap_new_ESLconnection(lua_State* L) { _v = lua_isnumber(L,argv[0]); } if (_v) { - return _wrap_new_ESLconnection__SWIG_2(L); + return _wrap_new_ESLconnection__SWIG_4(L); + } + } + if (argc == 3) { + int _v; + { + _v = lua_isstring(L,argv[0]); + } + if (_v) { + { + _v = lua_isnumber(L,argv[1]); + } + if (_v) { + { + _v = lua_isstring(L,argv[2]); + } + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(L); + } + } } } if (argc == 3) { @@ -2338,7 +2414,31 @@ static int _wrap_new_ESLconnection(lua_State* L) { _v = lua_isstring(L,argv[2]); } if (_v) { - return _wrap_new_ESLconnection__SWIG_1(L); + return _wrap_new_ESLconnection__SWIG_3(L); + } + } + } + } + if (argc == 4) { + int _v; + { + _v = lua_isstring(L,argv[0]); + } + if (_v) { + { + _v = lua_isnumber(L,argv[1]); + } + if (_v) { + { + _v = lua_isstring(L,argv[2]); + } + if (_v) { + { + _v = lua_isstring(L,argv[3]); + } + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(L); + } } } } @@ -2361,7 +2461,7 @@ static int _wrap_new_ESLconnection(lua_State* L) { _v = lua_isstring(L,argv[3]); } if (_v) { - return _wrap_new_ESLconnection__SWIG_0(L); + return _wrap_new_ESLconnection__SWIG_2(L); } } } diff --git a/libs/esl/managed/ESLPINVOKE.cs b/libs/esl/managed/ESLPINVOKE.cs index 5ada2c148d..749ebeabfe 100644 --- a/libs/esl/managed/ESLPINVOKE.cs +++ b/libs/esl/managed/ESLPINVOKE.cs @@ -251,13 +251,19 @@ class ESLPINVOKE { public static extern string ESLevent_NextHeader(HandleRef jarg1); [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_0")] - public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, string jarg2, string jarg3, string jarg4); + public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, int jarg2, string jarg3, string jarg4); [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_1")] - public static extern IntPtr new_ESLconnection__SWIG_1(string jarg1, string jarg2, string jarg3); + public static extern IntPtr new_ESLconnection__SWIG_1(string jarg1, int jarg2, string jarg3); [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_2")] - public static extern IntPtr new_ESLconnection__SWIG_2(int jarg1); + public static extern IntPtr new_ESLconnection__SWIG_2(string jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_3")] + public static extern IntPtr new_ESLconnection__SWIG_3(string jarg1, string jarg2, string jarg3); + + [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_4")] + public static extern IntPtr new_ESLconnection__SWIG_4(int jarg1); [DllImport("ESL", EntryPoint="CSharp_delete_ESLconnection")] public static extern void delete_ESLconnection(HandleRef jarg1); diff --git a/libs/esl/managed/ESLconnection.cs b/libs/esl/managed/ESLconnection.cs index 2d1e6d4dc3..82efb907ed 100644 --- a/libs/esl/managed/ESLconnection.cs +++ b/libs/esl/managed/ESLconnection.cs @@ -38,13 +38,19 @@ public class ESLconnection : IDisposable { } } - public ESLconnection(string host, string port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_0(host, port, user, password), true) { + public ESLconnection(string host, int port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_0(host, port, user, password), true) { } - public ESLconnection(string host, string port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_1(host, port, password), true) { + public ESLconnection(string host, int port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_1(host, port, password), true) { } - public ESLconnection(int socket) : this(ESLPINVOKE.new_ESLconnection__SWIG_2(socket), true) { + public ESLconnection(string host, string port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_2(host, port, user, password), true) { + } + + public ESLconnection(string host, string port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_3(host, port, password), true) { + } + + public ESLconnection(int socket) : this(ESLPINVOKE.new_ESLconnection__SWIG_4(socket), true) { } public int SocketDescriptor() { diff --git a/libs/esl/managed/esl_wrap.cpp b/libs/esl/managed/esl_wrap.cpp index 65da98a15a..010ece83e2 100644 --- a/libs/esl/managed/esl_wrap.cpp +++ b/libs/esl/managed/esl_wrap.cpp @@ -576,7 +576,41 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_ESLevent_NextHeader(void * jarg1) { } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, char * jarg2, char * jarg3, char * jarg4) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, int jarg2, char * jarg3, char * jarg4) { + void * jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, int jarg2, char * jarg3) { + void * jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (char *)jarg3; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_2(char * jarg1, char * jarg2, char * jarg3, char * jarg4) { void * jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -594,7 +628,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, cha } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, char * jarg2, char * jarg3) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_3(char * jarg1, char * jarg2, char * jarg3) { void * jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -610,7 +644,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, cha } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_2(int jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_4(int jarg1) { void * jresult ; int arg1 ; ESLconnection *result = 0 ; diff --git a/libs/esl/perl/esl_wrap.cpp b/libs/esl/perl/esl_wrap.cpp index 832289f156..e2b7eec88c 100644 --- a/libs/esl/perl/esl_wrap.cpp +++ b/libs/esl/perl/esl_wrap.cpp @@ -2673,6 +2673,117 @@ XS(_wrap_ESLevent_nextHeader) { XS(_wrap_new_ESLconnection__SWIG_0) { + { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: new_ESLconnection(host,port,user,password);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_1) { + { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: new_ESLconnection(host,port,password);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_2) { { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2734,7 +2845,7 @@ XS(_wrap_new_ESLconnection__SWIG_0) { } -XS(_wrap_new_ESLconnection__SWIG_1) { +XS(_wrap_new_ESLconnection__SWIG_3) { { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -2785,7 +2896,7 @@ XS(_wrap_new_ESLconnection__SWIG_1) { } -XS(_wrap_new_ESLconnection__SWIG_2) { +XS(_wrap_new_ESLconnection__SWIG_4) { { int arg1 ; ESLconnection *result = 0 ; @@ -2855,8 +2966,10 @@ XS(_wrap_new_ESLconnection) { _rankm += _pi; _pi *= SWIG_MAXCASTRANK; { - int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); - _v = SWIG_CheckState(res); + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } } if (!_v) goto check_2; _ranki += _v*_pi; @@ -2877,7 +2990,7 @@ XS(_wrap_new_ESLconnection) { } check_2: - if (items == 4) { + if (items == 3) { SWIG_TypeRank _ranki = 0; SWIG_TypeRank _rankm = 0; SWIG_TypeRank _pi = 1; @@ -2906,14 +3019,6 @@ XS(_wrap_new_ESLconnection) { _ranki += _v*_pi; _rankm += _pi; _pi *= SWIG_MAXCASTRANK; - { - int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); - _v = SWIG_CheckState(res); - } - if (!_v) goto check_3; - _ranki += _v*_pi; - _rankm += _pi; - _pi *= SWIG_MAXCASTRANK; if (!_index || (_ranki < _rank)) { _rank = _ranki; _index = 3; if (_rank == _rankm) goto dispatch; @@ -2921,14 +3026,108 @@ XS(_wrap_new_ESLconnection) { } check_3: + if (items == 4) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 4; + if (_rank == _rankm) goto dispatch; + } + } + check_4: + + if (items == 4) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_5; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 5; + if (_rank == _rankm) goto dispatch; + } + } + check_5: + dispatch: switch(_index) { case 1: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_2); return; + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_4); return; case 2: ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_1); return; case 3: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_3); return; + case 4: ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_0); return; + case 5: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_2); return; } } diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index b5fd7a7d52..8c91f25452 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -1796,6 +1796,93 @@ fail: ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_0) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + zval **args[4]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 4 || zend_get_parameters_array_ex(4, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG@*/; + + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + zval **args[3]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,7,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@SWIG@*/; + + + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -1842,7 +1929,7 @@ fail: } -ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) { +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_3) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -1882,7 +1969,7 @@ fail: } -ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) { +ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_4) { int arg1 ; ESLconnection *result = 0 ; zval **args[1]; @@ -1918,7 +2005,20 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { int _v; _v = (Z_TYPE_PP(argv[0]) == IS_LONG); if (_v) { - return _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); + return _wrap_new_ESLconnection__SWIG_4(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + if (argc == 3) { + int _v; + _v = (Z_TYPE_PP(argv[0]) == IS_STRING); + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG); + if (_v) { + _v = (Z_TYPE_PP(argv[2]) == IS_STRING); + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } } } if (argc == 3) { @@ -1929,7 +2029,23 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[2]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + return _wrap_new_ESLconnection__SWIG_3(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + if (argc == 4) { + int _v; + _v = (Z_TYPE_PP(argv[0]) == IS_STRING); + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG); + if (_v) { + _v = (Z_TYPE_PP(argv[2]) == IS_STRING); + if (_v) { + _v = (Z_TYPE_PP(argv[3]) == IS_STRING); + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } } } } @@ -1944,7 +2060,7 @@ ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) { if (_v) { _v = (Z_TYPE_PP(argv[3]) == IS_STRING); if (_v) { - return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + return _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU); } } } diff --git a/libs/esl/python/esl_wrap.cpp b/libs/esl/python/esl_wrap.cpp index 35d600e0b0..b12f21cab0 100644 --- a/libs/esl/python/esl_wrap.cpp +++ b/libs/esl/python/esl_wrap.cpp @@ -3786,6 +3786,124 @@ SWIGINTERN PyObject *ESLevent_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObj } SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (!PyArg_ParseTuple(args,(char *)"OOOO:new_ESLconnection",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_PYTHON_THREAD_END_BLOCK; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (!PyArg_ParseTuple(args,(char *)"OOO:new_ESLconnection",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_PYTHON_THREAD_END_BLOCK; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -3853,7 +3971,7 @@ fail: } -SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -3909,7 +4027,7 @@ fail: } -SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; ESLconnection *result = 0 ; @@ -3957,7 +4075,26 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { } if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; - return _wrap_new_ESLconnection__SWIG_2(self, args); + return _wrap_new_ESLconnection__SWIG_4(self, args); + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + SWIG_PYTHON_THREAD_END_BLOCK; + return _wrap_new_ESLconnection__SWIG_1(self, args); + } + } } } if (argc == 3) { @@ -3972,7 +4109,30 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; - return _wrap_new_ESLconnection__SWIG_1(self, args); + return _wrap_new_ESLconnection__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + SWIG_PYTHON_THREAD_END_BLOCK; + return _wrap_new_ESLconnection__SWIG_0(self, args); + } } } } @@ -3992,7 +4152,7 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; - return _wrap_new_ESLconnection__SWIG_0(self, args); + return _wrap_new_ESLconnection__SWIG_2(self, args); } } } @@ -4003,6 +4163,8 @@ SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_ESLconnection'.\n" " Possible C/C++ prototypes are:\n" + " ESLconnection(char const *,int const,char const *,char const *)\n" + " ESLconnection(char const *,int const,char const *)\n" " ESLconnection(char const *,char const *,char const *,char const *)\n" " ESLconnection(char const *,char const *,char const *)\n" " ESLconnection(int)\n"); diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 223ba3ea34..2d7e906402 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -2745,6 +2745,107 @@ swig_class cESLconnection; SWIGINTERN VALUE _wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","ESLconnection", 1, argv[0] )); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","ESLconnection", 2, argv[1] )); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] )); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(argv[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","ESLconnection", 4, argv[3] )); + } + arg4 = reinterpret_cast< char * >(buf4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4);DATA_PTR(self) = result; + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + + if ((argc < 3) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","ESLconnection", 1, argv[0] )); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","ESLconnection", 2, argv[1] )); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] )); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3);DATA_PTR(self) = result; + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -2803,7 +2904,7 @@ fail: SWIGINTERN VALUE -_wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) { +_wrap_new_ESLconnection__SWIG_3(int argc, VALUE *argv, VALUE self) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; @@ -2868,7 +2969,7 @@ _wrap_ESLconnection_allocate(VALUE self) { SWIGINTERN VALUE -_wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) { +_wrap_new_ESLconnection__SWIG_4(int argc, VALUE *argv, VALUE self) { int arg1 ; ESLconnection *result = 0 ; int val1 ; @@ -2907,7 +3008,25 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { _v = SWIG_CheckState(res); } if (_v) { - return _wrap_new_ESLconnection__SWIG_2(nargs, args, self); + return _wrap_new_ESLconnection__SWIG_4(nargs, args, self); + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(nargs, args, self); + } + } } } if (argc == 3) { @@ -2921,7 +3040,29 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_ESLconnection__SWIG_1(nargs, args, self); + return _wrap_new_ESLconnection__SWIG_3(nargs, args, self); + } + } + } + } + if (argc == 4) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(nargs, args, self); + } } } } @@ -2940,7 +3081,7 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_ESLconnection__SWIG_0(nargs, args, self); + return _wrap_new_ESLconnection__SWIG_2(nargs, args, self); } } } @@ -2949,6 +3090,8 @@ SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 4, "ESLconnection.new", + " ESLconnection.new(char const *host, int const port, char const *user, char const *password)\n" + " ESLconnection.new(char const *host, int const port, char const *password)\n" " ESLconnection.new(char const *host, char const *port, char const *user, char const *password)\n" " ESLconnection.new(char const *host, char const *port, char const *password)\n" " ESLconnection.new(int socket)\n"); diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c index 19cb6708a5..910180f47e 100644 --- a/libs/esl/src/esl_event.c +++ b/libs/esl/src/esl_event.c @@ -445,7 +445,7 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st fly++; } - if ((header = esl_event_get_header_ptr(event, header_name))) { + if (header || (header = esl_event_get_header_ptr(event, header_name))) { if (index_ptr) { if (index > -1 && index <= 4000) { diff --git a/libs/esl/src/esl_oop.cpp b/libs/esl/src/esl_oop.cpp index 3fa4dcce56..9c202f2160 100644 --- a/libs/esl/src/esl_oop.cpp +++ b/libs/esl/src/esl_oop.cpp @@ -9,6 +9,20 @@ void eslSetLogLevel(int level) esl_global_set_default_logger(level); } +ESLconnection::ESLconnection(const char *host, const int port, const char *password) +{ + connection_construct_common(); + + esl_connect(&handle, host, port, NULL, password); +} + +ESLconnection::ESLconnection(const char *host, const int port, const char *user, const char *password) +{ + connection_construct_common(); + + esl_connect(&handle, host, port, user, password); +} + ESLconnection::ESLconnection(const char *host, const char *port, const char *password) { connection_construct_common(); diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 450b047afc..93ce487965 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -74,6 +74,8 @@ class ESLconnection { private: esl_handle_t handle; public: + ESLconnection(const char *host, const int port, const char *user, const char *password); + ESLconnection(const char *host, const int port, const char *password); ESLconnection(const char *host, const char *port, const char *user, const char *password); ESLconnection(const char *host, const char *port, const char *password); ESLconnection(int socket); diff --git a/libs/freetdm/.gitignore b/libs/freetdm/.gitignore index ff2a46a071..da2caa7d87 100644 --- a/libs/freetdm/.gitignore +++ b/libs/freetdm/.gitignore @@ -26,6 +26,9 @@ testr2 testsangomaboost testtones +!/msvc/testanalog/ +!/msvc/testboost/ + !/sample/boost/Makefile !/sample/dso/Makefile diff --git a/libs/freetdm/src/libteletone_generate.c b/libs/freetdm/src/libteletone_generate.c index 3654d1ec34..ef7a7e03ec 100644 --- a/libs/freetdm/src/libteletone_generate.c +++ b/libs/freetdm/src/libteletone_generate.c @@ -382,9 +382,12 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm break; case 'L': if (!LOOPING) { - ts->LOOPS = atoi(cur + 2); + int L; + if ((L = atoi(cur + 2)) > 0) { + ts->LOOPS = L; + LOOPING++; + } } - LOOPING++; break; } } else { @@ -480,6 +483,7 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm bottom: free(data); data = NULL; + if (ts->LOOPS > 0) { ts->LOOPS--; } diff --git a/libs/iksemel/.update b/libs/iksemel/.update index b391edc878..a3a56a0ec9 100644 --- a/libs/iksemel/.update +++ b/libs/iksemel/.update @@ -1 +1 @@ -Tue May 14 07:44:21 CDT 2013 +Mon Jul 15 16:57:11 CDT 2013 diff --git a/libs/iksemel/include/iksemel.h b/libs/iksemel/include/iksemel.h index 9ef479a9ee..2b11070671 100644 --- a/libs/iksemel/include/iksemel.h +++ b/libs/iksemel/include/iksemel.h @@ -226,6 +226,7 @@ void iks_disconnect (iksparser *prs); int iks_has_tls (void); int iks_is_secure (iksparser *prs); int iks_start_tls (iksparser *prs); +int iks_proceed_tls (iksparser *prs, const char *cert_file, const char *key_file, int use_ssl); int iks_start_sasl (iksparser *prs, enum ikssasltype type, char *username, char *pass); /***** jabber *****/ diff --git a/libs/iksemel/src/stream.c b/libs/iksemel/src/stream.c index 559335b16e..658c40207c 100644 --- a/libs/iksemel/src/stream.c +++ b/libs/iksemel/src/stream.c @@ -35,6 +35,8 @@ typedef unsigned __int32 uint32_t; #define SF_FOREIGN 1 #define SF_TRY_SECURE 2 #define SF_SECURE 4 +#define SF_SERVER 8 +#define SF_SSLv23 16 struct stream_data { iksparser *prs; @@ -51,6 +53,8 @@ struct stream_data { unsigned int flags; char *auth_username; char *auth_pass; + char *cert_file; + char *key_file; #ifdef HAVE_GNUTLS gnutls_session sess; gnutls_certificate_credentials cred; @@ -201,6 +205,7 @@ handshake (struct stream_data *data) gnutls_certificate_free_credentials (data->cred); return IKS_NOMEM; } + gnutls_protocol_set_priority (data->sess, protocol_priority); gnutls_cipher_set_priority(data->sess, cipher_priority); gnutls_compression_set_priority(data->sess, comp_priority); @@ -224,7 +229,9 @@ handshake (struct stream_data *data) data->flags &= (~SF_TRY_SECURE); data->flags |= SF_SECURE; - iks_send_header (data->prs, data->server); + if (!(data->flags & SF_SERVER)) { + iks_send_header (data->prs, data->server); + } return IKS_OK; } // HAVE_GNUTLS @@ -311,8 +318,25 @@ handshake (struct stream_data *data) SSL_library_init(); SSL_load_error_strings(); - data->ssl_ctx = SSL_CTX_new(TLSv1_method()); - if(!data->ssl_ctx) return IKS_NOMEM; + if (data->flags & SF_SERVER) { + if (data->flags & SF_SSLv23) { + data->ssl_ctx = SSL_CTX_new(SSLv23_server_method()); + } else { + data->ssl_ctx = SSL_CTX_new(TLSv1_server_method()); + } + if(!data->ssl_ctx) return IKS_NOMEM; + + if (SSL_CTX_use_certificate_file(data->ssl_ctx, data->cert_file, SSL_FILETYPE_PEM) <= 0) { + return IKS_NET_TLSFAIL; + } + if (SSL_CTX_use_PrivateKey_file(data->ssl_ctx, data->key_file, SSL_FILETYPE_PEM) <= 0) { + return IKS_NET_TLSFAIL; + } + SSL_CTX_set_verify(data->ssl_ctx, SSL_VERIFY_NONE, NULL); + } else { + data->ssl_ctx = SSL_CTX_new(TLSv1_method()); + if(!data->ssl_ctx) return IKS_NOMEM; + } data->ssl = SSL_new(data->ssl_ctx); if(!data->ssl) return IKS_NOMEM; @@ -329,7 +353,11 @@ handshake (struct stream_data *data) do { - ret = SSL_connect(data->ssl); + if (data->flags & SF_SERVER) { + ret = SSL_accept(data->ssl); + } else { + ret = SSL_connect(data->ssl); + } if( ret != 1 ) { @@ -346,7 +374,9 @@ handshake (struct stream_data *data) data->flags &= (~SF_TRY_SECURE); data->flags |= SF_SECURE; - iks_send_header (data->prs, data->server); + if (!(data->flags & SF_SERVER)) { + iks_send_header (data->prs, data->server); + } } return ret == 1 ? IKS_OK : IKS_NET_TLSFAIL; @@ -954,6 +984,40 @@ iks_start_tls (iksparser *prs) #endif } +int +iks_proceed_tls (iksparser *prs, const char *cert_file, const char *key_file, int use_ssl) +{ +#ifdef HAVE_GNUTLS + int ret; + struct stream_data *data = iks_user_data (prs); + + ret = iks_send_raw (prs, ""); + if (ret) return ret; + data->cert_file = iks_stack_strdup(data->s, cert_file, 0); + data->key_file = iks_stack_strdup(data->s, key_file, 0); + data->flags |= SF_TRY_SECURE | SF_SERVER; + if (use_ssl) { + data->flags |= SF_SSLv23; + } + return handshake (data); +#elif HAVE_SSL + int ret; + struct stream_data *data = iks_user_data (prs); + + ret = iks_send_raw (prs, ""); + if (ret) return ret; + data->cert_file = iks_stack_strdup(data->s, cert_file, 0); + data->key_file = iks_stack_strdup(data->s, key_file, 0); + data->flags |= SF_TRY_SECURE | SF_SERVER; + if (use_ssl) { + data->flags |= SF_SSLv23; + } + return handshake (data); +#else + return IKS_NET_NOTSUPP; +#endif +} + /***** sasl *****/ int diff --git a/libs/libteletone/src/libteletone_generate.c b/libs/libteletone/src/libteletone_generate.c index 3654d1ec34..ef7a7e03ec 100644 --- a/libs/libteletone/src/libteletone_generate.c +++ b/libs/libteletone/src/libteletone_generate.c @@ -382,9 +382,12 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm break; case 'L': if (!LOOPING) { - ts->LOOPS = atoi(cur + 2); + int L; + if ((L = atoi(cur + 2)) > 0) { + ts->LOOPS = L; + LOOPING++; + } } - LOOPING++; break; } } else { @@ -480,6 +483,7 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm bottom: free(data); data = NULL; + if (ts->LOOPS > 0) { ts->LOOPS--; } diff --git a/libs/openzap/.gitignore b/libs/openzap/.gitignore index b0dc177c9a..48d9684d18 100644 --- a/libs/openzap/.gitignore +++ b/libs/openzap/.gitignore @@ -22,3 +22,6 @@ testisdn testpri testr2 testtones + +!/msvc/testanalog/ +!/msvc/testisdn/ diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 91bc2e3e8a..eba02f5caf 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Tue Jun 25 09:28:40 CDT 2013 +Mon Jul 29 16:07:25 CDT 2013 diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c index f5d61e4530..68563978cd 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c +++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c @@ -152,9 +152,7 @@ struct nta_agent_s nta_error_magic_t *sa_error_magic; nta_error_tport_f *sa_error_tport; - su_time_t sa_now; /**< Timestamp in microsecond resolution. */ uint32_t sa_next; /**< Timestamp for next agent_timer. */ - uint32_t sa_millisec; /**< Timestamp in milliseconds. */ msg_mclass_t const *sa_mclass; uint32_t sa_flags; /**< SIP message flags */ @@ -1242,15 +1240,12 @@ void agent_timer(su_root_magic_t *rm, su_timer_t *timer, nta_agent_t *agent) agent->sa_next = 0; - agent->sa_now = stamp; - agent->sa_millisec = now; agent->sa_in_timer = 1; + _nta_outgoing_timer(agent); _nta_incoming_timer(agent); - /* agent->sa_now is used only if sa_millisec != 0 */ - agent->sa_millisec = 0; agent->sa_in_timer = 0; /* Calculate next timeout */ @@ -1335,12 +1330,12 @@ uint32_t set_timeout(nta_agent_t *agent, uint32_t offset) if (offset == 0) return 0; - if (agent->sa_millisec) /* Avoid expensive call to su_now() */ - now = agent->sa_now, ms = agent->sa_millisec; - else - now = su_now(), ms = su_time_ms(now); + now = su_now(); + ms = su_time_ms(now); - next = ms + offset; if (next == 0) next = 1; + next = ms + offset; + + if (next == 0) next = 1; if (agent->sa_in_timer) /* Currently executing timer */ return next; @@ -1365,9 +1360,6 @@ uint32_t set_timeout(nta_agent_t *agent, uint32_t offset) static su_time_t agent_now(nta_agent_t const *agent) { - if (agent && agent->sa_millisec != 0) - return agent->sa_now; - else return su_now(); } @@ -2784,8 +2776,6 @@ void agent_recv_message(nta_agent_t *agent, { sip_t *sip = sip_object(msg); - agent->sa_millisec = su_time_ms(agent->sa_now = now); - if (sip && sip->sip_request) { agent_recv_request(agent, msg, sip, tport); } @@ -2795,8 +2785,6 @@ void agent_recv_message(nta_agent_t *agent, else { agent_recv_garbage(agent, msg, tport); } - - agent->sa_millisec = 0; } /** @internal Handle incoming requests. */ @@ -6869,7 +6857,7 @@ enum { static void _nta_incoming_timer(nta_agent_t *sa) { - uint32_t now = sa->sa_millisec; + uint32_t now = su_time_ms(su_now()); nta_incoming_t *irq, *irq_next; size_t retransmitted = 0, timeout = 0, terminated = 0, destroyed = 0; size_t unconfirmed = @@ -6886,6 +6874,9 @@ _nta_incoming_timer(nta_agent_t *sa) /* Handle retry queue */ while ((irq = sa->sa_in.re_list)) { + + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_retry - now) > 0) break; if (retransmitted >= timer_max_retransmit) @@ -6943,6 +6934,8 @@ _nta_incoming_timer(nta_agent_t *sa) } while ((irq = sa->sa_in.final_failed->q_head)) { + + incoming_remove(irq); irq->irq_final_failed = 0; @@ -6974,6 +6967,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_status < 200); assert(irq->irq_timeout); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0) break; if (timeout >= timer_max_timeout) @@ -6994,6 +6989,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_timeout); assert(irq->irq_method == sip_method_invite); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0 || timeout >= timer_max_timeout || terminated >= timer_max_terminate) @@ -7022,6 +7019,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_status >= 200); assert(irq->irq_method == sip_method_invite); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0 || terminated >= timer_max_terminate) break; @@ -7044,6 +7043,8 @@ _nta_incoming_timer(nta_agent_t *sa) assert(irq->irq_timeout); assert(irq->irq_method != sip_method_invite); + now = su_time_ms(su_now()); + if ((int32_t)(irq->irq_timeout - now) > 0 || terminated >= timer_max_terminate) break; @@ -7063,6 +7064,7 @@ _nta_incoming_timer(nta_agent_t *sa) } for (irq = sa->sa_in.terminated->q_head; irq; irq = irq_next) { + irq_next = irq->irq_next; if (irq->irq_destroyed) incoming_free_queue(rq, irq); @@ -8727,7 +8729,7 @@ void outgoing_destroy(nta_outgoing_t *orq) static void _nta_outgoing_timer(nta_agent_t *sa) { - uint32_t now = sa->sa_millisec; + uint32_t now = su_time_ms(su_now()); nta_outgoing_t *orq; outgoing_queue_t rq[1]; size_t retransmitted = 0, terminated = 0, timeout = 0, destroyed; @@ -8741,6 +8743,9 @@ _nta_outgoing_timer(nta_agent_t *sa) outgoing_queue_init(sa->sa_out.free = rq, 0); while ((orq = sa->sa_out.re_list)) { + + now = su_time_ms(su_now()); + if ((int32_t)(orq->orq_retry - now) > 0) break; if (retransmitted >= timer_max_retransmit) diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c index a9fed48ffe..c5400dd4ca 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c @@ -1062,11 +1062,15 @@ int nua_client_response(nua_client_request_t *cr, sip_method_t method = cr->cr_method; int terminated, graceful = 1; - if (status < 700) - terminated = sip_response_terminates_dialog(status, method, &graceful); - else - /* XXX - terminate usage by all internal error responses */ - terminated = 0, graceful = 1; + if (status < 700) { + terminated = sip_response_terminates_dialog(status, method, &graceful); + if (terminated && !cr->cr_initial) { + terminated = 0, graceful = 1; + } + } else { + /* XXX - terminate usage by all internal error responses */ + terminated = 0, graceful = 1; + } if (terminated < 0) cr->cr_terminated = terminated; diff --git a/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c b/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c index c912dd3b59..b587aa5cc1 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c +++ b/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c @@ -590,7 +590,7 @@ static void print_media(sdp_printer_t *p, case sdp_proto_udp: proto = "udp"; break; case sdp_proto_rtp: proto = "RTP/AVP"; break; case sdp_proto_srtp: proto = "RTP/SAVP"; break; - case sdp_proto_extended_srtp: proto = "RTP/SAVPF"; break; + //case sdp_proto_extended_srtp: proto = "RTP/SAVPF"; break; case sdp_proto_udptl: proto = "udptl"; break; case sdp_proto_msrp: proto = "TCP/MSRP"; break; case sdp_proto_msrps: proto = "TCP/TLS/MSRP"; break; diff --git a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h index b4acba6a7d..ea347e80a0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h +++ b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_time.h @@ -85,6 +85,11 @@ typedef uint64_t su_nanotime_t; #define SU_E9 (1000000000U) +typedef void (*su_time_func_t)(su_time_t *tv); + + +SOFIAPUBFUN void su_set_time_func(su_time_func_t func); + SOFIAPUBFUN su_nanotime_t su_nanotime(su_nanotime_t *return_time); SOFIAPUBFUN su_nanotime_t su_monotime(su_nanotime_t *return_time); @@ -138,7 +143,7 @@ su_inline uint32_t su_ntp_fraq(su_time_t t) /** Time as milliseconds. */ su_inline uint32_t su_time_ms(su_time_t t) { - return t.tv_sec * 1000 + (t.tv_usec + 500) / 1000; + return (t.tv_sec * 1000) + ((t.tv_usec + 500) / 1000); } #endif diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c b/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c index 0543e45aa0..cae14a35a8 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_time0.c @@ -69,6 +69,13 @@ void (*_su_time)(su_time_t *tv); uint64_t (*_su_nanotime)(uint64_t *); +static su_time_func_t custom_time_func = NULL; + +void su_set_time_func(su_time_func_t func) { + custom_time_func = func; +} + + /** Get current time. * * The function @c su_time() fills its argument with the current NTP @@ -78,7 +85,20 @@ uint64_t (*_su_nanotime)(uint64_t *); */ void su_time(su_time_t *tv) { +#if HAVE_FILETIME + union { + FILETIME ft[1]; + ULARGE_INTEGER ull[1]; + } date; +#endif su_time_t ltv = {0,0}; + + if (custom_time_func) { + custom_time_func(<v); + if (tv) *tv = ltv; + return; + } + #if HAVE_CLOCK_GETTIME struct timespec ctv = {0}; if (clock_gettime(CLOCK_REALTIME, &ctv) == 0) { @@ -91,10 +111,6 @@ void su_time(su_time_t *tv) ltv.tv_sec += NTP_EPOCH; #elif HAVE_FILETIME - union { - FILETIME ft[1]; - ULARGE_INTEGER ull[1]; - } date; GetSystemTimeAsFileTime(date.ft); diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c index 6cbb4336ce..50050e2289 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c @@ -885,12 +885,16 @@ tport_t *tport_alloc_secondary(tport_primary_t *pri, self->tp_stime = self->tp_ktime = self->tp_rtime = su_now(); if (pri->pri_vtable->vtp_init_secondary && - pri->pri_vtable->vtp_init_secondary(self, socket, accepted, - return_reason) < 0) { - if (pri->pri_vtable->vtp_deinit_secondary) - pri->pri_vtable->vtp_deinit_secondary(self); - su_home_zap(self->tp_home); - return NULL; + + pri->pri_vtable->vtp_init_secondary(self, socket, accepted, return_reason) < 0) { + + if (pri->pri_vtable->vtp_deinit_secondary) { + pri->pri_vtable->vtp_deinit_secondary(self); + } + su_timer_destroy(self->tp_timer); + su_home_zap(self->tp_home); + + return NULL; } /* Set IP TOS if it is set in primary */ diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c index c6846be1e1..67f78148fb 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c @@ -207,23 +207,14 @@ int tport_recv_stream_ws(tport_t *self) int err; msg_iovec_t iovec[msg_n_fragments] = {{ 0 }}; tport_ws_t *wstp = (tport_ws_t *)self; - wsh_t *ws = wstp->ws; - tport_ws_primary_t *wspri = (tport_ws_primary_t *)self->tp_pri; uint8_t *data; ws_opcode_t oc; if (wstp->ws_initialized < 0) { return -1; - } else if (wstp->ws_initialized == 0) { - if (ws_init(ws, self->tp_socket, 65336, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0) == -2) { - return 2; - } - wstp->ws_initialized = 1; - self->tp_pre_framed = 1; - return 1; } - N = ws_read_frame(ws, &oc, &data); + N = ws_read_frame(&wstp->ws, &oc, &data); if (N == -2) { return 2; @@ -276,7 +267,6 @@ ssize_t tport_send_stream_ws(tport_t const *self, msg_t *msg, size_t i, j, n, m, size = 0; ssize_t nerror; tport_ws_t *wstp = (tport_ws_t *)self; - wsh_t *ws = wstp->ws; enum { WSBUFSIZE = 2048 }; @@ -311,10 +301,10 @@ ssize_t tport_send_stream_ws(tport_t const *self, msg_t *msg, iov[j].siv_base = buf, iov[j].siv_len = m; } - nerror = ws_feed_buf(ws, buf, m); + nerror = ws_feed_buf(&wstp->ws, buf, m); SU_DEBUG_9(("tport_ws_writevec: vec %p %p %lu ("MOD_ZD")\n", - (void *)ws, (void *)iov[i].siv_base, (LU)iov[i].siv_len, + (void *)&wstp->ws, (void *)iov[i].siv_base, (LU)iov[i].siv_len, nerror)); if (nerror == -1) { @@ -333,7 +323,7 @@ ssize_t tport_send_stream_ws(tport_t const *self, msg_t *msg, break; } - ws_send_buf(ws, WSOC_TEXT); + ws_send_buf(&wstp->ws, WSOC_TEXT); return size; @@ -446,13 +436,39 @@ int tport_ws_init_secondary(tport_t *self, int socket, int accepted, self->tp_has_connection = 1; if (setsockopt(socket, SOL_TCP, TCP_NODELAY, (void *)&one, sizeof one) == -1) - return *return_reason = "TCP_NODELAY", -1; + return *return_reason = "TCP_NODELAY", -1; + +#if defined(SO_KEEPALIVE) + setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof one); +#endif + one = 30; +#if defined(TCP_KEEPIDLE) + setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&one, sizeof one); +#endif +#if defined(TCP_KEEPINTVL) + setsockopt(socket, SOL_TCP, TCP_KEEPINTVL, (void *)&one, sizeof one); +#endif + if (!accepted) tport_ws_setsndbuf(socket, 64 * 1024); if ( wspri->ws_secure ) wstp->ws_secure = 1; + memset(&wstp->ws, 0, sizeof(wstp->ws)); + + if (ws_init(&wstp->ws, socket, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0) < 0) { + ws_destroy(&wstp->ws); + su_close(socket); + wstp->ws_initialized = -1; + return *return_reason = "WS_INIT", -1; + } + + wstp->ws_initialized = 1; + self->tp_pre_framed = 1; + + + return 0; } @@ -461,10 +477,9 @@ static void tport_ws_deinit_secondary(tport_t *self) tport_ws_t *wstp = (tport_ws_t *)self; if (wstp->ws_initialized == 1) { - wsh_t *wsh = wstp->ws; - SU_DEBUG_1(("%p destroy ws%s transport %p.\n", (void *) self, wstp->ws_secure ? "s" : "", (void *) wsh)); - ws_destroy(&wsh); - wstp->ws_initialized = 1; + SU_DEBUG_1(("%p destroy ws%s transport %p.\n", (void *) self, wstp->ws_secure ? "s" : "", (void *) &wstp->ws)); + ws_destroy(&wstp->ws); + wstp->ws_initialized = -1; } } diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/tport_ws.h index 034b6f8fde..b4a5d42b5a 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_ws.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_ws.h @@ -55,7 +55,7 @@ typedef enum { typedef struct tport_ws_s { tport_t wstp_tp[1]; - wsh_t ws[1]; + wsh_t ws; char *wstp_buffer; SU_S8_T ws_initialized; unsigned ws_secure:1; diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 938b3f6d04..35fb4c0f22 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -1,5 +1,10 @@ #include "ws.h" #include + +#ifndef _MSC_VER +#include +#endif + #define SHA1_HASH_SIZE 20 struct globals_s globals; @@ -237,6 +242,10 @@ int ws_handshake(wsh_t *wsh) } } + if (bytes > sizeof(wsh->buffer)) { + goto err; + } + *(wsh->buffer+bytes) = '\0'; if (strncasecmp(wsh->buffer, "GET ", 4)) { @@ -316,16 +325,17 @@ issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes) do { r = recv(wsh->sock, data, bytes, 0); #ifndef _MSC_VER - if (x++) usleep(10000); + if (x++) usleep(10000); #else - if (x++) Sleep(10); + if (x++) Sleep(10); #endif - } while (r == -1 && (errno == EAGAIN || errno == EINTR) && x < 100); - - //if (r<0) { - // printf("READ FAIL: %s\n", strerror(errno)); - //} - + } while (r == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK || + errno == 35 || errno == 730035 || errno == 2 || errno == 60) && x < 100); + + if (x >= 100) { + r = -1; + } + return r; } @@ -352,7 +362,54 @@ issize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes) return r; } -int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int close_sock) +#ifdef _MSC_VER +static int setup_socket(ws_socket_t sock) +{ + unsigned long v = 1; + + if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR) { + return -1; + } + + return 0; + +} + +static int restore_socket(ws_socket_t sock) +{ + unsigned long v = 0; + + if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR) { + return -1; + } + + return 0; + +} + +#else + +static int setup_socket(ws_socket_t sock) +{ + int flags = fcntl(sock, F_GETFL, 0); + return fcntl(sock, F_SETFL, flags | O_NONBLOCK); +} + +static int restore_socket(ws_socket_t sock) +{ + int flags = fcntl(sock, F_GETFL, 0); + + flags &= ~O_NONBLOCK; + + return fcntl(sock, F_SETFL, flags); + +} + +#endif + + + +int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) { memset(wsh, 0, sizeof(*wsh)); wsh->sock = sock; @@ -365,21 +422,15 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int c wsh->close_sock = 1; } - if (buflen > MAXLEN) { - buflen = MAXLEN; - } - - wsh->buflen = buflen; + wsh->buflen = sizeof(wsh->buffer); wsh->secure = ssl_ctx ? 1 : 0; - if (!wsh->buffer) { - wsh->buffer = malloc(wsh->buflen); - assert(wsh->buffer); - } + setup_socket(sock); if (wsh->secure) { int code; - + int sanity = 500; + wsh->ssl = SSL_new(ssl_ctx); assert(wsh->ssl); @@ -387,12 +438,41 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int c do { code = SSL_accept(wsh->ssl); - } while (code == -1 && SSL_get_error(wsh->ssl, code) == SSL_ERROR_WANT_READ); + if (code == 1) { + break; + } + + if (code == 0) { + return -1; + } + + if (code < 0) { + if (code == -1 && SSL_get_error(wsh->ssl, code) != SSL_ERROR_WANT_READ) { + return -1; + } + } +#ifndef _MSC_VER + usleep(10000); +#else + Sleep(10); +#endif + + } while (--sanity > 0); + + if (!sanity) { + return -1; + } + } while (!wsh->down && !wsh->handshake) { - ws_handshake(wsh); + int r = ws_handshake(wsh); + + if (r < 0) { + wsh->down = 1; + return -1; + } } if (wsh->down) { @@ -402,17 +482,13 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int c return 0; } -void ws_destroy(wsh_t **wshp) +void ws_destroy(wsh_t *wsh) { - wsh_t *wsh; - if (!wshp || ! *wshp) { + if (!wsh) { return; } - wsh = *wshp; - *wshp = NULL; - if (!wsh->down) { ws_close(wsh, WS_NONE); } @@ -432,16 +508,6 @@ void ws_destroy(wsh_t **wshp) SSL_free(wsh->ssl); wsh->ssl = NULL; } - - if (wsh->buffer) { - free(wsh->buffer); - wsh->buffer = NULL; - } - - if (wsh->wbuffer) { - free(wsh->wbuffer); - wsh->wbuffer = NULL; - } } issize_t ws_close(wsh_t *wsh, int16_t reason) @@ -462,6 +528,8 @@ issize_t ws_close(wsh_t *wsh, int16_t reason) ws_raw_write(wsh, fr, 4); } + restore_socket(wsh->sock); + if (wsh->close_sock) { close(wsh->sock); } @@ -632,13 +700,6 @@ issize_t ws_feed_buf(wsh_t *wsh, void *data, size_t bytes) return -1; } - - if (!wsh->wbuffer) { - wsh->wbuffer = malloc(wsh->buflen); - assert(wsh->wbuffer); - } - - memcpy(wsh->wbuffer + wsh->wdatalen, data, bytes); wsh->wdatalen += bytes; diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h index 2182960c14..81368158b3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h @@ -3,7 +3,6 @@ //#define WSS_STANDALONE 1 -#define MAXLEN 0x10000 #define WEBSOCKET_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" #define B64BUFFLEN 1024 @@ -59,8 +58,8 @@ typedef enum { typedef struct wsh_s { ws_socket_t sock; - char *buffer; - char *wbuffer; + char buffer[65536]; + char wbuffer[65536]; size_t buflen; issize_t datalen; issize_t wdatalen; @@ -71,8 +70,7 @@ typedef struct wsh_s { int handshake; uint8_t down; int secure; - unsigned close_sock:1; - unsigned :0; + uint8_t close_sock; } wsh_t; issize_t ws_send_buf(wsh_t *wsh, ws_opcode_t oc); @@ -83,9 +81,9 @@ issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes); issize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes); issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data); issize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes); -int ws_init(wsh_t *wsh, ws_socket_t sock, size_t buflen, SSL_CTX *ssl_ctx, int close_sock); +int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock); issize_t ws_close(wsh_t *wsh, int16_t reason); -void ws_destroy(wsh_t **wshp); +void ws_destroy(wsh_t *wsh); void init_ssl(void); void deinit_ssl(void); diff --git a/libs/spandsp/INSTALL b/libs/spandsp/INSTALL index 2abc70492a..007e9396d0 100644 --- a/libs/spandsp/INSTALL +++ b/libs/spandsp/INSTALL @@ -1,121 +1,80 @@ -Building and installing spandsp -=============================== - -A number of distributions include spandsp, but they usually use older versions -of the library, which lack a lot of the features of the current version. Before -installing spandsp, make sure there are no older versions already on your -machine. Make sure libtiff is installed on your machine. Versions 3.5.7, -3.6.0, 3.7.1 and 3.8.2 seem to work OK. There have been several bugs related -to FAX document handling in some versions of libtiff. Also, some people have -had trouble using spandsp because they had more than one version of libtiff -on their machine. Take care with this. If you are using an RPM based system, -such as RedHat or Fedora, you will need the libtiff and libtiff-devel RPMs -installed to be able to build spandsp. - -You can use the usual: - - ./configure - make - make install - -process to build the spandsp library. Note that if you use configure in this -way, the software will be installed in /usr/local. In this case make sure your -/etc/ld.so.conf file has an entry for /usr/local/lib. If you wish the software -to be installed in /usr, you should build it with the commands. - - ./configure --prefix=/usr - make - make install - - -Building the programming documentation -====================================== - -If you wish to build the programming documentation for spandsp, configure -spandsp with: - - ./configure --enable-doc - -You need doxygen installed on your machine. - - -Building the test suite -======================= - -Most sections of the spandsp library have an accompanying test program in the -test directory. If you wish to build these test programs, configure spandsp -with: - - ./configure --enable-tests - -To build these tests you will need libaudiofile installed on your machine. To -build the modem tests, with the GUI monitoring feature you will need Fltk 1.1.4 -or later, an audio meter module and a cartesian plotting module. Fltk may be -obtained from http://www.fltk.org. The audio meter module may be obtained from -http://www.soft-switch.org/downloads/Fl_Audio_Meter.tgz . The cartesian plotting -module may be obtained from http://134.226.68.29/fltk. However, there is no -suitable makefile supplied with that. You can find a version at -http://www.soft-switch.org/downloads/Fl_Cartesian.tgz which will build as a -Linux library. The actual code in both these versions is identical. -You need to have Fltk 1.1.4 or later installed before building the plotting -library. - - -Applications -============ - -Applications support for spandsp is built into packages such as Callweaver, -FreeSwitch and iaxmodem. Code to add spandsp based FAX support to Asterisk may -be found at http://sourceforge.net/projects/agx-ast-addons. - +Installation Instructions +************************* +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Inc. + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. Basic Installation ================== - These are generic installation instructions. + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. - The file `configure.ac' is used to create `configure' by a program -called `autoconf'. You only need `configure.ac' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. -The simplest way to compile this package is: + The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. + `./configure' to configure the package for your system. - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with - the package. + the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and - documentation. + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. - 5. You can remove the program binaries and object files from the + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is @@ -124,62 +83,119 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + Compilers and Options ===================== Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the +own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. Installation Names ================== - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular +options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. -Optional Features -================= - Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE @@ -192,25 +208,80 @@ find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + Specifying the System Type ========================== - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + CPU-COMPANY-SYSTEM -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. +where SYSTEM can have one of these forms: - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. Sharing Defaults ================ @@ -223,19 +294,56 @@ default values for variables like `CC', `cache_file', and `prefix'. `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. -Operation Controls +Defining Variables ================== + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + `configure' recognizes the following options to control how it operates. -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - `--help' - Print a summary of the options to `configure', and exit. +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. `--quiet' `--silent' @@ -248,8 +356,15 @@ operates. Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. -`configure' also accepts some other, not widely useful, options. +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. diff --git a/libs/spandsp/configure.ac b/libs/spandsp/configure.ac index dacc3ae4ed..13e31152a4 100644 --- a/libs/spandsp/configure.ac +++ b/libs/spandsp/configure.ac @@ -138,6 +138,7 @@ AC_ARG_ENABLE(avx, [ --enable-avx Enable AVX support]) AC_ARG_ENABLE(avx2, [ --enable-avx2 Enable AVX2 support]) AC_ARG_ENABLE(neon, [ --enable-neon Enable NEON support]) AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support]) + # The following is for MSVC, where we may be using a local copy of libtiff, built alongside spandsp AC_ARG_ENABLE(builtin_tiff, [AC_HELP_STRING([--enable-builtin-tiff],[build with builtin libtiff])],[enable_builtin_tiff="$enableval"],[enable_builtin_tiff="no"]) @@ -164,6 +165,8 @@ fi AX_C99_FLEXIBLE_ARRAY AC_CHECK_FUNCS([aligned_alloc]) +AC_CHECK_FUNCS([memalign]) +AC_CHECK_FUNCS([posix_memalign]) AC_CHECK_FUNCS([memmove]) AC_CHECK_FUNCS([memset]) AC_CHECK_FUNCS([select]) @@ -184,6 +187,9 @@ AC_HEADER_TIME AC_CHECK_HEADERS([socket.h]) AC_CHECK_HEADERS([inttypes.h], [INSERT_INTTYPES_HEADER="#include "]) AC_CHECK_HEADERS([stdint.h], [INSERT_STDINT_HEADER="#include "]) +AC_CHECK_HEADERS([stdatomic.h]) +AC_CHECK_HEADERS([stdbool.h], [INSERT_STDBOOL_HEADER="#include "], [INSERT_STDBOOL_HEADER="#include "]) +AC_CHECK_HEADERS([stdfix.h]) AC_CHECK_HEADERS([unistd.h]) AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([string.h]) @@ -589,6 +595,7 @@ AC_SUBST(INSERT_INTTYPES_HEADER) AC_SUBST(INSERT_STDINT_HEADER) AC_SUBST(INSERT_TGMATH_HEADER) AC_SUBST(INSERT_MATH_HEADER) +AC_SUBST(INSERT_STDBOOL_HEADER) AC_CONFIG_FILES([Makefile doc/Makefile diff --git a/libs/spandsp/spandsp-sim/Makefile.am b/libs/spandsp/spandsp-sim/Makefile.am index d33575a55c..4eb86c4b49 100644 --- a/libs/spandsp/spandsp-sim/Makefile.am +++ b/libs/spandsp/spandsp-sim/Makefile.am @@ -34,7 +34,7 @@ EXTRA_DIST = libspandsp_sim.dsp \ msvc/vc9proj.head \ msvc/vc9proj.foot -INCLUDES = -I$(top_builddir) -I$(top_builddir)/src -DDATADIR="\"$(pkgdatadir)\"" +AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/src -DDATADIR="\"$(pkgdatadir)\"" noinst_PROGRAMS = make_line_models diff --git a/libs/spandsp/src/Makefile.am b/libs/spandsp/src/Makefile.am index 3d63ae7274..812100f9cb 100644 --- a/libs/spandsp/src/Makefile.am +++ b/libs/spandsp/src/Makefile.am @@ -78,12 +78,13 @@ EXTRA_DIST = floating_fudge.h \ spandsp/private/README \ spandsp/version.h.in -INCLUDES = -I$(top_builddir) +AM_CPPFLAGS = -I$(top_builddir) lib_LTLIBRARIES = libspandsp.la libspandsp_la_SOURCES = ademco_contactid.c \ adsi.c \ + alloc.c \ async.c \ at_interpreter.c \ awgn.c \ @@ -178,6 +179,7 @@ libspandsp_la_LDFLAGS = -version-info @SPANDSP_LT_CURRENT@:@SPANDSP_LT_REVISION@ nobase_include_HEADERS = spandsp/ademco_contactid.h \ spandsp/adsi.h \ + spandsp/alloc.h \ spandsp/async.h \ spandsp/arctan2.h \ spandsp/at_interpreter.h \ @@ -222,6 +224,7 @@ nobase_include_HEADERS = spandsp/ademco_contactid.h \ spandsp/queue.h \ spandsp/saturated.h \ spandsp/schedule.h \ + spandsp/stdbool.h \ spandsp/sig_tone.h \ spandsp/silence_gen.h \ spandsp/super_tone_rx.h \ diff --git a/libs/spandsp/src/ademco_contactid.c b/libs/spandsp/src/ademco_contactid.c index 6aaf99c382..453ccc0394 100644 --- a/libs/spandsp/src/ademco_contactid.c +++ b/libs/spandsp/src/ademco_contactid.c @@ -39,6 +39,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include @@ -46,6 +51,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/queue.h" @@ -447,7 +453,7 @@ static const struct ademco_code_s ademco_codes[] = #define TONE_TO_TOTAL_ENERGY 45.2233f /* -0.85dB [GOERTZEL_SAMPLES_PER_BLOCK*10^(-0.85/10.0)] */ #endif -static int tone_rx_init = FALSE; +static int tone_rx_init = false; static goertzel_descriptor_t tone_1400_desc; static goertzel_descriptor_t tone_2300_desc; @@ -749,7 +755,7 @@ SPAN_DECLARE(ademco_contactid_receiver_state_t *) ademco_contactid_receiver_init { if (s == NULL) { - if ((s = (ademco_contactid_receiver_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (ademco_contactid_receiver_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -776,7 +782,7 @@ SPAN_DECLARE(int) ademco_contactid_receiver_release(ademco_contactid_receiver_st SPAN_DECLARE(int) ademco_contactid_receiver_free(ademco_contactid_receiver_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -793,7 +799,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_tx(ademco_contactid_sender_state_t *s, case 0: if (!s->clear_to_send) return 0; - s->clear_to_send = FALSE; + s->clear_to_send = false; s->step++; s->remaining_samples = ms_to_samples(250); /* Fall through */ @@ -810,7 +816,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_tx(ademco_contactid_sender_state_t *s, samples = dtmf_tx(&s->dtmf, &[sample], max_samples - sample); if (samples == 0) { - s->clear_to_send = FALSE; + s->clear_to_send = false; s->step = 0; return sample; } @@ -947,7 +953,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_rx(ademco_contactid_sender_state_t *s, s->callback(s->callback_user_data, -1, 0, 0); s->tone_state = 4; /* Release the transmit side, and it will time the 250ms post tone delay */ - s->clear_to_send = TRUE; + s->clear_to_send = true; s->tries = 0; if (s->tx_digits_len) s->timer = ms_to_samples(3000); @@ -968,7 +974,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_rx(ademco_contactid_sender_state_t *s, case 5: if (hit == 0) { - s->busy = FALSE; + s->busy = false; if (s->duration < ms_to_samples(400) || s->duration > ms_to_samples(1500)) { span_log(&s->logging, SPAN_LOG_FLOW, "Bad kissoff duration %d\n", s->duration); @@ -982,18 +988,18 @@ SPAN_DECLARE(int) ademco_contactid_sender_rx(ademco_contactid_sender_state_t *s, { s->timer = 0; if (s->callback) - s->callback(s->callback_user_data, FALSE, 0, 0); + s->callback(s->callback_user_data, false, 0, 0); } } else { span_log(&s->logging, SPAN_LOG_FLOW, "Received good kissoff\n"); - s->clear_to_send = TRUE; + s->clear_to_send = true; s->tx_digits_len = 0; if (s->callback) - s->callback(s->callback_user_data, TRUE, 0, 0); + s->callback(s->callback_user_data, true, 0, 0); s->tone_state = 4; - s->clear_to_send = TRUE; + s->clear_to_send = true; s->tries = 0; if (s->tx_digits_len) s->timer = ms_to_samples(3000); @@ -1023,7 +1029,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_rx(ademco_contactid_sender_state_t *s, { s->timer = 0; if (s->callback) - s->callback(s->callback_user_data, FALSE, 0, 0); + s->callback(s->callback_user_data, false, 0, 0); } } } @@ -1058,7 +1064,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_put(ademco_contactid_sender_state_t *s return -1; if ((s->tx_digits_len = encode_msg(s->tx_digits, report)) < 0) return -1; - s->busy = TRUE; + s->busy = true; return dtmf_tx_put(&s->dtmf, s->tx_digits, s->tx_digits_len); } /*- End of function --------------------------------------------------------*/ @@ -1084,7 +1090,7 @@ SPAN_DECLARE(ademco_contactid_sender_state_t *) ademco_contactid_sender_init(ade { if (s == NULL) { - if ((s = (ademco_contactid_sender_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (ademco_contactid_sender_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1095,7 +1101,7 @@ SPAN_DECLARE(ademco_contactid_sender_state_t *) ademco_contactid_sender_init(ade { make_goertzel_descriptor(&tone_1400_desc, 1400.0f, GOERTZEL_SAMPLES_PER_BLOCK); make_goertzel_descriptor(&tone_2300_desc, 2300.0f, GOERTZEL_SAMPLES_PER_BLOCK); - tone_rx_init = TRUE; + tone_rx_init = true; } goertzel_init(&s->tone_1400, &tone_1400_desc); goertzel_init(&s->tone_2300, &tone_2300_desc); @@ -1121,7 +1127,7 @@ SPAN_DECLARE(int) ademco_contactid_sender_release(ademco_contactid_sender_state_ SPAN_DECLARE(int) ademco_contactid_sender_free(ademco_contactid_sender_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/adsi.c b/libs/spandsp/src/adsi.c index 44add41be0..1f711bf44f 100644 --- a/libs/spandsp/src/adsi.c +++ b/libs/spandsp/src/adsi.c @@ -40,10 +40,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/queue.h" @@ -63,6 +69,7 @@ #include "spandsp/private/queue.h" #include "spandsp/private/tone_generate.h" #include "spandsp/private/async.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/dtmf.h" #include "spandsp/private/adsi.h" @@ -150,7 +157,7 @@ static int adsi_tx_get_bit(void *user_data) if (s->tx_signal_on) { /* The FSK should now be switched off. */ - s->tx_signal_on = FALSE; + s->tx_signal_on = false; s->msg_len = 0; } } @@ -169,7 +176,7 @@ static int adsi_tdd_get_async_byte(void *user_data) if (s->tx_signal_on) { /* The FSK should now be switched off. */ - s->tx_signal_on = FALSE; + s->tx_signal_on = false; s->msg_len = 0; } return 0x1F; @@ -384,13 +391,13 @@ static void start_tx(adsi_tx_state_t *s) dtmf_tx_init(&s->dtmftx, NULL, NULL); break; case ADSI_STANDARD_TDD: - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_WEITBRECHT], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 5, ASYNC_PARITY_NONE, 2, FALSE, adsi_tdd_get_async_byte, s); + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_WEITBRECHT_4545], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 5, ASYNC_PARITY_NONE, 2, false, adsi_tdd_get_async_byte, s); /* Schedule an explicit shift at the start of baudot transmission */ s->baudot_shift = 2; break; } - s->tx_signal_on = TRUE; + s->tx_signal_on = true; } /*- End of function --------------------------------------------------------*/ @@ -426,7 +433,7 @@ SPAN_DECLARE(adsi_rx_state_t *) adsi_rx_init(adsi_rx_state_t *s, { if (s == NULL) { - if ((s = (adsi_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (adsi_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -448,7 +455,7 @@ SPAN_DECLARE(adsi_rx_state_t *) adsi_rx_init(adsi_rx_state_t *s, case ADSI_STANDARD_TDD: /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and ride over the fraction. */ - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_WEITBRECHT], FSK_FRAME_MODE_5N1_FRAMES, adsi_tdd_put_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_WEITBRECHT_4545], FSK_FRAME_MODE_5N1_FRAMES, adsi_tdd_put_async_byte, s); break; } s->standard = standard; @@ -465,7 +472,7 @@ SPAN_DECLARE(int) adsi_rx_release(adsi_rx_state_t *s) SPAN_DECLARE(int) adsi_rx_free(adsi_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -488,7 +495,7 @@ SPAN_DECLARE(int) adsi_tx(adsi_tx_state_t *s, int16_t amp[], int max_len) if (len < max_len) { if ((lenx = fsk_tx(&s->fsktx, amp + len, max_len - len)) <= 0) - s->tx_signal_on = FALSE; + s->tx_signal_on = false; len += lenx; } break; @@ -658,7 +665,7 @@ SPAN_DECLARE(adsi_tx_state_t *) adsi_tx_init(adsi_tx_state_t *s, int standard) { if (s == NULL) { - if ((s = (adsi_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (adsi_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -671,7 +678,7 @@ SPAN_DECLARE(adsi_tx_state_t *) adsi_tx_init(adsi_tx_state_t *s, int standard) 60, 0, 0, - FALSE); + false); s->standard = standard; adsi_tx_set_preamble(s, -1, -1, -1, -1); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); @@ -688,7 +695,7 @@ SPAN_DECLARE(int) adsi_tx_release(adsi_tx_state_t *s) SPAN_DECLARE(int) adsi_tx_free(adsi_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/alloc.c b/libs/spandsp/src/alloc.c new file mode 100644 index 0000000000..06600adb30 --- /dev/null +++ b/libs/spandsp/src/alloc.c @@ -0,0 +1,145 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * alloc.c - memory allocation handling. + * + * Written by Steve Underwood + * + * Copyright (C) 2013 Steve Underwood + * + * 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. + * + * 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. + * + * 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. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#if !defined(__USE_ISOC11) +#define __USE_ISOC11 +#endif +#include +#if defined(HAVE_MALLOC_H) +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "spandsp/telephony.h" +#include "spandsp/alloc.h" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4232) /* address of dllimport is not static, identity not guaranteed */ +#endif + +#if defined(HAVE_ALIGNED_ALLOC) +static span_aligned_alloc_t __span_aligned_alloc = aligned_alloc; +#elif defined(HAVE_MEMALIGN) +static span_aligned_alloc_t __span_aligned_alloc = memalign; +#elif defined(HAVE_POSIX_MEMALIGN) +static void *fake_posix_memalign(size_t alignment, size_t size); +static span_aligned_alloc_t __span_aligned_alloc = fake_posix_memalign; +#else +static void *fake_aligned_alloc(size_t alignment, size_t size); +static span_aligned_alloc_t __span_aligned_alloc = fake_aligned_alloc; +#endif +static span_alloc_t __span_alloc = malloc; +static span_realloc_t __span_realloc = realloc; +static span_free_t __span_free = free; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#if defined(HAVE_ALIGNED_ALLOC) +#elif defined(HAVE_MEMALIGN) +#elif defined(HAVE_POSIX_MEMALIGN) +static void *fake_posix_memalign(size_t alignment, size_t size) +{ + void *ptr; + + /* Make posix_memalign look like the more modern aligned_alloc */ + posix_memalign(&ptr, alignment, size); + return ptr; +} +/*- End of function --------------------------------------------------------*/ +#else +static void *fake_aligned_alloc(size_t alignment, size_t size) +{ + return malloc(size); +} +/*- End of function --------------------------------------------------------*/ +#endif + +SPAN_DECLARE(void *) span_aligned_alloc(size_t alignment, size_t size) +{ + return __span_aligned_alloc(alignment, size); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void *) span_alloc(size_t size) +{ + return __span_alloc(size); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void *) span_realloc(void *ptr, size_t size) +{ + return __span_realloc(ptr, size); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) span_free(void *ptr) +{ + __span_free(ptr); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) span_mem_allocators(span_aligned_alloc_t custom_aligned_alloc, + span_alloc_t custom_alloc, + span_realloc_t custom_realloc, + span_free_t custom_free) +{ + __span_aligned_alloc = (custom_aligned_alloc) + ? + custom_aligned_alloc + : +#if defined(HAVE_ALIGNED_ALLOC) + aligned_alloc; +#elif defined(HAVE_MEMALIGN) + memalign; +#elif defined(HAVE_POSIX_MEMALIGN) + fake_posix_memalign; +#else + fake_aligned_alloc; +#endif + __span_alloc = (custom_alloc) ? custom_alloc : malloc; + __span_realloc = (custom_realloc) ? custom_realloc : realloc; + __span_free = (custom_free) ? custom_free : free; + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/async.c b/libs/spandsp/src/async.c index fb381bb7bc..d1bf5bda5b 100644 --- a/libs/spandsp/src/async.c +++ b/libs/spandsp/src/async.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -168,13 +174,13 @@ SPAN_DECLARE(async_rx_state_t *) async_rx_init(async_rx_state_t *s, int data_bits, int parity, int stop_bits, - int use_v14, + bool use_v14, put_byte_func_t put_byte, void *user_data) { if (s == NULL) { - if ((s = (async_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (async_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } s->data_bits = data_bits; @@ -203,7 +209,7 @@ SPAN_DECLARE(int) async_rx_release(async_rx_state_t *s) SPAN_DECLARE(int) async_rx_free(async_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -268,13 +274,13 @@ SPAN_DECLARE(async_tx_state_t *) async_tx_init(async_tx_state_t *s, int data_bits, int parity, int stop_bits, - int use_v14, + bool use_v14, get_byte_func_t get_byte, void *user_data) { if (s == NULL) { - if ((s = (async_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (async_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } /* We have a use_v14 parameter for completeness, but right now V.14 only @@ -304,7 +310,7 @@ SPAN_DECLARE(int) async_tx_release(async_tx_state_t *s) SPAN_DECLARE(int) async_tx_free(async_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/at_interpreter.c b/libs/spandsp/src/at_interpreter.c index 2ecdbb866d..d43ffb3671 100644 --- a/libs/spandsp/src/at_interpreter.c +++ b/libs/spandsp/src/at_interpreter.c @@ -43,9 +43,15 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/queue.h" #include "spandsp/power_meter.h" @@ -77,20 +83,20 @@ static at_profile_t profiles[3] = { { #if defined(_MSC_VER) || defined(__sunos) || defined(__solaris) || defined(__sun) - /*.echo =*/ TRUE, - /*.verbose =*/ TRUE, + /*.echo =*/ true, + /*.verbose =*/ true, /*.result_code_format =*/ ASCII_RESULT_CODES, - /*.pulse_dial =*/ FALSE, - /*.double_escape =*/ FALSE, - /*.adaptive_receive =*/ FALSE, + /*.pulse_dial =*/ false, + /*.double_escape =*/ false, + /*.adaptive_receive =*/ false, /*.s_regs[100] =*/ {0, 0, 0, '\r', '\n', '\b', 1, 60, 5, 0, 0} #else - .echo = TRUE, - .verbose = TRUE, + .echo = true, + .verbose = true, .result_code_format = ASCII_RESULT_CODES, - .pulse_dial = FALSE, - .double_escape = FALSE, - .adaptive_receive = FALSE, + .pulse_dial = false, + .double_escape = false, + .adaptive_receive = false, .s_regs[0] = 0, .s_regs[3] = '\r', .s_regs[4] = '\n', @@ -255,11 +261,11 @@ SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code) static int answer_call(at_state_t *s) { if (at_modem_control(s, AT_MODEM_CONTROL_ANSWER, NULL) < 0) - return FALSE; + return false; /* Answering should now be in progress. No AT response should be issued at this point. */ - s->do_hangup = FALSE; - return TRUE; + s->do_hangup = false; + return true; } /*- End of function --------------------------------------------------------*/ @@ -318,7 +324,7 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event) at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_NOCNG_TONE_TX); else at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_CNG_TONE_TX); - s->dte_is_waiting = TRUE; + s->dte_is_waiting = true; } } break; @@ -342,13 +348,13 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event) if (s->ok_is_pending) { at_put_response_code(s, AT_RESPONSE_CODE_OK); - s->ok_is_pending = FALSE; + s->ok_is_pending = false; } else { at_put_response_code(s, AT_RESPONSE_CODE_NO_CARRIER); } - s->dte_is_waiting = FALSE; + s->dte_is_waiting = false; at_set_at_rx_mode(s, AT_MODE_ONHOOK_COMMAND); } else if (s->fclass_mode && s->rx_signal_present) @@ -360,7 +366,7 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event) } if (s->at_rx_mode != AT_MODE_OFFHOOK_COMMAND && s->at_rx_mode != AT_MODE_ONHOOK_COMMAND) at_put_response_code(s, AT_RESPONSE_CODE_NO_CARRIER); - s->rx_signal_present = FALSE; + s->rx_signal_present = false; at_modem_control(s, AT_MODEM_CONTROL_RNG, (void *) 0); at_set_at_rx_mode(s, AT_MODE_ONHOOK_COMMAND); break; @@ -379,11 +385,11 @@ SPAN_DECLARE(void) at_reset_call_info(at_state_t *s) for (call_id = s->call_id; call_id; call_id = next) { next = call_id->next; - free(call_id); + span_free(call_id); } s->call_id = NULL; s->rings_indicated = 0; - s->call_info_displayed = FALSE; + s->call_info_displayed = false; } /*- End of function --------------------------------------------------------*/ @@ -392,8 +398,8 @@ SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *v at_call_id_t *new_call_id; at_call_id_t *call_id; - /* TODO: We should really not merely ignore a failure to malloc */ - if ((new_call_id = (at_call_id_t *) malloc(sizeof(*new_call_id))) == NULL) + /* TODO: We should really not merely ignore a failure to allocate */ + if ((new_call_id = (at_call_id_t *) span_alloc(sizeof(*new_call_id))) == NULL) return; call_id = s->call_id; /* If these strdups fail its pretty harmless. We just appear to not @@ -430,7 +436,7 @@ SPAN_DECLARE(void) at_display_call_info(at_state_t *s) at_put_response(s, buf); call_id = call_id->next; } - s->call_info_displayed = TRUE; + s->call_info_displayed = true; } /*- End of function --------------------------------------------------------*/ @@ -525,7 +531,7 @@ static int parse_out(at_state_t *s, const char **t, int *target, int max_value, default: /* Set value */ if ((val = parse_num(t, max_value)) < 0) - return FALSE; + return false; if (target) *target = val; break; @@ -538,9 +544,9 @@ static int parse_out(at_state_t *s, const char **t, int *target, int max_value, at_put_response(s, buf); break; default: - return FALSE; + return false; } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -564,14 +570,14 @@ static int parse_2_out(at_state_t *s, const char **t, int *target1, int max_valu default: /* Set value */ if ((val1 = parse_num(t, max_value1)) < 0) - return FALSE; + return false; if (target1) *target1 = val1; if (**t == ',') { (*t)++; if ((val2 = parse_num(t, max_value2)) < 0) - return FALSE; + return false; if (target2) *target2 = val2; } @@ -586,9 +592,9 @@ static int parse_2_out(at_state_t *s, const char **t, int *target1, int max_valu at_put_response(s, buf); break; default: - return FALSE; + return false; } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -621,7 +627,7 @@ static int parse_n_out(at_state_t *s, for (i = 0; i < entries; i++) { if ((val = parse_num(t, max_values[i])) < 0) - return FALSE; + return false; if (targets[i]) *targets[i] = val; if (**t != ',') @@ -644,9 +650,9 @@ static int parse_n_out(at_state_t *s, at_put_response(s, buf); break; default: - return FALSE; + return false; } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -669,7 +675,7 @@ static int parse_hex_out(at_state_t *s, const char **t, int *target, int max_val default: /* Set value */ if ((val = parse_hex_num(t, max_value)) < 0) - return FALSE; + return false; if (target) *target = val; break; @@ -682,9 +688,9 @@ static int parse_hex_out(at_state_t *s, const char **t, int *target, int max_val at_put_response(s, buf); break; default: - return FALSE; + return false; } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -709,7 +715,7 @@ static int parse_string_list_out(at_state_t *s, const char **t, int *target, int default: /* Set value */ if ((val = match_element(t, def)) < 0) - return FALSE; + return false; if (target) *target = val; break; @@ -728,9 +734,9 @@ static int parse_string_list_out(at_state_t *s, const char **t, int *target, int at_put_response(s, buf); break; default: - return FALSE; + return false; } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -752,7 +758,7 @@ static int parse_string_out(at_state_t *s, const char **t, char **target, const default: /* Set value */ if (*target) - free(*target); + span_free(*target); /* If this strdup fails, it should be harmless */ *target = strdup(*t); break; @@ -763,11 +769,11 @@ static int parse_string_out(at_state_t *s, const char **t, char **target, const at_put_response(s, (*target) ? *target : ""); break; default: - return FALSE; + return false; } while (*t) t++; - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -862,18 +868,18 @@ static int process_class1_cmd(at_state_t *s, const char **t) val = -1; if (!parse_out(s, t, &val, 255, NULL, allowed)) - return TRUE; + return true; if (val < 0) { /* It was just a query */ - return TRUE; + return true; } /* All class 1 FAX commands are supposed to give an ERROR response, if the phone is on-hook. */ if (s->at_rx_mode == AT_MODE_ONHOOK_COMMAND) - return FALSE; + return false; - result = TRUE; + result = true; if (s->class1_handler) result = s->class1_handler(s, s->class1_user_data, direction, operation, val); switch (result) @@ -881,11 +887,11 @@ static int process_class1_cmd(at_state_t *s, const char **t) case 0: /* Inhibit an immediate response. (These commands should not be part of a multi-command entry.) */ *t = (const char *) -1; - return TRUE; + return true; case -1: - return FALSE; + return false; } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -915,11 +921,11 @@ static const char *at_cmd_D(at_state_t *s, const char *t) /* V.250 6.3.1 - Dial (abortable) */ at_reset_call_info(s); - s->do_hangup = FALSE; - s->silent_dial = FALSE; - s->command_dial = FALSE; + s->do_hangup = false; + s->silent_dial = false; + s->command_dial = false; t += 1; - ok = FALSE; + ok = false; /* There are a numbers of options in a dial command string. Many are completely irrelevant in this application. */ u = num; @@ -961,11 +967,11 @@ static const char *at_cmd_D(at_state_t *s, const char *t) break; case 'T': /* V.250 6.3.1.3 Tone dial */ - s->p.pulse_dial = FALSE; + s->p.pulse_dial = false; break; case 'P': /* V.250 6.3.1.4 Pulse dial */ - s->p.pulse_dial = TRUE; + s->p.pulse_dial = true; break; case '!': /* V.250 6.3.1.5 Hook flash, register recall */ @@ -977,7 +983,7 @@ static const char *at_cmd_D(at_state_t *s, const char *t) break; case '@': /* V.250 6.3.1.7 Wait for quiet answer */ - s->silent_dial = TRUE; + s->silent_dial = true; break; case 'S': /* V.250 6.3.1.8 Invoke stored string */ @@ -998,7 +1004,7 @@ static const char *at_cmd_D(at_state_t *s, const char *t) break; case ';': /* V.250 6.3.1 - Dial string terminator - make voice call and remain in command mode */ - s->command_dial = TRUE; + s->command_dial = true; break; case '>': /* GSM07.07 6.2 - Direct dialling from phone book supplementary service subscription @@ -1054,7 +1060,7 @@ static const char *at_cmd_H(at_state_t *s, const char *t) { /* Push out the last of the audio (probably by sending a short silence). */ at_modem_control(s, AT_MODEM_CONTROL_RESTART, (void *) FAX_MODEM_FLUSH); - s->do_hangup = TRUE; + s->do_hangup = true; at_set_at_rx_mode(s, AT_MODE_CONNECTED); return (const char *) -1; } @@ -1137,7 +1143,7 @@ static const char *at_cmd_P(at_state_t *s, const char *t) { /* V.250 6.3.3 - Select pulse dialling (command) */ t += 1; - s->p.pulse_dial = TRUE; + s->p.pulse_dial = true; return t; } /*- End of function --------------------------------------------------------*/ @@ -1231,7 +1237,7 @@ static const char *at_cmd_T(at_state_t *s, const char *t) { /* V.250 6.3.2 - Select tone dialling (command) */ t += 1; - s->p.pulse_dial = FALSE; + s->p.pulse_dial = false; return t; } /*- End of function --------------------------------------------------------*/ @@ -5590,7 +5596,7 @@ SPAN_DECLARE(at_state_t *) at_init(at_state_t *s, { if (s == NULL) { - if ((s = (at_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (at_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, '\0', sizeof(*s)); @@ -5615,7 +5621,7 @@ SPAN_DECLARE(int) at_release(at_state_t *s) { at_reset_call_info(s); if (s->local_id) - free(s->local_id); + span_free(s->local_id); return 0; } /*- End of function --------------------------------------------------------*/ @@ -5625,7 +5631,7 @@ SPAN_DECLARE(int) at_free(at_state_t *s) int ret; ret = at_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/awgn.c b/libs/spandsp/src/awgn.c index 582959cc93..fa33b1b4c5 100644 --- a/libs/spandsp/src/awgn.c +++ b/libs/spandsp/src/awgn.c @@ -55,6 +55,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/saturated.h" #include "spandsp/awgn.h" @@ -100,7 +101,7 @@ SPAN_DECLARE(awgn_state_t *) awgn_init_dbov(awgn_state_t *s, int idum, float lev if (s == NULL) { - if ((s = (awgn_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (awgn_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } if (idum < 0) @@ -140,7 +141,7 @@ SPAN_DECLARE(int) awgn_release(awgn_state_t *s) SPAN_DECLARE(int) awgn_free(awgn_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/bell_r2_mf.c b/libs/spandsp/src/bell_r2_mf.c index dba407cddd..8f74b7a86a 100644 --- a/libs/spandsp/src/bell_r2_mf.c +++ b/libs/spandsp/src/bell_r2_mf.c @@ -40,9 +40,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/queue.h" @@ -77,10 +83,10 @@ typedef struct uint8_t off_time; /* Minimum post tone silence (ms) */ } mf_digit_tones_t; -int bell_mf_gen_inited = FALSE; +int bell_mf_gen_inited = false; tone_gen_descriptor_t bell_mf_digit_tones[15]; -int r2_mf_gen_inited = FALSE; +int r2_mf_gen_inited = false; tone_gen_descriptor_t r2_mf_fwd_digit_tones[15]; tone_gen_descriptor_t r2_mf_back_digit_tones[15]; @@ -270,10 +276,10 @@ static void bell_mf_gen_init(void) tones->off_time, 0, 0, - FALSE); + false); tones++; } - bell_mf_gen_inited = TRUE; + bell_mf_gen_inited = true; } /*- End of function --------------------------------------------------------*/ @@ -325,7 +331,7 @@ SPAN_DECLARE(bell_mf_tx_state_t *) bell_mf_tx_init(bell_mf_tx_state_t *s) { if (s == NULL) { - if ((s = (bell_mf_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (bell_mf_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -348,7 +354,7 @@ SPAN_DECLARE(int) bell_mf_tx_release(bell_mf_tx_state_t *s) SPAN_DECLARE(int) bell_mf_tx_free(bell_mf_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -390,14 +396,14 @@ SPAN_DECLARE(int) r2_mf_tx_put(r2_mf_tx_state_t *s, char digit) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(r2_mf_tx_state_t *) r2_mf_tx_init(r2_mf_tx_state_t *s, int fwd) +SPAN_DECLARE(r2_mf_tx_state_t *) r2_mf_tx_init(r2_mf_tx_state_t *s, bool fwd) { int i; const mf_digit_tones_t *tones; if (s == NULL) { - if ((s = (r2_mf_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (r2_mf_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -436,7 +442,7 @@ SPAN_DECLARE(r2_mf_tx_state_t *) r2_mf_tx_init(r2_mf_tx_state_t *s, int fwd) (tones->off_time == 0)); tones++; } - r2_mf_gen_inited = TRUE; + r2_mf_gen_inited = true; } s->fwd = fwd; return s; @@ -451,7 +457,7 @@ SPAN_DECLARE(int) r2_mf_tx_release(r2_mf_tx_state_t *s) SPAN_DECLARE(int) r2_mf_tx_free(r2_mf_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -629,11 +635,11 @@ SPAN_DECLARE(bell_mf_rx_state_t *) bell_mf_rx_init(bell_mf_rx_state_t *s, void *user_data) { int i; - static int initialised = FALSE; + static int initialised = false; if (s == NULL) { - if ((s = (bell_mf_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (bell_mf_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -642,7 +648,7 @@ SPAN_DECLARE(bell_mf_rx_state_t *) bell_mf_rx_init(bell_mf_rx_state_t *s, { for (i = 0; i < 6; i++) make_goertzel_descriptor(&bell_mf_detect_desc[i], (float) bell_mf_frequencies[i], BELL_MF_SAMPLES_PER_BLOCK); - initialised = TRUE; + initialised = true; } s->digits_callback = callback; s->digits_callback_data = user_data; @@ -671,7 +677,7 @@ SPAN_DECLARE(int) bell_mf_rx_release(bell_mf_rx_state_t *s) SPAN_DECLARE(int) bell_mf_rx_free(bell_mf_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -745,7 +751,7 @@ SPAN_DECLARE(int) r2_mf_rx(r2_mf_rx_state_t *s, const int16_t amp[], int samples } } /* Basic signal level and twist tests */ - hit = FALSE; + hit = false; if (energy[best] >= R2_MF_THRESHOLD && energy[second_best] >= R2_MF_THRESHOLD @@ -755,7 +761,7 @@ SPAN_DECLARE(int) r2_mf_rx(r2_mf_rx_state_t *s, const int16_t amp[], int samples energy[best]*R2_MF_TWIST > energy[second_best]) { /* Relative peak test */ - hit = TRUE; + hit = true; for (i = 0; i < 6; i++) { if (i != best && i != second_best) @@ -763,7 +769,7 @@ SPAN_DECLARE(int) r2_mf_rx(r2_mf_rx_state_t *s, const int16_t amp[], int samples if (energy[i]*R2_MF_RELATIVE_PEAK >= energy[second_best]) { /* The best two are not clearly the best */ - hit = FALSE; + hit = false; break; } } @@ -804,16 +810,16 @@ SPAN_DECLARE(int) r2_mf_rx_get(r2_mf_rx_state_t *s) /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(r2_mf_rx_state_t *) r2_mf_rx_init(r2_mf_rx_state_t *s, - int fwd, + bool fwd, tone_report_func_t callback, void *user_data) { int i; - static int initialised = FALSE; + static int initialised = false; if (s == NULL) { - if ((s = (r2_mf_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (r2_mf_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -827,7 +833,7 @@ SPAN_DECLARE(r2_mf_rx_state_t *) r2_mf_rx_init(r2_mf_rx_state_t *s, make_goertzel_descriptor(&mf_fwd_detect_desc[i], (float) r2_mf_fwd_frequencies[i], R2_MF_SAMPLES_PER_BLOCK); make_goertzel_descriptor(&mf_back_detect_desc[i], (float) r2_mf_back_frequencies[i], R2_MF_SAMPLES_PER_BLOCK); } - initialised = TRUE; + initialised = true; } if (fwd) { @@ -855,7 +861,7 @@ SPAN_DECLARE(int) r2_mf_rx_release(r2_mf_rx_state_t *s) SPAN_DECLARE(int) r2_mf_rx_free(r2_mf_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/bert.c b/libs/spandsp/src/bert.c index a8ad5ad6b7..728476d65e 100644 --- a/libs/spandsp/src/bert.c +++ b/libs/spandsp/src/bert.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/async.h" #include "spandsp/bert.h" @@ -136,14 +142,14 @@ static void assess_error_rate(bert_state_t *s) int i; int j; int sum; - int test; + bool test; /* We assess the error rate in decadic steps. For each decade we assess the error over 10 times the number of bits, to smooth the result. This means we assess the 1 in 100 rate based on 1000 bits (i.e. we look for >=10 errors in 1000 bits). We make an assessment every 100 bits, using a sliding window over the last 1000 bits. We assess the 1 in 1000 rate over 10000 bits in a similar way, and so on for the lower error rates. */ - test = TRUE; + test = false; for (i = 2; i <= 7; i++) { if (++s->decade_ptr[i] < 10) @@ -156,7 +162,7 @@ static void assess_error_rate(bert_state_t *s) if (test && sum > 10) { /* We overflow into the next decade */ - test = FALSE; + test = false; if (s->error_rate != i && s->reporter) s->reporter(s->user_data, BERT_REPORT_GT_10_2 + i - 2, &s->results); s->error_rate = i; @@ -350,7 +356,7 @@ SPAN_DECLARE(bert_state_t *) bert_init(bert_state_t *s, int limit, int pattern, if (s == NULL) { - if ((s = (bert_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (bert_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -503,7 +509,7 @@ SPAN_DECLARE(int) bert_release(bert_state_t *s) SPAN_DECLARE(int) bert_free(bert_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/bitstream.c b/libs/spandsp/src/bitstream.c index 9a8c0bc9dd..6c0b9dde4b 100644 --- a/libs/spandsp/src/bitstream.c +++ b/libs/spandsp/src/bitstream.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/bitstream.h" #include "spandsp/private/bitstream.h" @@ -132,7 +138,7 @@ SPAN_DECLARE(bitstream_state_t *) bitstream_init(bitstream_state_t *s, int lsb_f { if (s == NULL) { - if ((s = (bitstream_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (bitstream_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } s->bitstream = 0; @@ -151,7 +157,7 @@ SPAN_DECLARE(int) bitstream_release(bitstream_state_t *s) SPAN_DECLARE(int) bitstream_free(bitstream_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/cielab_luts.h b/libs/spandsp/src/cielab_luts.h deleted file mode 100644 index 0a3c697915..0000000000 --- a/libs/spandsp/src/cielab_luts.h +++ /dev/null @@ -1,4358 +0,0 @@ -static const float srgb_to_linear[256] = -{ - 0.000000, - 0.000302, - 0.000605, - 0.000907, - 0.001209, - 0.001512, - 0.001814, - 0.002116, - 0.002419, - 0.002721, - 0.003023, - 0.003333, - 0.003661, - 0.004007, - 0.004371, - 0.004754, - 0.005156, - 0.005577, - 0.006017, - 0.006477, - 0.006957, - 0.007457, - 0.007977, - 0.008518, - 0.009080, - 0.009663, - 0.010267, - 0.010893, - 0.011540, - 0.012209, - 0.012900, - 0.013614, - 0.014350, - 0.015109, - 0.015890, - 0.016695, - 0.017523, - 0.018375, - 0.019250, - 0.020149, - 0.021072, - 0.022019, - 0.022991, - 0.023987, - 0.025008, - 0.026054, - 0.027125, - 0.028221, - 0.029343, - 0.030490, - 0.031663, - 0.032862, - 0.034087, - 0.035338, - 0.036616, - 0.037920, - 0.039250, - 0.040608, - 0.041993, - 0.043404, - 0.044844, - 0.046310, - 0.047804, - 0.049326, - 0.050876, - 0.052454, - 0.054060, - 0.055694, - 0.057357, - 0.059049, - 0.060769, - 0.062518, - 0.064296, - 0.066103, - 0.067940, - 0.069806, - 0.071701, - 0.073626, - 0.075581, - 0.077566, - 0.079581, - 0.081627, - 0.083702, - 0.085808, - 0.087945, - 0.090112, - 0.092311, - 0.094540, - 0.096800, - 0.099092, - 0.101414, - 0.103769, - 0.106155, - 0.108572, - 0.111021, - 0.113503, - 0.116016, - 0.118562, - 0.121139, - 0.123750, - 0.126392, - 0.129068, - 0.131776, - 0.134517, - 0.137291, - 0.140098, - 0.142938, - 0.145812, - 0.148719, - 0.151659, - 0.154633, - 0.157641, - 0.160683, - 0.163758, - 0.166868, - 0.170012, - 0.173190, - 0.176403, - 0.179650, - 0.182932, - 0.186248, - 0.189599, - 0.192985, - 0.196407, - 0.199863, - 0.203354, - 0.206881, - 0.210443, - 0.214041, - 0.217675, - 0.221344, - 0.225049, - 0.228789, - 0.232566, - 0.236379, - 0.240229, - 0.244114, - 0.248036, - 0.251995, - 0.255990, - 0.260022, - 0.264090, - 0.268196, - 0.272338, - 0.276518, - 0.280734, - 0.284988, - 0.289280, - 0.293609, - 0.297975, - 0.302379, - 0.306821, - 0.311301, - 0.315818, - 0.320374, - 0.324967, - 0.329599, - 0.334269, - 0.338978, - 0.343725, - 0.348510, - 0.353334, - 0.358197, - 0.363099, - 0.368040, - 0.373019, - 0.378038, - 0.383096, - 0.388193, - 0.393329, - 0.398505, - 0.403721, - 0.408976, - 0.414270, - 0.419605, - 0.424979, - 0.430393, - 0.435848, - 0.441342, - 0.446877, - 0.452452, - 0.458067, - 0.463722, - 0.469419, - 0.475156, - 0.480933, - 0.486751, - 0.492610, - 0.498510, - 0.504452, - 0.510434, - 0.516457, - 0.522522, - 0.528628, - 0.534775, - 0.540964, - 0.547194, - 0.553466, - 0.559780, - 0.566136, - 0.572533, - 0.578973, - 0.585455, - 0.591978, - 0.598544, - 0.605152, - 0.611803, - 0.618496, - 0.625232, - 0.632010, - 0.638831, - 0.645694, - 0.652600, - 0.659550, - 0.666542, - 0.673577, - 0.680656, - 0.687777, - 0.694942, - 0.702151, - 0.709402, - 0.716698, - 0.724036, - 0.731419, - 0.738845, - 0.746315, - 0.753829, - 0.761386, - 0.768988, - 0.776634, - 0.784324, - 0.792058, - 0.799837, - 0.807660, - 0.815527, - 0.823439, - 0.831396, - 0.839397, - 0.847443, - 0.855534, - 0.863669, - 0.871850, - 0.880075, - 0.888346, - 0.896662, - 0.905023, - 0.913429, - 0.921881, - 0.930378, - 0.938921, - 0.947509, - 0.956143, - 0.964823, - 0.973548, - 0.982319, - 0.991137 -}; -static const uint8_t linear_to_srgb[4096] = -{ - 0, - 0, - 1, - 2, - 3, - 4, - 4, - 5, - 6, - 7, - 8, - 8, - 9, - 10, - 11, - 12, - 12, - 13, - 14, - 14, - 15, - 15, - 16, - 17, - 17, - 18, - 18, - 19, - 19, - 20, - 20, - 21, - 21, - 22, - 22, - 23, - 23, - 23, - 24, - 24, - 25, - 25, - 25, - 26, - 26, - 27, - 27, - 27, - 28, - 28, - 28, - 29, - 29, - 30, - 30, - 30, - 31, - 31, - 31, - 32, - 32, - 32, - 33, - 33, - 33, - 33, - 34, - 34, - 34, - 35, - 35, - 35, - 36, - 36, - 36, - 36, - 37, - 37, - 37, - 38, - 38, - 38, - 38, - 39, - 39, - 39, - 39, - 40, - 40, - 40, - 40, - 41, - 41, - 41, - 41, - 42, - 42, - 42, - 42, - 43, - 43, - 43, - 43, - 44, - 44, - 44, - 44, - 45, - 45, - 45, - 45, - 45, - 46, - 46, - 46, - 46, - 47, - 47, - 47, - 47, - 47, - 48, - 48, - 48, - 48, - 49, - 49, - 49, - 49, - 49, - 50, - 50, - 50, - 50, - 50, - 51, - 51, - 51, - 51, - 51, - 52, - 52, - 52, - 52, - 52, - 53, - 53, - 53, - 53, - 53, - 54, - 54, - 54, - 54, - 54, - 54, - 55, - 55, - 55, - 55, - 55, - 56, - 56, - 56, - 56, - 56, - 56, - 57, - 57, - 57, - 57, - 57, - 57, - 58, - 58, - 58, - 58, - 58, - 59, - 59, - 59, - 59, - 59, - 59, - 60, - 60, - 60, - 60, - 60, - 60, - 61, - 61, - 61, - 61, - 61, - 61, - 62, - 62, - 62, - 62, - 62, - 62, - 62, - 63, - 63, - 63, - 63, - 63, - 63, - 64, - 64, - 64, - 64, - 64, - 64, - 65, - 65, - 65, - 65, - 65, - 65, - 65, - 66, - 66, - 66, - 66, - 66, - 66, - 66, - 67, - 67, - 67, - 67, - 67, - 67, - 68, - 68, - 68, - 68, - 68, - 68, - 68, - 69, - 69, - 69, - 69, - 69, - 69, - 69, - 70, - 70, - 70, - 70, - 70, - 70, - 70, - 70, - 71, - 71, - 71, - 71, - 71, - 71, - 71, - 72, - 72, - 72, - 72, - 72, - 72, - 72, - 73, - 73, - 73, - 73, - 73, - 73, - 73, - 73, - 74, - 74, - 74, - 74, - 74, - 74, - 74, - 75, - 75, - 75, - 75, - 75, - 75, - 75, - 75, - 76, - 76, - 76, - 76, - 76, - 76, - 76, - 76, - 77, - 77, - 77, - 77, - 77, - 77, - 77, - 77, - 78, - 78, - 78, - 78, - 78, - 78, - 78, - 78, - 79, - 79, - 79, - 79, - 79, - 79, - 79, - 79, - 80, - 80, - 80, - 80, - 80, - 80, - 80, - 80, - 80, - 81, - 81, - 81, - 81, - 81, - 81, - 81, - 81, - 82, - 82, - 82, - 82, - 82, - 82, - 82, - 82, - 82, - 83, - 83, - 83, - 83, - 83, - 83, - 83, - 83, - 83, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 85, - 85, - 85, - 85, - 85, - 85, - 85, - 85, - 85, - 86, - 86, - 86, - 86, - 86, - 86, - 86, - 86, - 86, - 87, - 87, - 87, - 87, - 87, - 87, - 87, - 87, - 87, - 88, - 88, - 88, - 88, - 88, - 88, - 88, - 88, - 88, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 90, - 90, - 90, - 90, - 90, - 90, - 90, - 90, - 90, - 90, - 91, - 91, - 91, - 91, - 91, - 91, - 91, - 91, - 91, - 92, - 92, - 92, - 92, - 92, - 92, - 92, - 92, - 92, - 92, - 93, - 93, - 93, - 93, - 93, - 93, - 93, - 93, - 93, - 93, - 94, - 94, - 94, - 94, - 94, - 94, - 94, - 94, - 94, - 94, - 95, - 95, - 95, - 95, - 95, - 95, - 95, - 95, - 95, - 95, - 95, - 96, - 96, - 96, - 96, - 96, - 96, - 96, - 96, - 96, - 96, - 97, - 97, - 97, - 97, - 97, - 97, - 97, - 97, - 97, - 97, - 97, - 98, - 98, - 98, - 98, - 98, - 98, - 98, - 98, - 98, - 98, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 100, - 100, - 100, - 100, - 100, - 100, - 100, - 100, - 100, - 100, - 100, - 101, - 101, - 101, - 101, - 101, - 101, - 101, - 101, - 101, - 101, - 101, - 102, - 102, - 102, - 102, - 102, - 102, - 102, - 102, - 102, - 102, - 102, - 103, - 103, - 103, - 103, - 103, - 103, - 103, - 103, - 103, - 103, - 103, - 103, - 104, - 104, - 104, - 104, - 104, - 104, - 104, - 104, - 104, - 104, - 104, - 105, - 105, - 105, - 105, - 105, - 105, - 105, - 105, - 105, - 105, - 105, - 105, - 106, - 106, - 106, - 106, - 106, - 106, - 106, - 106, - 106, - 106, - 106, - 106, - 107, - 107, - 107, - 107, - 107, - 107, - 107, - 107, - 107, - 107, - 107, - 107, - 108, - 108, - 108, - 108, - 108, - 108, - 108, - 108, - 108, - 108, - 108, - 108, - 109, - 109, - 109, - 109, - 109, - 109, - 109, - 109, - 109, - 109, - 109, - 109, - 110, - 110, - 110, - 110, - 110, - 110, - 110, - 110, - 110, - 110, - 110, - 110, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 111, - 112, - 112, - 112, - 112, - 112, - 112, - 112, - 112, - 112, - 112, - 112, - 112, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 113, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 114, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 115, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 116, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 117, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 118, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 119, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 120, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 121, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 122, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 123, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 124, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 125, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 126, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 127, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 128, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 129, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 130, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 131, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 132, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 133, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 134, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 135, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 136, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 137, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 138, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 139, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 140, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 141, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 142, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 143, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 144, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 145, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 146, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 147, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 148, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 149, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 150, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 151, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 152, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 153, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 154, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 155, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 156, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 157, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 158, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 159, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 160, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 161, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 162, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 163, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 164, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 165, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 166, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 167, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 168, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 169, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 170, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 171, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 172, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 173, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 174, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 175, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 176, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 177, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 178, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 179, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 180, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 181, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 182, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 183, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 184, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 185, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 186, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 187, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 188, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 189, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 190, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 191, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 192, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 193, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 194, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 195, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 196, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 197, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 198, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 199, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 200, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 201, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 202, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 203, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 204, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 205, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 206, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 207, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 208, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 209, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 210, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 211, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 214, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 215, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 216, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 217, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 218, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 219, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 220, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 221, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 222, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 223, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 224, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 225, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 226, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 227, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 228, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 229, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 230, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 231, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 232, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 233, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 234, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 235, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 236, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 237, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 238, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 239, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 240, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 241, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 242, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 243, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 244, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 245, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 246, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 247, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 248, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 249, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 250, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 251, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 252, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 253, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 254, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255, - 255 -}; diff --git a/libs/spandsp/src/complex_filters.c b/libs/spandsp/src/complex_filters.c index d54e55818a..22cf4ac9b8 100644 --- a/libs/spandsp/src/complex_filters.c +++ b/libs/spandsp/src/complex_filters.c @@ -32,6 +32,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/complex.h" #include "spandsp/complex_filters.h" @@ -40,7 +41,7 @@ SPAN_DECLARE(filter_t *) filter_create(fspec_t *fs) int i; filter_t *fi; - if ((fi = (filter_t *) malloc(sizeof(*fi) + sizeof(float)*(fs->np + 1)))) + if ((fi = (filter_t *) span_alloc(sizeof(*fi) + sizeof(float)*(fs->np + 1)))) { fi->fs = fs; fi->sum = 0.0; @@ -56,7 +57,7 @@ SPAN_DECLARE(filter_t *) filter_create(fspec_t *fs) SPAN_DECLARE(void) filter_delete(filter_t *fi) { if (fi) - free(fi); + span_free(fi); } /*- End of function --------------------------------------------------------*/ @@ -70,17 +71,17 @@ SPAN_DECLARE(cfilter_t *) cfilter_create(fspec_t *fs) { cfilter_t *cfi; - if ((cfi = (cfilter_t *) malloc(sizeof(*cfi)))) + if ((cfi = (cfilter_t *) span_alloc(sizeof(*cfi)))) { if ((cfi->ref = filter_create(fs)) == NULL) { - free(cfi); + span_free(cfi); return NULL; } if ((cfi->imf = filter_create(fs)) == NULL) { - free(cfi->ref); - free(cfi); + span_free(cfi->ref); + span_free(cfi); return NULL; } } diff --git a/libs/spandsp/src/complex_vector_float.c b/libs/spandsp/src/complex_vector_float.c index ebb6accba4..710cbef435 100644 --- a/libs/spandsp/src/complex_vector_float.c +++ b/libs/spandsp/src/complex_vector_float.c @@ -39,6 +39,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include #include "floating_fudge.h" diff --git a/libs/spandsp/src/complex_vector_int.c b/libs/spandsp/src/complex_vector_int.c index 0bf7eb8a98..66a0cd62cd 100644 --- a/libs/spandsp/src/complex_vector_int.c +++ b/libs/spandsp/src/complex_vector_int.c @@ -39,6 +39,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include #include "floating_fudge.h" diff --git a/libs/spandsp/src/crc.c b/libs/spandsp/src/crc.c index f7407eda1f..cf4dd0cd0f 100644 --- a/libs/spandsp/src/crc.c +++ b/libs/spandsp/src/crc.c @@ -32,6 +32,11 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" #include "spandsp/crc.h" @@ -102,7 +107,7 @@ SPAN_DECLARE(int) crc_itu32_append(uint8_t *buf, int len) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) crc_itu32_check(const uint8_t *buf, int len) +SPAN_DECLARE(bool) crc_itu32_check(const uint8_t *buf, int len) { uint32_t crc; int i; @@ -193,7 +198,7 @@ SPAN_DECLARE(int) crc_itu16_append(uint8_t *buf, int len) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) crc_itu16_check(const uint8_t *buf, int len) +SPAN_DECLARE(bool) crc_itu16_check(const uint8_t *buf, int len) { uint16_t crc; int i; diff --git a/libs/spandsp/src/dtmf.c b/libs/spandsp/src/dtmf.c index 991f3d6a85..9f6401028c 100644 --- a/libs/spandsp/src/dtmf.c +++ b/libs/spandsp/src/dtmf.c @@ -31,18 +31,24 @@ #include #include +#include +#include +#include #if defined(HAVE_TGMATH_H) #include #endif #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" -#include -#include -#include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/queue.h" @@ -93,11 +99,11 @@ static const float dtmf_col[] = static const char dtmf_positions[] = "123A" "456B" "789C" "*0#D"; -static int dtmf_rx_inited = FALSE; +static bool dtmf_rx_inited = false; static goertzel_descriptor_t dtmf_detect_row[4]; static goertzel_descriptor_t dtmf_detect_col[4]; -static int dtmf_tx_inited = FALSE; +static bool dtmf_tx_inited = false; static tone_gen_descriptor_t dtmf_digit_tones[16]; SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples) @@ -413,7 +419,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s, if (s == NULL) { - if ((s = (dtmf_rx_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (dtmf_rx_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -423,7 +429,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s, s->digits_callback_data = user_data; s->realtime_callback = NULL; s->realtime_callback_data = NULL; - s->filter_dialtone = FALSE; + s->filter_dialtone = false; s->normal_twist = DTMF_NORMAL_TWIST; s->reverse_twist = DTMF_REVERSE_TWIST; s->threshold = DTMF_THRESHOLD; @@ -438,7 +444,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s, make_goertzel_descriptor(&dtmf_detect_row[i], dtmf_row[i], DTMF_SAMPLES_PER_BLOCK); make_goertzel_descriptor(&dtmf_detect_col[i], dtmf_col[i], DTMF_SAMPLES_PER_BLOCK); } - dtmf_rx_inited = TRUE; + dtmf_rx_inited = true; } for (i = 0; i < 4; i++) { @@ -466,7 +472,7 @@ SPAN_DECLARE(int) dtmf_rx_release(dtmf_rx_state_t *s) SPAN_DECLARE(int) dtmf_rx_free(dtmf_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -491,10 +497,10 @@ static void dtmf_tx_initialise(void) DEFAULT_DTMF_TX_OFF_TIME, 0, 0, - FALSE); + false); } } - dtmf_tx_inited = TRUE; + dtmf_tx_inited = true; } /*- End of function --------------------------------------------------------*/ @@ -578,7 +584,7 @@ SPAN_DECLARE(dtmf_tx_state_t *) dtmf_tx_init(dtmf_tx_state_t *s, { if (s == NULL) { - if ((s = (dtmf_tx_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (dtmf_tx_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -603,7 +609,7 @@ SPAN_DECLARE(int) dtmf_tx_release(dtmf_tx_state_t *s) SPAN_DECLARE(int) dtmf_tx_free(dtmf_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/echo.c b/libs/spandsp/src/echo.c index 84926fa3c4..5d6a1cadd2 100644 --- a/libs/spandsp/src/echo.c +++ b/libs/spandsp/src/echo.c @@ -88,11 +88,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/saturated.h" @@ -105,12 +111,6 @@ #if !defined(NULL) #define NULL (void *) 0 #endif -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif #define NONUPDATE_DWELL_TIME 600 /* 600 samples, or 75ms */ @@ -244,26 +244,26 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode) int i; int j; - if ((ec = (echo_can_state_t *) malloc(sizeof(*ec))) == NULL) + if ((ec = (echo_can_state_t *) span_alloc(sizeof(*ec))) == NULL) return NULL; memset(ec, 0, sizeof(*ec)); ec->taps = len; ec->curr_pos = ec->taps - 1; ec->tap_mask = ec->taps - 1; - if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL) + if ((ec->fir_taps32 = (int32_t *) span_alloc(ec->taps*sizeof(int32_t))) == NULL) { - free(ec); + span_free(ec); return NULL; } memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t)); for (i = 0; i < 4; i++) { - if ((ec->fir_taps16[i] = (int16_t *) malloc(ec->taps*sizeof(int16_t))) == NULL) + if ((ec->fir_taps16[i] = (int16_t *) span_alloc(ec->taps*sizeof(int16_t))) == NULL) { for (j = 0; j < i; j++) - free(ec->fir_taps16[j]); - free(ec->fir_taps32); - free(ec); + span_free(ec->fir_taps16[j]); + span_free(ec->fir_taps32); + span_free(ec); return NULL; } memset(ec->fir_taps16[i], 0, ec->taps*sizeof(int16_t)); @@ -274,7 +274,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode) ec->rx_power_threshold = 10000000; ec->geigel_max = 0; ec->geigel_lag = 0; - ec->dtd_onset = FALSE; + ec->dtd_onset = false; ec->tap_set = 0; ec->tap_rotate_counter = 1600; ec->cng_level = 1000; @@ -294,10 +294,10 @@ SPAN_DECLARE(int) echo_can_free(echo_can_state_t *ec) int i; fir16_free(&ec->fir_state); - free(ec->fir_taps32); + span_free(ec->fir_taps32); for (i = 0; i < 4; i++) - free(ec->fir_taps16[i]); - free(ec); + span_free(ec->fir_taps16[i]); + span_free(ec); return 0; } /*- End of function --------------------------------------------------------*/ @@ -337,7 +337,7 @@ SPAN_DECLARE(void) echo_can_flush(echo_can_state_t *ec) ec->geigel_max = 0; ec->geigel_lag = 0; - ec->dtd_onset = FALSE; + ec->dtd_onset = false; ec->tap_set = 0; ec->tap_rotate_counter = 1600; @@ -485,7 +485,7 @@ printf("Revert to %d at %d\n", (ec->tap_set + 1)%3, sample_no); ec->narrowband_score = 0; } } - ec->dtd_onset = FALSE; + ec->dtd_onset = false; if (--ec->tap_rotate_counter <= 0) { printf("Rotate to %d at %d\n", ec->tap_set, sample_no); @@ -532,7 +532,7 @@ printf("Revert to %d at %d\n", (ec->tap_set + 1)%3, sample_no); for (i = 0; i < ec->taps; i++) ec->fir_taps32[i] = ec->fir_taps16[(ec->tap_set + 1)%3][i] << 15; ec->tap_rotate_counter = 1600; - ec->dtd_onset = TRUE; + ec->dtd_onset = true; } ec->nonupdate_dwell = NONUPDATE_DWELL_TIME; } @@ -575,7 +575,7 @@ printf("Revert to %d at %d\n", (ec->tap_set + 1)%3, sample_no); if (!ec->cng) { ec->cng_level = ec->clean_rx_power; - ec->cng = TRUE; + ec->cng = true; } if ((ec->adaption_mode & ECHO_CAN_USE_CNG)) { @@ -594,12 +594,12 @@ printf("Revert to %d at %d\n", (ec->tap_set + 1)%3, sample_no); } else { - ec->cng = FALSE; + ec->cng = false; } } else { - ec->cng = FALSE; + ec->cng = false; } printf("Narrowband score %4d %5d at %d\n", ec->narrowband_score, score, sample_no); diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index ef7e33433a..a220c4f818 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -40,6 +40,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include @@ -50,6 +55,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/queue.h" #include "spandsp/dc_restore.h" @@ -95,6 +101,7 @@ #include "spandsp/private/logging.h" #include "spandsp/private/silence_gen.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/modem_connect_tones.h" #include "spandsp/private/v8.h" @@ -209,7 +216,7 @@ static int set_next_tx_type(fax_state_t *s) silence_gen_alter(&t->silence_gen, 0); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - t->transmit = FALSE; + t->transmit = false; return -1; } /*- End of function --------------------------------------------------------*/ @@ -276,7 +283,7 @@ static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_t t->current_rx_type = type; t->rx_bit_rate = bit_rate; if (use_hdlc) - hdlc_rx_init(&t->hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, t30_hdlc_accept, &s->t30); + hdlc_rx_init(&t->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, t30_hdlc_accept, &s->t30); switch (type) { @@ -319,14 +326,14 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t silence_gen_alter(&t->silence_gen, ms_to_samples(short_train)); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - t->transmit = TRUE; + t->transmit = true; break; case T30_MODEM_CED: case T30_MODEM_CNG: tone = (type == T30_MODEM_CED) ? FAX_MODEM_CED_TONE_TX : FAX_MODEM_CNG_TONE_TX; fax_modems_start_slow_modem(t, tone); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - t->transmit = TRUE; + t->transmit = true; break; case T30_MODEM_V21: fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); @@ -339,7 +346,7 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t silence_gen_alter(&t->silence_gen, ms_to_samples(75)); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &fsk_tx, &t->v21_tx); - t->transmit = TRUE; + t->transmit = true; break; case T30_MODEM_V17: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); @@ -348,7 +355,7 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t fax_modems_start_fast_modem(t, FAX_MODEM_V17_TX, bit_rate, short_train, use_hdlc); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); - t->transmit = TRUE; + t->transmit = true; break; case T30_MODEM_V27TER: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); @@ -357,7 +364,7 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_TX, bit_rate, short_train, use_hdlc); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); - t->transmit = TRUE; + t->transmit = true; break; case T30_MODEM_V29: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); @@ -366,7 +373,7 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t fax_modems_start_fast_modem(t, FAX_MODEM_V29_TX, bit_rate, short_train, use_hdlc); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); - t->transmit = TRUE; + t->transmit = true; break; case T30_MODEM_DONE: span_log(&s->logging, SPAN_LOG_FLOW, "FAX exchange complete\n"); @@ -375,7 +382,7 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t silence_gen_alter(&t->silence_gen, 0); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - t->transmit = FALSE; + t->transmit = false; break; } t->tx_bit_rate = bit_rate; @@ -470,14 +477,14 @@ SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) if (s == NULL) { - if ((s = (fax_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (fax_state_t *) span_alloc(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, + false, t30_hdlc_accept, hdlc_underflow_handler, t30_non_ecm_put_bit, @@ -525,7 +532,7 @@ SPAN_DECLARE(int) fax_release(fax_state_t *s) SPAN_DECLARE(int) fax_free(fax_state_t *s) { t30_release(&s->t30); - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/fax_modems.c b/libs/spandsp/src/fax_modems.c index 3cf658e4df..9f6cc4ba4c 100644 --- a/libs/spandsp/src/fax_modems.c +++ b/libs/spandsp/src/fax_modems.c @@ -39,6 +39,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include @@ -48,6 +53,7 @@ #endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/dc_restore.h" @@ -73,6 +79,7 @@ #include "spandsp/private/logging.h" #include "spandsp/private/silence_gen.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/v17tx.h" #include "spandsp/private/v17rx.h" @@ -92,7 +99,7 @@ static void fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, s = (fax_modems_state_t *) user_data; if (ok) - s->rx_frame_received = TRUE; + s->rx_frame_received = false; if (s->hdlc_accept) s->hdlc_accept(s->hdlc_accept_user_data, msg, len, ok); } @@ -263,7 +270,7 @@ SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which) fsk_rx_init(&s->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &s->hdlc_rx); fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); fsk_rx_signal_cutoff(&s->v21_rx, -39.09f); - s->rx_frame_received = FALSE; + s->rx_frame_received = false; break; case FAX_MODEM_CED_TONE_RX: modem_connect_tones_rx_init(&s->connect_rx, MODEM_CONNECT_TONES_FAX_CED, s->tone_callback, s->tone_callback_user_data); @@ -321,10 +328,10 @@ SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, if (s->fast_modem != which) { s->current_rx_type = which; - s->short_train = FALSE; + s->short_train = false; s->fast_modem = which; if (hdlc_mode) - s->rx_frame_received = FALSE; + s->rx_frame_received = false; switch (s->fast_modem) { case FAX_MODEM_V27TER_RX: @@ -367,13 +374,13 @@ SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, switch (s->fast_modem) { case FAX_MODEM_V27TER_RX: - v27ter_rx_restart(&s->fast_modems.v27ter_rx, s->bit_rate, FALSE); + v27ter_rx_restart(&s->fast_modems.v27ter_rx, s->bit_rate, false); v27ter_rx_set_put_bit(&s->fast_modems.v27ter_rx, put_bit, put_bit_user_data); v27ter_rx_set_modem_status_handler(&s->fast_modems.v27ter_rx, v27ter_rx_status_handler, s); fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v27ter_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v27ter_v21_rx_fillin, s); break; case FAX_MODEM_V29_RX: - v29_rx_restart(&s->fast_modems.v29_rx, s->bit_rate, FALSE); + v29_rx_restart(&s->fast_modems.v29_rx, s->bit_rate, false); v29_rx_set_put_bit(&s->fast_modems.v29_rx, put_bit, put_bit_user_data); v29_rx_set_modem_status_handler(&s->fast_modems.v29_rx, v29_rx_status_handler, s); fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v29_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v29_v21_rx_fillin, s); @@ -503,7 +510,7 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s, { if (s == NULL) { - if ((s = (fax_modems_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (fax_modems_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } /*endif*/ @@ -534,15 +541,15 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s, s->hdlc_accept = hdlc_accept; s->hdlc_accept_user_data = user_data; - hdlc_rx_init(&s->hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s); - hdlc_tx_init(&s->hdlc_tx, FALSE, 2, FALSE, hdlc_tx_underflow, user_data); + hdlc_rx_init(&s->hdlc_rx, false, false, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s); + hdlc_tx_init(&s->hdlc_tx, false, 2, false, hdlc_tx_underflow, user_data); fax_modems_start_slow_modem(s, FAX_MODEM_V21_RX); fsk_tx_init(&s->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &s->hdlc_tx); silence_gen_init(&s->silence_gen, 0); - s->rx_signal_present = FALSE; + s->rx_signal_present = false; s->rx_handler = (span_rx_handler_t) &span_dummy_rx; s->rx_fillin_handler = (span_rx_fillin_handler_t) &span_dummy_rx; s->rx_user_data = NULL; @@ -562,7 +569,7 @@ SPAN_DECLARE(int) fax_modems_release(fax_modems_state_t *s) SPAN_DECLARE(int) fax_modems_free(fax_modems_state_t *s) { if (s) - free(s); + span_free(s); /*endif*/ return 0; } diff --git a/libs/spandsp/src/filter_tools.c b/libs/spandsp/src/filter_tools.c index 88967e93ed..ff625bb13d 100644 --- a/libs/spandsp/src/filter_tools.c +++ b/libs/spandsp/src/filter_tools.c @@ -32,29 +32,27 @@ #include #include +#include +#include +#include +#include #if defined(HAVE_TGMATH_H) #include #endif #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" -#include -#include -#include -#include #include "spandsp/telephony.h" #include "spandsp/complex.h" #include "filter_tools.h" -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - #define MAXPZ 8192 #define SEQ_LEN 8192 #define MAX_FFT_LEN SEQ_LEN diff --git a/libs/spandsp/src/fsk.c b/libs/spandsp/src/fsk.c index 56f155169e..29b32c65ea 100644 --- a/libs/spandsp/src/fsk.c +++ b/libs/spandsp/src/fsk.c @@ -38,16 +38,23 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/complex.h" #include "spandsp/dds.h" #include "spandsp/power_meter.h" #include "spandsp/async.h" #include "spandsp/fsk.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" const fsk_spec_t preset_fsk_specs[] = @@ -69,6 +76,7 @@ const fsk_spec_t preset_fsk_specs[] = 300*100 }, { + /* This is mode 2 of the V.23 spec. Mode 1 (the 600baud mode) is not defined here */ "V23 ch 1", 1700 + 400, 1700 - 400, @@ -124,6 +132,14 @@ const fsk_spec_t preset_fsk_specs[] = -30, 50*100 }, + { + "Weitbrecht 47.6", /* Used for V.18 probing */ + 1600 + 200, + 1600 - 200, + -14, + -30, + 4760 + }, { "V21 (110bps) ch 1", 1080 + 100, @@ -145,7 +161,7 @@ SPAN_DECLARE(int) fsk_tx_restart(fsk_tx_state_t *s, const fsk_spec_t *spec) s->baud_frac = 0; s->current_phase_rate = s->phase_rates[1]; - s->shutdown = FALSE; + s->shutdown = false; return 0; } /*- End of function --------------------------------------------------------*/ @@ -157,7 +173,7 @@ SPAN_DECLARE(fsk_tx_state_t *) fsk_tx_init(fsk_tx_state_t *s, { if (s == NULL) { - if ((s = (fsk_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (fsk_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -177,7 +193,7 @@ SPAN_DECLARE(int) fsk_tx_release(fsk_tx_state_t *s) SPAN_DECLARE(int) fsk_tx_free(fsk_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -204,7 +220,7 @@ SPAN_DECLARE_NONSTD(int) fsk_tx(fsk_tx_state_t *s, int16_t amp[], int len) s->status_handler(s->status_user_data, SIG_STATUS_END_OF_DATA); if (s->status_handler) s->status_handler(s->status_user_data, SIG_STATUS_SHUTDOWN_COMPLETE); - s->shutdown = TRUE; + s->shutdown = true; break; } s->current_phase_rate = s->phase_rates[bit & 1]; @@ -319,7 +335,7 @@ SPAN_DECLARE(fsk_rx_state_t *) fsk_rx_init(fsk_rx_state_t *s, { if (s == NULL) { - if ((s = (fsk_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (fsk_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -339,7 +355,7 @@ SPAN_DECLARE(int) fsk_rx_release(fsk_rx_state_t *s) SPAN_DECLARE(int) fsk_rx_free(fsk_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/g711.c b/libs/spandsp/src/g711.c index 173bd2ae53..edccd27bb1 100644 --- a/libs/spandsp/src/g711.c +++ b/libs/spandsp/src/g711.c @@ -35,6 +35,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/bit_operations.h" #include "spandsp/g711.h" #include "spandsp/private/g711.h" @@ -171,7 +172,7 @@ SPAN_DECLARE(g711_state_t *) g711_init(g711_state_t *s, int mode) { if (s == NULL) { - if ((s = (g711_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (g711_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } s->mode = mode; @@ -187,7 +188,7 @@ SPAN_DECLARE(int) g711_release(g711_state_t *s) SPAN_DECLARE(int) g711_free(g711_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/g722.c b/libs/spandsp/src/g722.c index 22715cfa4a..2f11715c10 100644 --- a/libs/spandsp/src/g722.c +++ b/libs/spandsp/src/g722.c @@ -38,9 +38,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/saturated.h" #include "spandsp/vector_int.h" @@ -251,7 +257,7 @@ SPAN_DECLARE(g722_decode_state_t *) g722_decode_init(g722_decode_state_t *s, int { if (s == NULL) { - if ((s = (g722_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (g722_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -262,11 +268,11 @@ SPAN_DECLARE(g722_decode_state_t *) g722_decode_init(g722_decode_state_t *s, int else s->bits_per_sample = 8; if ((options & G722_SAMPLE_RATE_8000)) - s->eight_k = TRUE; + s->eight_k = true; if ((options & G722_PACKED) && s->bits_per_sample != 8) - s->packed = TRUE; + s->packed = true; else - s->packed = FALSE; + s->packed = false; s->band[0].det = 32; s->band[1].det = 8; return s; @@ -281,7 +287,7 @@ SPAN_DECLARE(int) g722_decode_release(g722_decode_state_t *s) SPAN_DECLARE(int) g722_decode_free(g722_decode_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -432,7 +438,7 @@ SPAN_DECLARE(g722_encode_state_t *) g722_encode_init(g722_encode_state_t *s, int { if (s == NULL) { - if ((s = (g722_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (g722_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -443,11 +449,11 @@ SPAN_DECLARE(g722_encode_state_t *) g722_encode_init(g722_encode_state_t *s, int else s->bits_per_sample = 8; if ((options & G722_SAMPLE_RATE_8000)) - s->eight_k = TRUE; + s->eight_k = true; if ((options & G722_PACKED) && s->bits_per_sample != 8) - s->packed = TRUE; + s->packed = true; else - s->packed = FALSE; + s->packed = false; s->band[0].det = 32; s->band[1].det = 8; return s; @@ -462,7 +468,7 @@ SPAN_DECLARE(int) g722_encode_release(g722_encode_state_t *s) SPAN_DECLARE(int) g722_encode_free(g722_encode_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/g726.c b/libs/spandsp/src/g726.c index 6be385fc5f..4f3bea3b6b 100644 --- a/libs/spandsp/src/g726.c +++ b/libs/spandsp/src/g726.c @@ -64,9 +64,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/bitstream.h" #include "spandsp/bit_operations.h" #include "spandsp/g711.h" @@ -393,7 +399,7 @@ static void update(g726_state_t *s, int16_t thr; int16_t pk0; int i; - int tr; + bool tr; a2p = 0; /* Needed in updating predictor poles */ @@ -408,11 +414,11 @@ static void update(g726_state_t *s, thr = (ylint > 9) ? (31 << 10) : ((32 + ylfrac) << ylint); dqthr = (thr + (thr >> 1)) >> 1; /* dqthr = 0.75 * thr */ if (!s->td) /* signal supposed voice */ - tr = FALSE; + tr = false; else if (mag <= dqthr) /* supposed data, but small mag */ - tr = FALSE; /* treated as voice */ + tr = false; /* treated as voice */ else /* signal is data (modem) */ - tr = TRUE; + tr = true; /* * Quantizer scale factor adaptation. @@ -563,11 +569,11 @@ static void update(g726_state_t *s, /* TONE */ if (tr) /* this sample has been treated as data */ - s->td = FALSE; /* next one will be treated as voice */ + s->td = false; /* next one will be treated as voice */ else if (a2p < -11776) /* small sample-to-sample correlation */ - s->td = TRUE; /* signal may be data */ + s->td = true; /* signal may be data */ else /* signal is voice */ - s->td = FALSE; + s->td = false; /* Adaptation speed control. */ /* FILTA */ @@ -1002,7 +1008,7 @@ SPAN_DECLARE(g726_state_t *) g726_init(g726_state_t *s, int bit_rate, int ext_co return NULL; if (s == NULL) { - if ((s = (g726_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (g726_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } s->yl = 34816; @@ -1024,7 +1030,7 @@ SPAN_DECLARE(g726_state_t *) g726_init(g726_state_t *s, int bit_rate, int ext_co s->b[i] = 0; s->dq[i] = 32; } - s->td = FALSE; + s->td = false; switch (bit_rate) { case 16000: @@ -1062,7 +1068,7 @@ SPAN_DECLARE(int) g726_release(g726_state_t *s) SPAN_DECLARE(int) g726_free(g726_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/gsm0610_encode.c b/libs/spandsp/src/gsm0610_encode.c index 2c359688fe..eeac7d2881 100644 --- a/libs/spandsp/src/gsm0610_encode.c +++ b/libs/spandsp/src/gsm0610_encode.c @@ -45,6 +45,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/bitstream.h" #include "spandsp/saturated.h" @@ -115,7 +116,7 @@ SPAN_DECLARE(gsm0610_state_t *) gsm0610_init(gsm0610_state_t *s, int packing) { if (s == NULL) { - if ((s = (gsm0610_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (gsm0610_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; /*endif*/ } @@ -136,7 +137,7 @@ SPAN_DECLARE(int) gsm0610_release(gsm0610_state_t *s) SPAN_DECLARE(int) gsm0610_free(gsm0610_state_t *s) { if (s) - free(s); + span_free(s); /*endif*/ return 0; } diff --git a/libs/spandsp/src/gsm0610_rpe.c b/libs/spandsp/src/gsm0610_rpe.c index 68ddff3e1e..387ef1493b 100644 --- a/libs/spandsp/src/gsm0610_rpe.c +++ b/libs/spandsp/src/gsm0610_rpe.c @@ -59,7 +59,7 @@ static void weighting_filter(int16_t x[40], const int16_t *e) // signal [-5..0.39.44] IN) { -#if defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__x86_64__) && !(defined(__APPLE_CC__) && __APPLE_CC__ >= 5448) +#if defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__x86_64__) /* Table 4.4 Coefficients of the weighting filter */ /* This must be padded to a multiple of 4 for MMX to work */ static const union diff --git a/libs/spandsp/src/hdlc.c b/libs/spandsp/src/hdlc.c index 7733aa8280..7a20bf2451 100644 --- a/libs/spandsp/src/hdlc.c +++ b/libs/spandsp/src/hdlc.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/async.h" #include "spandsp/crc.h" #include "spandsp/bit_operations.h" @@ -46,7 +52,7 @@ static void report_status_change(hdlc_rx_state_t *s, int status) if (s->status_handler) s->status_handler(s->status_user_data, status); else if (s->frame_handler) - s->frame_handler(s->frame_user_data, NULL, status, TRUE); + s->frame_handler(s->frame_user_data, NULL, status, true); } /*- End of function --------------------------------------------------------*/ @@ -62,7 +68,7 @@ static void rx_special_condition(hdlc_rx_state_t *s, int status) s->len = 0; s->num_bits = 0; s->flags_seen = 0; - s->framing_ok_announced = FALSE; + s->framing_ok_announced = false; /* Fall through */ case SIG_STATUS_TRAINING_IN_PROGRESS: case SIG_STATUS_TRAINING_FAILED: @@ -94,7 +100,7 @@ static __inline__ void octet_set_and_count(hdlc_rx_state_t *s) } else { - s->octet_counting_mode = TRUE; + s->octet_counting_mode = true; s->octet_count = s->octet_count_report_interval; } } @@ -139,7 +145,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) { /* Hit HDLC flag */ /* A flag clears octet counting */ - s->octet_counting_mode = FALSE; + s->octet_counting_mode = false; if (s->flags_seen >= s->framing_ok_threshold) { /* We may have a frame, or we may have back to back flags */ @@ -155,7 +161,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) s->rx_bytes += s->len - s->crc_bytes; s->len -= s->crc_bytes; if (s->frame_handler) - s->frame_handler(s->frame_user_data, s->buffer, s->len, TRUE); + s->frame_handler(s->frame_user_data, s->buffer, s->len, true); } else { @@ -164,7 +170,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) { s->len -= s->crc_bytes; if (s->frame_handler) - s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE); + s->frame_handler(s->frame_user_data, s->buffer, s->len, false); } } } @@ -180,7 +186,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) else s->len = 0; if (s->frame_handler) - s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE); + s->frame_handler(s->frame_user_data, s->buffer, s->len, false); } s->rx_length_errors++; } @@ -205,7 +211,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) if (++s->flags_seen >= s->framing_ok_threshold && !s->framing_ok_announced) { report_status_change(s, SIG_STATUS_FRAMING_OK); - s->framing_ok_announced = TRUE; + s->framing_ok_announced = true; } } } @@ -306,15 +312,15 @@ SPAN_DECLARE(void) hdlc_rx_set_octet_counting_report_interval(hdlc_rx_state_t *s /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s, - int crc32, - int report_bad_frames, + bool crc32, + bool report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data) { if (s == NULL) { - if ((s = (hdlc_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (hdlc_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -350,7 +356,7 @@ SPAN_DECLARE(int) hdlc_rx_release(hdlc_rx_state_t *s) SPAN_DECLARE(int) hdlc_rx_free(hdlc_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -371,7 +377,7 @@ SPAN_DECLARE(int) hdlc_tx_frame(hdlc_tx_state_t *s, const uint8_t *frame, size_t { if (len <= 0) { - s->tx_end = TRUE; + s->tx_end = true; return 0; } if (s->len + len > s->max_frame_len) @@ -397,7 +403,7 @@ SPAN_DECLARE(int) hdlc_tx_frame(hdlc_tx_state_t *s, const uint8_t *frame, size_t s->len += len; else s->len = len; - s->tx_end = FALSE; + s->tx_end = false; return 0; } /*- End of function --------------------------------------------------------*/ @@ -412,8 +418,8 @@ SPAN_DECLARE(int) hdlc_tx_flags(hdlc_tx_state_t *s, int len) s->flag_octets += -len; else s->flag_octets = len; - s->report_flag_underflow = TRUE; - s->tx_end = FALSE; + s->report_flag_underflow = true; + s->tx_end = false; return 0; } /*- End of function --------------------------------------------------------*/ @@ -452,7 +458,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s) /* We are in a timed flag section (preamble, inter frame gap, etc.) */ if (--s->flag_octets <= 0 && s->report_flag_underflow) { - s->report_flag_underflow = FALSE; + s->report_flag_underflow = false; if (s->len == 0) { /* The timed flags have finished, there is nothing else queued to go, @@ -508,7 +514,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s) s->crc = 0xFFFFFFFF; /* Report the underflow now. If there are timed flags still in progress, loading the next frame right now will be harmless. */ - s->report_flag_underflow = FALSE; + s->report_flag_underflow = false; if (s->underflow_handler) s->underflow_handler(s->user_data); /* Make sure we finish off with at least one flag octet, if the underflow report did not result @@ -539,7 +545,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s) /* Untimed idling on flags */ if (s->tx_end) { - s->tx_end = FALSE; + s->tx_end = false; return SIG_STATUS_END_OF_DATA; } return s->idle_octet; @@ -584,15 +590,15 @@ SPAN_DECLARE(void) hdlc_tx_set_max_frame_len(hdlc_tx_state_t *s, size_t max_len) /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(hdlc_tx_state_t *) hdlc_tx_init(hdlc_tx_state_t *s, - int crc32, + bool crc32, int inter_frame_flags, - int progressive, + bool progressive, hdlc_underflow_handler_t handler, void *user_data) { if (s == NULL) { - if ((s = (hdlc_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (hdlc_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -624,7 +630,7 @@ SPAN_DECLARE(int) hdlc_tx_release(hdlc_tx_state_t *s) SPAN_DECLARE(int) hdlc_tx_free(hdlc_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/ima_adpcm.c b/libs/spandsp/src/ima_adpcm.c index 6c4cc16370..fbd59df621 100644 --- a/libs/spandsp/src/ima_adpcm.c +++ b/libs/spandsp/src/ima_adpcm.c @@ -42,6 +42,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/saturated.h" #include "spandsp/ima_adpcm.h" @@ -282,7 +283,7 @@ SPAN_DECLARE(ima_adpcm_state_t *) ima_adpcm_init(ima_adpcm_state_t *s, { if (s == NULL) { - if ((s = (ima_adpcm_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (ima_adpcm_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } /*endif*/ @@ -301,7 +302,7 @@ SPAN_DECLARE(int) ima_adpcm_release(ima_adpcm_state_t *s) SPAN_DECLARE(int) ima_adpcm_free(ima_adpcm_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/image_translate.c b/libs/spandsp/src/image_translate.c index b504ca9074..442d188be5 100644 --- a/libs/spandsp/src/image_translate.c +++ b/libs/spandsp/src/image_translate.c @@ -47,11 +47,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/saturated.h" @@ -712,7 +718,7 @@ SPAN_DECLARE(int) image_translate_restart(image_translate_state_t *s, int input_ { if (s->raw_pixel_row[i] == NULL) { - if ((s->raw_pixel_row[i] = (uint8_t *) malloc(raw_row_size)) == NULL) + if ((s->raw_pixel_row[i] = (uint8_t *) span_alloc(raw_row_size)) == NULL) return -1; } memset(s->raw_pixel_row[i], 0, raw_row_size); @@ -729,7 +735,7 @@ SPAN_DECLARE(int) image_translate_restart(image_translate_state_t *s, int input_ { if (s->pixel_row[i] == NULL) { - if ((s->pixel_row[i] = (uint8_t *) malloc(raw_row_size)) == NULL) + if ((s->pixel_row[i] = (uint8_t *) span_alloc(raw_row_size)) == NULL) return -1; } memset(s->pixel_row[i], 0, raw_row_size); @@ -757,7 +763,7 @@ SPAN_DECLARE(image_translate_state_t *) image_translate_init(image_translate_sta { if (s == NULL) { - if ((s = (image_translate_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (image_translate_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -794,12 +800,12 @@ SPAN_DECLARE(int) image_translate_release(image_translate_state_t *s) { if (s->raw_pixel_row[i]) { - free(s->raw_pixel_row[i]); + span_free(s->raw_pixel_row[i]); s->raw_pixel_row[i] = NULL; } if (s->pixel_row[i]) { - free(s->pixel_row[i]); + span_free(s->pixel_row[i]); s->pixel_row[i] = NULL; } } @@ -812,7 +818,7 @@ SPAN_DECLARE(int) image_translate_free(image_translate_state_t *s) int res; res = image_translate_release(s); - free(s); + span_free(s); return res; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/libspandsp.2010.vcxproj b/libs/spandsp/src/libspandsp.2010.vcxproj index d3793f5b18..8bb87b58c6 100644 --- a/libs/spandsp/src/libspandsp.2010.vcxproj +++ b/libs/spandsp/src/libspandsp.2010.vcxproj @@ -157,6 +157,7 @@ + @@ -427,6 +428,9 @@ {dee932ab-5911-4700-9eeb-8c7090a0a330} false + + {85f0cf8c-c7ab-48f6-ba19-cc94cf87f981} + {9d04a840-ce18-4ff5-a6d3-0a2bb92ff2e6} diff --git a/libs/spandsp/src/libspandsp.2010.vcxproj.filters b/libs/spandsp/src/libspandsp.2010.vcxproj.filters index 05763b180c..cc34e6c278 100644 --- a/libs/spandsp/src/libspandsp.2010.vcxproj.filters +++ b/libs/spandsp/src/libspandsp.2010.vcxproj.filters @@ -283,6 +283,9 @@ Source Files + + Source Files + diff --git a/libs/spandsp/src/libspandsp.2012.vcxproj b/libs/spandsp/src/libspandsp.2012.vcxproj index 1c5ce3c257..dd99dbc2d9 100644 --- a/libs/spandsp/src/libspandsp.2012.vcxproj +++ b/libs/spandsp/src/libspandsp.2012.vcxproj @@ -161,6 +161,7 @@ + @@ -431,6 +432,9 @@ {dee932ab-5911-4700-9eeb-8c7090a0a330} false + + {85f0cf8c-c7ab-48f6-ba19-cc94cf87f981} + {2386b892-35f5-46cf-a0f0-10394d2fbf9b} diff --git a/libs/spandsp/src/libspandsp.2012.vcxproj.filters b/libs/spandsp/src/libspandsp.2012.vcxproj.filters index 05763b180c..cc34e6c278 100644 --- a/libs/spandsp/src/libspandsp.2012.vcxproj.filters +++ b/libs/spandsp/src/libspandsp.2012.vcxproj.filters @@ -283,6 +283,9 @@ Source Files + + Source Files + diff --git a/libs/spandsp/src/logging.c b/libs/spandsp/src/logging.c index 3f9aa58f17..09bc29b6c6 100644 --- a/libs/spandsp/src/logging.c +++ b/libs/spandsp/src/logging.c @@ -40,8 +40,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/private/logging.h" @@ -73,11 +79,11 @@ static void default_message_handler(void *user_data, int level, const char *text } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) span_log_test(logging_state_t *s, int level) +SPAN_DECLARE(bool) span_log_test(logging_state_t *s, int level) { if (s && (s->level & SPAN_LOG_SEVERITY_MASK) >= (level & SPAN_LOG_SEVERITY_MASK)) - return TRUE; - return FALSE; + return true; + return false; } /*- End of function --------------------------------------------------------*/ @@ -229,7 +235,7 @@ SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, con { if (s == NULL) { - if ((s = (logging_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (logging_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } s->span_message = __span_message; @@ -252,7 +258,7 @@ SPAN_DECLARE(int) span_log_release(logging_state_t *s) SPAN_DECLARE(int) span_log_free(logging_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/lpc10_analyse.c b/libs/spandsp/src/lpc10_analyse.c index e809d41ec8..082dbbb3ac 100644 --- a/libs/spandsp/src/lpc10_analyse.c +++ b/libs/spandsp/src/lpc10_analyse.c @@ -41,6 +41,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" @@ -349,7 +354,7 @@ static void onset(lpc10_encode_state_t *s, osbuf[*osptr - 1] = i - 9; (*osptr)++; } - s->hyst = TRUE; + s->hyst = true; } s->lasti = i; /* After one onset detection, at least OSHYST sample times must go */ @@ -357,7 +362,7 @@ static void onset(lpc10_encode_state_t *s, } else if (s->hyst && i - s->lasti >= 10) { - s->hyst = FALSE; + s->hyst = false; } } } diff --git a/libs/spandsp/src/lpc10_decode.c b/libs/spandsp/src/lpc10_decode.c index 19860e149d..2242133591 100644 --- a/libs/spandsp/src/lpc10_decode.c +++ b/libs/spandsp/src/lpc10_decode.c @@ -34,16 +34,22 @@ #include #include #include +#include #if defined(HAVE_TGMATH_H) #include #endif #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" -#include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/lpc10.h" #include "spandsp/private/lpc10.h" @@ -279,7 +285,7 @@ static int pitsyn(lpc10_decode_state_t *s, ipiti[i] = *pitch; rmsi[i] = *rms; } - s->first_pitsyn = FALSE; + s->first_pitsyn = false; } else { @@ -406,7 +412,7 @@ static int pitsyn(lpc10_decode_state_t *s, /* NOUT | -- -- -- -- ?? ?? */ /* IVOICE | -- -- -- -- 0 0 */ - /* UVPIT is always 0.0 on the first pass through the DO WHILE (TRUE) + /* UVPIT is always 0.0 on the first pass through the DO WHILE (true) loop below. */ /* The only possible non-0 value of SLOPE (in column 111) is @@ -857,7 +863,7 @@ static void decode(lpc10_decode_state_t *s, /* Skip decoding on first frame because present data not yet available */ if (s->first) { - s->first = FALSE; + s->first = false; /* Assign PITCH a "default" value on the first call, since */ /* otherwise it would be left uninitialized. The two lines */ /* below were copied from above, since it seemed like a */ @@ -1016,7 +1022,7 @@ SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *s, if (s == NULL) { - if ((s = (lpc10_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (lpc10_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } @@ -1024,7 +1030,7 @@ SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *s, /* State used by function decode */ s->iptold = 60; - s->first = TRUE; + s->first = true; s->ivp2h = 0; s->iovoic = 0; s->iavgp = 60; @@ -1044,7 +1050,7 @@ SPAN_DECLARE(lpc10_decode_state_t *) lpc10_decode_init(lpc10_decode_state_t *s, /* State used by function pitsyn */ s->rmso = 1.0f; - s->first_pitsyn = TRUE; + s->first_pitsyn = true; /* State used by function bsynz */ s->ipo = 0; @@ -1084,7 +1090,7 @@ SPAN_DECLARE(int) lpc10_decode_release(lpc10_decode_state_t *s) SPAN_DECLARE(int) lpc10_decode_free(lpc10_decode_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/lpc10_encode.c b/libs/spandsp/src/lpc10_encode.c index 739734f866..27bf10c9b1 100644 --- a/libs/spandsp/src/lpc10_encode.c +++ b/libs/spandsp/src/lpc10_encode.c @@ -41,9 +41,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/lpc10.h" #include "spandsp/private/lpc10.h" @@ -269,7 +275,7 @@ SPAN_DECLARE(lpc10_encode_state_t *) lpc10_encode_init(lpc10_encode_state_t *s, if (s == NULL) { - if ((s = (lpc10_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (lpc10_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } @@ -321,7 +327,7 @@ SPAN_DECLARE(lpc10_encode_state_t *) lpc10_encode_init(lpc10_encode_state_t *s, s->l2sum1 = 0.0f; s->l2ptr1 = 1; s->l2ptr2 = 9; - s->hyst = FALSE; + s->hyst = false; /* State used by function lpc10_voicing */ s->dither = 20.0f; @@ -367,7 +373,7 @@ SPAN_DECLARE(int) lpc10_encode_release(lpc10_encode_state_t *s) SPAN_DECLARE(int) lpc10_encode_free(lpc10_encode_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/lpc10_placev.c b/libs/spandsp/src/lpc10_placev.c index f728d6fa63..339e241563 100644 --- a/libs/spandsp/src/lpc10_placev.c +++ b/libs/spandsp/src/lpc10_placev.c @@ -41,6 +41,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" @@ -67,7 +72,7 @@ void lpc10_placea(int32_t *ipitch, int32_t k; int32_t l; int32_t hrange; - int ephase; + bool ephase; int32_t lrange; lrange = (af - 2)*lframe + 1; @@ -148,14 +153,14 @@ void lpc10_placea(int32_t *ipitch, awin[af - 1][1] += *ipitch; } /* Make energy window be phase-synchronous. */ - ephase = TRUE; + ephase = true; } else { /* Case 3 */ awin[af - 1][0] = vwin[af - 1][0]; awin[af - 1][1] = vwin[af - 1][1]; - ephase = FALSE; + ephase = false; } /* RMS is computed over an integer number of pitch periods in the analysis window. When it is not placed phase-synchronously, it is placed as close @@ -193,7 +198,7 @@ void lpc10_placev(int32_t *osbuf, { int32_t i1; int32_t i2; - int crit; + bool crit; int32_t q; int32_t osptr1; int32_t hrange; @@ -286,12 +291,12 @@ void lpc10_placev(int32_t *osbuf, q++; /* Check for case 2 (placement before onset): */ /* Check for critical region exception: */ - crit = FALSE; + crit = false; for (i = q + 1; i < osptr1; i++) { if (osbuf[i - 1] - osbuf[q - 1] >= minwin) { - crit = TRUE; + crit = true; break; } } diff --git a/libs/spandsp/src/lpc10_voicing.c b/libs/spandsp/src/lpc10_voicing.c index 90891f9cca..fdb1b3f7c5 100644 --- a/libs/spandsp/src/lpc10_voicing.c +++ b/libs/spandsp/src/lpc10_voicing.c @@ -41,6 +41,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" diff --git a/libs/spandsp/src/make_modem_filter.c b/libs/spandsp/src/make_modem_filter.c index 8ceac8aab9..b0faed4a02 100644 --- a/libs/spandsp/src/make_modem_filter.c +++ b/libs/spandsp/src/make_modem_filter.c @@ -31,17 +31,22 @@ #include #include #include +#include +#include +#include +#include #if defined(HAVE_TGMATH_H) #include #endif #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" -#include -#include -#include -#include #if defined(__sunos) || defined(__solaris) || defined(__sun) #include #endif @@ -50,13 +55,6 @@ #include "spandsp/complex.h" #include "filter_tools.h" -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - //#define SAMPLE_RATE 8000.0 #define MAX_COEFFS_PER_FILTER 128 #define MAX_COEFF_SETS 384 @@ -84,7 +82,7 @@ static void make_tx_filter(int coeff_sets, alpha = baud_rate/(2.0*(double) (coeff_sets*baud_rate)); beta = excess_bandwidth; - compute_raised_cosine_filter(coeffs, total_coeffs, TRUE, FALSE, alpha, beta); + compute_raised_cosine_filter(coeffs, total_coeffs, true, false, alpha, beta); /* Find the DC gain of the filter, and adjust the filter to unity gain. */ floating_gain = 0.0; @@ -180,7 +178,7 @@ static void make_rx_filter(int coeff_sets, beta = excess_bandwidth; carrier *= 2.0*3.1415926535/SAMPLE_RATE; - compute_raised_cosine_filter(coeffs, total_coeffs, TRUE, FALSE, alpha, beta); + compute_raised_cosine_filter(coeffs, total_coeffs, true, false, alpha, beta); /* Find the DC gain of the filter, and adjust the filter to unity gain. */ floating_gain = 0.0; @@ -284,7 +282,7 @@ int main(int argc, char **argv) const char *tx_tag; const char *modem; - transmit_modem = FALSE; + transmit_modem = false; modem = ""; while ((opt = getopt(argc, argv, "m:rt")) != -1) { @@ -294,10 +292,10 @@ int main(int argc, char **argv) modem = optarg; break; case 'r': - transmit_modem = FALSE; + transmit_modem = false; break; case 't': - transmit_modem = TRUE; + transmit_modem = true; break; default: usage(); diff --git a/libs/spandsp/src/modem_connect_tones.c b/libs/spandsp/src/modem_connect_tones.c index 76b42a23fc..9c030ad0ed 100644 --- a/libs/spandsp/src/modem_connect_tones.c +++ b/libs/spandsp/src/modem_connect_tones.c @@ -53,10 +53,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/complex.h" @@ -69,6 +75,7 @@ #include "spandsp/fsk.h" #include "spandsp/modem_connect_tones.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/modem_connect_tones.h" @@ -255,12 +262,12 @@ SPAN_DECLARE(modem_connect_tones_tx_state_t *) modem_connect_tones_tx_init(modem { int alloced; - alloced = FALSE; + alloced = false; if (s == NULL) { - if ((s = (modem_connect_tones_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (modem_connect_tones_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; - alloced = TRUE; + alloced = true; } s->tone_type = tone_type; switch (s->tone_type) @@ -341,7 +348,7 @@ SPAN_DECLARE(modem_connect_tones_tx_state_t *) modem_connect_tones_tx_init(modem break; default: if (alloced) - free(s); + span_free(s); return NULL; } return s; @@ -356,7 +363,7 @@ SPAN_DECLARE(int) modem_connect_tones_tx_release(modem_connect_tones_tx_state_t SPAN_DECLARE(int) modem_connect_tones_tx_free(modem_connect_tones_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -398,7 +405,7 @@ static void v21_put_bit(void *user_data, int bit) s->raw_bit_stream = 0; s->num_bits = 0; s->flags_seen = 0; - s->framing_ok_announced = FALSE; + s->framing_ok_announced = false; break; } return; @@ -429,7 +436,7 @@ static void v21_put_bit(void *user_data, int bit) if (++s->flags_seen >= HDLC_FRAMING_OK_THRESHOLD && !s->framing_ok_announced) { report_tone_state(s, MODEM_CONNECT_TONES_FAX_PREAMBLE, lfastrintf(fsk_rx_signal_power(&(s->v21rx)))); - s->framing_ok_announced = TRUE; + s->framing_ok_announced = true; } } } @@ -441,7 +448,7 @@ static void v21_put_bit(void *user_data, int bit) { if (s->num_bits == 8) { - s->framing_ok_announced = FALSE; + s->framing_ok_announced = false; s->flags_seen = 0; } } @@ -547,7 +554,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * report_tone_state(s, MODEM_CONNECT_TONES_NONE, -99); s->tone_cycle_duration = 0; s->good_cycles = 0; - s->tone_on = FALSE; + s->tone_on = false; continue; } /* There is adequate energy in the channel. Is it mostly at 2100Hz? */ @@ -589,7 +596,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * s->tone_cycle_duration = ms_to_samples(450 + 100); } } - s->tone_on = TRUE; + s->tone_on = true; } else if (s->notch_level*5 > s->channel_level) { @@ -608,7 +615,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * s->good_cycles = 0; } } - s->tone_on = FALSE; + s->tone_on = false; } } break; @@ -716,7 +723,7 @@ SPAN_DECLARE(modem_connect_tones_rx_state_t *) modem_connect_tones_rx_init(modem { if (s == NULL) { - if ((s = (modem_connect_tones_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (modem_connect_tones_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } @@ -742,7 +749,7 @@ SPAN_DECLARE(modem_connect_tones_rx_state_t *) modem_connect_tones_rx_init(modem s->tone_cycle_duration = 0; s->good_cycles = 0; s->hit = MODEM_CONNECT_TONES_NONE; - s->tone_on = FALSE; + s->tone_on = false; s->tone_callback = tone_callback; s->callback_data = user_data; s->znotch_1 = 0.0f; @@ -751,7 +758,7 @@ SPAN_DECLARE(modem_connect_tones_rx_state_t *) modem_connect_tones_rx_init(modem s->z15hz_2 = 0.0f; s->num_bits = 0; s->flags_seen = 0; - s->framing_ok_announced = FALSE; + s->framing_ok_announced = false; s->raw_bit_stream = 0; return s; } @@ -765,7 +772,7 @@ SPAN_DECLARE(int) modem_connect_tones_rx_release(modem_connect_tones_rx_state_t SPAN_DECLARE(int) modem_connect_tones_rx_free(modem_connect_tones_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/modem_echo.c b/libs/spandsp/src/modem_echo.c index 14257c7eb7..622c201279 100644 --- a/libs/spandsp/src/modem_echo.c +++ b/libs/spandsp/src/modem_echo.c @@ -47,6 +47,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/bit_operations.h" #include "spandsp/dc_restore.h" #include "spandsp/modem_echo.h" @@ -56,9 +57,9 @@ 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); + span_free(ec->fir_taps32); + span_free(ec->fir_taps16); + span_free(ec); } /*- End of function --------------------------------------------------------*/ @@ -66,29 +67,29 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len) { modem_echo_can_state_t *ec; - if ((ec = (modem_echo_can_state_t *) malloc(sizeof(*ec))) == NULL) + if ((ec = (modem_echo_can_state_t *) span_alloc(sizeof(*ec))) == NULL) return NULL; memset(ec, 0, sizeof(*ec)); ec->taps = len; ec->curr_pos = ec->taps - 1; - if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL) + if ((ec->fir_taps32 = (int32_t *) span_alloc(ec->taps*sizeof(int32_t))) == NULL) { - free(ec); + span_free(ec); return NULL; } memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t)); - if ((ec->fir_taps16 = (int16_t *) malloc(ec->taps*sizeof(int16_t))) == NULL) + if ((ec->fir_taps16 = (int16_t *) span_alloc(ec->taps*sizeof(int16_t))) == NULL) { - free(ec->fir_taps32); - free(ec); + span_free(ec->fir_taps32); + span_free(ec); return NULL; } memset(ec->fir_taps16, 0, ec->taps*sizeof(int16_t)); if (fir16_create(&ec->fir_state, ec->fir_taps16, ec->taps) == NULL) { - free(ec->fir_taps16); - free(ec->fir_taps32); - free(ec); + span_free(ec->fir_taps16); + span_free(ec->fir_taps32); + span_free(ec); return NULL; } return ec; diff --git a/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj b/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj new file mode 100644 index 0000000000..de83ac7306 --- /dev/null +++ b/libs/spandsp/src/msvc/make_cielab_luts.2010.vcxproj @@ -0,0 +1,65 @@ + + + + + All + Win32 + + + + make_cielab_luts + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} + make_cielab_luts + Win32Proj + + + + Application + Unicode + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\$(Configuration)\ + $(PlatformName)\make_cielab_luts\$(Configuration)\ + false + + + + $(IntDir)BuildLog $(ProjectName).htm + + + Disabled + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;.\generated;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + $(IntDir)$(TargetName).pdb + Level3 + ProgramDatabase + + + true + Console + MachineX86 + + + "$(TargetPath)" >"$(ProjectDir)..\cielab_luts.h" + + + + + + + + + \ No newline at end of file diff --git a/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj b/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj new file mode 100644 index 0000000000..d7c54ca97f --- /dev/null +++ b/libs/spandsp/src/msvc/make_cielab_luts.2012.vcxproj @@ -0,0 +1,66 @@ + + + + + All + Win32 + + + + make_cielab_luts + {85F0CF8C-C7AB-48F6-BA19-CC94CF87F981} + make_cielab_luts + Win32Proj + + + + Application + Unicode + v110 + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\$(Configuration)\ + $(PlatformName)\make_cielab_luts\$(Configuration)\ + false + + + + $(IntDir)BuildLog $(ProjectName).htm + + + Disabled + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;.\generated;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + $(IntDir)$(TargetName).pdb + Level3 + ProgramDatabase + + + true + Console + MachineX86 + + + "$(TargetPath)" >"$(ProjectDir)..\cielab_luts.h" + + + + + + + + + \ No newline at end of file diff --git a/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj b/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj index a71f70e556..61465917f1 100644 --- a/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj +++ b/libs/spandsp/src/msvc/make_math_fixed_tables.2010.vcxproj @@ -27,7 +27,7 @@ <_ProjectFileVersion>10.0.30319.1 $(PlatformName)\$(Configuration)\ - $(PlatformName)\make_at_dictionary\$(Configuration)\ + $(PlatformName)\make_math_fixed_tables\$(Configuration)\ false diff --git a/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj b/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj index 610bb28625..ab6b648bcb 100644 --- a/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj +++ b/libs/spandsp/src/msvc/make_math_fixed_tables.2012.vcxproj @@ -28,7 +28,7 @@ <_ProjectFileVersion>10.0.30319.1 $(PlatformName)\$(Configuration)\ - $(PlatformName)\make_at_dictionary\$(Configuration)\ + $(PlatformName)\make_math_fixed_tables\$(Configuration)\ false diff --git a/libs/spandsp/src/noise.c b/libs/spandsp/src/noise.c index 5d7fe23aad..3ad164cf7f 100644 --- a/libs/spandsp/src/noise.c +++ b/libs/spandsp/src/noise.c @@ -43,6 +43,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/saturated.h" #include "spandsp/noise.h" @@ -84,7 +85,7 @@ SPAN_DECLARE(noise_state_t *) noise_init_dbov(noise_state_t *s, int seed, float if (s == NULL) { - if ((s = (noise_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (noise_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -121,7 +122,7 @@ SPAN_DECLARE(int) noise_release(noise_state_t *s) SPAN_DECLARE(int) noise_free(noise_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/oki_adpcm.c b/libs/spandsp/src/oki_adpcm.c index f6d54b804c..0e5e8f6659 100644 --- a/libs/spandsp/src/oki_adpcm.c +++ b/libs/spandsp/src/oki_adpcm.c @@ -39,6 +39,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/oki_adpcm.h" #include "spandsp/private/oki_adpcm.h" @@ -246,7 +247,7 @@ SPAN_DECLARE(oki_adpcm_state_t *) oki_adpcm_init(oki_adpcm_state_t *s, int bit_r return NULL; if (s == NULL) { - if ((s = (oki_adpcm_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (oki_adpcm_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -264,7 +265,7 @@ SPAN_DECLARE(int) oki_adpcm_release(oki_adpcm_state_t *s) SPAN_DECLARE(int) oki_adpcm_free(oki_adpcm_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/playout.c b/libs/spandsp/src/playout.c index e98e48d70c..9ad0d8dcf2 100644 --- a/libs/spandsp/src/playout.c +++ b/libs/spandsp/src/playout.c @@ -39,10 +39,18 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/playout.h" +#include "spandsp/private/playout.h" + static playout_frame_t *queue_get(playout_state_t *s, timestamp_t sender_stamp) { playout_frame_t *frame; @@ -120,7 +128,7 @@ SPAN_DECLARE(int) playout_get(playout_state_t *s, playout_frame_t *frameout, tim if (!s->not_first) { /* Prime things the first time through */ - s->not_first = TRUE; + s->not_first = true; s->latest_expected = frame->receiver_stamp + s->min_length; } /* Leaky integrate the rate of occurance of frames received just in time and late */ @@ -236,7 +244,7 @@ SPAN_DECLARE(int) playout_put(playout_state_t *s, void *data, int type, timestam } else { - if ((frame = (playout_frame_t *) malloc(sizeof(*frame))) == NULL) + if ((frame = (playout_frame_t *) span_alloc(sizeof(*frame))) == NULL) return PLAYOUT_ERROR; } @@ -296,7 +304,7 @@ SPAN_DECLARE(int) playout_put(playout_state_t *s, void *data, int type, timestam { s->last_speech_sender_stamp = sender_stamp - sender_len - s->min_length; s->last_speech_sender_len = sender_len; - s->start = FALSE; + s->start = false; } return PLAYOUT_OK; @@ -312,7 +320,7 @@ SPAN_DECLARE(void) playout_restart(playout_state_t *s, int min_length, int max_l for (frame = s->free_frames; frame; frame = next) { next = frame->later; - free(frame); + span_free(frame); } memset(s, 0, sizeof(*s)); @@ -320,7 +328,7 @@ SPAN_DECLARE(void) playout_restart(playout_state_t *s, int min_length, int max_l s->min_length = min_length; s->max_length = (max_length > min_length) ? max_length : min_length; s->dropable_threshold = 1*0x10000000/100; - s->start = TRUE; + s->start = true; s->since_last_step = 0x7FFFFFFF; /* Start with the minimum buffer length allowed, and work from there */ s->actual_buffer_length = @@ -332,7 +340,7 @@ SPAN_DECLARE(playout_state_t *) playout_init(int min_length, int max_length) { playout_state_t *s; - if ((s = (playout_state_t *) malloc(sizeof(playout_state_t))) == NULL) + if ((s = (playout_state_t *) span_alloc(sizeof(playout_state_t))) == NULL) return NULL; memset(s, 0, sizeof(*s)); playout_restart(s, min_length, max_length); @@ -350,13 +358,13 @@ SPAN_DECLARE(int) playout_release(playout_state_t *s) for (frame = s->first_frame; frame; frame = next) { next = frame->later; - free(frame); + span_free(frame); } /* Free all the frames on the free list */ for (frame = s->free_frames; frame; frame = next) { next = frame->later; - free(frame); + span_free(frame); } return 0; } @@ -368,7 +376,7 @@ SPAN_DECLARE(int) playout_free(playout_state_t *s) { playout_release(s); /* Finally, free ourselves! */ - free(s); + span_free(s); } return 0; } diff --git a/libs/spandsp/src/plc.c b/libs/spandsp/src/plc.c index dcb07120e1..7b45dad988 100644 --- a/libs/spandsp/src/plc.c +++ b/libs/spandsp/src/plc.c @@ -43,10 +43,13 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/saturated.h" #include "spandsp/plc.h" +#include "spandsp/private/plc.h" + /* We do a straight line fade to zero volume in 50ms when we are filling in for missing data. */ #define ATTENUATION_INCREMENT 0.0025f /* Attenuation per sample */ @@ -234,7 +237,7 @@ SPAN_DECLARE(plc_state_t *) plc_init(plc_state_t *s) { if (s == NULL) { - if ((s = (plc_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (plc_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -251,7 +254,7 @@ SPAN_DECLARE(int) plc_release(plc_state_t *s) SPAN_DECLARE(int) plc_free(plc_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/power_meter.c b/libs/spandsp/src/power_meter.c index f4fb2afa8f..147fb47029 100644 --- a/libs/spandsp/src/power_meter.c +++ b/libs/spandsp/src/power_meter.c @@ -41,17 +41,25 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/power_meter.h" +#include "spandsp/private/power_meter.h" + SPAN_DECLARE(power_meter_t *) power_meter_init(power_meter_t *s, int shift) { if (s == NULL) { - if ((s = (power_meter_t *) malloc(sizeof(*s))) == NULL) + if ((s = (power_meter_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } s->shift = shift; @@ -69,7 +77,7 @@ SPAN_DECLARE(int) power_meter_release(power_meter_t *s) SPAN_DECLARE(int) power_meter_free(power_meter_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -147,14 +155,14 @@ SPAN_DECLARE(int32_t) power_surge_detector(power_surge_detector_state_t *s, int1 { if (pow_short <= s->surge*(pow_medium >> 10)) return 0; - s->signal_present = TRUE; + s->signal_present = true; s->medium_term.reading = s->short_term.reading; } else { if (pow_short < s->sag*(pow_medium >> 10)) { - s->signal_present = FALSE; + s->signal_present = false; s->medium_term.reading = s->short_term.reading; return 0; } @@ -181,7 +189,7 @@ SPAN_DECLARE(power_surge_detector_state_t *) power_surge_detector_init(power_sur if (s == NULL) { - if ((s = (power_surge_detector_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (power_surge_detector_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -205,7 +213,7 @@ SPAN_DECLARE(int) power_surge_detector_release(power_surge_detector_state_t *s) SPAN_DECLARE(int) power_surge_detector_free(power_surge_detector_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/queue.c b/libs/spandsp/src/queue.c index 264cee0c87..d569039969 100644 --- a/libs/spandsp/src/queue.c +++ b/libs/spandsp/src/queue.c @@ -35,15 +35,24 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif +#if defined(HAVE_STDATOMIC_H) +#include +#endif #include #define SPANDSP_FULLY_DEFINE_QUEUE_STATE_T #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/queue.h" #include "spandsp/private/queue.h" -SPAN_DECLARE(int) queue_empty(queue_state_t *s) +SPAN_DECLARE(bool) queue_empty(queue_state_t *s) { return (s->iptr == s->optr); } @@ -395,7 +404,7 @@ SPAN_DECLARE(queue_state_t *) queue_init(queue_state_t *s, int len, int flags) { if (s == NULL) { - if ((s = (queue_state_t *) malloc(sizeof(*s) + len + 1)) == NULL) + if ((s = (queue_state_t *) span_alloc(sizeof(*s) + len + 1)) == NULL) return NULL; } s->iptr = @@ -414,7 +423,7 @@ SPAN_DECLARE(int) queue_release(queue_state_t *s) SPAN_DECLARE(int) queue_free(queue_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/schedule.c b/libs/spandsp/src/schedule.c index 60ba12bc1f..6e38e6bd94 100644 --- a/libs/spandsp/src/schedule.c +++ b/libs/spandsp/src/schedule.c @@ -31,8 +31,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/schedule.h" @@ -53,7 +59,7 @@ SPAN_DECLARE(int) span_schedule_event(span_sched_state_t *s, int us, span_sched_ if (i >= s->allocated) { s->allocated += 5; - s->sched = (span_sched_t *) realloc(s->sched, sizeof(span_sched_t)*s->allocated); + s->sched = (span_sched_t *) span_realloc(s->sched, sizeof(span_sched_t)*s->allocated); } /*endif*/ if (i >= s->max_to_date) @@ -141,7 +147,7 @@ SPAN_DECLARE(int) span_schedule_release(span_sched_state_t *s) { if (s->sched) { - free(s->sched); + span_free(s->sched); s->sched = NULL; } return 0; @@ -152,7 +158,7 @@ SPAN_DECLARE(int) span_schedule_free(span_sched_state_t *s) { span_schedule_release(s); if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/sig_tone.c b/libs/spandsp/src/sig_tone.c index 5e4e180178..e40d39ac37 100644 --- a/libs/spandsp/src/sig_tone.c +++ b/libs/spandsp/src/sig_tone.c @@ -38,12 +38,18 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/saturated.h" #include "spandsp/vector_int.h" @@ -53,6 +59,7 @@ #include "spandsp/super_tone_rx.h" #include "spandsp/sig_tone.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/sig_tone.h" /*! PI */ @@ -225,7 +232,7 @@ SPAN_DECLARE(int) sig_tone_tx(sig_tone_tx_state_t *s, int16_t amp[], int len) int k; int n; int16_t tone; - int need_update; + bool need_update; int high_low; for (i = 0; i < len; i += n) @@ -235,19 +242,19 @@ SPAN_DECLARE(int) sig_tone_tx(sig_tone_tx_state_t *s, int16_t amp[], int len) if (s->current_tx_timeout <= len - i) { n = s->current_tx_timeout; - need_update = TRUE; + need_update = true; } else { n = len - i; - need_update = FALSE; + need_update = false; } s->current_tx_timeout -= n; } else { n = len - i; - need_update = FALSE; + need_update = false; } if (!(s->current_tx_tone & SIG_TONE_TX_PASSTHROUGH)) vec_zeroi16(&[i], n); @@ -325,7 +332,7 @@ SPAN_DECLARE(sig_tone_tx_state_t *) sig_tone_tx_init(sig_tone_tx_state_t *s, int if (s == NULL) { - if ((s = (sig_tone_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (sig_tone_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -357,7 +364,7 @@ SPAN_DECLARE(int) sig_tone_tx_release(sig_tone_tx_state_t *s) SPAN_DECLARE(int) sig_tone_tx_free(sig_tone_tx_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ @@ -448,13 +455,13 @@ SPAN_DECLARE(int) sig_tone_rx(sig_tone_rx_state_t *s, int16_t amp[], int len) if ((s->signalling_state & (SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT))) { if (s->flat_mode_timeout && --s->flat_mode_timeout == 0) - s->flat_mode = TRUE; + s->flat_mode = true; /*endif*/ } else { s->flat_mode_timeout = s->desc->sharp_flat_timeout; - s->flat_mode = FALSE; + s->flat_mode = false; } /*endif*/ @@ -641,7 +648,7 @@ SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int if (s == NULL) { - if ((s = (sig_tone_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (sig_tone_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -685,7 +692,7 @@ SPAN_DECLARE(int) sig_tone_rx_release(sig_tone_rx_state_t *s) SPAN_DECLARE(int) sig_tone_rx_free(sig_tone_rx_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/silence_gen.c b/libs/spandsp/src/silence_gen.c index ad7d7caed0..7c24f4334e 100644 --- a/libs/spandsp/src/silence_gen.c +++ b/libs/spandsp/src/silence_gen.c @@ -40,11 +40,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/async.h" #include "spandsp/silence_gen.h" @@ -119,7 +125,7 @@ SPAN_DECLARE(silence_gen_state_t *) silence_gen_init(silence_gen_state_t *s, int { if (s == NULL) { - if ((s = (silence_gen_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (silence_gen_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -137,7 +143,7 @@ SPAN_DECLARE(int) silence_gen_release(silence_gen_state_t *s) SPAN_DECLARE(int) silence_gen_free(silence_gen_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp.h.in b/libs/spandsp/src/spandsp.h.in index 2764aa4289..6ed699f3b4 100644 --- a/libs/spandsp/src/spandsp.h.in +++ b/libs/spandsp/src/spandsp.h.in @@ -45,9 +45,11 @@ #include #include @INSERT_MATH_HEADER@ +@INSERT_STDBOOL_HEADER@ #include #include +#include #include #include #include diff --git a/libs/spandsp/src/spandsp/alloc.h b/libs/spandsp/src/spandsp/alloc.h new file mode 100644 index 0000000000..6ad81aa9be --- /dev/null +++ b/libs/spandsp/src/spandsp/alloc.h @@ -0,0 +1,63 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * alloc.h - memory allocation handling. + * + * Written by Steve Underwood + * + * Copyright (C) 2013 Steve Underwood + * + * 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. + * + * 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. + * + * 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. + */ + +/*! \file */ + +#if !defined(_SPANDSP_ALLOC_H_) +#define _SPANDSP_ALLOC_H_ + +typedef void *(*span_aligned_alloc_t)(size_t alignment, size_t size); +typedef void *(*span_alloc_t)(size_t size); +typedef void *(*span_realloc_t)(void *ptr, size_t size); +typedef void (*span_free_t)(void *ptr); + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/* Allocate size bytes allocated to ALIGNMENT bytes. */ +SPAN_DECLARE(void *) span_aligned_alloc(size_t alignment, size_t size); + +/* Allocate size bytes of memory. */ +SPAN_DECLARE(void *) span_alloc(size_t size); + +/* Re-allocate the previously allocated block in ptr, making the new block size bytes long. */ +SPAN_DECLARE(void *) span_realloc(void *ptr, size_t size); + +/* Free a block allocated by span_alloc, span_aligned_alloc, or span_realloc. */ +SPAN_DECLARE(void) span_free(void *ptr); + +SPAN_DECLARE(int) span_mem_allocators(span_aligned_alloc_t custom_aligned_alloc, + span_alloc_t custom_alloc, + span_realloc_t custom_realloc, + span_free_t custom_free); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/async.h b/libs/spandsp/src/spandsp/async.h index 1b22cd5caf..eabb41d3f1 100644 --- a/libs/spandsp/src/spandsp/async.h +++ b/libs/spandsp/src/spandsp/async.h @@ -164,7 +164,7 @@ SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data, int bit); \param data_bits The number of data bits. \param parity_bits The type of parity. \param stop_bits The number of stop bits. - \param use_v14 TRUE if V.14 rate adaption processing should be used. + \param use_v14 True if V.14 rate adaption processing should be used. \param put_byte The callback routine used to put the received data. \param user_data An opaque pointer. \return A pointer to the initialised context, or NULL if there was a problem. */ @@ -172,7 +172,7 @@ SPAN_DECLARE(async_rx_state_t *) async_rx_init(async_rx_state_t *s, int data_bits, int parity_bits, int stop_bits, - int use_v14, + bool use_v14, put_byte_func_t put_byte, void *user_data); @@ -198,7 +198,7 @@ SPAN_DECLARE_NONSTD(int) async_tx_get_bit(void *user_data); \param data_bits The number of data bit. \param parity_bits The type of parity. \param stop_bits The number of stop bits. - \param use_v14 TRUE if V.14 rate adaption processing should be used. + \param use_v14 True if V.14 rate adaption processing should be used. \param get_byte The callback routine used to get the data to be transmitted. \param user_data An opaque pointer. \return A pointer to the initialised context, or NULL if there was a problem. */ @@ -206,7 +206,7 @@ SPAN_DECLARE(async_tx_state_t *) async_tx_init(async_tx_state_t *s, int data_bits, int parity_bits, int stop_bits, - int use_v14, + bool use_v14, get_byte_func_t get_byte, void *user_data); diff --git a/libs/spandsp/src/spandsp/at_interpreter.h b/libs/spandsp/src/spandsp/at_interpreter.h index 7f8ebbb16b..aa390d509b 100644 --- a/libs/spandsp/src/spandsp/at_interpreter.h +++ b/libs/spandsp/src/spandsp/at_interpreter.h @@ -115,14 +115,14 @@ enum */ typedef struct { - /*! TRUE if character echo is enabled */ - int echo; - /*! TRUE if verbose reporting is enabled */ - int verbose; - /*! TRUE if result codes are verbose */ + /*! True if character echo is enabled */ + bool echo; + /*! True if verbose reporting is enabled */ + bool verbose; + /*! Result code format code - numeic or verbose */ int result_code_format; - /*! TRUE if pulse dialling is the default */ - int pulse_dial; + /*! True if pulse dialling is the default */ + bool pulse_dial; /*! ??? */ int double_escape; /*! ??? */ diff --git a/libs/spandsp/src/spandsp/bell_r2_mf.h b/libs/spandsp/src/spandsp/bell_r2_mf.h index 98d9f749e8..2d40848a34 100644 --- a/libs/spandsp/src/spandsp/bell_r2_mf.h +++ b/libs/spandsp/src/spandsp/bell_r2_mf.h @@ -175,10 +175,10 @@ SPAN_DECLARE(int) r2_mf_tx_put(r2_mf_tx_state_t *s, char digit); /*! \brief Initialise an R2 MF tone generator context. \param s The R2 MF generator context. - \param fwd TRUE if the context is for forward signals. FALSE if the + \param fwd True if the context is for forward signals. False if the context is for backward signals. \return A pointer to the MFC/R2 generator context.*/ -SPAN_DECLARE(r2_mf_tx_state_t *) r2_mf_tx_init(r2_mf_tx_state_t *s, int fwd); +SPAN_DECLARE(r2_mf_tx_state_t *) r2_mf_tx_init(r2_mf_tx_state_t *s, bool fwd); /*! \brief Release an R2 MF tone generator context. \param s The R2 MF tone generator context. @@ -242,7 +242,7 @@ SPAN_DECLARE(int) r2_mf_rx_get(r2_mf_rx_state_t *s); /*! \brief Initialise an R2 MF receiver context. \param s The R2 MF receiver context. - \param fwd TRUE if the context is for forward signals. FALSE if the + \param fwd True if the context is for forward signals. False if the context is for backward signals. \param callback An optional callback routine, used to report received digits. If no callback routine is set, digits may be collected, using the r2_mf_rx_get() @@ -251,7 +251,7 @@ SPAN_DECLARE(int) r2_mf_rx_get(r2_mf_rx_state_t *s); and supplied in callbacks. \return A pointer to the R2 MF receiver context. */ SPAN_DECLARE(r2_mf_rx_state_t *) r2_mf_rx_init(r2_mf_rx_state_t *s, - int fwd, + bool fwd, tone_report_func_t callback, void *user_data); diff --git a/libs/spandsp/src/spandsp/bitstream.h b/libs/spandsp/src/spandsp/bitstream.h index b55e4afd16..edbaedb48f 100644 --- a/libs/spandsp/src/spandsp/bitstream.h +++ b/libs/spandsp/src/spandsp/bitstream.h @@ -71,7 +71,7 @@ SPAN_DECLARE(void) bitstream_flush(bitstream_state_t *s, uint8_t **c); /*! \brief Initialise a bitstream context. \param s A pointer to the bitstream context. - \param lsb_first TRUE if the bit stream is LSB first, else its MSB first. + \param lsb_first True if the bit stream is LSB first, else its MSB first. \return A pointer to the bitstream context. */ SPAN_DECLARE(bitstream_state_t *) bitstream_init(bitstream_state_t *s, int direction); diff --git a/libs/spandsp/src/spandsp/crc.h b/libs/spandsp/src/spandsp/crc.h index a4d9b8040a..9d02355621 100644 --- a/libs/spandsp/src/spandsp/crc.h +++ b/libs/spandsp/src/spandsp/crc.h @@ -60,9 +60,9 @@ SPAN_DECLARE(int) crc_itu32_append(uint8_t *buf, int len); /*! \brief Check the ITU/CCITT CRC-32 value in a frame. \param buf The buffer containing the frame. \param len The length of the frame. - \return TRUE if the CRC is OK, else FALSE. + \return True if the CRC is OK, else false. */ -SPAN_DECLARE(int) crc_itu32_check(const uint8_t *buf, int len); +SPAN_DECLARE(bool) crc_itu32_check(const uint8_t *buf, int len); /*! \brief Calculate the ITU/CCITT CRC-16 value in buffer by whole bytes. \param buf The buffer containing the data. @@ -93,9 +93,9 @@ SPAN_DECLARE(int) crc_itu16_append(uint8_t *buf, int len); /*! \brief Check the ITU/CCITT CRC-16 value in a frame. \param buf The buffer containing the frame. \param len The length of the frame. - \return TRUE if the CRC is OK, else FALSE. + \return True if the CRC is OK, else false. */ -SPAN_DECLARE(int) crc_itu16_check(const uint8_t *buf, int len); +SPAN_DECLARE(bool) crc_itu16_check(const uint8_t *buf, int len); #if defined(__cplusplus) } diff --git a/libs/spandsp/src/spandsp/dtmf.h b/libs/spandsp/src/spandsp/dtmf.h index df9660feee..15915f75a6 100644 --- a/libs/spandsp/src/spandsp/dtmf.h +++ b/libs/spandsp/src/spandsp/dtmf.h @@ -156,7 +156,7 @@ SPAN_DECLARE(void) dtmf_rx_set_realtime_callback(dtmf_rx_state_t *s, /*! \brief Adjust a DTMF receiver context. \param s The DTMF receiver context. - \param filter_dialtone TRUE to enable filtering of dialtone, FALSE + \param filter_dialtone True to enable filtering of dialtone, false to disable, < 0 to leave unchanged. \param twist Acceptable twist, in dB. < 0.0 to leave unchanged. \param reverse_twist Acceptable reverse twist, in dB. < 0.0 to leave unchanged. diff --git a/libs/spandsp/src/spandsp/expose.h b/libs/spandsp/src/spandsp/expose.h index 5424b7c67e..a6ca48e5a5 100644 --- a/libs/spandsp/src/spandsp/expose.h +++ b/libs/spandsp/src/spandsp/expose.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,8 @@ #include #include #include +#include +#include #include #include #include @@ -70,11 +73,10 @@ #include #include #include -/*#include */ -/*#include */ #include #include #include +//#include #include #include #include diff --git a/libs/spandsp/src/spandsp/fax.h b/libs/spandsp/src/spandsp/fax.h index 9d268770bc..01dbb80d80 100644 --- a/libs/spandsp/src/spandsp/fax.h +++ b/libs/spandsp/src/spandsp/fax.h @@ -75,16 +75,16 @@ 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. \param s The FAX context. - \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is - idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default - behaviour is FALSE. + \param transmit_on_idle True if silent audio should be output when the FAX transmitter is + idle. False to transmit zero length audio when the FAX transmitter is idle. The default + behaviour is false. */ SPAN_DECLARE(void) fax_set_transmit_on_idle(fax_state_t *s, int transmit_on_idle); /*! Select whether talker echo protection tone will be sent for the image modems. \brief Select whether TEP will be sent for the image modems. \param s The FAX context. - \param use_tep TRUE if TEP should be sent. + \param use_tep True if TEP should be sent. */ SPAN_DECLARE(void) fax_set_tep_mode(fax_state_t *s, int use_tep); @@ -105,7 +105,7 @@ 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 + \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); @@ -113,7 +113,7 @@ 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. - \param calling_party TRUE if the context is for a calling party. FALSE if the + \param calling_party True if the context is for a calling party. False if the context is for an answering party. \return A pointer to the FAX context, or NULL if there was a problem. */ diff --git a/libs/spandsp/src/spandsp/fsk.h b/libs/spandsp/src/spandsp/fsk.h index bcb8df1de7..b65cd7842f 100644 --- a/libs/spandsp/src/spandsp/fsk.h +++ b/libs/spandsp/src/spandsp/fsk.h @@ -109,9 +109,10 @@ enum FSK_BELL103CH1, FSK_BELL103CH2, FSK_BELL202, - FSK_WEITBRECHT, /* 45.45 baud version, used for TDD (Telecom Device for the Deaf) */ - FSK_WEITBRECHT50, /* 50 baud version, used for TDD (Telecom Device for the Deaf) */ - FSK_V21CH1_110 /* 110 bps version of V.21 channel 1, as used by V.18 */ + FSK_WEITBRECHT_4545, /* 45.45 baud version, used for TDD (Telecom Device for the Deaf) */ + FSK_WEITBRECHT_50, /* 50 baud version, used for TDD (Telecom Device for the Deaf) */ + FSK_WEITBRECHT_476, /* 47.6 baud version, used for V.18 probing */ + FSK_V21CH1_110 /* 110 bps version of V.21 channel 1, as used by V.18 */ }; enum diff --git a/libs/spandsp/src/spandsp/hdlc.h b/libs/spandsp/src/spandsp/hdlc.h index cf5efe4330..a0916d1d5f 100644 --- a/libs/spandsp/src/spandsp/hdlc.h +++ b/libs/spandsp/src/spandsp/hdlc.h @@ -83,8 +83,8 @@ extern "C" /*! \brief Initialise an HDLC receiver context. \param s A pointer to an HDLC receiver context. - \param crc32 TRUE to use ITU CRC32. FALSE to use ITU CRC16. - \param report_bad_frames TRUE to request the reporting of bad frames. + \param crc32 True to use ITU CRC32. False to use ITU CRC16. + \param report_bad_frames True to request the reporting of bad frames. \param framing_ok_threshold The number of back-to-back flags needed to start the framing OK condition. This may be used where a series of flag octets is used as a preamble, such as in the T.30 protocol. @@ -93,8 +93,8 @@ extern "C" \return A pointer to the HDLC receiver context. */ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s, - int crc32, - int report_bad_frames, + bool crc32, + bool report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data); @@ -169,17 +169,17 @@ SPAN_DECLARE_NONSTD(void) hdlc_rx_put(hdlc_rx_state_t *s, const uint8_t buf[], i /*! \brief Initialise an HDLC transmitter context. \param s A pointer to an HDLC transmitter context. - \param crc32 TRUE to use ITU CRC32. FALSE to use ITU CRC16. + \param crc32 True to use ITU CRC32. False to use ITU CRC16. \param inter_frame_flags The minimum flag octets to insert between frames (usually one). - \param progressive TRUE if frame creation works in progressive mode. + \param progressive True if frame creation works in progressive mode. \param handler The callback function called when the HDLC transmitter underflows. \param user_data An opaque parameter for the callback routine. \return A pointer to the HDLC transmitter context. */ SPAN_DECLARE(hdlc_tx_state_t *) hdlc_tx_init(hdlc_tx_state_t *s, - int crc32, + bool crc32, int inter_frame_flags, - int progressive, + bool progressive, hdlc_underflow_handler_t handler, void *user_data); diff --git a/libs/spandsp/src/spandsp/logging.h b/libs/spandsp/src/spandsp/logging.h index 2de8eb8767..78db086ef0 100644 --- a/libs/spandsp/src/spandsp/logging.h +++ b/libs/spandsp/src/spandsp/logging.h @@ -80,9 +80,9 @@ extern "C" \brief Test if logging of a specified severity level is enabled. \param s The logging context. \param level The severity level to be tested. - \return TRUE if logging is enable, else FALSE. + \return True if logging is enable. */ -SPAN_DECLARE(int) span_log_test(logging_state_t *s, int level); +SPAN_DECLARE(bool) span_log_test(logging_state_t *s, int level); /*! Generate a log entry. \brief Generate a log entry. diff --git a/libs/spandsp/src/spandsp/modem_connect_tones.h b/libs/spandsp/src/spandsp/modem_connect_tones.h index 7c2b980753..713f813bbb 100644 --- a/libs/spandsp/src/spandsp/modem_connect_tones.h +++ b/libs/spandsp/src/spandsp/modem_connect_tones.h @@ -153,7 +153,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx_fillin(modem_connect_tones_rx_st /*! \brief Test if a modem_connect tone has been detected. \param s The context. - \return TRUE if tone is detected, else FALSE. + \return The code for the detected tone. */ SPAN_DECLARE(int) modem_connect_tones_rx_get(modem_connect_tones_rx_state_t *s); diff --git a/libs/spandsp/src/spandsp/playout.h b/libs/spandsp/src/spandsp/playout.h index 582fcb2c51..8e038086df 100644 --- a/libs/spandsp/src/spandsp/playout.h +++ b/libs/spandsp/src/spandsp/playout.h @@ -56,80 +56,13 @@ enum typedef int timestamp_t; -typedef struct playout_frame_s -{ - /*! The actual frame data */ - void *data; - /*! The type of frame */ - int type; - /*! The timestamp assigned by the sending end */ - timestamp_t sender_stamp; - /*! The timespan covered by the data in this frame */ - timestamp_t sender_len; - /*! The timestamp assigned by the receiving end */ - timestamp_t receiver_stamp; - /*! Pointer to the next earlier frame */ - struct playout_frame_s *earlier; - /*! Pointer to the next later frame */ - struct playout_frame_s *later; -} playout_frame_t; +typedef struct playout_frame_s playout_frame_t; /*! Playout (jitter buffer) descriptor. This defines the working state for a single instance of playout buffering. */ -typedef struct -{ - /*! TRUE if the buffer is dynamically sized */ - int dynamic; - /*! The minimum length (dynamic) or fixed length (static) of the buffer */ - int min_length; - /*! The maximum length (dynamic) or fixed length (static) of the buffer */ - int max_length; - /*! The target filter threshold for adjusting dynamic buffering. */ - int dropable_threshold; - - int start; - - /*! The queued frame list */ - playout_frame_t *first_frame; - playout_frame_t *last_frame; - /*! The free frame pool */ - playout_frame_t *free_frames; - - /*! The total frames input to the buffer, to date. */ - int frames_in; - /*! The total frames output from the buffer, to date. */ - int frames_out; - /*! The number of frames received out of sequence. */ - int frames_oos; - /*! The number of frames which were discarded, due to late arrival. */ - int frames_late; - /*! The number of frames which were never received. */ - int frames_missing; - /*! The number of frames trimmed from the stream, due to buffer shrinkage. */ - int frames_trimmed; - - timestamp_t latest_expected; - /*! The present jitter adjustment */ - timestamp_t current; - /*! The sender_stamp of the last speech frame */ - timestamp_t last_speech_sender_stamp; - /*! The duration of the last speech frame */ - timestamp_t last_speech_sender_len; - - int not_first; - /*! The time since the target buffer length was last changed. */ - timestamp_t since_last_step; - /*! Filter state for tracking the packets arriving just in time */ - int32_t state_just_in_time; - /*! Filter state for tracking the packets arriving late */ - int32_t state_late; - /*! The current target length of the buffer */ - int target_buffer_length; - /*! The current actual length of the buffer, which may lag behind the target value */ - int actual_buffer_length; -} playout_state_t; +typedef struct playout_state_s playout_state_t; #if defined(__cplusplus) extern "C" diff --git a/libs/spandsp/src/spandsp/plc.h b/libs/spandsp/src/spandsp/plc.h index 801c6ac65f..6d5c301073 100644 --- a/libs/spandsp/src/spandsp/plc.h +++ b/libs/spandsp/src/spandsp/plc.h @@ -109,21 +109,7 @@ That's it! /*! The generic packet loss concealer context. */ -typedef struct -{ - /*! Consecutive erased samples */ - int missing_samples; - /*! Current offset into pitch period */ - int pitch_offset; - /*! Pitch estimate */ - int pitch; - /*! Buffer for a cycle of speech */ - float pitchbuf[PLC_PITCH_MIN]; - /*! History buffer */ - int16_t history[PLC_HISTORY_LEN]; - /*! Current pointer into the history buffer */ - int buf_ptr; -} plc_state_t; +typedef struct plc_state_s plc_state_t; #if defined(__cplusplus) diff --git a/libs/spandsp/src/spandsp/power_meter.h b/libs/spandsp/src/spandsp/power_meter.h index 5eff21fccd..e949858607 100644 --- a/libs/spandsp/src/spandsp/power_meter.h +++ b/libs/spandsp/src/spandsp/power_meter.h @@ -23,8 +23,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(_POWER_METER_H_) -#define _POWER_METER_H_ +#if !defined(_SPANDSP_POWER_METER_H_) +#define _SPANDSP_POWER_METER_H_ /*! \page power_meter_page Power metering @@ -45,24 +45,9 @@ values +/-8031, and this square wave represents 0dBov. This translates into 6.1 Power meter descriptor. This defines the working state for a single instance of a power measurement device. */ -typedef struct -{ - /*! The shift factor, which controls the damping of the power meter. */ - int shift; +typedef struct power_meter_s power_meter_t; - /*! The current power reading. */ - int32_t reading; -} power_meter_t; - -typedef struct -{ - power_meter_t short_term; - power_meter_t medium_term; - int signal_present; - int32_t surge; - int32_t sag; - int32_t min; -} power_surge_detector_state_t; +typedef struct power_surge_detector_state_s power_surge_detector_state_t; #if defined(__cplusplus) extern "C" diff --git a/libs/spandsp/src/spandsp/private/async.h b/libs/spandsp/src/spandsp/private/async.h index 39bb1d4a44..1c9c926595 100644 --- a/libs/spandsp/src/spandsp/private/async.h +++ b/libs/spandsp/src/spandsp/private/async.h @@ -69,8 +69,8 @@ struct async_rx_state_s int parity; /*! \brief The number of stop bits per character. */ int stop_bits; - /*! \brief TRUE if V.14 rate adaption processing should be performed. */ - int use_v14; + /*! \brief True if V.14 rate adaption processing should be performed. */ + bool use_v14; /*! \brief A pointer to the callback routine used to handle received characters. */ put_byte_func_t put_byte; /*! \brief An opaque pointer passed when calling put_byte. */ diff --git a/libs/spandsp/src/spandsp/private/at_interpreter.h b/libs/spandsp/src/spandsp/private/at_interpreter.h index a60a9aa46e..3ddade99c5 100644 --- a/libs/spandsp/src/spandsp/private/at_interpreter.h +++ b/libs/spandsp/src/spandsp/private/at_interpreter.h @@ -106,10 +106,10 @@ struct at_state_s int command_dial; int ok_is_pending; int dte_is_waiting; - /*! \brief TRUE if a carrier is presnt. Otherwise FALSE. */ - int rx_signal_present; - /*! \brief TRUE if a modem has trained, Otherwise FALSE. */ - int rx_trained; + /*! \brief True if a carrier is presnt. Otherwise false. */ + bool rx_signal_present; + /*! \brief True if a modem has trained, Otherwise false. */ + bool rx_trained; int transmit; char line[256]; diff --git a/libs/spandsp/src/spandsp/private/bell_r2_mf.h b/libs/spandsp/src/spandsp/private/bell_r2_mf.h index 234e4c9ba0..d0681be23f 100644 --- a/libs/spandsp/src/spandsp/private/bell_r2_mf.h +++ b/libs/spandsp/src/spandsp/private/bell_r2_mf.h @@ -73,8 +73,8 @@ struct r2_mf_tx_state_s { /*! The tone generator. */ tone_gen_state_t tone; - /*! TRUE if generating forward tones, otherwise generating reverse tones. */ - int fwd; + /*! True if generating forward tones, otherwise generating reverse tones. */ + bool fwd; /*! The current digit being generated. */ int digit; }; @@ -88,8 +88,8 @@ struct r2_mf_rx_state_s tone_report_func_t callback; /*! An opaque pointer passed to the callback function. */ void *callback_data; - /*! TRUE is we are detecting forward tones. FALSE if we are detecting backward tones */ - int fwd; + /*! Tue is we are detecting forward tones. False if we are detecting backward tones */ + bool fwd; /*! Tone detector working states */ goertzel_state_t out[6]; /*! The current sample number within a processing block. */ diff --git a/libs/spandsp/src/spandsp/private/bitstream.h b/libs/spandsp/src/spandsp/private/bitstream.h index aec8d5e124..e957eabd61 100644 --- a/libs/spandsp/src/spandsp/private/bitstream.h +++ b/libs/spandsp/src/spandsp/private/bitstream.h @@ -33,8 +33,8 @@ struct bitstream_state_s uint32_t bitstream; /*! The residual bits in bitstream. */ int residue; - /*! TRUE if the stream is LSB first, else MSB first */ - int lsb_first; + /*! True if the stream is LSB first, else MSB first */ + bool lsb_first; }; diff --git a/libs/spandsp/src/spandsp/private/dtmf.h b/libs/spandsp/src/spandsp/private/dtmf.h index c773ee61ee..37450fdba5 100644 --- a/libs/spandsp/src/spandsp/private/dtmf.h +++ b/libs/spandsp/src/spandsp/private/dtmf.h @@ -61,8 +61,8 @@ struct dtmf_rx_state_s tone_report_func_t realtime_callback; /*! An opaque pointer passed to the real time callback function. */ void *realtime_callback_data; - /*! TRUE if dialtone should be filtered before processing */ - int filter_dialtone; + /*! True if dialtone should be filtered before processing */ + bool filter_dialtone; #if defined(SPANDSP_USE_FIXED_POINT) /*! 350Hz filter state for the optional dialtone filter. */ float z350[2]; diff --git a/libs/spandsp/src/spandsp/private/fax_modems.h b/libs/spandsp/src/spandsp/private/fax_modems.h index cb66c2f576..373a692994 100644 --- a/libs/spandsp/src/spandsp/private/fax_modems.h +++ b/libs/spandsp/src/spandsp/private/fax_modems.h @@ -33,14 +33,14 @@ */ struct fax_modems_state_s { - /*! TRUE is talker echo protection should be sent for the image modems */ - int use_tep; + /*! True is talker echo protection should be sent for the image modems */ + bool use_tep; /*! \brief The callback function used to report detected tones. */ tone_report_func_t tone_callback; /*! \brief A user specified opaque pointer passed to the tone_callback function. */ void *tone_callback_user_data; - /*! If TRUE, transmit silence when there is nothing else to transmit. If FALSE return only + /*! If true, transmit silence when there is nothing else to transmit. If false return only the actual generated audio. Note that this only affects untimed silences. Timed silences (e.g. the 75ms silence between V.21 and a high speed modem) will alway be transmitted as silent audio. */ @@ -110,12 +110,12 @@ struct fax_modems_state_s hdlc_frame_handler_t hdlc_accept; void *hdlc_accept_user_data; - /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ - int rx_signal_present; - /*! \brief TRUE if a modem has trained correctly. */ - int rx_trained; - /*! \brief TRUE if an HDLC frame has been received correctly. */ - int rx_frame_received; + /*! \brief True if a carrier is present. Otherwise false. */ + bool rx_signal_present; + /*! \brief True if a modem has trained correctly. */ + bool rx_trained; + /*! \brief True if an HDLC frame has been received correctly. */ + bool rx_frame_received; int deferred_rx_handler_updates; /*! \brief The current receive signal handler */ @@ -145,8 +145,8 @@ struct fax_modems_state_s /*! \brief The current bit rate of the receiver. */ int rx_bit_rate; - /*! \brief If TRUE, transmission is in progress */ - int transmit; + /*! \brief If True, transmission is in progress */ + bool transmit; /*! \brief Audio logging file handle for received audio. */ int audio_rx_log; /*! \brief Audio logging file handle for transmitted audio. */ diff --git a/libs/spandsp/src/spandsp/private/g722.h b/libs/spandsp/src/spandsp/private/g722.h index 74ee517f3f..47b2abaa2f 100644 --- a/libs/spandsp/src/spandsp/private/g722.h +++ b/libs/spandsp/src/spandsp/private/g722.h @@ -21,15 +21,8 @@ * 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. - * - * Based on a single channel G.722 codec which is: - * - ***** Copyright (c) CMU 1993 ***** - * Computer Science, Speech Group - * Chengxiang Lu and Alex Hauptmann */ - /*! \file */ #if !defined(_SPANDSP_PRIVATE_G722_H_) @@ -54,13 +47,13 @@ typedef struct */ struct g722_encode_state_s { - /*! TRUE if the operating in the special ITU test mode, with the band split filters + /*! True if the operating in the special ITU test mode, with the band split filters disabled. */ - int itu_test_mode; - /*! TRUE if the G.722 data is packed */ - int packed; - /*! TRUE if encode from 8k samples/second */ - int eight_k; + bool itu_test_mode; + /*! True if the G.722 data is packed */ + bool packed; + /*! True if encode from 8k samples/second */ + bool eight_k; /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ int bits_per_sample; @@ -82,13 +75,13 @@ struct g722_encode_state_s */ struct g722_decode_state_s { - /*! TRUE if the operating in the special ITU test mode, with the band split filters + /*! True if the operating in the special ITU test mode, with the band split filters disabled. */ - int itu_test_mode; - /*! TRUE if the G.722 data is packed */ - int packed; - /*! TRUE if decode to 8k samples/second */ - int eight_k; + bool itu_test_mode; + /*! True if the G.722 data is packed */ + bool packed; + /*! True if decode to 8k samples/second */ + bool eight_k; /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ int bits_per_sample; diff --git a/libs/spandsp/src/spandsp/private/hdlc.h b/libs/spandsp/src/spandsp/private/hdlc.h index de87394daf..6390a52f08 100644 --- a/libs/spandsp/src/spandsp/private/hdlc.h +++ b/libs/spandsp/src/spandsp/private/hdlc.h @@ -43,24 +43,24 @@ struct hdlc_rx_state_s modem_status_func_t status_handler; /*! \brief An opaque parameter passed to the status callback routine. */ void *status_user_data; - /*! \brief TRUE if bad frames are to be reported. */ - int report_bad_frames; + /*! \brief True if bad frames are to be reported. */ + bool report_bad_frames; /*! \brief The number of consecutive flags which must be seen before framing is declared OK. */ int framing_ok_threshold; - /*! \brief TRUE if framing OK has been announced. */ - int framing_ok_announced; + /*! \brief True if framing OK has been announced. */ + bool framing_ok_announced; /*! \brief Number of consecutive flags seen so far. */ int flags_seen; /*! \brief The raw (stuffed) bit stream buffer. */ - unsigned int raw_bit_stream; + uint32_t raw_bit_stream; /*! \brief The destuffed bit stream buffer. */ - unsigned int byte_in_progress; + uint32_t byte_in_progress; /*! \brief The current number of bits in byte_in_progress. */ int num_bits; - /*! \brief TRUE if in octet counting mode (e.g. for MTP). */ - int octet_counting_mode; + /*! \brief True if in octet counting mode (e.g. for MTP). */ + bool octet_counting_mode; /*! \brief Octet count, to achieve the functionality needed for things like MTP. */ int octet_count; @@ -98,8 +98,8 @@ struct hdlc_tx_state_s void *user_data; /*! \brief The minimum flag octets to insert between frames. */ int inter_frame_flags; - /*! \brief TRUE if frame creation works in progressive mode. */ - int progressive; + /*! \brief True if frame creation works in progressive mode. */ + bool progressive; /*! \brief Maximum permitted frame length. */ size_t max_frame_len; @@ -113,8 +113,8 @@ struct hdlc_tx_state_s int flag_octets; /*! \brief The number of abort octets to send for a timed burst of aborts. */ int abort_octets; - /*! \brief TRUE if the next underflow of timed flag octets should be reported */ - int report_flag_underflow; + /*! \brief True if the next underflow of timed flag octets should be reported */ + bool report_flag_underflow; /*! \brief The current message being transmitted, with its CRC attached. */ uint8_t buffer[HDLC_MAXFRAME_LEN + 4]; @@ -130,8 +130,8 @@ struct hdlc_tx_state_s /*! \brief The number of bits remaining in byte. */ int bits; - /*! \brief TRUE if transmission should end on buffer underflow .*/ - int tx_end; + /*! \brief True if transmission should end on buffer underflow .*/ + bool tx_end; }; #endif diff --git a/libs/spandsp/src/spandsp/private/lpc10.h b/libs/spandsp/src/spandsp/private/lpc10.h index b61893637c..e02096e6d5 100644 --- a/libs/spandsp/src/spandsp/private/lpc10.h +++ b/libs/spandsp/src/spandsp/private/lpc10.h @@ -92,8 +92,8 @@ struct lpc10_encode_state_s int32_t l2ptr2; /*! \brief No initial value necessary */ int32_t lasti; - /*! \brief Initial value FALSE */ - int hyst; + /*! \brief Initial value false */ + bool hyst; /* State used by function lpc10_voicing */ /*! \brief Initial value 20.0f */ @@ -148,8 +148,8 @@ struct lpc10_decode_state_s /* State used by function decode */ /*! \brief Initial value 60 */ int32_t iptold; - /*! \brief Initial value TRUE */ - int first; + /*! \brief Initial value true */ + bool first; /*! \brief ??? */ int32_t ivp2h; /*! \brief ??? */ @@ -172,18 +172,18 @@ struct lpc10_decode_state_s int32_t buflen; /* State used by function pitsyn */ - /*! \brief No initial value necessary as long as first_pitsyn is initially TRUE */ + /*! \brief No initial value necessary as long as first_pitsyn is initially true */ int32_t ivoico; - /*! \brief No initial value necessary as long as first_pitsyn is initially TRUE */ + /*! \brief No initial value necessary as long as first_pitsyn is initially true */ int32_t ipito; /*! \brief Initial value 1.0f */ float rmso; - /*! \brief No initial value necessary as long as first_pitsyn is initially TRUE */ + /*! \brief No initial value necessary as long as first_pitsyn is initially true */ float rco[10]; - /*! \brief No initial value necessary as long as first_pitsyn is initially TRUE */ + /*! \brief No initial value necessary as long as first_pitsyn is initially true */ int32_t jsamp; - /*! \brief Initial value TRUE */ - int first_pitsyn; + /*! \brief Initial value true */ + bool first_pitsyn; /* State used by function bsynz */ /*! \brief ??? */ diff --git a/libs/spandsp/src/spandsp/private/modem_connect_tones.h b/libs/spandsp/src/spandsp/private/modem_connect_tones.h index c1c33d25a4..d76faf1de3 100644 --- a/libs/spandsp/src/spandsp/private/modem_connect_tones.h +++ b/libs/spandsp/src/spandsp/private/modem_connect_tones.h @@ -77,7 +77,7 @@ struct modem_connect_tones_rx_state_s int32_t am_level; /*! \brief Sample counter for the small chunks of samples, after which a test is conducted. */ int chunk_remainder; - /*! \brief TRUE is the tone is currently confirmed present in the audio. */ + /*! \brief The code for the tone currently confirmed present in the audio. */ int tone_present; /*! \brief */ int tone_on; @@ -85,7 +85,7 @@ struct modem_connect_tones_rx_state_s int tone_cycle_duration; /*! \brief A count of the number of good cycles of tone reversal seen. */ int good_cycles; - /*! \brief TRUE if the tone has been seen since the last time the user tested for it */ + /*! \brief The confirmed tone code. */ int hit; /*! \brief A V.21 FSK modem context used when searching for FAX preamble. */ fsk_rx_state_t v21rx; @@ -95,8 +95,8 @@ struct modem_connect_tones_rx_state_s int num_bits; /*! \brief Number of consecutive flags seen so far. */ int flags_seen; - /*! \brief TRUE if framing OK has been announced. */ - int framing_ok_announced; + /*! \brief True if framing OK has been announced. */ + bool framing_ok_announced; }; #endif diff --git a/libs/spandsp/src/spandsp/private/playout.h b/libs/spandsp/src/spandsp/private/playout.h new file mode 100644 index 0000000000..dd8c9a53e9 --- /dev/null +++ b/libs/spandsp/src/spandsp/private/playout.h @@ -0,0 +1,105 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * private/playout.h + * + * Written by Steve Underwood + * + * Copyright (C) 2005 Steve Underwood + * + * 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. + * + * 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. + * + * 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. + */ + +#if !defined(_SPANDSP_PRIVATE_PLAYOUT_H_) +#define _SPANDSP_PRIVATE_PLAYOUT_H_ + +struct playout_frame_s +{ + /*! The actual frame data */ + void *data; + /*! The type of frame */ + int type; + /*! The timestamp assigned by the sending end */ + timestamp_t sender_stamp; + /*! The timespan covered by the data in this frame */ + timestamp_t sender_len; + /*! The timestamp assigned by the receiving end */ + timestamp_t receiver_stamp; + /*! Pointer to the next earlier frame */ + struct playout_frame_s *earlier; + /*! Pointer to the next later frame */ + struct playout_frame_s *later; +}; + +/*! + Playout (jitter buffer) descriptor. This defines the working state + for a single instance of playout buffering. +*/ +struct playout_state_s +{ + /*! True if the buffer is dynamically sized */ + bool dynamic; + /*! The minimum length (dynamic) or fixed length (static) of the buffer */ + int min_length; + /*! The maximum length (dynamic) or fixed length (static) of the buffer */ + int max_length; + /*! The target filter threshold for adjusting dynamic buffering. */ + int dropable_threshold; + + int start; + + /*! The queued frame list */ + playout_frame_t *first_frame; + playout_frame_t *last_frame; + /*! The free frame pool */ + playout_frame_t *free_frames; + + /*! The total frames input to the buffer, to date. */ + int frames_in; + /*! The total frames output from the buffer, to date. */ + int frames_out; + /*! The number of frames received out of sequence. */ + int frames_oos; + /*! The number of frames which were discarded, due to late arrival. */ + int frames_late; + /*! The number of frames which were never received. */ + int frames_missing; + /*! The number of frames trimmed from the stream, due to buffer shrinkage. */ + int frames_trimmed; + + timestamp_t latest_expected; + /*! The present jitter adjustment */ + timestamp_t current; + /*! The sender_stamp of the last speech frame */ + timestamp_t last_speech_sender_stamp; + /*! The duration of the last speech frame */ + timestamp_t last_speech_sender_len; + + int not_first; + /*! The time since the target buffer length was last changed. */ + timestamp_t since_last_step; + /*! Filter state for tracking the packets arriving just in time */ + int32_t state_just_in_time; + /*! Filter state for tracking the packets arriving late */ + int32_t state_late; + /*! The current target length of the buffer */ + int target_buffer_length; + /*! The current actual length of the buffer, which may lag behind the target value */ + int actual_buffer_length; +}; + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/plc.h b/libs/spandsp/src/spandsp/private/plc.h new file mode 100644 index 0000000000..79975b02f1 --- /dev/null +++ b/libs/spandsp/src/spandsp/private/plc.h @@ -0,0 +1,64 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * private/plc.h + * + * Written by Steve Underwood + * + * Copyright (C) 2004 Steve Underwood + * + * 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. + * + * 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. + * + * 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. + */ + +/*! \file */ + +#if !defined(_SPANDSP_PRIVATE_PLC_H_) +#define _SPANDSP_PRIVATE_PLC_H_ + +/*! Minimum allowed pitch (66 Hz) */ +#define PLC_PITCH_MIN 120 +/*! Maximum allowed pitch (200 Hz) */ +#define PLC_PITCH_MAX 40 +/*! Maximum pitch OLA window */ +#define PLC_PITCH_OVERLAP_MAX (PLC_PITCH_MIN >> 2) +/*! The length over which the AMDF function looks for similarity (20 ms) */ +#define CORRELATION_SPAN 160 +/*! History buffer length. The buffer much also be at leat 1.25 times + PLC_PITCH_MIN, but that is much smaller than the buffer needs to be for + the pitch assessment. */ +#define PLC_HISTORY_LEN (CORRELATION_SPAN + PLC_PITCH_MIN) + +/*! + The generic packet loss concealer context. +*/ +struct plc_state_s +{ + /*! Consecutive erased samples */ + int missing_samples; + /*! Current offset into pitch period */ + int pitch_offset; + /*! Pitch estimate */ + int pitch; + /*! Buffer for a cycle of speech */ + float pitchbuf[PLC_PITCH_MIN]; + /*! History buffer */ + int16_t history[PLC_HISTORY_LEN]; + /*! Current pointer into the history buffer */ + int buf_ptr; +}; + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/power_meter.h b/libs/spandsp/src/spandsp/private/power_meter.h new file mode 100644 index 0000000000..64b8ec3f45 --- /dev/null +++ b/libs/spandsp/src/spandsp/private/power_meter.h @@ -0,0 +1,53 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * private/power_meter.h + * + * Written by Steve Underwood + * + * Copyright (C) 2003 Steve Underwood + * + * 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. + * + * 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. + * + * 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. + */ + +#if !defined(_SPANDSP_PRIVATE_POWER_METER_H_) +#define _SPANDSP_PRIVATE_POWER_METER_H_ + +/*! + Power meter descriptor. This defines the working state for a + single instance of a power measurement device. +*/ +struct power_meter_s +{ + /*! The shift factor, which controls the damping of the power meter. */ + int shift; + + /*! The current power reading. */ + int32_t reading; +}; + +struct power_surge_detector_state_s +{ + power_meter_t short_term; + power_meter_t medium_term; + int signal_present; + int32_t surge; + int32_t sag; + int32_t min; +}; + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/sig_tone.h b/libs/spandsp/src/spandsp/private/sig_tone.h index e7c6217051..3ec02d9bf9 100644 --- a/libs/spandsp/src/spandsp/private/sig_tone.h +++ b/libs/spandsp/src/spandsp/private/sig_tone.h @@ -210,10 +210,10 @@ struct sig_tone_rx_state_s /*! \brief The minimum ratio between notched power and total power for detection */ int32_t detection_ratio; - /*! \brief TRUE if in flat mode. FALSE if in sharp mode. */ - int flat_mode; - /*! \brief TRUE if the notch filter is enabled in the media path */ - int notch_enabled; + /*! \brief True if in flat mode. False if in sharp mode. */ + bool flat_mode; + /*! \brief True if the notch filter is enabled in the media path */ + bool notch_enabled; /*! \brief ??? */ int flat_mode_timeout; /*! \brief ??? */ diff --git a/libs/spandsp/src/spandsp/private/t30.h b/libs/spandsp/src/spandsp/private/t30.h index 786fd4f0d2..06b35b67a2 100644 --- a/libs/spandsp/src/spandsp/private/t30.h +++ b/libs/spandsp/src/spandsp/private/t30.h @@ -43,8 +43,8 @@ struct t30_state_s /*! \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 True if behaving as the calling party */ + bool calling_party; /*! \brief Internet aware FAX mode bit mask. */ int iaf; @@ -64,10 +64,10 @@ struct t30_state_s 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; - /*! \brief TRUE if we are capable of retransmitting pages */ - int retransmit_capable; + /*! \brief True is ECM mode handling is enabled. */ + bool ecm_allowed; + /*! \brief True if we are capable of retransmitting pages */ + bool retransmit_capable; /*! \brief The received DCS, formatted as an ASCII string, for inclusion in the TIFF file. */ @@ -75,17 +75,17 @@ struct t30_state_s /*! \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]; - /*! \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 + /*! \brief True for FAX page headers to overlay (i.e. replace) the beginning of the + page image. False for FAX page headers to add to the overall length of the page. */ - int header_overlays_image; - /*! \brief Use private timezone if TRUE */ - int use_own_tz; + bool header_overlays_image; + /*! \brief Use private timezone if true */ + bool use_own_tz; /*! \brief Optional per instance time zone for the FAX page header timestamp. */ tz_t tz; - /*! \brief TRUE if remote T.30 procedural interrupts are allowed. */ - int remote_interrupts_allowed; + /*! \brief True if remote T.30 procedural interrupts are allowed. */ + bool remote_interrupts_allowed; /*! \brief The information fields received. */ t30_exchanged_info_t rx_info; @@ -163,11 +163,11 @@ struct t30_state_s int local_dis_dtc_len; /*! \brief The last DIS or DTC message received form the far end. */ uint8_t far_dis_dtc_frame[T30_MAX_DIS_DTC_DCS_LEN]; - /*! \brief TRUE if a valid DIS has been received from the far end. */ - int dis_received; + /*! \brief True if a valid DIS has been received from the far end. */ + bool dis_received; - /*! \brief TRUE if the short training sequence should be used. */ - int short_train; + /*! \brief True if the short training sequence should be used. */ + bool short_train; /*! \brief A count of the number of bits in the trainability test. This counts down to zero when sending TCF, and counts up when receiving it. */ @@ -181,12 +181,12 @@ struct t30_state_s int current_fallback; /*! \brief The subset of supported modems allowed at the current time, allowing for negotiation. */ int current_permitted_modems; - /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ - int rx_signal_present; - /*! \brief TRUE if a modem has trained correctly. */ - int rx_trained; - /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */ - int rx_frame_received; + /*! \brief True if a carrier is present. Otherwise false. */ + bool rx_signal_present; + /*! \brief True if a modem has trained correctly. */ + bool rx_trained; + /*! \brief True if a valid HDLC frame has been received in the current reception period. */ + bool rx_frame_received; /*! \brief Current reception mode. */ int current_rx_type; @@ -214,14 +214,14 @@ struct t30_state_s /*! \brief This is only used in full duplex (e.g. ISDN) modes. */ int timer_t8; - /*! \brief TRUE once the far end FAX entity has been detected. */ - int far_end_detected; + /*! \brief True once the far end FAX entity has been detected. */ + bool far_end_detected; - /*! \brief TRUE once the end of procedure condition has been detected. */ - int end_of_procedure_detected; + /*! \brief True once the end of procedure condition has been detected. */ + bool end_of_procedure_detected; - /*! \brief TRUE if a local T.30 interrupt is pending. */ - int local_interrupt_pending; + /*! \brief True if a local T.30 interrupt is pending. */ + bool local_interrupt_pending; /*! \brief The common ground in compression schemes between the local and far ends. */ int mutual_compressions; /*! \brief The common group of supported bi-level image resolutions. */ @@ -248,8 +248,8 @@ struct t30_state_s t4_image_width_t image_width; /*! \brief Current number of retries of the action in progress. */ int retries; - /*! \brief TRUE if error correcting mode is used. */ - int error_correcting_mode; + /*! \brief True if error correcting mode is used. */ + bool error_correcting_mode; /*! \brief The number of HDLC frame retries, if error correcting mode is used. */ int error_correcting_mode_retries; /*! \brief The current count of consecutive T30_PPR messages. */ @@ -277,9 +277,9 @@ struct t30_state_s int ecm_frames_this_tx_burst; /*! \brief The current ECM frame, during ECM transmission. */ int ecm_current_tx_frame; - /*! \brief TRUE if we are at the end of an ECM page to se sent - i.e. there are no more + /*! \brief True if we are at the end of an ECM page to se sent - i.e. there are no more partial pages still to come. */ - int ecm_at_page_end; + bool ecm_at_page_end; /*! \brief The transmission step queued to follow the one in progress. */ int next_tx_step; @@ -305,8 +305,8 @@ struct t30_state_s /*! \brief the FCF2 field of the last PPS message we received. */ uint8_t last_pps_fcf2; - /*! \brief TRUE if all frames of the current received ECM block are now OK */ - int rx_ecm_block_ok; + /*! \brief True if all frames of the current received ECM block are now OK */ + bool 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; diff --git a/libs/spandsp/src/spandsp/private/t31.h b/libs/spandsp/src/spandsp/private/t31.h index 2686b5f503..1f7de41f99 100644 --- a/libs/spandsp/src/spandsp/private/t31.h +++ b/libs/spandsp/src/spandsp/private/t31.h @@ -108,8 +108,8 @@ typedef struct /*! \brief The current transmit step being timed */ int timed_step; - /*! \brief TRUE is there has been some T.38 data missed */ - int rx_data_missing; + /*! \brief True is there has been some T.38 data missed */ + bool rx_data_missing; /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current rate and the current specified packet interval. */ @@ -138,9 +138,9 @@ typedef struct t31_hdlc_state_t hdlc_from_t31; - /*! \brief TRUE if we are using ECM mode. This is used to select HDLC faking, necessary + /*! \brief True if we are using ECM mode. This is used to select HDLC faking, necessary with clunky class 1 modems. */ - int ecm_mode; + bool ecm_mode; /*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */ int non_ecm_trailer_bytes; @@ -179,8 +179,8 @@ struct t31_state_s t31_audio_front_end_state_t audio; t31_t38_front_end_state_t t38_fe; - /*! TRUE if working in T.38 mode. */ - int t38_mode; + /*! True if working in T.38 mode. */ + bool t38_mode; /*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */ struct @@ -189,8 +189,8 @@ struct t31_state_s uint8_t buf[T31_MAX_HDLC_LEN]; int len; int ptr; - /*! \brief TRUE when the end of HDLC data from the computer has been detected. */ - int final; + /*! \brief True when the end of HDLC data from the computer has been detected. */ + bool final; } hdlc_tx; /*! Buffer for data from the computer to the channel. */ struct @@ -201,24 +201,24 @@ struct t31_state_s int in_bytes; /*! \brief The number of bytes sent from the transmit buffer. */ int out_bytes; - /*! \brief TRUE if the flow of real data has started. */ - int data_started; - /*! \brief TRUE if holding up further data into the buffer, for flow control. */ - int holding; - /*! \brief TRUE when the end of non-ECM data from the computer has been detected. */ - int final; + /*! \brief True if the flow of real data has started. */ + bool data_started; + /*! \brief True if holding up further data into the buffer, for flow control. */ + bool holding; + /*! \brief True when the end of non-ECM data from the computer has been detected. */ + bool final; } non_ecm_tx; - /*! TRUE if DLE prefix just used */ - int dled; + /*! True if DLE prefix just used */ + bool dled; /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */ int silence_awaited; /*! \brief The current bit rate for the FAX fast message transfer modem. */ int bit_rate; - /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */ - int rx_frame_received; + /*! \brief True if a valid HDLC frame has been received in the current reception period. */ + bool rx_frame_received; /*! \brief Samples elapsed in the current call */ int64_t call_samples; @@ -226,8 +226,8 @@ struct t31_state_s /*! \brief The currently queued modem type. */ int modem; - /*! \brief TRUE when short training mode has been selected by the computer. */ - int short_train; + /*! \brief True when short training mode has been selected by the computer. */ + bool short_train; queue_state_t *rx_queue; /*! \brief Error and flow logging control */ diff --git a/libs/spandsp/src/spandsp/private/t38_core.h b/libs/spandsp/src/spandsp/private/t38_core.h index 40123128af..6d29957067 100644 --- a/libs/spandsp/src/spandsp/private/t38_core.h +++ b/libs/spandsp/src/spandsp/private/t38_core.h @@ -98,9 +98,9 @@ struct t38_core_state_s /*! \brief Pace transmission */ int pace_transmission; - /*! \brief TRUE if IFP packet sequence numbers are relevant. For some transports, like TPKT + /*! \brief True if IFP packet sequence numbers are relevant. For some transports, like TPKT over TCP they are not relevent. */ - int check_sequence_numbers; + bool check_sequence_numbers; /*! \brief The number of times each packet type will be sent (low byte). The depth of redundancy (2nd byte). Higher numbers may increase reliability diff --git a/libs/spandsp/src/spandsp/private/t38_gateway.h b/libs/spandsp/src/spandsp/private/t38_gateway.h index 075a9b221c..23c6dd59bf 100644 --- a/libs/spandsp/src/spandsp/private/t38_gateway.h +++ b/libs/spandsp/src/spandsp/private/t38_gateway.h @@ -43,12 +43,12 @@ typedef struct /*! \brief Core T.38 IFP support */ t38_core_state_t t38; - /*! \brief TRUE if the NSF, NSC, and NSS are to be suppressed by altering - their contents to something the far end will not recognise. */ + /*! \brief If NSF, NSC, and NSS are to be suppressed by altering their contents to + something the far end will not recognise, this is the amount to overwrite. */ int suppress_nsx_len[2]; - /*! \brief TRUE if we need to corrupt the HDLC frame in progress, so the receiver cannot + /*! \brief True if we need to corrupt the HDLC frame in progress, so the receiver cannot interpret it. The two values are for the two directions. */ - int corrupt_current_frame[2]; + bool corrupt_current_frame[2]; /*! \brief the current class of field being received - i.e. none, non-ECM or HDLC */ int current_rx_field_class; @@ -87,8 +87,8 @@ typedef struct int bit_no; /*! \brief Progressively calculated CRC for HDLC messages received from a modem. */ uint16_t crc; - /*! \brief TRUE if non-ECM fill bits are to be stripped when sending image data. */ - int fill_bit_removal; + /*! \brief True if non-ECM fill bits are to be stripped when sending image data. */ + bool fill_bit_removal; /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current rate and the current specified packet interval. */ int octets_per_data_packet; @@ -134,27 +134,27 @@ typedef struct { /*! \brief A bit mask of the currently supported modem types. */ int supported_modems; - /*! \brief TRUE if ECM FAX mode is allowed through the gateway. */ - int ecm_allowed; + /*! \brief True if ECM FAX mode is allowed through the gateway. */ + bool ecm_allowed; /*! \brief Required time between T.38 transmissions, in ms. */ int ms_per_tx_chunk; - /*! \brief TRUE if in image data modem is to use short training. This usually + /*! \brief True if in image data modem is to use short training. This usually follows image_data_mode, but in ECM mode T.30 defines recovery conditions in which long training is used for image data. */ - int short_train; - /*! \brief TRUE if in image data mode, as opposed to TCF mode. */ - int image_data_mode; + bool short_train; + /*! \brief True if in image data mode, as opposed to TCF mode. */ + bool image_data_mode; /*! \brief The minimum permitted bits per FAX scan line row. */ int min_row_bits; - /*! \brief TRUE if we should count the next MCF as a page end, else FALSE */ - int count_page_on_mcf; + /*! \brief True if we should count the next MCF as a page end, else false */ + bool count_page_on_mcf; /*! \brief The number of pages for which a confirm (MCF) message was returned. */ int pages_confirmed; - /*! \brief TRUE if we are in error correcting (ECM) mode */ - int ecm_mode; + /*! \brief True if we are in error correcting (ECM) mode */ + bool ecm_mode; /*! \brief The current bit rate for the fast modem. */ int fast_bit_rate; /*! \brief The current fast receive modem type. */ diff --git a/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h b/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h index 78604420a9..9220f78af1 100644 --- a/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h +++ b/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h @@ -55,14 +55,14 @@ struct t38_non_ecm_buffer_state_s uint8_t flow_control_fill_octet; /*! \brief A code for the phase of input buffering, from initial all ones to completion. */ int input_phase; - /*! \brief TRUE is the end of non-ECM data indication has been received. */ - int data_finished; + /*! \brief True is the end of non-ECM data indication has been received. */ + bool data_finished; /*! \brief The current octet being transmitted from the buffer. */ unsigned int octet; /*! \brief The current bit number in the current non-ECM octet. */ int bit_no; - /*! \brief TRUE if in image data mode, as opposed to TCF mode. */ - int image_data_mode; + /*! \brief True if in image data mode, as opposed to TCF mode. */ + bool image_data_mode; /*! \brief The number of octets input to the buffer. */ int in_octets; diff --git a/libs/spandsp/src/spandsp/private/t38_terminal.h b/libs/spandsp/src/spandsp/private/t38_terminal.h index 0bd75a6cfb..219b1e3cf7 100644 --- a/libs/spandsp/src/spandsp/private/t38_terminal.h +++ b/libs/spandsp/src/spandsp/private/t38_terminal.h @@ -46,9 +46,9 @@ typedef struct /*! \brief The timed step to go to when we reach idle from the current timed step */ int queued_timed_step; - /*! \brief TRUE is there has been some T.38 data missed (i.e. lost packets) in the current + /*! \brief True is there has been some T.38 data missed (i.e. lost packets) in the current reception period. */ - int rx_data_missing; + bool rx_data_missing; /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current rate and the current specified packet interval. */ @@ -84,8 +84,8 @@ typedef struct /*! \brief The current T.38 data type being transmitted. */ int current_tx_data_type; - /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ - int rx_signal_present; + /*! \brief True if a carrier is present. Otherwise false. */ + bool rx_signal_present; /*! \brief The current operating mode of the receiver. */ int current_rx_type; diff --git a/libs/spandsp/src/spandsp/private/t4_rx.h b/libs/spandsp/src/spandsp/private/t4_rx.h index e896869e7a..99a3e5ef55 100644 --- a/libs/spandsp/src/spandsp/private/t4_rx.h +++ b/libs/spandsp/src/spandsp/private/t4_rx.h @@ -26,6 +26,8 @@ #if !defined(_SPANDSP_PRIVATE_T4_RX_H_) #define _SPANDSP_PRIVATE_T4_RX_H_ +typedef int (*t4_image_put_handler_t)(void *user_data, const uint8_t buf[], size_t len); + /*! TIFF specific state information to go with T.4 compression or decompression handling. */ @@ -125,6 +127,9 @@ struct t4_rx_state_s t45_decode_state_t t45; #endif } decoder; + + t4_image_put_handler_t image_put_handler; + int current_decoder; uint8_t *pre_encoded_buf; diff --git a/libs/spandsp/src/spandsp/private/t4_t6_decode.h b/libs/spandsp/src/spandsp/private/t4_t6_decode.h index 90b4e72d66..616e1be879 100644 --- a/libs/spandsp/src/spandsp/private/t4_t6_decode.h +++ b/libs/spandsp/src/spandsp/private/t4_t6_decode.h @@ -81,8 +81,8 @@ struct t4_t6_decode_state_s int run_length; /*! \brief 2D horizontal mode control. */ int black_white; - /*! \brief TRUE if the current run is black */ - int in_black; + /*! \brief True if the current run is black */ + bool in_black; /*! \brief The current step into the current row run-lengths buffer. */ int a_cursor; diff --git a/libs/spandsp/src/spandsp/private/t4_t6_encode.h b/libs/spandsp/src/spandsp/private/t4_t6_encode.h index ea080109aa..4ac35f76a9 100644 --- a/libs/spandsp/src/spandsp/private/t4_t6_encode.h +++ b/libs/spandsp/src/spandsp/private/t4_t6_encode.h @@ -59,7 +59,7 @@ struct t4_t6_encode_state_s /*! \brief This variable is set if we are treating the current row as a 2D encoded one. */ - int row_is_2d; + bool row_is_2d; /*! \brief Encoded data bits buffer. */ uint32_t tx_bitstream; diff --git a/libs/spandsp/src/spandsp/private/t4_tx.h b/libs/spandsp/src/spandsp/private/t4_tx.h index e691758fc5..5ff0d2ea27 100644 --- a/libs/spandsp/src/spandsp/private/t4_tx.h +++ b/libs/spandsp/src/spandsp/private/t4_tx.h @@ -26,6 +26,8 @@ #if !defined(_SPANDSP_PRIVATE_T4_TX_H_) #define _SPANDSP_PRIVATE_T4_TX_H_ +typedef int (*t4_image_get_handler_t)(void *user_data, uint8_t buf[], size_t len); + /*! TIFF specific state information to go with T.4 compression or decompression handling. */ @@ -45,6 +47,17 @@ typedef struct /*! \brief The TIFF fill order setting for the current page. */ uint16_t fill_order; + /*! \brief Width of the image in the file. */ + uint32_t image_width; + /*! \brief Length of the image in the file. */ + uint32_t image_length; + /*! \brief Column-to-column (X) resolution in pixels per metre of the image in the file. */ + int x_resolution; + /*! \brief Row-to-row (Y) resolution in pixels per metre of the image in the file. */ + int y_resolution; + /*! \brief Code for the combined X and Y resolution of the image in the file. */ + int resolution_code; + /*! \brief The number of pages in the current image file. */ int pages_in_file; @@ -56,18 +69,6 @@ typedef struct int image_buffer_size; /*! \brief Row counter for playing out the rows of the image. */ int row; - - /*! \brief Width of the image in the file. */ - uint32_t image_width; - /*! \brief Length of the image in the file. */ - uint32_t image_length; - /*! \brief Column-to-column (X) resolution in pixels per metre of the image in the file. */ - int image_x_resolution; - /*! \brief Row-to-row (Y) resolution in pixels per metre of the image in the file. */ - int image_y_resolution; - /*! \brief Code for the combined X and Y resolution of the image in the file. */ - int resolution_code; - /*! \brief Row counter used when the image is resized or dithered flat. */ int raw_row; } t4_tx_tiff_state_t; @@ -123,10 +124,10 @@ struct t4_tx_state_s /*! \brief The last page to transfer. -1 to continue to the end of the file. */ int stop_page; - /*! \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 + /*! \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; + bool header_overlays_image; /*! \brief The text which will be used in FAX page header. No text results in no header line. */ const char *header_info; @@ -162,23 +163,25 @@ struct t4_tx_state_s #endif } encoder; - image_translate_state_t translator; - uint8_t *pack_buf; - int pack_ptr; - int pack_row; - int pack_bit_mask; + t4_image_get_handler_t image_get_handler; int apply_lab; lab_params_t lab_params; uint8_t *colour_map; int colour_map_entries; + image_translate_state_t translator; + uint8_t *pack_buf; + int pack_ptr; + int pack_row; + int pack_bit_mask; + uint8_t *pre_encoded_buf; int pre_encoded_len; int pre_encoded_ptr; int pre_encoded_bit; - /* Supporting information, like resolutions, which the backend may want. */ + /*! \brief Supporting information, like resolutions, which the backend may want. */ t4_tx_metadata_t metadata; /*! \brief All TIFF file specific state information for the T.4 context. */ diff --git a/libs/spandsp/src/spandsp/private/t85.h b/libs/spandsp/src/spandsp/private/t85.h index 586a5cc22f..5eb2b50676 100644 --- a/libs/spandsp/src/spandsp/private/t85.h +++ b/libs/spandsp/src/spandsp/private/t85.h @@ -89,8 +89,8 @@ struct t85_encode_state_s uint32_t c[128]; /*! New TX value, or <0 for analysis in progress */ int32_t new_tx; - /*! TRUE if previous row was typical */ - int prev_ltp; + /*! True if previous row was typical */ + bool prev_ltp; /*! Pointers to the 3 row buffers */ uint8_t *prev_row[3]; /*! Pointer to a block of allocated memory 3 rows long, which diff --git a/libs/spandsp/src/spandsp/private/timezone.h b/libs/spandsp/src/spandsp/private/timezone.h index 9f28cc3d2b..87c67978a7 100644 --- a/libs/spandsp/src/spandsp/private/timezone.h +++ b/libs/spandsp/src/spandsp/private/timezone.h @@ -54,8 +54,8 @@ struct tz_ttinfo_s int32_t gmtoff; /* UTC offset in seconds */ int isdst; /* Used to set tm_isdst */ int abbrind; /* Abbreviation list index */ - int ttisstd; /* TRUE if transition is std time */ - int ttisgmt; /* TRUE if transition is UTC */ + bool ttisstd; /* True if transition is std time */ + bool ttisgmt; /* True if transition is UTC */ }; /* Leap second information */ diff --git a/libs/spandsp/src/spandsp/private/v17rx.h b/libs/spandsp/src/spandsp/private/v17rx.h index 2082722fd6..f6f847c553 100644 --- a/libs/spandsp/src/spandsp/private/v17rx.h +++ b/libs/spandsp/src/spandsp/private/v17rx.h @@ -156,8 +156,8 @@ struct v17_rx_state_s /*! \brief Scrambler tap */ int scrambler_tap; - /*! \brief TRUE if the short training sequence is to be used. */ - int short_train; + /*! \brief True if the short training sequence is to be used. */ + bool short_train; /*! \brief The section of the training data we are currently in. */ int training_stage; /*! \brief A count of how far through the current training step we are. */ diff --git a/libs/spandsp/src/spandsp/private/v17tx.h b/libs/spandsp/src/spandsp/private/v17tx.h index 3e2fff6d2c..acf2819371 100644 --- a/libs/spandsp/src/spandsp/private/v17tx.h +++ b/libs/spandsp/src/spandsp/private/v17tx.h @@ -81,10 +81,10 @@ struct v17_tx_state_s uint32_t scramble_reg; /*! \brief Scrambler tap */ int scrambler_tap; - /*! \brief TRUE if transmitting the training sequence. FALSE if transmitting user data. */ - int in_training; - /*! \brief TRUE if the short training sequence is to be used. */ - int short_train; + /*! \brief True if transmitting the training sequence. False if transmitting user data. */ + bool in_training; + /*! \brief True if the short training sequence is to be used. */ + bool short_train; /*! \brief A counter used to track progress through sending the training sequence. */ int training_step; diff --git a/libs/spandsp/src/spandsp/private/v18.h b/libs/spandsp/src/spandsp/private/v18.h index a991cc5107..a7575b870b 100644 --- a/libs/spandsp/src/spandsp/private/v18.h +++ b/libs/spandsp/src/spandsp/private/v18.h @@ -28,9 +28,10 @@ struct v18_state_s { - /*! \brief TRUE if we are the calling modem */ - int calling_party; + /*! \brief True if we are the calling modem */ + bool calling_party; int mode; + int nation; put_msg_func_t put_msg; void *user_data; int repeat_shifts; @@ -42,15 +43,15 @@ struct v18_state_s } queue; tone_gen_descriptor_t alert_tone_desc; tone_gen_state_t alert_tone_gen; - fsk_tx_state_t fsktx; - dtmf_tx_state_t dtmftx; - async_tx_state_t asynctx; + fsk_tx_state_t fsk_tx; + dtmf_tx_state_t dtmf_tx; + async_tx_state_t async_tx; int baudot_tx_shift; int tx_signal_on; uint8_t next_byte; - fsk_rx_state_t fskrx; - dtmf_rx_state_t dtmfrx; + fsk_rx_state_t fsk_rx; + dtmf_rx_state_t dtmf_rx; int baudot_rx_shift; int consecutive_ones; uint8_t rx_msg[256 + 1]; diff --git a/libs/spandsp/src/spandsp/private/v22bis.h b/libs/spandsp/src/spandsp/private/v22bis.h index c0da6b0aa6..dac5becb68 100644 --- a/libs/spandsp/src/spandsp/private/v22bis.h +++ b/libs/spandsp/src/spandsp/private/v22bis.h @@ -79,8 +79,8 @@ struct v22bis_state_s { /*! \brief The maximum permitted bit rate of the modem. Valid values are 1200 and 2400. */ int bit_rate; - /*! \brief TRUE is this is the calling side modem. */ - int calling_party; + /*! \brief True is this is the calling side modem. */ + bool calling_party; /*! \brief The callback function used to get the next bit to be transmitted. */ get_bit_func_t get_bit; /*! \brief A user specified opaque pointer passed to the get_bit callback routine. */ diff --git a/libs/spandsp/src/spandsp/private/v27ter_rx.h b/libs/spandsp/src/spandsp/private/v27ter_rx.h index fbec14c5ed..fc7912febc 100644 --- a/libs/spandsp/src/spandsp/private/v27ter_rx.h +++ b/libs/spandsp/src/spandsp/private/v27ter_rx.h @@ -130,8 +130,8 @@ struct v27ter_rx_state_s int scrambler_pattern_count; /*! \brief The current step in the table of BC constellation positions. */ int training_bc; - /*! \brief TRUE if the previous trained values are to be reused. */ - int old_train; + /*! \brief True if the previous trained values are to be reused. */ + bool old_train; /*! \brief The section of the training data we are currently in. */ int training_stage; /*! \brief A count of how far through the current training step we are. */ diff --git a/libs/spandsp/src/spandsp/private/v27ter_tx.h b/libs/spandsp/src/spandsp/private/v27ter_tx.h index ba9ab8b5aa..add5b36979 100644 --- a/libs/spandsp/src/spandsp/private/v27ter_tx.h +++ b/libs/spandsp/src/spandsp/private/v27ter_tx.h @@ -73,9 +73,9 @@ struct v27ter_tx_state_s /*! \brief A counter for the number of consecutive bits of repeating pattern through the scrambler. */ int scrambler_pattern_count; - /*! \brief TRUE if transmitting the training sequence, or shutting down transmission. - FALSE if transmitting user data. */ - int in_training; + /*! \brief True if transmitting the training sequence, or shutting down transmission. + False if transmitting user data. */ + bool in_training; /*! \brief A counter used to track progress through sending the training sequence. */ int training_step; diff --git a/libs/spandsp/src/spandsp/private/v29rx.h b/libs/spandsp/src/spandsp/private/v29rx.h index fd931af0f8..8b38b467bf 100644 --- a/libs/spandsp/src/spandsp/private/v29rx.h +++ b/libs/spandsp/src/spandsp/private/v29rx.h @@ -139,8 +139,8 @@ struct v29_rx_state_s uint8_t training_scramble_reg; /*! \brief The current step in the table of CD constellation positions. */ int training_cd; - /*! \brief TRUE if the previous trained values are to be reused. */ - int old_train; + /*! \brief True if the previous trained values are to be reused. */ + bool old_train; /*! \brief The section of the training data we are currently in. */ int training_stage; /*! \brief A count of how far through the current training step we are. */ diff --git a/libs/spandsp/src/spandsp/private/v29tx.h b/libs/spandsp/src/spandsp/private/v29tx.h index 67c2b7098d..58f86a2af7 100644 --- a/libs/spandsp/src/spandsp/private/v29tx.h +++ b/libs/spandsp/src/spandsp/private/v29tx.h @@ -76,9 +76,9 @@ struct v29_tx_state_s uint32_t scramble_reg; /*! \brief The register for the training scrambler. */ uint8_t training_scramble_reg; - /*! \brief TRUE if transmitting the training sequence, or shutting down transmission. - FALSE if transmitting user data. */ - int in_training; + /*! \brief True if transmitting the training sequence, or shutting down transmission. + False if transmitting user data. */ + bool in_training; /*! \brief A counter used to track progress through sending the training sequence. */ int training_step; /*! \brief An offset value into the table of training parameters, used to match the diff --git a/libs/spandsp/src/spandsp/private/v42.h b/libs/spandsp/src/spandsp/private/v42.h index b45b716349..5eac89f873 100644 --- a/libs/spandsp/src/spandsp/private/v42.h +++ b/libs/spandsp/src/spandsp/private/v42.h @@ -92,9 +92,9 @@ typedef struct uint8_t vr; int state; int configuring; - int local_busy; - int far_busy; - int rejected; + bool local_busy; + bool far_busy; + bool rejected; int retry_count; /* The control frame buffer, and its pointers */ @@ -131,11 +131,11 @@ typedef struct */ struct v42_state_s { - /*! TRUE if we are the calling party, otherwise FALSE. */ - int calling_party; - /*! TRUE if we should detect whether the far end is V.42 capable. FALSE if we go + /*! True if we are the calling party, otherwise false. */ + bool calling_party; + /*! True if we should detect whether the far end is V.42 capable. false if we go directly to protocol establishment. */ - int detect; + bool detect; /*! The bit rate, used to time events */ int tx_bit_rate; diff --git a/libs/spandsp/src/spandsp/private/v42bis.h b/libs/spandsp/src/spandsp/private/v42bis.h index 967b1fd909..216199d79b 100644 --- a/libs/spandsp/src/spandsp/private/v42bis.h +++ b/libs/spandsp/src/spandsp/private/v42bis.h @@ -60,8 +60,8 @@ typedef struct /*! \brief The maximum amount to be passed to the data handler. */ int max_output_len; - /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */ - int transparent; + /*! \brief True if we are in transparent (i.e. uncompressable) mode */ + bool transparent; /*! \brief Next empty dictionary entry */ uint16_t v42bis_parm_c1; /*! \brief Current codeword size */ @@ -104,8 +104,8 @@ typedef struct /*! \brief The current value of the escape code */ uint8_t escape_code; - /*! \brief TRUE if we just hit an escape code, and are waiting for the following octet */ - int escaped; + /*! \brief True if we just hit an escape code, and are waiting for the following octet */ + bool escaped; } v42bis_comp_state_t; /*! diff --git a/libs/spandsp/src/spandsp/private/v8.h b/libs/spandsp/src/spandsp/private/v8.h index 213d445f52..3c07b0e3bc 100644 --- a/libs/spandsp/src/spandsp/private/v8.h +++ b/libs/spandsp/src/spandsp/private/v8.h @@ -28,8 +28,8 @@ struct v8_state_s { - /*! \brief TRUE if we are the calling party */ - int calling_party; + /*! \brief True if we are the calling party */ + bool calling_party; /*! \brief A handler to process the V.8 signals */ v8_result_handler_t result_handler; @@ -38,7 +38,7 @@ struct v8_state_s /*! \brief The current state of the V.8 protocol */ int state; - int fsk_tx_on; + bool fsk_tx_on; int modem_connect_tone_tx_on; int negotiation_timer; int ci_timer; @@ -67,8 +67,8 @@ struct v8_state_s testing for matches. */ uint8_t cm_jm_data[64]; int cm_jm_len; - int got_cm_jm; - int got_cj; + bool got_cm_jm; + bool got_cj; int zero_byte_count; /*! \brief Error and flow logging control */ logging_state_t logging; diff --git a/libs/spandsp/src/spandsp/queue.h b/libs/spandsp/src/spandsp/queue.h index cbb4357916..7e56a59fc7 100644 --- a/libs/spandsp/src/spandsp/queue.h +++ b/libs/spandsp/src/spandsp/queue.h @@ -63,8 +63,8 @@ extern "C" /*! Check if a queue is empty. \brief Check if a queue is empty. \param s The queue context. - \return TRUE if empty, else FALSE. */ -SPAN_DECLARE(int) queue_empty(queue_state_t *s); + \return True if empty, else false. */ +SPAN_DECLARE(bool) queue_empty(queue_state_t *s); /*! Check the available free space in a queue's buffer. \brief Check available free space. diff --git a/libs/spandsp/src/spandsp/stdbool.h b/libs/spandsp/src/spandsp/stdbool.h new file mode 100644 index 0000000000..8c722fad17 --- /dev/null +++ b/libs/spandsp/src/spandsp/stdbool.h @@ -0,0 +1,55 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * stdbool.h - A version for systems which lack their own stdbool.h + * + * Written by Steve Underwood + * + * Copyright (C) 2003 Steve Underwood + * + * 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. + * + * 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. + * + * 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. + */ + +/*! \file */ + + +/* + * ISO C Standard: 7.16 Boolean type and values + */ + +#if !defined(_STDBOOL_H) +#define _STDBOOL_H + +#if !defined(__cplusplus) + +#define _Bool int +#define bool int +#define false 0 +#define true (!false) + +#else + +#define _Bool bool +#define bool bool +#define false false +#define true true + +#endif + +/* Signal that all the definitions are present. */ +#define __bool_true_false_are_defined 1 + +#endif diff --git a/libs/spandsp/src/spandsp/t30.h b/libs/spandsp/src/spandsp/t30.h index 2ba1330538..e4d734a8e4 100644 --- a/libs/spandsp/src/spandsp/t30.h +++ b/libs/spandsp/src/spandsp/t30.h @@ -32,7 +32,7 @@ \section t30_page_sec_1 What does it do? The T.30 protocol is the core protocol used for FAX transmission. This module -implements most of its key featrues. It does not interface to the outside work. +implements most of its key features. It does not interface to the outside work. Seperate modules do that for T.38, analogue line, and other forms of FAX communication. @@ -184,13 +184,13 @@ typedef void (*t30_phase_e_handler_t)(t30_state_t *s, void *user_data, int compl \brief T.30 real time frame handler. \param s The T.30 context. \param user_data An opaque pointer. - \param direction TRUE for incoming, FALSE for outgoing. + \param incoming True for incoming, false for outgoing. \param msg The HDLC message. \param len The length of the message. */ typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s, void *user_data, - int direction, + bool direction, const uint8_t msg[], int len); @@ -209,8 +209,8 @@ typedef int (*t30_document_handler_t)(t30_state_t *s, void *user_data, int statu \param user_data An opaque pointer. \param type The modem, tone or silence to be sent or received. \param bit_rate The bit rate of the modem to be sent or received. - \param short_train TRUE if the short training sequence should be used (where one exists). - \param use_hdlc FALSE for bit stream, TRUE for HDLC framing. + \param short_train True if the short training sequence should be used (where one exists). + \param use_hdlc False for bit stream, true for HDLC framing. */ typedef void (*t30_set_handler_t)(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); @@ -448,7 +448,7 @@ typedef struct { /*! \brief The current bit rate for image transfer. */ int bit_rate; - /*! \brief TRUE if error correcting mode is used. */ + /*! \brief True if error correcting mode is used. */ int error_correcting_mode; /*! \brief The number of pages sent so far. */ int pages_tx; @@ -502,7 +502,7 @@ extern "C" /*! Initialise a T.30 context. \brief Initialise a T.30 context. \param s The T.30 context. - \param calling_party TRUE if the context is for a calling party. FALSE if the + \param calling_party True if the context is for a calling party. False if the context is for an answering party. \param set_rx_type_handler \param set_rx_type_user_data @@ -542,7 +542,7 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s); if the job has finished. \brief Check if a T.30 call is still active. \param s The T.30 context. - \return TRUE for call still active, or FALSE for call completed. */ + \return True for call still active, or false for call completed. */ SPAN_DECLARE(int) t30_call_active(t30_state_t *s); /*! Cleanup a T.30 context if the call terminates. @@ -588,7 +588,7 @@ SPAN_DECLARE(void) t30_non_ecm_put(void *user_data, const uint8_t buf[], int len \param user_data The T.30 context. \param msg The HDLC message. \param len The length of the message, in octets. - \param ok TRUE if the frame was received without error. */ + \param ok True if the frame was received without error. */ SPAN_DECLARE_NONSTD(void) t30_hdlc_accept(void *user_data, const uint8_t msg[], int len, int ok); /*! Report the passage of time to the T.30 engine. @@ -606,13 +606,13 @@ SPAN_DECLARE(void) t30_get_transfer_statistics(t30_state_t *s, t30_stats_t *t); /*! Request a local interrupt of FAX exchange. \brief Request a local interrupt of FAX exchange. \param s The T.30 context. - \param state TRUE to enable interrupt request, else FALSE. */ + \param state True to enable interrupt request, else false. */ SPAN_DECLARE(void) t30_local_interrupt_request(t30_state_t *s, int state); /*! Allow remote interrupts of FAX exchange. \brief Allow remote interrupts of FAX exchange. \param s The T.30 context. - \param state TRUE to allow interruptd, else FALSE. */ + \param state True to allow interruptd, else false. */ SPAN_DECLARE(void) t30_remote_interrupts_allowed(t30_state_t *s, int state); #if defined(__cplusplus) diff --git a/libs/spandsp/src/spandsp/t30_api.h b/libs/spandsp/src/spandsp/t30_api.h index da3ef01a30..1c9a6e51de 100644 --- a/libs/spandsp/src/spandsp/t30_api.h +++ b/libs/spandsp/src/spandsp/t30_api.h @@ -363,8 +363,8 @@ SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *addre /*! 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); + \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, bool 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. @@ -426,15 +426,15 @@ SPAN_DECLARE(void) t30_set_tx_file(t30_state_t *s, const char *file, int start_p /*! Set Internet aware FAX (IAF) mode. \brief Set Internet aware FAX (IAF) mode. \param s The T.30 context. - \param iaf TRUE for IAF, or FALSE for non-IAF. */ -SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, int iaf); + \param iaf True for IAF, or false for non-IAF. */ +SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, bool iaf); /*! Specify if error correction mode (ECM) is allowed by a T.30 context. \brief Select ECM capability. \param s The T.30 context. - \param enabled TRUE for ECM capable, FALSE for not ECM capable. + \param enabled True for ECM capable, or false for not ECM capable. \return 0 if OK, else -1. */ -SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, int enabled); +SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, bool enabled); /*! Specify the output encoding for TIFF files created during FAX reception. \brief Specify the output encoding for TIFF files created during FAX reception. diff --git a/libs/spandsp/src/spandsp/t31.h b/libs/spandsp/src/spandsp/t31.h index 4e8452e497..b61a4142f9 100644 --- a/libs/spandsp/src/spandsp/t31.h +++ b/libs/spandsp/src/spandsp/t31.h @@ -89,33 +89,33 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples); /*! Select whether silent audio will be sent when transmit is idle. \brief Select whether silent audio will be sent when transmit is idle. \param s The T.31 modem context. - \param transmit_on_idle TRUE if silent audio should be output when the transmitter is - idle. FALSE to transmit zero length audio when the transmitter is idle. The default - behaviour is FALSE. + \param transmit_on_idle True if silent audio should be output when the transmitter is + idle. False to transmit zero length audio when the transmitter is idle. The default + behaviour is false. */ -SPAN_DECLARE(void) t31_set_transmit_on_idle(t31_state_t *s, int transmit_on_idle); +SPAN_DECLARE(void) t31_set_transmit_on_idle(t31_state_t *s, bool transmit_on_idle); /*! Select whether TEP mode will be used (or time allowed for it (when transmitting). \brief Select whether TEP mode will be used. \param s The T.31 modem context. - \param use_tep TRUE if TEP is to be ised. + \param use_tep True if TEP is to be used. */ -SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, int use_tep); +SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, bool use_tep); /*! Select whether T.38 data will be paced as it is transmitted. \brief Select whether T.38 data will be paced. \param s The T.31 modem context. - \param without_pacing TRUE if data is to be sent as fast as possible. FALSE if it is + \param without_pacing True if data is to be sent as fast as possible. False if it is to be paced. */ -SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, int without_pacing); +SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, bool without_pacing); /*! Set audio or T.38 mode. \brief Set audio or T.38 mode. \param s The T.31 modem context. - \param t38_mode TRUE for T.38 mode operation. FALSE for audio mode operation. + \param t38_mode True for T.38 mode operation. False for audio mode operation. */ -SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, int t38_mode); +SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, bool t38_mode); /*! Get a pointer to the logging context associated with a T.31 context. \brief Get a pointer to the logging context associated with a T.31 context. diff --git a/libs/spandsp/src/spandsp/t35.h b/libs/spandsp/src/spandsp/t35.h index efd644b390..fdef41fdf2 100644 --- a/libs/spandsp/src/spandsp/t35.h +++ b/libs/spandsp/src/spandsp/t35.h @@ -83,9 +83,9 @@ SPAN_DECLARE(const char *) t35_vendor_to_str(const uint8_t *msg, int len); \param model A pointer which will be pointed to the identified model. If a NULL pointer is given, the model will not be returned. If the model is not identified, NULL will be returned. - \return TRUE if the machine was identified, otherwise FALSE. + \return True if the machine was identified. */ -SPAN_DECLARE(int) t35_decode(const uint8_t *msg, int len, const char **country, const char **vendor, const char **model); +SPAN_DECLARE(bool) t35_decode(const uint8_t *msg, int len, const char **country, const char **vendor, const char **model); #if defined(__cplusplus) } diff --git a/libs/spandsp/src/spandsp/t38_core.h b/libs/spandsp/src/spandsp/t38_core.h index 662cf8d37e..86e45089ac 100644 --- a/libs/spandsp/src/spandsp/t38_core.h +++ b/libs/spandsp/src/spandsp/t38_core.h @@ -312,21 +312,21 @@ SPAN_DECLARE(void) t38_set_data_transport_protocol(t38_core_state_t *s, int data /*! Set the non-ECM fill bit removal mode. \param s The T.38 context. - \param fill_bit_removal TRUE to remove fill bits across the T.38 link, else FALSE. + \param fill_bit_removal True to remove fill bits across the T.38 link. */ -SPAN_DECLARE(void) t38_set_fill_bit_removal(t38_core_state_t *s, int fill_bit_removal); +SPAN_DECLARE(void) t38_set_fill_bit_removal(t38_core_state_t *s, bool fill_bit_removal); /*! Set the MMR transcoding mode. \param s The T.38 context. - \param mmr_transcoding TRUE to transcode to MMR across the T.38 link, else FALSE. + \param mmr_transcoding True to transcode to MMR across the T.38 link. */ -SPAN_DECLARE(void) t38_set_mmr_transcoding(t38_core_state_t *s, int mmr_transcoding); +SPAN_DECLARE(void) t38_set_mmr_transcoding(t38_core_state_t *s, bool mmr_transcoding); /*! Set the JBIG transcoding mode. \param s The T.38 context. - \param jbig_transcoding TRUE to transcode to JBIG across the T.38 link, else FALSE. + \param jbig_transcoding True to transcode to JBIG across the T.38 link. */ -SPAN_DECLARE(void) t38_set_jbig_transcoding(t38_core_state_t *s, int jbig_transcoding); +SPAN_DECLARE(void) t38_set_jbig_transcoding(t38_core_state_t *s, bool jbig_transcoding); /*! Set the maximum buffer size for received data at the far end. \param s The T.38 context. @@ -363,16 +363,16 @@ SPAN_DECLARE(void) t38_set_t38_version(t38_core_state_t *s, int t38_version); /*! Set the sequence number handling option. \param s The T.38 context. - \param check TRUE to check sequence numbers, and handle gaps reasonably. FALSE + \param check True to check sequence numbers, and handle gaps reasonably. False for no sequence number processing (e.g. for TPKT over TCP transport). */ -SPAN_DECLARE(void) t38_set_sequence_number_handling(t38_core_state_t *s, int check); +SPAN_DECLARE(void) t38_set_sequence_number_handling(t38_core_state_t *s, bool check); /*! Set the TEP handling option. \param s The T.38 context. - \param allow_for_tep TRUE to allow for TEP playout, else FALSE. + \param allow_for_tep True to allow for TEP playout. */ -SPAN_DECLARE(void) t38_set_tep_handling(t38_core_state_t *s, int allow_for_tep); +SPAN_DECLARE(void) t38_set_tep_handling(t38_core_state_t *s, bool allow_for_tep); /*! Get a pointer to the logging context associated with a T.38 context. \brief Get a pointer to the logging context associated with a T.38 context. diff --git a/libs/spandsp/src/spandsp/t38_gateway.h b/libs/spandsp/src/spandsp/t38_gateway.h index 4971e8d4bf..89bd9b116d 100644 --- a/libs/spandsp/src/spandsp/t38_gateway.h +++ b/libs/spandsp/src/spandsp/t38_gateway.h @@ -45,13 +45,13 @@ typedef struct t38_gateway_state_s t38_gateway_state_t; \brief T.30 real time frame handler. \param s The T.30 context. \param user_data An opaque pointer. - \param direction TRUE for incoming, FALSE for outgoing. + \param incoming True for incoming, false for outgoing. \param msg The HDLC message. \param len The length of the message. */ typedef void (*t38_gateway_real_time_frame_handler_t)(t38_gateway_state_t *s, void *user_data, - int direction, + bool incoming, const uint8_t *msg, int len); @@ -62,8 +62,8 @@ typedef struct { /*! \brief The current bit rate for image transfer. */ int bit_rate; - /*! \brief TRUE if error correcting mode is used. */ - int error_correcting_mode; + /*! \brief True if error correcting mode is used. */ + bool error_correcting_mode; /*! \brief The number of pages transferred so far. */ int pages_transferred; } t38_stats_t; @@ -124,18 +124,18 @@ SPAN_DECLARE_NONSTD(int) t38_gateway_tx(t38_gateway_state_t *s, int16_t amp[], i /*! Control whether error correcting mode (ECM) is allowed. \brief Control whether error correcting mode (ECM) is allowed. \param s The T.38 context. - \param ecm_allowed TRUE is ECM is to be allowed. + \param ecm_allowed True is ECM is to be allowed. */ -SPAN_DECLARE(void) t38_gateway_set_ecm_capability(t38_gateway_state_t *s, int ecm_allowed); +SPAN_DECLARE(void) t38_gateway_set_ecm_capability(t38_gateway_state_t *s, bool ecm_allowed); /*! Select whether silent audio will be sent when transmit is idle. \brief Select whether silent audio will be sent when transmit is idle. \param s The T.38 context. - \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is - idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default - behaviour is FALSE. + \param transmit_on_idle True if silent audio should be output when the FAX transmitter is + idle. False to transmit zero length audio when the FAX transmitter is idle. The default + behaviour is false. */ -SPAN_DECLARE(void) t38_gateway_set_transmit_on_idle(t38_gateway_state_t *s, int transmit_on_idle); +SPAN_DECLARE(void) t38_gateway_set_transmit_on_idle(t38_gateway_state_t *s, bool transmit_on_idle); /*! Specify which modem types are supported by a T.30 context. \brief Specify supported modems. @@ -165,16 +165,16 @@ SPAN_DECLARE(void) t38_gateway_set_nsx_suppression(t38_gateway_state_t *s, /*! Select whether talker echo protection tone will be sent for the image modems. \brief Select whether TEP will be sent for the image modems. \param s The T.38 context. - \param use_tep TRUE if TEP should be sent. + \param use_tep True if TEP should be sent. */ -SPAN_DECLARE(void) t38_gateway_set_tep_mode(t38_gateway_state_t *s, int use_tep); +SPAN_DECLARE(void) t38_gateway_set_tep_mode(t38_gateway_state_t *s, bool use_tep); /*! Select whether non-ECM fill bits are to be removed during transmission. \brief Select whether non-ECM fill bits are to be removed during transmission. \param s The T.38 context. - \param remove TRUE if fill bits are to be removed. + \param remove True if fill bits are to be removed. */ -SPAN_DECLARE(void) t38_gateway_set_fill_bit_removal(t38_gateway_state_t *s, int remove); +SPAN_DECLARE(void) t38_gateway_set_fill_bit_removal(t38_gateway_state_t *s, bool remove); /*! Get the current transfer statistics for the current T.38 session. \brief Get the current transfer statistics. diff --git a/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h b/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h index 0b1bee6af6..3ca28c3d12 100644 --- a/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h +++ b/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h @@ -83,10 +83,10 @@ extern "C" /*! \brief Initialise a T.38 rate adapting non-ECM buffer context. \param s The buffer context. - \param mode TRUE for image data mode, or FALSE for TCF mode. + \param image_mode True for image data mode, or false for TCF mode. \param bits The minimum number of bits per FAX image row. \return A pointer to the buffer context, or NULL if there was a problem. */ -SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_buffer_state_t *s, int mode, int min_row_bits); +SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_buffer_state_t *s, bool image_mode, int min_row_bits); SPAN_DECLARE(int) t38_non_ecm_buffer_release(t38_non_ecm_buffer_state_t *s); @@ -94,9 +94,9 @@ SPAN_DECLARE(int) t38_non_ecm_buffer_free(t38_non_ecm_buffer_state_t *s); /*! \brief Set the mode of a T.38 rate adapting non-ECM buffer context. \param s The buffer context. - \param mode TRUE for image data mode, or FALSE for TCF mode. + \param mode True for image data mode, or false for TCF mode. \param bits The minimum number of bits per FAX image row. */ -SPAN_DECLARE(void) t38_non_ecm_buffer_set_mode(t38_non_ecm_buffer_state_t *s, int mode, int min_row_bits); +SPAN_DECLARE(void) t38_non_ecm_buffer_set_mode(t38_non_ecm_buffer_state_t *s, bool image_mode, int min_row_bits); /*! \brief Inject data to T.38 rate adapting non-ECM buffer context. \param s The buffer context. diff --git a/libs/spandsp/src/spandsp/t38_terminal.h b/libs/spandsp/src/spandsp/t38_terminal.h index dbf0dca9cb..630fbb80bc 100644 --- a/libs/spandsp/src/spandsp/t38_terminal.h +++ b/libs/spandsp/src/spandsp/t38_terminal.h @@ -72,16 +72,16 @@ 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. \param s The T.38 context. - \param use_tep TRUE if TEP should be allowed for. + \param use_tep True if TEP should be allowed for. */ -SPAN_DECLARE(void) t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_tep); +SPAN_DECLARE(void) t38_terminal_set_tep_mode(t38_terminal_state_t *s, bool use_tep); /*! Select whether non-ECM fill bits are to be removed during transmission. \brief Select whether non-ECM fill bits are to be removed during transmission. \param s The T.38 context. - \param remove TRUE if fill bits are to be removed. + \param remove True if fill bits are to be removed. */ -SPAN_DECLARE(void) t38_terminal_set_fill_bit_removal(t38_terminal_state_t *s, int remove); +SPAN_DECLARE(void) t38_terminal_set_fill_bit_removal(t38_terminal_state_t *s, bool remove); /*! Get a pointer to the T.30 engine associated with a termination mode T.38 context. \brief Get a pointer to the T.30 engine associated with a T.38 context. @@ -108,21 +108,21 @@ SPAN_DECLARE(logging_state_t *) t38_terminal_get_logging_state(t38_terminal_stat /*! \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 + \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); + bool 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 + \param calling_party True if the context is for a calling party. False if the context is for an answering party. \param tx_packet_handler A callback routine to encapsulate and transmit T.38 packets. \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler routine. \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */ SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s, - int calling_party, + bool calling_party, t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data); diff --git a/libs/spandsp/src/spandsp/t42.h b/libs/spandsp/src/spandsp/t42.h index 343780b9fe..17c4758a7f 100644 --- a/libs/spandsp/src/spandsp/t42.h +++ b/libs/spandsp/src/spandsp/t42.h @@ -76,16 +76,6 @@ SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *s, int L_P, int L_Q, int a_P, in SPAN_DECLARE(void) get_lab_gamut2(lab_params_t *s, int *L_P, int *L_Q, int *a_P, int *a_Q, int *b_P, int *b_Q); -SPAN_DECLARE(int) t42_itulab_to_itulab(logging_state_t *logging, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height); - -SPAN_DECLARE(int) t42_itulab_to_jpeg(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen); - -SPAN_DECLARE(int) t42_jpeg_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen); - -SPAN_DECLARE(int) t42_srgb_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height); - -SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s, tdata_t dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t *width, uint32_t *height); - SPAN_DECLARE(void) t42_encode_set_options(t42_encode_state_t *s, uint32_t l0, int quality, int options); SPAN_DECLARE(int) t42_encode_set_image_width(t42_encode_state_t *s, uint32_t image_width); diff --git a/libs/spandsp/src/spandsp/t4_rx.h b/libs/spandsp/src/spandsp/t4_rx.h index ed56cbcf8f..0401d10823 100644 --- a/libs/spandsp/src/spandsp/t4_rx.h +++ b/libs/spandsp/src/spandsp/t4_rx.h @@ -49,68 +49,44 @@ typedef int (*t4_row_write_handler_t)(void *user_data, const uint8_t buf[], size typedef enum { /*! No compression */ - T4_COMPRESSION_NONE = 0, - /*! T.1 1D compression */ - T4_COMPRESSION_T4_1D = 1, + T4_COMPRESSION_NONE = 0x01, + /*! T.4 1D compression */ + T4_COMPRESSION_T4_1D = 0x02, /*! T.4 2D compression */ - T4_COMPRESSION_T4_2D = 2, + T4_COMPRESSION_T4_2D = 0x04, /*! T.6 2D compression */ - T4_COMPRESSION_T6 = 3, + T4_COMPRESSION_T6 = 0x08, /*! T.85 monochrome JBIG coding with L0 fixed. */ - T4_COMPRESSION_T85 = 4, + T4_COMPRESSION_T85 = 0x10, /*! T.85 monochrome JBIG coding with L0 variable. */ - T4_COMPRESSION_T85_L0 = 5, + T4_COMPRESSION_T85_L0 = 0x20, /*! T.43 gray-scale/colour JBIG coding */ - T4_COMPRESSION_T43 = 6, + T4_COMPRESSION_T43 = 0x40, /*! T.45 run length colour compression */ - T4_COMPRESSION_T45 = 7, + T4_COMPRESSION_T45 = 0x80, /*! T.42 + T.81 + T.30 Annex E colour JPEG coding */ - T4_COMPRESSION_T42_T81 = 8, + T4_COMPRESSION_T42_T81 = 0x100, /*! T.42 + T.81 + T.30 Annex K colour sYCC-JPEG coding */ - T4_COMPRESSION_SYCC_T81 = 9, + T4_COMPRESSION_SYCC_T81 = 0x200, /*! T.88 monochrome JBIG2 compression */ - T4_COMPRESSION_T88 = 10 -} t4_image_compression_t; - -enum -{ - /*! No compression */ - T4_SUPPORT_COMPRESSION_NONE = 0x01, - /*! T.1 1D compression */ - T4_SUPPORT_COMPRESSION_T4_1D = 0x02, - /*! T.4 2D compression */ - T4_SUPPORT_COMPRESSION_T4_2D = 0x04, - /*! T.6 2D compression */ - T4_SUPPORT_COMPRESSION_T6 = 0x08, - /*! T.85 monochrome JBIG compression, with fixed L0 */ - T4_SUPPORT_COMPRESSION_T85 = 0x10, - /*! T.85 monochrome JBIG compression, with variable L0 */ - T4_SUPPORT_COMPRESSION_T85_L0 = 0x20, - /*! T.43 colour JBIG compression */ - T4_SUPPORT_COMPRESSION_T43 = 0x40, - /*! T.45 run length colour compression */ - T4_SUPPORT_COMPRESSION_T45 = 0x80, - /*! T.81 + T.30 Annex E colour JPEG compression */ - T4_SUPPORT_COMPRESSION_T42_T81 = 0x100, - /*! T.81 + T.30 Annex K colour sYCC-JPEG compression */ - T4_SUPPORT_COMPRESSION_SYCC_T81 = 0x200, - /*! T.88 monochrome JBIG2 compression */ - T4_SUPPORT_COMPRESSION_T88 = 0x400, + T4_COMPRESSION_T88 = 0x400, + /*! Support solour compression without sub-sampling */ + T4_COMPRESSION_NO_SUBSAMPLING = 0x800000, /*! Gray-scale support by multi-level codecs */ - T4_SUPPORT_COMPRESSION_GRAYSCALE = 0x1000000, + T4_COMPRESSION_GRAYSCALE = 0x1000000, /*! Colour support by multi-level codecs */ - T4_SUPPORT_COMPRESSION_COLOUR = 0x2000000, + T4_COMPRESSION_COLOUR = 0x2000000, /*! 12 bit mode for gray-scale and colour */ - T4_SUPPORT_COMPRESSION_12BIT = 0x4000000, + T4_COMPRESSION_12BIT = 0x4000000, /*! Convert a colour image to a gray-scale one */ - T4_SUPPORT_COMPRESSION_COLOUR_TO_GRAY = 0x8000000, + T4_COMPRESSION_COLOUR_TO_GRAY = 0x8000000, /*! Dither a gray-scale image down a simple bilevel image, with rescaling to fit a FAX page */ - T30_SUPPORT_GRAY_TO_BILEVEL = 0x10000000, + T4_COMPRESSION_GRAY_TO_BILEVEL = 0x10000000, /*! Dither a colour image down a simple bilevel image, with rescaling to fit a FAX page */ - T30_SUPPORT_COLOUR_TO_BILEVEL = 0x20000000, + T4_COMPRESSION_COLOUR_TO_BILEVEL = 0x20000000, /*! Rescale an image (except a bi-level image) to fit a permitted FAX width when necessary */ - T4_SUPPORT_COMPRESSION_RESCALING = 0x40000000 -}; + T4_COMPRESSION_RESCALING = 0x40000000 +} t4_image_compression_t; /*! Image type */ typedef enum @@ -169,71 +145,36 @@ typedef enum enum { /*! Standard FAX resolution 204dpi x 98dpi - bi-level only */ - T4_RESOLUTION_R8_STANDARD = 1, + T4_RESOLUTION_R8_STANDARD = 0x1, /*! Fine FAX resolution 204dpi x 196dpi - bi-level only */ - T4_RESOLUTION_R8_FINE = 2, + T4_RESOLUTION_R8_FINE = 0x2, /*! Super-fine FAX resolution 204dpi x 391dpi - bi-level only */ - T4_RESOLUTION_R8_SUPERFINE = 3, + T4_RESOLUTION_R8_SUPERFINE = 0x4, /*! Double FAX resolution 408dpi x 391dpi - bi-level only */ - T4_RESOLUTION_R16_SUPERFINE = 4, + T4_RESOLUTION_R16_SUPERFINE = 0x8, /*! 100dpi x 100dpi - gray-scale and colour only */ - T4_RESOLUTION_100_100 = 5, + T4_RESOLUTION_100_100 = 0x10, /*! 200dpi x 100dpi - bi-level only */ - T4_RESOLUTION_200_100 = 6, + T4_RESOLUTION_200_100 = 0x20, /*! 200dpi x 200dpi */ - T4_RESOLUTION_200_200 = 7, + T4_RESOLUTION_200_200 = 0x40, /*! 200dpi x 400dpi - bi-level only */ - T4_RESOLUTION_200_400 = 8, + T4_RESOLUTION_200_400 = 0x80, /*! 300dpi x 300dpi */ - T4_RESOLUTION_300_300 = 9, + T4_RESOLUTION_300_300 = 0x100, /*! 300dpi x 600dpi - bi-level only */ - T4_RESOLUTION_300_600 = 10, + T4_RESOLUTION_300_600 = 0x200, /*! 400dpi x 400dpi */ - T4_RESOLUTION_400_400 = 11, + T4_RESOLUTION_400_400 = 0x400, /*! 400dpi x 800dpi - bi-level only */ - T4_RESOLUTION_400_800 = 12, + T4_RESOLUTION_400_800 = 0x800, /*! 600dpi x 600dpi */ - T4_RESOLUTION_600_600 = 13, + T4_RESOLUTION_600_600 = 0x1000, /*! 600dpi x 1200dpi - bi-level only */ - T4_RESOLUTION_600_1200 = 14, + T4_RESOLUTION_600_1200 = 0x2000, /*! 1200dpi x 1200dpi */ - T4_RESOLUTION_1200_1200 = 15 -}; - -enum -{ - /*! Support standard FAX resolution 204dpi x 98dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_R8_STANDARD = 0x1, - /*! Support fine FAX resolution 204dpi x 196dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_R8_FINE = 0x2, - /*! Support super-fine FAX resolution 204dpi x 391dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_R8_SUPERFINE = 0x4, - /*! Support double FAX resolution 408dpi x 391dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_R16_SUPERFINE = 0x8, - - /*! Support 100dpi x 100dpi - gray-scale and colour only */ - T4_SUPPORT_RESOLUTION_100_100 = 0x10, - /*! Support 200dpi x 100dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_200_100 = 0x20, - /*! Support 200dpi x 200dpi */ - T4_SUPPORT_RESOLUTION_200_200 = 0x40, - /*! Support 200dpi x 400dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_200_400 = 0x80, - /*! Support 300dpi x 300dpi */ - T4_SUPPORT_RESOLUTION_300_300 = 0x100, - /*! Support 300dpi x 600dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_300_600 = 0x200, - /*! Support 400dpi x 400dpi */ - T4_SUPPORT_RESOLUTION_400_400 = 0x400, - /*! Support 400dpi x 800dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_400_800 = 0x800, - /*! Support 600dpi x 600dpi */ - T4_SUPPORT_RESOLUTION_600_600 = 0x1000, - /*! Support 600dpi x 1200dpi - bi-level only */ - T4_SUPPORT_RESOLUTION_600_1200 = 0x2000, - /*! Support 1200dpi x 1200dpi */ - T4_SUPPORT_RESOLUTION_1200_1200 = 0x4000 + T4_RESOLUTION_1200_1200 = 0x4000 }; /*! @@ -461,14 +402,14 @@ SPAN_DECLARE(int) t4_rx_start_page(t4_rx_state_t *s); /*! \brief Put a bit of the current document page. \param s The T.4 context. \param bit The data bit. - \return TRUE when the bit ends the document page, otherwise FALSE. */ + \return Decode status. */ SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit); /*! \brief Put a byte of the current document page. \param s The T.4 context. \param buf The buffer containing the chunk. \param len The length of the chunk. - \return TRUE when the byte ends the document page, otherwise FALSE. */ + \return Decode status. */ SPAN_DECLARE(int) t4_rx_put(t4_rx_state_t *s, const uint8_t buf[], size_t len); /*! \brief Complete the reception of a page. diff --git a/libs/spandsp/src/spandsp/t4_t6_decode.h b/libs/spandsp/src/spandsp/t4_t6_decode.h index 16e2348fbc..aa50e5ee60 100644 --- a/libs/spandsp/src/spandsp/t4_t6_decode.h +++ b/libs/spandsp/src/spandsp/t4_t6_decode.h @@ -48,7 +48,7 @@ extern "C" { /*! \brief Put a bit of the current document page. \param s The T.4/T.6 context. \param bit The data bit. - \return TRUE when the bit ends the document page, otherwise FALSE. */ + \return Decode status. */ SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit); /*! \brief Put a byte of the current document page. diff --git a/libs/spandsp/src/spandsp/t4_t6_encode.h b/libs/spandsp/src/spandsp/t4_t6_encode.h index a157b444b9..81c6ddb3e4 100644 --- a/libs/spandsp/src/spandsp/t4_t6_encode.h +++ b/libs/spandsp/src/spandsp/t4_t6_encode.h @@ -77,6 +77,12 @@ SPAN_DECLARE(int) t4_t6_encode_set_encoding(t4_t6_encode_state_t *s, int encodin \return 0 for success, otherwise -1. */ SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int image_width); +/*! \brief Set the length of the image. + \param s The T.4/T.6 context. + \param image_length The image length, in pixels. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_encode_set_image_length(t4_t6_encode_state_t *s, int image_length); + /*! \brief Get the width of the image. \param s The T.4/T.6 context. \return The width of the image, in pixels. */ diff --git a/libs/spandsp/src/spandsp/t4_tx.h b/libs/spandsp/src/spandsp/t4_tx.h index bcf75d6c02..019e2e6cd5 100644 --- a/libs/spandsp/src/spandsp/t4_tx.h +++ b/libs/spandsp/src/spandsp/t4_tx.h @@ -212,6 +212,14 @@ ImageLayer(34732) LONG #define COMPRESSION_T43 10 #endif +typedef enum +{ + T4_IMAGE_FORMAT_OK = 0, + T4_IMAGE_FORMAT_INCOMPATIBLE = -1, + T4_IMAGE_FORMAT_NOSIZESUPPORT = -2, + T4_IMAGE_FORMAT_NORESSUPPORT = -3 +} t4_image_format_status_t; + #if defined(__cplusplus) extern "C" { #endif @@ -267,11 +275,53 @@ SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s); indicates that the end of the document has been reached. */ SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len); -/*! \brief Set the encoding for the encoded data. +/*! \brief Get the compression for the encoded data. \param s The T.4 context. - \param encoding The encoding. - \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding); + \return the chosen compression for success, otherwise -1. */ +SPAN_DECLARE(int) t4_tx_get_tx_compression(t4_tx_state_t *s); + +/*! \brief Get the image type of the encoded data. + \param s The T.4 context. + \return the chosen image type for success, otherwise -1. */ +SPAN_DECLARE(int) t4_tx_get_tx_image_type(t4_tx_state_t *s); + +/*! \brief Get the X and Y resolution code of the current page. + \param s The T.4 context. + \return The resolution code,. */ +SPAN_DECLARE(int) t4_tx_get_tx_resolution(t4_tx_state_t *s); + +/*! \brief Get the column-to-column (x) resolution of the current page. + \param s The T.4 context. + \return The resolution, in pixels per metre. */ +SPAN_DECLARE(int) t4_tx_get_tx_x_resolution(t4_tx_state_t *s); + +/*! \brief Get the row-to-row (y) resolution of the current page. + \param s The T.4 context. + \return The resolution, in pixels per metre. */ +SPAN_DECLARE(int) t4_tx_get_tx_y_resolution(t4_tx_state_t *s); + +/*! \brief Get the width of the encoded data. + \param s The T.4 context. + \return the width, in pixels, for success, otherwise -1. */ +SPAN_DECLARE(int) t4_tx_get_tx_image_width(t4_tx_state_t *s); + +/*! \brief Get the width code of the encoded data. + \param s The T.4 context. + \return the width code, for success, otherwise -1. */ +SPAN_DECLARE(int) t4_tx_get_tx_image_width_code(t4_tx_state_t *s); + +/*! \brief Auto-select the format in which to send the image. + \param s The T.4 context. + \param supported_compressions The set of compressions supported for this transmission + \param supported_image_sizes The set of image sizes supported for this transmission + \param supported_bilevel_resolutions The set of bi-level resolutions supported for this transmission + \param supported_colour_resolutions The set of gray scale and colour resolutions supported for this transmission + \return A t4_image_format_status_t result code */ +SPAN_DECLARE(int) t4_tx_set_tx_image_format(t4_tx_state_t *s, + int supported_compressions, + int supported_image_sizes, + int supported_bilevel_resolutions, + int supported_colour_resolutions); /*! \brief Set the minimum number of encoded bits per row. This allows the makes the encoding process to be set to comply with the minimum row @@ -280,11 +330,6 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding); \param bits The minimum number of bits per row. */ SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits); -/*! \brief Set the width of the image. - \param s The T.4 context. - \param image_width The image width, in pixels. */ -SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width); - /*! \brief Set the maximum number of 2D encoded rows between 1D encoded rows. This is only valid for T.4 2D encoding. \param s The T.4 context. @@ -315,8 +360,8 @@ SPAN_DECLARE(void) t4_tx_set_header_tz(t4_tx_state_t *s, tz_t *tz); /*! Set page header extends or overlays the image mode. \brief Set page header overlay mode. \param s The T.4 context. - \param header_overlays_image TRUE for overlay, or FALSE for extend the page. */ -SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, int header_overlays_image); + \param header_overlays_image True for overlay, or false to extend the page. */ +SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, bool header_overlays_image); /*! \brief Set the row read handler for a T.4 transmit context. \param s The T.4 transmit context. @@ -325,37 +370,6 @@ SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, int header_ \return 0 for success, otherwise -1. */ SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, void *user_data); -/*! \brief Set the row squashing ratio, for adjusting row-to-row (y) resolution of bi-level - images for a T.4 transmit context. - \param s The T.4 transmit context. - \param row_squashing_ratio Vertical squashing ratio. */ -SPAN_DECLARE(void) t4_tx_set_row_squashing_ratio(t4_tx_state_t *s, int row_squashing_ratio); - -/*! \brief Get the row-to-row (y) resolution of the current page. - \param s The T.4 context. - \return The resolution, in pixels per metre. */ -SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_tx_state_t *s); - -/*! \brief Get the column-to-column (x) resolution of the current page. - \param s The T.4 context. - \return The resolution, in pixels per metre. */ -SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_tx_state_t *s); - -/*! \brief Get the X and Y resolution code of the current page. - \param s The T.4 context. - \return The resolution code,. */ -SPAN_DECLARE(int) t4_tx_get_resolution(t4_tx_state_t *s); - -/*! \brief Get the width of the current page, in pixel columns. - \param s The T.4 context. - \return The number of columns. */ -SPAN_DECLARE(int) t4_tx_get_image_width(t4_tx_state_t *s); - -/*! \brief Get the type of the current page, in pixel columns. - \param s The T.4 context. - \return The type. */ -SPAN_DECLARE(int) t4_tx_get_image_type(t4_tx_state_t *s); - /*! \brief Get the number of pages in the file. \param s The T.4 context. \return The number of pages, or -1 if there is an error. */ diff --git a/libs/spandsp/src/spandsp/telephony.h b/libs/spandsp/src/spandsp/telephony.h index 132cce9bf8..b32ecfa0f5 100644 --- a/libs/spandsp/src/spandsp/telephony.h +++ b/libs/spandsp/src/spandsp/telephony.h @@ -70,13 +70,6 @@ typedef int (*span_tx_handler_t)(void *s, int16_t amp[], int max_len); #define ms_to_samples(t) ((t)*(SAMPLE_RATE/1000)) #define us_to_samples(t) ((t)/(1000000/SAMPLE_RATE)) -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - /* Fixed point constant macros */ #define FP_Q_9_7(x) ((int16_t) (128.0*x + ((x >= 0.0) ? 0.5 : -0.5))) #define FP_Q_8_8(x) ((int16_t) (256.0*x + ((x >= 0.0) ? 0.5 : -0.5))) diff --git a/libs/spandsp/src/spandsp/v17rx.h b/libs/spandsp/src/spandsp/v17rx.h index 21c34f5b29..74c4b1dd8e 100644 --- a/libs/spandsp/src/spandsp/v17rx.h +++ b/libs/spandsp/src/spandsp/v17rx.h @@ -239,9 +239,9 @@ SPAN_DECLARE(v17_rx_state_t *) v17_rx_init(v17_rx_state_t *s, int bit_rate, put_ \brief Reinitialise an existing V.17 modem receive context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. - \param short_train TRUE if a short training sequence is expected. + \param short_train True if a short training sequence is expected. \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_train); +SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, bool short_train); /*! Release a V.17 modem receive context. \brief Release a V.17 modem receive context. diff --git a/libs/spandsp/src/spandsp/v17tx.h b/libs/spandsp/src/spandsp/v17tx.h index 0d98cc7010..02fb7309ad 100644 --- a/libs/spandsp/src/spandsp/v17tx.h +++ b/libs/spandsp/src/spandsp/v17tx.h @@ -101,20 +101,20 @@ SPAN_DECLARE(void) v17_tx_power(v17_tx_state_t *s, float power); \brief Initialise a V.17 modem transmit context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. - \param tep TRUE is the optional TEP tone is to be transmitted. + \param tep True is the optional TEP tone is to be transmitted. \param get_bit The callback routine used to get the data to be transmitted. \param user_data An opaque pointer. \return A pointer to the modem context, or NULL if there was a problem. */ -SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data); +SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, bool tep, get_bit_func_t get_bit, void *user_data); /*! Reinitialise an existing V.17 modem transmit context, so it may be reused. \brief Reinitialise an existing V.17 modem transmit context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. - \param tep TRUE is the optional TEP tone is to be transmitted. - \param short_train TRUE if the short training sequence should be used. + \param tep True is the optional TEP tone is to be transmitted. + \param short_train True if the short training sequence should be used. \return 0 for OK, -1 for parameter error. */ -SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int short_train); +SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, bool tep, bool short_train); /*! Release a V.17 modem transmit context. \brief Release a V.17 modem transmit context. diff --git a/libs/spandsp/src/spandsp/v18.h b/libs/spandsp/src/spandsp/v18.h index fbd4994a59..04c0db7c15 100644 --- a/libs/spandsp/src/spandsp/v18.h +++ b/libs/spandsp/src/spandsp/v18.h @@ -38,28 +38,34 @@ typedef struct v18_state_s v18_state_t; enum { - V18_MODE_NONE = 0, + V18_MODE_NONE = 0x0001, /* V.18 Annex A - Weitbrecht TDD at 45.45bps (US TTY), half-duplex, 5 bit baudot (USA). */ - V18_MODE_5BIT_45 = 1, + V18_MODE_5BIT_4545 = 0x0002, /* V.18 Annex A - Weitbrecht TDD at 50bps (International TTY), half-duplex, 5 bit baudot (UK, Australia and others). */ - V18_MODE_5BIT_50 = 2, + V18_MODE_5BIT_50 = 0x0004, /* V.18 Annex B - DTMF encoding of ASCII (Denmark, Holland and others). */ - V18_MODE_DTMF = 3, + V18_MODE_DTMF = 0x0008, /* V.18 Annex C - EDT (European Deaf Telephone) 110bps, V.21, half-duplex, ASCII (Germany, Austria, Switzerland and others). */ - V18_MODE_EDT = 4, + V18_MODE_EDT = 0x0010, /* V.18 Annex D - 300bps, Bell 103, duplex, ASCII (USA). */ - V18_MODE_BELL103 = 5, + V18_MODE_BELL103 = 0x0020, /* V.18 Annex E - 1200bps Videotex terminals, ASCII (France). */ - V18_MODE_V23VIDEOTEX = 6, + V18_MODE_V23VIDEOTEX = 0x0040, /* V.18 Annex F - V.21 text telephone, V.21, duplex, ASCII (Sweden, Norway and Finland). */ - V18_MODE_V21TEXTPHONE = 7, + V18_MODE_V21TEXTPHONE = 0x0080, /* V.18 Annex G - V.18 text telephone mode. */ - V18_MODE_V18TEXTPHONE = 8 + V18_MODE_V18TEXTPHONE = 0x0100, + /* V.18 Annex A - Used during probing. */ + V18_MODE_5BIT_476 = 0x0200, + /* Use repetitive shift characters where character set shifts are used */ + V18_MODE_REPETITIVE_SHIFTS_OPTION = 0x1000 }; /* Automoding sequences for different countries */ enum { + V18_AUTOMODING_GLOBAL = 0, + /* 5-bit, V.21, V.23, EDT, DTMF, Bell 103 */ V18_AUTOMODING_AUSTRALIA, V18_AUTOMODING_IRELAND, @@ -89,7 +95,9 @@ enum /* V.23, EDT, DTMF, 5-bit, V.21, Bell 103 */ V18_AUTOMODING_FRANCE, - V18_AUTOMODING_BELGIUM + V18_AUTOMODING_BELGIUM, + + V18_AUTOMODING_END }; #if defined(__cplusplus) @@ -102,15 +110,17 @@ SPAN_DECLARE(logging_state_t *) v18_get_logging_state(v18_state_t *s); /*! Initialise a V.18 context. \brief Initialise a V.18 context. \param s The V.18 context. - \param calling_party TRUE if caller mode, else answerer mode. + \param calling_party True if caller mode, else answerer mode. \param mode Mode of operation. + \param nation National variant for automoding. \param put_msg A callback routine called to deliver the received text to the application. \param user_data An opaque pointer for the callback routine. \return A pointer to the V.18 context, or NULL if there was a problem. */ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s, - int calling_party, + bool calling_party, int mode, + int nation, put_msg_func_t put_msg, void *user_data); @@ -163,28 +173,6 @@ SPAN_DECLARE_NONSTD(int) v18_rx_fillin(v18_state_t *s, int len); invalid, this function will return -1. */ SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len); -/*! Convert a text string to a V.18 DTMF string. - \brief Convert a text string to a V.18 DTMF string. - \param s The V.18 context. - \param dtmf The resulting DTMF string. - \param msg The text string to be converted. - \return The length of the DTMF string. -*/ -SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[]); - -/*! Convert a V.18 DTMF string to a text string. - \brief Convert a V.18 DTMF string to a text string. - \param s The V.18 context. - \param msg The resulting test string. - \param dtmf The DTMF string to be converted. - \return The length of the text string. -*/ -SPAN_DECLARE(int) v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[]); - -SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch); - -SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch); - /*! \brief Return a short name for an V.18 mode \param mode The code for the V.18 mode. \return A pointer to the name. diff --git a/libs/spandsp/src/spandsp/v22bis.h b/libs/spandsp/src/spandsp/v22bis.h index 6361c05841..f20656919f 100644 --- a/libs/spandsp/src/spandsp/v22bis.h +++ b/libs/spandsp/src/spandsp/v22bis.h @@ -155,9 +155,9 @@ SPAN_DECLARE(int) v22bis_request_retrain(v22bis_state_t *s, int bit_rate); /*! Request a loopback 2 for a V.22bis modem context. \brief Request a loopback 2 for a V.22bis modem context. \param s The modem context. - \param enable TRUE to enable loopback, or FALSE to disable it. + \param enable True to enable loopback, or false to disable it. \return 0 for OK, -1 for request reject. */ -SPAN_DECLARE(int) v22bis_remote_loopback(v22bis_state_t *s, int enable); +SPAN_DECLARE(int) v22bis_remote_loopback(v22bis_state_t *s, bool enable); /*! 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 @@ -170,7 +170,7 @@ SPAN_DECLARE(int) v22bis_get_current_bit_rate(v22bis_state_t *s); \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400. \param guard The guard tone option. 0 = none, 1 = 550Hz, 2 = 1800Hz. - \param calling_party TRUE if this is the calling modem. + \param calling_party True if this is the calling modem. \param get_bit The callback routine used to get the data to be transmitted. \param put_bit The callback routine used to get the data to be transmitted. \param user_data An opaque pointer, passed in calls to the get and put routines. @@ -178,7 +178,7 @@ SPAN_DECLARE(int) v22bis_get_current_bit_rate(v22bis_state_t *s); SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s, int bit_rate, int guard, - int calling_party, + bool calling_party, get_bit_func_t get_bit, void *get_bit_user_data, put_bit_func_t put_bit, diff --git a/libs/spandsp/src/spandsp/v27ter_rx.h b/libs/spandsp/src/spandsp/v27ter_rx.h index 5881f4cf02..80fdb3655f 100644 --- a/libs/spandsp/src/spandsp/v27ter_rx.h +++ b/libs/spandsp/src/spandsp/v27ter_rx.h @@ -74,9 +74,9 @@ SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_r \brief Reinitialise an existing V.27ter modem receive context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800. - \param old_train TRUE if a previous trained values are to be reused. + \param old_train True if a previous trained values are to be reused. \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_train); +SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, bool old_train); /*! Release a V.27ter modem receive context. \brief Release a V.27ter modem receive context. diff --git a/libs/spandsp/src/spandsp/v27ter_tx.h b/libs/spandsp/src/spandsp/v27ter_tx.h index e785c889ec..fba064fea0 100644 --- a/libs/spandsp/src/spandsp/v27ter_tx.h +++ b/libs/spandsp/src/spandsp/v27ter_tx.h @@ -83,19 +83,19 @@ SPAN_DECLARE(void) v27ter_tx_power(v27ter_tx_state_t *s, float power); \brief Initialise a V.27ter modem transmit context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800. - \param tep TRUE is the optional TEP tone is to be transmitted. + \param tep True is the optional TEP tone is to be transmitted. \param get_bit The callback routine used to get the data to be transmitted. \param user_data An opaque pointer. \return A pointer to the modem context, or NULL if there was a problem. */ -SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data); +SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_rate, bool tep, get_bit_func_t get_bit, void *user_data); /*! Reinitialise an existing V.27ter modem transmit context, so it may be reused. \brief Reinitialise an existing V.27ter modem transmit context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800. - \param tep TRUE is the optional TEP tone is to be transmitted. + \param tep True is the optional TEP tone is to be transmitted. \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep); +SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, bool tep); /*! Release a V.27ter modem transmit context. \brief Release a V.27ter modem transmit context. diff --git a/libs/spandsp/src/spandsp/v29rx.h b/libs/spandsp/src/spandsp/v29rx.h index ec3a945ad4..378d4fe955 100644 --- a/libs/spandsp/src/spandsp/v29rx.h +++ b/libs/spandsp/src/spandsp/v29rx.h @@ -154,9 +154,9 @@ SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int bit_rate, put_ \brief Reinitialise an existing V.29 modem receive context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 4800, 7200 and 9600. - \param old_train TRUE if a previous trained values are to be reused. + \param old_train True if a previous trained values are to be reused. \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train); +SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, bool old_train); /*! Release a V.29 modem receive context. \brief Release a V.29 modem receive context. diff --git a/libs/spandsp/src/spandsp/v29tx.h b/libs/spandsp/src/spandsp/v29tx.h index 86737d1ba3..18bcf66b6a 100644 --- a/libs/spandsp/src/spandsp/v29tx.h +++ b/libs/spandsp/src/spandsp/v29tx.h @@ -114,19 +114,19 @@ SPAN_DECLARE(void) v29_tx_power(v29_tx_state_t *s, float power); \brief Initialise a V.29 modem transmit context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 4800, 7200 and 9600. - \param tep TRUE is the optional TEP tone is to be transmitted. + \param tep True is the optional TEP tone is to be transmitted. \param get_bit The callback routine used to get the data to be transmitted. \param user_data An opaque pointer. \return A pointer to the modem context, or NULL if there was a problem. */ -SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data); +SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, bool tep, get_bit_func_t get_bit, void *user_data); /*! Reinitialise an existing V.29 modem transmit context, so it may be reused. \brief Reinitialise an existing V.29 modem transmit context. \param s The modem context. \param bit_rate The bit rate of the modem. Valid values are 4800, 7200 and 9600. - \param tep TRUE is the optional TEP tone is to be transmitted. + \param tep True is the optional TEP tone is to be transmitted. \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep); +SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, bool tep); /*! Release a V.29 modem transmit context. \brief Release a V.29 modem transmit context. diff --git a/libs/spandsp/src/spandsp/v42.h b/libs/spandsp/src/spandsp/v42.h index 6332e5cd61..8002d43eed 100644 --- a/libs/spandsp/src/spandsp/v42.h +++ b/libs/spandsp/src/spandsp/v42.h @@ -78,16 +78,16 @@ SPAN_DECLARE(logging_state_t *) v42_get_logging_state(v42_state_t *s); /*! Initialise a V.42 context. \param s The V.42 context. - \param calling_party TRUE if caller mode, else answerer mode. - \param detect TRUE to perform the V.42 detection, else go straight into LAP.M + \param calling_party True if caller mode, else answerer mode. + \param detect True to perform the V.42 detection, else go straight into LAP.M \param iframe_get A callback function to handle received frames of data. \param iframe_put A callback function to get frames of data for transmission. \param user_data An opaque pointer passed to the frame handler routines. \return ??? */ SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, - int calling_party, - int detect, + bool calling_party, + bool detect, get_msg_func_t iframe_get, put_msg_func_t iframe_put, void *user_data); diff --git a/libs/spandsp/src/spandsp/v8.h b/libs/spandsp/src/spandsp/v8.h index 0c1924c1e8..9ded271aec 100644 --- a/libs/spandsp/src/spandsp/v8.h +++ b/libs/spandsp/src/spandsp/v8.h @@ -135,19 +135,19 @@ extern "C" #endif SPAN_DECLARE(int) v8_restart(v8_state_t *s, - int calling_party, + bool calling_party, v8_parms_t *parms); /*! Initialise a V.8 context. \brief Initialise a V.8 context. \param s The V.8 context. - \param calling_party TRUE if caller mode, else answerer mode. + \param calling_party True if caller mode, else answerer mode. \param parms The allowed parameters for the call. \param result_handler The callback routine used to handle the results of negotiation. \param user_data An opaque pointer passed to the result_handler routine. \return A pointer to the V.8 context, or NULL if there was a problem. */ SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s, - int calling_party, + bool calling_party, v8_parms_t *parms, v8_result_handler_t result_handler, void *user_data); diff --git a/libs/spandsp/src/super_tone_rx.c b/libs/spandsp/src/super_tone_rx.c index e46faa8148..eabebe6a30 100644 --- a/libs/spandsp/src/super_tone_rx.c +++ b/libs/spandsp/src/super_tone_rx.c @@ -45,6 +45,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/complex.h" #include "spandsp/vector_float.h" @@ -95,7 +96,7 @@ static int add_super_tone_freq(super_tone_rx_descriptor_t *desc, int freq) desc->pitches[i][1] = desc->monitored_frequencies; if (desc->monitored_frequencies%5 == 0) { - desc->desc = (goertzel_descriptor_t *) realloc(desc->desc, (desc->monitored_frequencies + 5)*sizeof(goertzel_descriptor_t)); + desc->desc = (goertzel_descriptor_t *) span_realloc(desc->desc, (desc->monitored_frequencies + 5)*sizeof(goertzel_descriptor_t)); } make_goertzel_descriptor(&desc->desc[desc->monitored_frequencies++], (float) freq, SUPER_TONE_BINS); desc->used_frequencies++; @@ -107,8 +108,8 @@ SPAN_DECLARE(int) super_tone_rx_add_tone(super_tone_rx_descriptor_t *desc) { if (desc->tones%5 == 0) { - desc->tone_list = (super_tone_rx_segment_t **) realloc(desc->tone_list, (desc->tones + 5)*sizeof(super_tone_rx_segment_t *)); - desc->tone_segs = (int *) realloc(desc->tone_segs, (desc->tones + 5)*sizeof(int)); + desc->tone_list = (super_tone_rx_segment_t **) span_realloc(desc->tone_list, (desc->tones + 5)*sizeof(super_tone_rx_segment_t *)); + desc->tone_segs = (int *) span_realloc(desc->tone_segs, (desc->tones + 5)*sizeof(int)); } desc->tone_list[desc->tones] = NULL; desc->tone_segs[desc->tones] = 0; @@ -129,7 +130,7 @@ SPAN_DECLARE(int) super_tone_rx_add_element(super_tone_rx_descriptor_t *desc, step = desc->tone_segs[tone]; if (step%5 == 0) { - desc->tone_list[tone] = (super_tone_rx_segment_t *) realloc(desc->tone_list[tone], (step + 5)*sizeof(super_tone_rx_segment_t)); + desc->tone_list[tone] = (super_tone_rx_segment_t *) span_realloc(desc->tone_list[tone], (step + 5)*sizeof(super_tone_rx_segment_t)); } desc->tone_list[tone][step].f1 = add_super_tone_freq(desc, f1); desc->tone_list[tone][step].f2 = add_super_tone_freq(desc, f2); @@ -199,7 +200,7 @@ SPAN_DECLARE(super_tone_rx_descriptor_t *) super_tone_rx_make_descriptor(super_t { if (desc == NULL) { - if ((desc = (super_tone_rx_descriptor_t *) malloc(sizeof(*desc))) == NULL) + if ((desc = (super_tone_rx_descriptor_t *) span_alloc(sizeof(*desc))) == NULL) return NULL; } desc->tone_list = NULL; @@ -222,15 +223,15 @@ SPAN_DECLARE(int) super_tone_rx_free_descriptor(super_tone_rx_descriptor_t *desc for (i = 0; i < desc->tones; i++) { if (desc->tone_list[i]) - free(desc->tone_list[i]); + span_free(desc->tone_list[i]); } if (desc->tone_list) - free(desc->tone_list); + span_free(desc->tone_list); if (desc->tone_segs) - free(desc->tone_segs); + span_free(desc->tone_segs); if (desc->desc) - free(desc->desc); - free(desc); + span_free(desc->desc); + span_free(desc); } return 0; } @@ -265,7 +266,7 @@ SPAN_DECLARE(super_tone_rx_state_t *) super_tone_rx_init(super_tone_rx_state_t * return NULL; if (s == NULL) { - if ((s = (super_tone_rx_state_t *) malloc(sizeof(*s) + desc->monitored_frequencies*sizeof(goertzel_state_t))) == NULL) + if ((s = (super_tone_rx_state_t *) span_alloc(sizeof(*s) + desc->monitored_frequencies*sizeof(goertzel_state_t))) == NULL) return NULL; } @@ -301,7 +302,7 @@ SPAN_DECLARE(int) super_tone_rx_release(super_tone_rx_state_t *s) SPAN_DECLARE(int) super_tone_rx_free(super_tone_rx_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/super_tone_tx.c b/libs/spandsp/src/super_tone_tx.c index 3809bb4bf8..5b8ab4303d 100644 --- a/libs/spandsp/src/super_tone_tx.c +++ b/libs/spandsp/src/super_tone_tx.c @@ -45,6 +45,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/complex.h" #include "spandsp/dds.h" @@ -78,7 +79,7 @@ SPAN_DECLARE(super_tone_tx_step_t *) super_tone_tx_make_step(super_tone_tx_step_ { if (s == NULL) { - if ((s = (super_tone_tx_step_t *) malloc(sizeof(*s))) == NULL) + if ((s = (super_tone_tx_step_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } if (f1 >= 1.0f) @@ -121,7 +122,7 @@ SPAN_DECLARE(int) super_tone_tx_free_tone(super_tone_tx_step_t *s) super_tone_tx_free_tone(s->nest); t = s; s = s->next; - free(t); + span_free(t); } return 0; } @@ -133,7 +134,7 @@ SPAN_DECLARE(super_tone_tx_state_t *) super_tone_tx_init(super_tone_tx_state_t * return NULL; if (s == NULL) { - if ((s = (super_tone_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (super_tone_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -155,7 +156,7 @@ SPAN_DECLARE(int) super_tone_tx_release(super_tone_tx_state_t *s) SPAN_DECLARE(int) super_tone_tx_free(super_tone_tx_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/swept_tone.c b/libs/spandsp/src/swept_tone.c index f5ccc9bed8..d371bb2828 100644 --- a/libs/spandsp/src/swept_tone.c +++ b/libs/spandsp/src/swept_tone.c @@ -39,9 +39,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/complex.h" #include "spandsp/vector_float.h" @@ -59,7 +65,7 @@ SPAN_DECLARE(swept_tone_state_t *) swept_tone_init(swept_tone_state_t *s, float { if (s == NULL) { - if ((s = (swept_tone_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (swept_tone_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -119,7 +125,7 @@ SPAN_DECLARE(int) swept_tone_release(swept_tone_state_t *s) SPAN_DECLARE(int) swept_tone_free(swept_tone_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index 66a5271bf3..1d3555a97d 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -41,10 +41,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/queue.h" @@ -434,8 +440,7 @@ static void disconnect(t30_state_t *s); static void decode_20digit_msg(t30_state_t *s, char *msg, const uint8_t *pkt, int len); static void decode_url_msg(t30_state_t *s, char *msg, const uint8_t *pkt, int len); static int decode_nsf_nss_nsc(t30_state_t *s, uint8_t *msg[], const uint8_t *pkt, int len); -static int set_min_scan_time_code(t30_state_t *s); -static int send_cfr_sequence(t30_state_t *s, int start); +static void set_min_scan_time(t30_state_t *s); static void timer_t2_start(t30_state_t *s); static void timer_t2a_start(t30_state_t *s); static void timer_t2b_start(t30_state_t *s); @@ -637,89 +642,89 @@ static void release_resources(t30_state_t *s) { if (s->tx_info.nsf) { - free(s->tx_info.nsf); + span_free(s->tx_info.nsf); s->tx_info.nsf = NULL; } s->tx_info.nsf_len = 0; if (s->tx_info.nsc) { - free(s->tx_info.nsc); + span_free(s->tx_info.nsc); s->tx_info.nsc = NULL; } s->tx_info.nsc_len = 0; if (s->tx_info.nss) { - free(s->tx_info.nss); + span_free(s->tx_info.nss); s->tx_info.nss = NULL; } s->tx_info.nss_len = 0; if (s->tx_info.tsa) { - free(s->tx_info.tsa); + span_free(s->tx_info.tsa); s->tx_info.tsa = NULL; } if (s->tx_info.ira) { - free(s->tx_info.ira); + span_free(s->tx_info.ira); s->tx_info.ira = NULL; } if (s->tx_info.cia) { - free(s->tx_info.cia); + span_free(s->tx_info.cia); s->tx_info.cia = NULL; } if (s->tx_info.isp) { - free(s->tx_info.isp); + span_free(s->tx_info.isp); s->tx_info.isp = NULL; } if (s->tx_info.csa) { - free(s->tx_info.csa); + span_free(s->tx_info.csa); s->tx_info.csa = NULL; } if (s->rx_info.nsf) { - free(s->rx_info.nsf); + span_free(s->rx_info.nsf); s->rx_info.nsf = NULL; } s->rx_info.nsf_len = 0; if (s->rx_info.nsc) { - free(s->rx_info.nsc); + span_free(s->rx_info.nsc); s->rx_info.nsc = NULL; } s->rx_info.nsc_len = 0; if (s->rx_info.nss) { - free(s->rx_info.nss); + span_free(s->rx_info.nss); s->rx_info.nss = NULL; } s->rx_info.nss_len = 0; if (s->rx_info.tsa) { - free(s->rx_info.tsa); + span_free(s->rx_info.tsa); s->rx_info.tsa = NULL; } if (s->rx_info.ira) { - free(s->rx_info.ira); + span_free(s->rx_info.ira); s->rx_info.ira = NULL; } if (s->rx_info.cia) { - free(s->rx_info.cia); + span_free(s->rx_info.cia); s->rx_info.cia = NULL; } if (s->rx_info.isp) { - free(s->rx_info.isp); + span_free(s->rx_info.isp); s->rx_info.isp = NULL; } if (s->rx_info.csa) { - free(s->rx_info.csa); + span_free(s->rx_info.csa); s->rx_info.csa = NULL; } } @@ -748,7 +753,7 @@ static uint8_t check_next_tx_step(t30_state_t *s) if (s->document_handler) more = s->document_handler(s, s->document_user_data, 0); else - more = FALSE; + more = false; if (more) { span_log(&s->logging, SPAN_LOG_FLOW, "Another document to send\n"); @@ -795,7 +800,7 @@ static int get_partial_ecm_page(t30_state_t *s) } s->ecm_frames = i; span_log(&s->logging, SPAN_LOG_FLOW, "Partial page buffer contains %d frames (%d per frame)\n", i, s->octets_per_ecm_frame); - s->ecm_at_page_end = TRUE; + s->ecm_at_page_end = true; return i; } s->ecm_len[i] = (int16_t) (4 + len); @@ -844,7 +849,7 @@ static int send_next_ecm_frame(t30_state_t *s) send_frame(s, frame, 3); /* In case we are just after a CTC/CTR exchange, which kicked us back to long training */ - s->short_train = TRUE; + s->short_train = true; return 0; } return -1; @@ -892,7 +897,7 @@ static void send_frame(t30_state_t *s, const uint8_t *msg, int len) print_frame(s, "Tx: ", msg, len); if (s->real_time_frame_handler) - s->real_time_frame_handler(s, s->real_time_frame_user_data, FALSE, msg, len); + s->real_time_frame_handler(s, s->real_time_frame_user_data, false, msg, len); if (s->send_hdlc_handler) s->send_hdlc_handler(s->send_hdlc_user_data, msg, len); } @@ -939,9 +944,9 @@ static int send_nsf_frame(t30_state_t *s) s->tx_info.nsf[1] = CONTROL_FIELD_NON_FINAL_FRAME; s->tx_info.nsf[2] = (uint8_t) (T30_NSF | s->dis_received); send_frame(s, s->tx_info.nsf, s->tx_info.nsf_len + 3); - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -955,9 +960,9 @@ static int send_nss_frame(t30_state_t *s) s->tx_info.nss[1] = CONTROL_FIELD_NON_FINAL_FRAME; s->tx_info.nss[2] = (uint8_t) (T30_NSS | s->dis_received); send_frame(s, s->tx_info.nss, s->tx_info.nss_len + 3); - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -971,9 +976,9 @@ static int send_nsc_frame(t30_state_t *s) s->tx_info.nsc[1] = CONTROL_FIELD_NON_FINAL_FRAME; s->tx_info.nsc[2] = (uint8_t) (T30_NSC | s->dis_received); send_frame(s, s->tx_info.nsc, s->tx_info.nsc_len + 3); - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -984,9 +989,9 @@ static int send_ident_frame(t30_state_t *s, uint8_t cmd) span_log(&s->logging, SPAN_LOG_FLOW, "Sending ident '%s'\n", s->tx_info.ident); /* 'cmd' should be T30_TSI, T30_CIG or T30_CSI */ send_20digit_msg_frame(s, cmd, s->tx_info.ident); - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -997,10 +1002,10 @@ static int send_psa_frame(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Sending polled sub-address '%s'\n", s->tx_info.polled_sub_address); send_20digit_msg_frame(s, T30_PSA, s->tx_info.polled_sub_address); set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE); - return TRUE; + return true; } clr_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1011,10 +1016,10 @@ static int send_sep_frame(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Sending selective polling address '%s'\n", s->tx_info.selective_polling_address); send_20digit_msg_frame(s, T30_SEP, s->tx_info.selective_polling_address); set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE); - return TRUE; + return true; } clr_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1026,10 +1031,10 @@ static int send_sid_frame(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Sending sender identification '%s'\n", s->tx_info.sender_ident); send_20digit_msg_frame(s, T30_SID, s->tx_info.sender_ident); set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_SENDER_ID_TRANSMISSION); - return TRUE; + return true; } clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_SENDER_ID_TRANSMISSION); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1041,10 +1046,10 @@ static int send_pwd_frame(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Sending password '%s'\n", s->tx_info.password); send_20digit_msg_frame(s, T30_PWD, s->tx_info.password); set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_PASSWORD); - return TRUE; + return true; } clr_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_PASSWORD); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1056,10 +1061,10 @@ static int send_sub_frame(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Sending sub-address '%s'\n", s->tx_info.sub_address); send_20digit_msg_frame(s, T30_SUB, s->tx_info.sub_address); set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_SUBADDRESS_TRANSMISSION); - return TRUE; + return true; } clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_SUBADDRESS_TRANSMISSION); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1068,9 +1073,9 @@ static int send_tsa_frame(t30_state_t *s) if ((test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T37) || test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T38)) && 0) { span_log(&s->logging, SPAN_LOG_FLOW, "Sending transmitting subscriber internet address '%s'\n", ""); - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1080,10 +1085,10 @@ static int send_ira_frame(t30_state_t *s) { span_log(&s->logging, SPAN_LOG_FLOW, "Sending internet routing address '%s'\n", ""); set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INTERNET_ROUTING_ADDRESS_TRANSMISSION); - return TRUE; + return true; } clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INTERNET_ROUTING_ADDRESS_TRANSMISSION); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1092,9 +1097,9 @@ static int send_cia_frame(t30_state_t *s) if ((test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T37) || test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T38)) && 0) { span_log(&s->logging, SPAN_LOG_FLOW, "Sending calling subscriber internet address '%s'\n", ""); - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1104,10 +1109,10 @@ static int send_isp_frame(t30_state_t *s) { span_log(&s->logging, SPAN_LOG_FLOW, "Sending internet selective polling address '%s'\n", ""); set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS); - return TRUE; + return true; } clr_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1117,10 +1122,10 @@ static int send_csa_frame(t30_state_t *s) if (("in T.37 mode" || "in T.38 mode") && 0) { span_log(&s->logging, SPAN_LOG_FLOW, "Sending called subscriber internet address '%s'\n", ""); - return TRUE; + return true; } #endif - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1195,9 +1200,9 @@ int t30_build_dis_or_dtc(t30_state_t *s) /* No scan-line padding required, but some may be specified by the application. */ set_ctrl_bits(s->local_dis_dtc_frame, s->local_min_scan_time_code, T30_DIS_BIT_MIN_SCAN_LINE_TIME_CAPABILITY_1); - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T4_2D)) + if ((s->supported_compressions & T4_COMPRESSION_T4_2D)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE); - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_NONE)) + if ((s->supported_compressions & T4_COMPRESSION_NONE)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_UNCOMPRESSED_CAPABLE); if (s->ecm_allowed) { @@ -1206,50 +1211,55 @@ int t30_build_dis_or_dtc(t30_state_t *s) /* Only offer the option of fancy compression schemes, if we are also offering the ECM option needed to support them. */ - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T6)) + if ((s->supported_compressions & T4_COMPRESSION_T6)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE); - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T85)) + if ((s->supported_compressions & T4_COMPRESSION_T85)) { set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE); /* Bit 79 set with bit 78 clear is invalid, so only check for L0 support here. */ - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T85_L0)) + if ((s->supported_compressions & T4_COMPRESSION_T85_L0)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE); } - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_COLOUR)) - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_FULL_COLOUR_CAPABLE); - - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T42_T81)) - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE); - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T43)) - { - /* Note 25 of table 2/T.30 */ - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE); - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE); - } - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T45)) - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T45_CAPABLE); - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_SYCC_T81)) - { - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE); - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SYCC_T81_CAPABLE); - } - //if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T88)) + //if ((s->supported_compressions & T4_COMPRESSION_T88)) //{ // set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T88_CAPABILITY_1); // set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T88_CAPABILITY_2); // set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T88_CAPABILITY_3); //} - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_12BIT)) - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE); + if ((s->supported_compressions & (T4_COMPRESSION_COLOUR | T4_COMPRESSION_GRAYSCALE))) + { + if ((s->supported_compressions & T4_COMPRESSION_COLOUR)) + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_FULL_COLOUR_CAPABLE); - //if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_NO_SUBSAMPLING)) - // set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_NO_SUBSAMPLING); + if ((s->supported_compressions & T4_COMPRESSION_T42_T81)) + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE); + if ((s->supported_compressions & T4_COMPRESSION_T43)) + { + /* Note 25 of table 2/T.30 */ + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE); + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE); + /* No plane interleave */ + } + if ((s->supported_compressions & T4_COMPRESSION_T45)) + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T45_CAPABLE); + if ((s->supported_compressions & T4_COMPRESSION_SYCC_T81)) + { + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE); + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SYCC_T81_CAPABLE); + } - /* No custom illuminant */ - /* No custom gamut range */ + if ((s->supported_compressions & T4_COMPRESSION_12BIT)) + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE); + + if ((s->supported_compressions & T4_COMPRESSION_NO_SUBSAMPLING)) + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_NO_SUBSAMPLING); + + /* No custom illuminant */ + /* No custom gamut range */ + } } if ((s->supported_t30_features & T30_SUPPORT_FIELD_NOT_VALID)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_FNV_CAPABLE); @@ -1257,12 +1267,6 @@ int t30_build_dis_or_dtc(t30_state_t *s) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_MULTIPLE_SELECTIVE_POLLING_CAPABLE); if ((s->supported_t30_features & T30_SUPPORT_POLLED_SUB_ADDRESSING)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE); - - /* No plane interleave */ - /* No G.726 */ - /* No extended voice coding */ - /* Superfine minimum scan line time pattern follows fine */ - if ((s->supported_t30_features & T30_SUPPORT_SELECTIVE_POLLING)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE); if ((s->supported_t30_features & T30_SUPPORT_SUB_ADDRESSING)) @@ -1270,10 +1274,16 @@ int t30_build_dis_or_dtc(t30_state_t *s) if ((s->supported_t30_features & T30_SUPPORT_IDENTIFICATION)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_PASSWORD); + /* No G.726 */ + /* No extended voice coding */ + /* Superfine minimum scan line time pattern follows fine */ + /* Ready to transmit a data file (polling) */ if (s->tx_file[0]) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_READY_TO_TRANSMIT_DATA_FILE); + /* No simple phase C BFT negotiations */ + /* No extended BFT negotiations */ /* No Binary file transfer (BFT) */ /* No Document transfer mode (DTM) */ /* No Electronic data interchange (EDI) */ @@ -1295,67 +1305,65 @@ int t30_build_dis_or_dtc(t30_state_t *s) /* No HFX40-I hashing */ /* No alternative hashing system number 2 */ /* No alternative hashing system number 3 */ - /* No T.44 (mixed raster content) */ + /* No T.44 (mixed raster content) */ /* No page length maximum strip size for T.44 (mixed raster content) */ - /* No simple phase C BFT negotiations */ - /* No extended BFT negotiations */ if ((s->supported_t30_features & T30_SUPPORT_INTERNET_SELECTIVE_POLLING_ADDRESS)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS); if ((s->supported_t30_features & T30_SUPPORT_INTERNET_ROUTING_ADDRESS)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_INTERNET_ROUTING_ADDRESS); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_1200_1200)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_1200_1200)) { set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_1200_1200_CAPABLE); - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_1200_1200)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_1200_1200)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_1200_1200_CAPABLE); } - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_600_1200)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_600_1200)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_600_1200_CAPABLE); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_600_600)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_600_600)) { set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_600_600_CAPABLE); - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_600_600)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_600_600)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_600_600_CAPABLE); } - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_400_800)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_400_800)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_400_800_CAPABLE); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_R16_SUPERFINE)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_R16_SUPERFINE)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_400_400_CAPABLE); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_400_400)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_400_400)) { set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_400_400_CAPABLE); - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_400_400)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_400_400)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_300_300_400_400_CAPABLE); } - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_300_600)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_300_600)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_300_600_CAPABLE); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_300_300)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_300_300)) { set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_300_300_CAPABLE); - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_300_300)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_300_300)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_300_300_400_400_CAPABLE); } - if ((s->supported_bilevel_resolutions & (T4_SUPPORT_RESOLUTION_200_400 | T4_SUPPORT_RESOLUTION_R8_SUPERFINE))) + if ((s->supported_bilevel_resolutions & (T4_RESOLUTION_200_400 | T4_RESOLUTION_R8_SUPERFINE))) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_200_400_CAPABLE); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_R8_FINE)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_R8_FINE)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_200_200_CAPABLE); - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_200_200)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_200_200)) { set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_200_200_CAPABLE); - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_200_200)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_200_200)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_FULL_COLOUR_CAPABLE); } /* Standard FAX resolution bi-level image support goes without saying */ - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_100_100)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_100_100)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_100_100_CAPABLE); - if ((s->supported_bilevel_resolutions & (T4_SUPPORT_RESOLUTION_R8_STANDARD | T4_SUPPORT_RESOLUTION_R8_FINE | T4_SUPPORT_RESOLUTION_R8_SUPERFINE | T4_SUPPORT_RESOLUTION_R16_SUPERFINE))) - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_INCH_RESOLUTION_PREFERRED); - if ((s->supported_bilevel_resolutions & (T4_SUPPORT_RESOLUTION_200_100 | T4_SUPPORT_RESOLUTION_200_200 | T4_SUPPORT_RESOLUTION_200_400 | T4_SUPPORT_RESOLUTION_300_300 | T4_SUPPORT_RESOLUTION_300_600 | T4_SUPPORT_RESOLUTION_400_400 | T4_SUPPORT_RESOLUTION_400_800 | T4_SUPPORT_RESOLUTION_600_600 | T4_SUPPORT_RESOLUTION_600_1200 | T4_SUPPORT_RESOLUTION_1200_1200))) + if ((s->supported_bilevel_resolutions & (T4_RESOLUTION_R8_STANDARD | T4_RESOLUTION_R8_FINE | T4_RESOLUTION_R8_SUPERFINE | T4_RESOLUTION_R16_SUPERFINE))) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED); + if ((s->supported_bilevel_resolutions & (T4_RESOLUTION_200_100 | T4_RESOLUTION_200_200 | T4_RESOLUTION_200_400 | T4_RESOLUTION_300_300 | T4_RESOLUTION_300_600 | T4_RESOLUTION_400_400 | T4_RESOLUTION_400_800 | T4_RESOLUTION_600_600 | T4_RESOLUTION_600_1200 | T4_RESOLUTION_1200_1200))) + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_INCH_RESOLUTION_PREFERRED); /* No double sided printing (alternate mode) */ /* No double sided printing (continuous mode) */ @@ -1420,17 +1428,15 @@ static int prune_dis_dtc(t30_state_t *s) static int build_dcs(t30_state_t *s) { int i; - int bad; - int row_squashing_ratio; int use_bilevel; int image_type; /* Reacquire page information, in case the image was resized, flattened, etc. */ - s->x_resolution = t4_tx_get_x_resolution(&s->t4.tx); - s->y_resolution = t4_tx_get_y_resolution(&s->t4.tx); - s->current_page_resolution = t4_tx_get_resolution(&s->t4.tx); - s->image_width = t4_tx_get_image_width(&s->t4.tx); - image_type = t4_tx_get_image_type(&s->t4.tx); + s->current_page_resolution = t4_tx_get_tx_resolution(&s->t4.tx); + s->x_resolution = t4_tx_get_tx_x_resolution(&s->t4.tx); + s->y_resolution = t4_tx_get_tx_y_resolution(&s->t4.tx); + s->image_width = t4_tx_get_tx_image_width(&s->t4.tx); + image_type = t4_tx_get_tx_image_type(&s->t4.tx); /* Make a DCS frame based on local issues and the latest received DIS/DTC frame. Negotiate the result based on what both parties can do. */ @@ -1456,7 +1462,7 @@ static int build_dcs(t30_state_t *s) s->dcs_frame[4] |= fallback_sequence[s->current_fallback].dcs_code; /* Select the compression to use. */ - use_bilevel = TRUE; + use_bilevel = true; set_ctrl_bits(s->dcs_frame, s->min_scan_time_code, T30_DCS_BIT_MIN_SCAN_LINE_TIME_1); switch (s->line_compression) { @@ -1490,7 +1496,7 @@ static int build_dcs(t30_state_t *s) //if (???????? & T4_COMPRESSION_?????)) // set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_PREFERRED_HUFFMAN_TABLES); set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, T30_DCS_BIT_MIN_SCAN_LINE_TIME_1); - use_bilevel = FALSE; + use_bilevel = false; break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: @@ -1502,17 +1508,17 @@ static int build_dcs(t30_state_t *s) //if (???????? & T4_COMPRESSION_NO_SUBSAMPLING)) // set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_NO_SUBSAMPLING); set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, T30_DCS_BIT_MIN_SCAN_LINE_TIME_1); - use_bilevel = FALSE; + use_bilevel = false; break; #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: - use_bilevel = FALSE; + use_bilevel = false; break; #endif #if defined(SPANDSP_SUPPORT_SYCC_T81) case T4_COMPRESSION_SYCC_T81: - use_bilevel = FALSE; + use_bilevel = false; break; #endif default: @@ -1520,229 +1526,21 @@ static int build_dcs(t30_state_t *s) break; } - /* Set the Y resolution bits */ - row_squashing_ratio = 1; - bad = T30_ERR_NORESSUPPORT; - if ((use_bilevel && (s->current_page_resolution & s->mutual_bilevel_resolutions)) - || - (!use_bilevel && (s->current_page_resolution & s->mutual_colour_resolutions))) + /* Set the image width */ + switch (s->line_width_code) { - /* The resolution is supported by both parties */ - switch (s->current_page_resolution) - { - case T4_RESOLUTION_1200_1200: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_1200_1200); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - if (!use_bilevel) - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_1200_1200); - break; - case T4_RESOLUTION_600_1200: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_600_1200); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - break; - case T4_RESOLUTION_600_600: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_600_600); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - if (!use_bilevel) - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_600_600); - break; - case T4_RESOLUTION_400_800: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_400_800); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - break; - case T4_RESOLUTION_400_400: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_400_400); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - if (!use_bilevel) - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_300_300_400_400); - break; - case T4_RESOLUTION_300_600: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_300_600); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - break; - case T4_RESOLUTION_300_300: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_300_300); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - if (!use_bilevel) - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_300_300_400_400); - break; - case T4_RESOLUTION_200_400: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_400); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - break; - case T4_RESOLUTION_200_200: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_200); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - if (!use_bilevel) - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_FULL_COLOUR_MODE); - break; - case T4_RESOLUTION_200_100: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - break; - case T4_RESOLUTION_100_100: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); - if (!use_bilevel) - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_100_100); - break; - case T4_RESOLUTION_R16_SUPERFINE: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_400_400); - break; - case T4_RESOLUTION_R8_SUPERFINE: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_400); - break; - case T4_RESOLUTION_R8_FINE: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_200); - break; - case T4_RESOLUTION_R8_STANDARD: - /* Nothing special to set */ - break; - } - bad = T30_ERR_OK; - } - else - { -#if 0 - /* Deal with resolution fudging */ - if ((s->current_page_resolution & (T4_RESOLUTION_R16_SUPERFINE | T4_RESOLUTION_R8_SUPERFINE | T4_RESOLUTION_R8_FINE | T4_RESOLUTION_R8_STANDARD))) - { - if ((s->mutual_bilevel_resolutions & (T4_RESOLUTION_400_400 | T4_RESOLUTION_200_400 | T4_RESOLUTION_200_200 | T4_RESOLUTION_200_100))) - { - /* Fudge between imperial and metric */ - } - } - else if ((s->current_page_resolution & (T4_RESOLUTION_400_400 | T4_RESOLUTION_200_400 | T4_RESOLUTION_200_200 | T4_RESOLUTION_200_100)) - { - if ((s->mutual_bilevel_resolutions & (T4_RESOLUTION_R16_SUPERFINE | T4_RESOLUTION_R8_SUPERFINE | T4_RESOLUTION_R8_FINE | T4_RESOLUTION_R8_STANDARD))) - { - /* Fudge between imperial and metric */ - } - } -#endif - /* Deal with squashing options */ - if ((s->current_page_resolution & T4_RESOLUTION_R8_SUPERFINE)) - { - if ((s->mutual_bilevel_resolutions & T4_RESOLUTION_R8_FINE)) - { - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_200); - row_squashing_ratio = 2; - bad = T30_ERR_OK; - } - else if ((s->mutual_bilevel_resolutions & T4_RESOLUTION_R8_STANDARD)) - { - row_squashing_ratio = 4; - bad = T30_ERR_OK; - } - } - else if ((s->current_page_resolution & T4_RESOLUTION_R8_FINE) && (s->mutual_bilevel_resolutions & T4_RESOLUTION_R8_STANDARD)) - { - row_squashing_ratio = 2; - bad = T30_ERR_OK; - } - else if ((s->current_page_resolution & T4_RESOLUTION_200_400)) - { - if ((s->mutual_bilevel_resolutions & T4_RESOLUTION_200_200)) - { - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_200); - row_squashing_ratio = 2; - bad = T30_ERR_OK; - } - else if ((s->mutual_bilevel_resolutions & T4_RESOLUTION_200_100)) - { - row_squashing_ratio = 4; - bad = T30_ERR_OK; - } - } - else if ((s->current_page_resolution & T4_RESOLUTION_200_200) && (s->mutual_bilevel_resolutions & T4_RESOLUTION_200_100)) - { - row_squashing_ratio = 2; - bad = T30_ERR_OK; - } - } - - t4_tx_set_row_squashing_ratio(&s->t4.tx, row_squashing_ratio); - if (bad != T30_ERR_OK) - { - t30_set_status(s, bad); - span_log(&s->logging, SPAN_LOG_FLOW, "Image resolution (%d x %d) not acceptable\n", s->x_resolution, s->y_resolution); - return -1; - } - - /* Deal with the image width. */ - /* Low (R4) res widths are not supported in recent versions of T.30 */ - bad = T30_ERR_OK; - /* The following treats a width field of 11 like 10, which does what note 6 of Table 2/T.30 - says we should do with the invalid value 11. */ - if (((s->image_width == T4_WIDTH_200_A4) && (s->x_resolution == T4_X_RESOLUTION_200 || s->x_resolution == T4_X_RESOLUTION_R8)) - || - ((s->image_width == T4_WIDTH_300_A4) && (s->x_resolution == T4_X_RESOLUTION_300)) - || - ((s->image_width == T4_WIDTH_400_A4) && (s->x_resolution == T4_X_RESOLUTION_400 || s->x_resolution == T4_X_RESOLUTION_R16)) - || - ((s->image_width == T4_WIDTH_600_A4) && (s->x_resolution == T4_X_RESOLUTION_600)) - || - ((s->image_width == T4_WIDTH_1200_A4) && (s->x_resolution == T4_X_RESOLUTION_1200))) - { - span_log(&s->logging, SPAN_LOG_FLOW, "Image width is A4 at %ddpi x %ddpi\n", s->x_resolution, s->y_resolution); + case T4_SUPPORT_WIDTH_215MM: + span_log(&s->logging, SPAN_LOG_FLOW, "Image width is A4 at %ddpm x %ddpm\n", s->x_resolution, s->y_resolution); /* No width related bits need to be set. */ - } - else if (((s->image_width == T4_WIDTH_200_B4) && (s->x_resolution == T4_X_RESOLUTION_200 || s->x_resolution == T4_X_RESOLUTION_R8)) - || - ((s->image_width == T4_WIDTH_300_B4) && (s->x_resolution == T4_X_RESOLUTION_300)) - || - ((s->image_width == T4_WIDTH_400_B4) && (s->x_resolution == T4_X_RESOLUTION_400 || s->x_resolution == T4_X_RESOLUTION_R16)) - || - ((s->image_width == T4_WIDTH_600_B4) && (s->x_resolution == T4_X_RESOLUTION_600)) - || - ((s->image_width == T4_WIDTH_1200_B4) && (s->x_resolution == T4_X_RESOLUTION_1200))) - { - if ((s->mutual_image_sizes & T4_SUPPORT_WIDTH_255MM)) - { - span_log(&s->logging, SPAN_LOG_FLOW, "Image width is B4 at %ddpi x %ddpi\n", s->x_resolution, s->y_resolution); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_255MM_WIDTH); - } - else - { - /* We do not support this width and resolution combination */ - bad = T30_ERR_NOSIZESUPPORT; - } - } - else if (((s->image_width == T4_WIDTH_200_A3) && (s->x_resolution == T4_X_RESOLUTION_200 || s->x_resolution == T4_X_RESOLUTION_R8)) - || - ((s->image_width == T4_WIDTH_300_A3) && (s->x_resolution == T4_X_RESOLUTION_300)) - || - ((s->image_width == T4_WIDTH_400_A3) && (s->x_resolution == T4_X_RESOLUTION_400 || s->x_resolution == T4_X_RESOLUTION_R16)) - || - ((s->image_width == T4_WIDTH_600_A3) && (s->x_resolution == T4_X_RESOLUTION_600)) - || - ((s->image_width == T4_WIDTH_1200_A3) && (s->x_resolution == T4_X_RESOLUTION_1200))) - { - if ((s->mutual_image_sizes & T4_SUPPORT_WIDTH_303MM)) - { - span_log(&s->logging, SPAN_LOG_FLOW, "Image width is A3 at %ddpi x %ddpi\n", s->x_resolution, s->y_resolution); - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_303MM_WIDTH); - } - else - { - /* We do not support this width and resolution combination */ - bad = T30_ERR_NOSIZESUPPORT; - } - } - else - { - /* We do not support this width and resolution combination */ - bad = T30_ERR_NOSIZESUPPORT; - } - - if (bad != T30_ERR_OK) - { - t30_set_status(s, bad); - span_log(&s->logging, - SPAN_LOG_FLOW, - "Image width (%d pixels) and resolution (%d x %d) is not an acceptable\n", - s->image_width, - s->x_resolution, - s->y_resolution); - return -1; + break; + case T4_SUPPORT_WIDTH_255MM: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_255MM_WIDTH); + span_log(&s->logging, SPAN_LOG_FLOW, "Image width is B4 at %ddpm x %ddpm\n", s->x_resolution, s->y_resolution); + break; + case T4_SUPPORT_WIDTH_303MM: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_303MM_WIDTH); + span_log(&s->logging, SPAN_LOG_FLOW, "Image width is A3 at %ddpm x %ddpm\n", s->x_resolution, s->y_resolution); + break; } /* Set the image length */ @@ -1757,6 +1555,77 @@ static int build_dcs(t30_state_t *s) else if ((s->mutual_image_sizes & T4_SUPPORT_LENGTH_US_LEGAL)) set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_NORTH_AMERICAN_LEGAL); + /* Set the Y resolution bits */ + switch (s->current_page_resolution) + { + case T4_RESOLUTION_1200_1200: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_1200_1200); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + if (!use_bilevel) + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_1200_1200); + break; + case T4_RESOLUTION_600_1200: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_600_1200); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + break; + case T4_RESOLUTION_600_600: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_600_600); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + if (!use_bilevel) + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_600_600); + break; + case T4_RESOLUTION_400_800: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_400_800); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + break; + case T4_RESOLUTION_400_400: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_400_400); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + if (!use_bilevel) + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_300_300_400_400); + break; + case T4_RESOLUTION_300_600: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_300_600); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + break; + case T4_RESOLUTION_300_300: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_300_300); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + if (!use_bilevel) + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_300_300_400_400); + break; + case T4_RESOLUTION_200_400: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_400); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + break; + case T4_RESOLUTION_200_200: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_200); + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + if (!use_bilevel) + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_FULL_COLOUR_MODE); + break; + case T4_RESOLUTION_200_100: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + break; + case T4_RESOLUTION_100_100: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_INCH_RESOLUTION); + if (!use_bilevel) + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_COLOUR_GRAY_100_100); + break; + case T4_RESOLUTION_R16_SUPERFINE: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_400_400); + break; + case T4_RESOLUTION_R8_SUPERFINE: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_400); + break; + case T4_RESOLUTION_R8_FINE: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_200_200); + break; + case T4_RESOLUTION_R8_STANDARD: + /* Nothing special to set */ + break; + } + if (s->error_correcting_mode) set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_ECM_MODE); @@ -1810,7 +1679,7 @@ static int analyze_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) } if (msg[2] == T30_DIS) - s->dis_received = TRUE; + s->dis_received = true; /* Make a local copy of the message, padded to the maximum possible length with zeros. This allows us to simply pick out the bits, without worrying about whether they were set from the remote side. */ @@ -1829,42 +1698,42 @@ static int analyze_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) if (!s->error_correcting_mode) { /* Remove any compression schemes which need error correction to work. */ - s->mutual_compressions &= (0xF0000000 | T4_SUPPORT_COMPRESSION_NONE | T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D); + s->mutual_compressions &= (0xFF800000 | T4_COMPRESSION_NONE | T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D); if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T4_2D; + s->mutual_compressions &= ~T4_COMPRESSION_T4_2D; } else { /* Check the bi-level capabilities */ if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T4_2D; + s->mutual_compressions &= ~T4_COMPRESSION_T4_2D; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T6; + s->mutual_compressions &= ~T4_COMPRESSION_T6; /* T.85 L0 capable without T.85 capable is an invalid combination, so let just zap both capabilities if the far end is not T.85 capable. */ if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE)) - s->mutual_compressions &= ~(T4_SUPPORT_COMPRESSION_T85 | T4_SUPPORT_COMPRESSION_T85_L0); + s->mutual_compressions &= ~(T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0); if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T85_L0; + s->mutual_compressions &= ~T4_COMPRESSION_T85_L0; /* Check for full colour or only gray-scale from the multi-level codecs */ if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_FULL_COLOUR_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_COLOUR; + s->mutual_compressions &= ~T4_COMPRESSION_COLOUR; /* Check the colour capabilities */ if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T42_T81; + s->mutual_compressions &= ~T4_COMPRESSION_T42_T81; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_SYCC_T81_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_SYCC_T81; + s->mutual_compressions &= ~T4_COMPRESSION_SYCC_T81; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T43; + s->mutual_compressions &= ~T4_COMPRESSION_T43; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T45_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_T45; + s->mutual_compressions &= ~T4_COMPRESSION_T45; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_12BIT_CAPABLE)) - s->mutual_compressions &= ~T4_SUPPORT_COMPRESSION_12BIT; - //if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_NO_SUBSAMPLING)) - // ???? = T4_COMPRESSION_T42_T81_SUBSAMPLING; + s->mutual_compressions &= ~T4_COMPRESSION_12BIT; + if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_NO_SUBSAMPLING)) + s->mutual_compressions &= ~T4_COMPRESSION_NO_SUBSAMPLING; /* bit74 custom illuminant */ /* bit75 custom gamut range */ @@ -1874,75 +1743,75 @@ static int analyze_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) s->mutual_colour_resolutions = s->supported_colour_resolutions; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_1200_1200_CAPABLE)) { - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_1200_1200; - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_1200_1200; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_1200_1200; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_1200_1200; } else { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_1200_1200_CAPABLE)) - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_1200_1200; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_1200_1200; } if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_600_1200_CAPABLE)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_600_1200; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_600_1200; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_600_600_CAPABLE)) { - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_600_600; - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_600_600; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_600_600; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_600_600; } else { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_600_600_CAPABLE)) - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_600_600; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_600_600; } if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_400_800_CAPABLE)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_400_800; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_400_800; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_400_400_CAPABLE)) { - s->mutual_bilevel_resolutions &= ~(T4_SUPPORT_RESOLUTION_400_400 | T4_SUPPORT_RESOLUTION_R16_SUPERFINE); - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_400_400; + s->mutual_bilevel_resolutions &= ~(T4_RESOLUTION_400_400 | T4_RESOLUTION_R16_SUPERFINE); + s->mutual_colour_resolutions &= ~T4_RESOLUTION_400_400; } else { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_300_300_400_400_CAPABLE)) - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_400_400; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_400_400; } if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_300_600_CAPABLE)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_300_600; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_300_600; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_300_300_CAPABLE)) { - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_300_300; - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_300_300; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_300_300; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_300_300; } else { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_300_300_400_400_CAPABLE)) - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_300_300; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_300_300; } if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_200_400_CAPABLE)) { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_INCH_RESOLUTION_PREFERRED)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_200_400; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_200_400; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_R8_SUPERFINE; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_R8_SUPERFINE; } if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_200_200_CAPABLE)) { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_INCH_RESOLUTION_PREFERRED)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_200_200; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_200_200; if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_R8_FINE; - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_200_200; + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_R8_FINE; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_200_200; } else { if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_INCH_RESOLUTION_PREFERRED)) - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_200_200; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_200_200; } if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_INCH_RESOLUTION_PREFERRED)) - s->mutual_bilevel_resolutions &= ~T4_SUPPORT_RESOLUTION_200_100; - /* Never suppress T4_SUPPORT_RESOLUTION_R8_STANDARD */ + s->mutual_bilevel_resolutions &= ~T4_RESOLUTION_200_100; + /* Never suppress T4_RESOLUTION_R8_STANDARD */ if (!test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_COLOUR_GRAY_100_100_CAPABLE)) - s->mutual_colour_resolutions &= ~T4_SUPPORT_RESOLUTION_100_100; + s->mutual_colour_resolutions &= ~T4_RESOLUTION_100_100; s->mutual_image_sizes = s->supported_image_sizes; /* 215mm wide is always supported */ @@ -2068,7 +1937,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) /* Note 35 of Table 2/T.30 */ if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_FULL_COLOUR_MODE)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_COMPRESSION_COLOUR)) + if ((s->supported_colour_resolutions & T4_COMPRESSION_COLOUR)) { /* We are going to work in full colour mode */ } @@ -2076,7 +1945,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_12BIT_COMPONENT)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_COMPRESSION_12BIT)) + if ((s->supported_colour_resolutions & T4_COMPRESSION_12BIT)) { /* We are going to work in 12 bit mode */ } @@ -2084,17 +1953,17 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_NO_SUBSAMPLING)) { - //???? = T4_SUPPORT_COMPRESSION_T42_T81_SUBSAMPLING; + //???? = T4_COMPRESSION_NO_SUBSAMPLING; } if (!test_ctrl_bit(dcs_frame, T30_DCS_BIT_PREFERRED_HUFFMAN_TABLES)) { - //???? = T4_SUPPORT_COMPRESSION_T42_T81_HUFFMAN; + //???? = T4_COMPRESSION_T42_T81_HUFFMAN; } if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_COLOUR_GRAY_1200_1200)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_1200_1200)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_1200_1200)) { s->x_resolution = T4_X_RESOLUTION_1200; s->y_resolution = T4_Y_RESOLUTION_1200; @@ -2104,7 +1973,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_COLOUR_GRAY_600_600)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_600_600)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_600_600)) { s->x_resolution = T4_X_RESOLUTION_600; s->y_resolution = T4_Y_RESOLUTION_600; @@ -2114,7 +1983,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_400_400)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_400_400)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_400_400)) { s->x_resolution = T4_X_RESOLUTION_400; s->y_resolution = T4_Y_RESOLUTION_400; @@ -2124,7 +1993,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_300)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_300_300)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_300_300)) { s->x_resolution = T4_X_RESOLUTION_300; s->y_resolution = T4_Y_RESOLUTION_300; @@ -2134,7 +2003,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_200_200)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_200_200)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_200_200)) { s->x_resolution = T4_X_RESOLUTION_200; s->y_resolution = T4_Y_RESOLUTION_200; @@ -2144,7 +2013,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_COLOUR_GRAY_100_100)) { - if ((s->supported_colour_resolutions & T4_SUPPORT_RESOLUTION_100_100)) + if ((s->supported_colour_resolutions & T4_RESOLUTION_100_100)) { s->x_resolution = T4_X_RESOLUTION_100; s->y_resolution = T4_Y_RESOLUTION_100; @@ -2156,22 +2025,22 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) /* Check which compression the far end has decided to use. */ if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T81_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T42_T81)) + if ((s->supported_compressions & T4_COMPRESSION_T42_T81)) s->line_compression = T4_COMPRESSION_T42_T81; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T43_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T43)) + if ((s->supported_compressions & T4_COMPRESSION_T43)) s->line_compression = T4_COMPRESSION_T43; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T45_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T45)) + if ((s->supported_compressions & T4_COMPRESSION_T45)) s->line_compression = T4_COMPRESSION_T45; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_SYCC_T81_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_SYCC_T81)) + if ((s->supported_compressions & T4_COMPRESSION_SYCC_T81)) s->line_compression = T4_COMPRESSION_SYCC_T81; } } @@ -2180,7 +2049,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) /* Bi-level image */ if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_1200_1200)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_1200_1200)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_1200_1200)) { s->x_resolution = T4_X_RESOLUTION_1200; s->y_resolution = T4_Y_RESOLUTION_1200; @@ -2190,7 +2059,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_600_1200)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_600_1200)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_600_1200)) { s->x_resolution = T4_X_RESOLUTION_600; s->y_resolution = T4_Y_RESOLUTION_1200; @@ -2200,7 +2069,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_600_600)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_600_600)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_600_600)) { s->x_resolution = T4_X_RESOLUTION_600; s->y_resolution = T4_Y_RESOLUTION_600; @@ -2210,7 +2079,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_400_800)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_400_800)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_400_800)) { s->x_resolution = T4_X_RESOLUTION_400; s->y_resolution = T4_Y_RESOLUTION_800; @@ -2222,7 +2091,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) { if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_INCH_RESOLUTION)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_400_400)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_400_400)) { s->x_resolution = T4_X_RESOLUTION_400; s->y_resolution = T4_Y_RESOLUTION_400; @@ -2232,7 +2101,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_R16_SUPERFINE)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_R16_SUPERFINE)) { s->x_resolution = T4_X_RESOLUTION_R16; s->y_resolution = T4_Y_RESOLUTION_SUPERFINE; @@ -2243,7 +2112,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_600)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_300_600)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_300_600)) { s->x_resolution = T4_X_RESOLUTION_300; s->y_resolution = T4_Y_RESOLUTION_600; @@ -2253,7 +2122,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_300)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_300_300)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_300_300)) { s->x_resolution = T4_X_RESOLUTION_300; s->y_resolution = T4_Y_RESOLUTION_300; @@ -2265,7 +2134,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) { if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_INCH_RESOLUTION)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_200_400)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_200_400)) { s->x_resolution = T4_X_RESOLUTION_200; s->y_resolution = T4_Y_RESOLUTION_400; @@ -2275,7 +2144,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_R8_SUPERFINE)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_R8_SUPERFINE)) { s->x_resolution = T4_X_RESOLUTION_R8; s->y_resolution = T4_Y_RESOLUTION_SUPERFINE; @@ -2288,7 +2157,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) { if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_INCH_RESOLUTION)) { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_200_200)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_200_200)) { s->x_resolution = T4_X_RESOLUTION_200; s->y_resolution = T4_Y_RESOLUTION_200; @@ -2298,7 +2167,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) } else { - if ((s->supported_bilevel_resolutions & T4_SUPPORT_RESOLUTION_R8_FINE)) + if ((s->supported_bilevel_resolutions & T4_RESOLUTION_R8_FINE)) { s->x_resolution = T4_X_RESOLUTION_R8; s->y_resolution = T4_Y_RESOLUTION_FINE; @@ -2332,32 +2201,32 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) || test_ctrl_bit(dcs_frame, T30_DCS_BIT_T88_MODE_3)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T88)) + if ((s->supported_compressions & T4_COMPRESSION_T88)) s->line_compression = T4_COMPRESSION_T88; } if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_L0_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T85_L0)) + if ((s->supported_compressions & T4_COMPRESSION_T85_L0)) s->line_compression = T4_COMPRESSION_T85_L0; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T85)) + if ((s->supported_compressions & T4_COMPRESSION_T85)) s->line_compression = T4_COMPRESSION_T85; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T6)) + if ((s->supported_compressions & T4_COMPRESSION_T6)) s->line_compression = T4_COMPRESSION_T6; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_2D_MODE)) { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T4_2D)) + if ((s->supported_compressions & T4_COMPRESSION_T4_2D)) s->line_compression = T4_COMPRESSION_T4_2D; } else { - if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T4_1D)) + if ((s->supported_compressions & T4_COMPRESSION_T4_1D)) s->line_compression = T4_COMPRESSION_T4_1D; } } @@ -2392,8 +2261,6 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) static int step_fallback_entry(t30_state_t *s) { - int min_row_bits; - while (fallback_sequence[++s->current_fallback].which) { if ((fallback_sequence[s->current_fallback].which & s->current_permitted_modems)) @@ -2401,12 +2268,9 @@ static int step_fallback_entry(t30_state_t *s) } if (fallback_sequence[s->current_fallback].which == 0) return -1; - /* TODO: This only sets the minimum row time for future pages. It doesn't fix up the - 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_bits_per_row(&s->t4.tx, min_row_bits); - /* We need to rebuild the DCS message we will send. */ + /* We need to update the minimum scan time, in case we are in non-ECM mode. */ + set_min_scan_time(s); + /* Now we need to rebuild the DCS message we will send. */ build_dcs(s); return s->current_fallback; } @@ -2531,7 +2395,6 @@ static int send_dcs_sequence(t30_state_t *s, int start) /* Schedule training after the messages */ if (start) { - prune_dcs(s); set_state(s, T30_STATE_D); s->step = 0; } @@ -2629,7 +2492,7 @@ static void disconnect(t30_state_t *s) } /*- End of function --------------------------------------------------------*/ -static int set_min_scan_time_code(t30_state_t *s) +static void set_min_scan_time(t30_state_t *s) { /* Translation between the codes for the minimum scan times the other end needs, and the codes for what we say will be used. We need 0 minimum. */ @@ -2645,6 +2508,7 @@ static int set_min_scan_time_code(t30_state_t *s) 20, 5, 10, 0, 40, 0, 0, 0 }; int min_bits_field; + int min_row_bits; /* Set the minimum scan time bits */ if (s->error_correcting_mode) @@ -2654,35 +2518,33 @@ static int set_min_scan_time_code(t30_state_t *s) switch (s->y_resolution) { case T4_Y_RESOLUTION_SUPERFINE: - if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_200_400_CAPABLE)) - { - s->min_scan_time_code = translate_min_scan_time[(test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_MIN_SCAN_TIME_HALVES)) ? 2 : 1][min_bits_field]; - break; - } - span_log(&s->logging, SPAN_LOG_FLOW, "Remote FAX does not support super-fine resolution. Squashing image.\n"); - /* Fall through */ + case T4_Y_RESOLUTION_400: + s->min_scan_time_code = translate_min_scan_time[(test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_MIN_SCAN_TIME_HALVES)) ? 2 : 1][min_bits_field]; + break; case T4_Y_RESOLUTION_FINE: - if (test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_200_200_CAPABLE)) - { - s->min_scan_time_code = translate_min_scan_time[1][min_bits_field]; - break; - } - span_log(&s->logging, SPAN_LOG_FLOW, "Remote FAX does not support fine resolution. Squashing image.\n"); - /* Fall through */ - default: + case T4_Y_RESOLUTION_200: + s->min_scan_time_code = translate_min_scan_time[1][min_bits_field]; + break; case T4_Y_RESOLUTION_STANDARD: + case T4_Y_RESOLUTION_100: s->min_scan_time_code = translate_min_scan_time[0][min_bits_field]; break; + default: + s->min_scan_time_code = T30_MIN_SCAN_0MS; + break; } - if (!s->error_correcting_mode && (s->iaf & T30_IAF_MODE_NO_FILL_BITS)) - return 0; - return fallback_sequence[s->current_fallback].bit_rate*min_scan_times[s->min_scan_time_code]/1000; + if ((s->iaf & T30_IAF_MODE_NO_FILL_BITS)) + min_row_bits = 0; + else + min_row_bits = (fallback_sequence[s->current_fallback].bit_rate*min_scan_times[s->min_scan_time_code])/1000; + span_log(&s->logging, SPAN_LOG_FLOW, "Minimum bits per row will be %d\n", min_row_bits); + t4_tx_set_min_bits_per_row(&s->t4.tx, min_row_bits); } /*- End of function --------------------------------------------------------*/ static int start_sending_document(t30_state_t *s) { - int min_row_bits; + int res; if (s->tx_file[0] == '\0') { @@ -2698,33 +2560,68 @@ static int start_sending_document(t30_state_t *s) return -1; } s->operation_in_progress = OPERATION_IN_PROGRESS_T4_TX; - t4_tx_get_pages_in_file(&s->t4.tx); - t4_tx_set_tx_encoding(&s->t4.tx, s->line_compression); + t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident); t4_tx_set_header_info(&s->t4.tx, s->header_info); if (s->use_own_tz) t4_tx_set_header_tz(&s->t4.tx, &s->tz); + t4_tx_get_pages_in_file(&s->t4.tx); + + if ((res = t4_tx_set_tx_image_format(&s->t4.tx, + s->mutual_compressions, + s->mutual_image_sizes, + s->mutual_bilevel_resolutions, + s->mutual_colour_resolutions)) < 0) + { + switch (res) + { + case T4_IMAGE_FORMAT_INCOMPATIBLE: + span_log(&s->logging, SPAN_LOG_WARNING, "Cannot negotiate an image format\n"); + t30_set_status(s, T30_ERR_BADTIFFHDR); + break; + case T4_IMAGE_FORMAT_NOSIZESUPPORT: + span_log(&s->logging, SPAN_LOG_WARNING, "Cannot negotiate an image size\n"); + t30_set_status(s, T30_ERR_NOSIZESUPPORT); + break; + case T4_IMAGE_FORMAT_NORESSUPPORT: + span_log(&s->logging, SPAN_LOG_WARNING, "Cannot negotiate an image resolution\n"); + t30_set_status(s, T30_ERR_NORESSUPPORT); + break; + default: + span_log(&s->logging, SPAN_LOG_WARNING, "Cannot negotiate an image format\n"); + t30_set_status(s, T30_ERR_BADTIFF); + break; + } + return -1; + } + s->line_image_type = t4_tx_get_tx_image_type(&s->t4.tx); + s->line_compression = t4_tx_get_tx_compression(&s->t4.tx); + s->image_width = t4_tx_get_tx_image_width(&s->t4.tx); + s->line_width_code = t4_tx_get_tx_image_width_code(&s->t4.tx); + + s->x_resolution = t4_tx_get_tx_x_resolution(&s->t4.tx); + s->y_resolution = t4_tx_get_tx_y_resolution(&s->t4.tx); + s->current_page_resolution = t4_tx_get_tx_resolution(&s->t4.tx); + + span_log(&s->logging, + SPAN_LOG_FLOW, + "Choose image type %s (%d), compression %s (%d)\n", + t4_image_type_to_str(s->line_image_type), + s->line_image_type, + t4_compression_to_str(s->line_compression), + s->line_compression); + + /* The minimum scan time to be used can't be evaluated until we know the Y resolution. */ + set_min_scan_time(s); + if (tx_start_page(s)) { span_log(&s->logging, SPAN_LOG_WARNING, "Something seems to be wrong in the file\n"); - t30_set_status(s, T30_ERR_FILEERROR); + t30_set_status(s, T30_ERR_BADTIFFHDR); return -1; } - s->x_resolution = t4_tx_get_x_resolution(&s->t4.tx); - s->y_resolution = t4_tx_get_y_resolution(&s->t4.tx); - s->image_width = t4_tx_get_image_width(&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) - { - 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_bits_per_row(&s->t4.tx, min_row_bits); - if (s->error_correcting_mode) { if (get_partial_ecm_page(s) == 0) @@ -2739,7 +2636,7 @@ static int restart_sending_document(t30_state_t *s) t4_tx_restart_page(&s->t4.tx); s->retries = 0; s->ecm_block = 0; - send_dcs_sequence(s, TRUE); + send_dcs_sequence(s, true); return 0; } /*- End of function --------------------------------------------------------*/ @@ -2755,7 +2652,7 @@ static int start_receiving_document(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Start receiving document\n"); queue_phase(s, T30_PHASE_B_TX); s->ecm_block = 0; - send_dis_or_dtc_sequence(s, TRUE); + send_dis_or_dtc_sequence(s, true); return 0; } /*- End of function --------------------------------------------------------*/ @@ -2796,21 +2693,6 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) send_dcn(s); return -1; } - - /* Choose a compression scheme from amongst those mutually available */ - if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T85_L0)) - s->line_compression = T4_COMPRESSION_T85_L0; - else if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T85)) - s->line_compression = T4_COMPRESSION_T85; - else if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T6)) - s->line_compression = T4_COMPRESSION_T6; - else if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T4_2D)) - s->line_compression = T4_COMPRESSION_T4_2D; - else - s->line_compression = T4_COMPRESSION_T4_1D; - - span_log(&s->logging, SPAN_LOG_FLOW, "Choose compression %s (%d)\n", t4_compression_to_str(s->line_compression), s->line_compression); - if (s->phase_b_handler) { new_status = s->phase_b_handler(s, s->phase_b_user_data, msg[2]); @@ -2846,7 +2728,7 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) return -1; } s->retries = 0; - send_dcs_sequence(s, TRUE); + send_dcs_sequence(s, true); return 0; } span_log(&s->logging, SPAN_LOG_FLOW, "%s nothing to send\n", t30_frametype(msg[2])); @@ -2873,7 +2755,7 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) return -1; } s->retries = 0; - send_dis_or_dtc_sequence(s, TRUE); + send_dis_or_dtc_sequence(s, true); return 0; } span_log(&s->logging, SPAN_LOG_FLOW, "%s nothing to receive\n", t30_frametype(msg[2])); @@ -2932,7 +2814,7 @@ static int process_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) if (!(s->iaf & T30_IAF_MODE_NO_TCF)) { /* TCF is always sent with long training */ - s->short_train = FALSE; + s->short_train = false; set_state(s, T30_STATE_F_TCF); queue_phase(s, T30_PHASE_C_NON_ECM_RX); timer_t2_start(s); @@ -2948,7 +2830,7 @@ static int send_response_to_pps(t30_state_t *s) { set_state(s, T30_STATE_F_POST_RCP_MCF); send_simple_frame(s, T30_MCF); - return TRUE; + return true; } /* We need to send the PPR frame we have created, to try to fill in the missing/bad data. */ set_state(s, T30_STATE_F_POST_RCP_PPR); @@ -2956,7 +2838,7 @@ static int send_response_to_pps(t30_state_t *s) s->ecm_frame_map[1] = CONTROL_FIELD_FINAL_FRAME; s->ecm_frame_map[2] = (uint8_t) (T30_PPR | s->dis_received); send_frame(s, s->ecm_frame_map, 3 + 32); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -3053,7 +2935,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) /* Build a bit map of which frames we now have stored OK */ first_bad_frame = 256; - first = TRUE; + first = true; expected_len = 256; for (i = 0; i < 32; i++) { @@ -3080,7 +2962,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) /* Use the length of the first frame as our model for what the length should be */ if (s->ecm_len[frame_no] == 64) expected_len = 64; - first = FALSE; + first = false; } /* Check the length is consistent with the first frame */ if (s->ecm_len[frame_no] != expected_len) @@ -3165,7 +3047,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) case T30_PRI_EOP: case T30_EOP: span_log(&s->logging, SPAN_LOG_FLOW, "End of procedure detected\n"); - s->end_of_procedure_detected = TRUE; + s->end_of_procedure_detected = true; break; } } @@ -3280,7 +3162,7 @@ static void process_rx_fcd(t30_state_t *s, const uint8_t *msg, int len) memcpy(&s->ecm_data[frame_no][0], &msg[4], len - 4); s->ecm_len[frame_no] = (int16_t) (len - 4); /* In case we are just after a CTC/CTR exchange, which kicked us back to long training */ - s->short_train = TRUE; + s->short_train = true; } /* We have received something, so any missing carrier status is out of date */ if (s->current_status == T30_ERR_RX_NOCARRIER) @@ -3545,7 +3427,7 @@ static void process_state_d_post_tcf(t30_state_t *s, const uint8_t *msg, int len /* Trainability test succeeded. Send the document. */ span_log(&s->logging, SPAN_LOG_FLOW, "Trainability test succeeded\n"); s->retries = 0; - s->short_train = TRUE; + s->short_train = true; if (s->error_correcting_mode) { set_state(s, T30_STATE_IV); @@ -3562,7 +3444,7 @@ static void process_state_d_post_tcf(t30_state_t *s, const uint8_t *msg, int len /* Trainability test failed. Try again. */ span_log(&s->logging, SPAN_LOG_FLOW, "Trainability test failed\n"); s->retries = 0; - s->short_train = FALSE; + s->short_train = false; if (step_fallback_entry(s) < 0) { /* We have fallen back as far as we can go. Give up. */ @@ -3572,7 +3454,7 @@ static void process_state_d_post_tcf(t30_state_t *s, const uint8_t *msg, int len break; } queue_phase(s, T30_PHASE_B_TX); - send_dcs_sequence(s, TRUE); + send_dcs_sequence(s, true); break; case T30_DIS: /* It appears they didn't see what we sent - retry the TCF */ @@ -3586,7 +3468,7 @@ static void process_state_d_post_tcf(t30_state_t *s, const uint8_t *msg, int len span_log(&s->logging, SPAN_LOG_FLOW, "Retry number %d\n", s->retries); queue_phase(s, T30_PHASE_B_TX); /* TODO: should we reassess the new DIS message, and possibly adjust the DCS we use? */ - send_dcs_sequence(s, TRUE); + send_dcs_sequence(s, true); break; case T30_DCN: t30_set_status(s, T30_ERR_TX_BADDCS); @@ -3848,7 +3730,7 @@ static void process_state_f_post_doc_non_ecm(t30_state_t *s, const uint8_t *msg, /* Fall through */ case T30_EOP: span_log(&s->logging, SPAN_LOG_FLOW, "End of procedure detected\n"); - s->end_of_procedure_detected = TRUE; + s->end_of_procedure_detected = true; s->next_rx_step = fcf; queue_phase(s, T30_PHASE_D_TX); switch (copy_quality(s)) @@ -3960,7 +3842,7 @@ static void process_state_f_doc_and_post_doc_ecm(t30_state_t *s, const uint8_t * break; case T30_CTC: /* T.30 says we change back to long training here */ - s->short_train = FALSE; + s->short_train = false; queue_phase(s, T30_PHASE_D_TX); set_state(s, T30_STATE_F_DOC_ECM); send_simple_frame(s, T30_CTR); @@ -4056,7 +3938,7 @@ static void process_state_f_post_rcp_rnr(t30_state_t *s, const uint8_t *msg, int case T30_PRI_EOP: case T30_EOP: span_log(&s->logging, SPAN_LOG_FLOW, "End of procedure detected\n"); - s->end_of_procedure_detected = TRUE; + s->end_of_procedure_detected = true; break; } } @@ -4221,8 +4103,8 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); - report_tx_result(s, TRUE); - return_to_phase_b(s, FALSE); + report_tx_result(s, true); + return_to_phase_b(s, false); break; case T30_PRI_EOP: case T30_EOP: @@ -4231,7 +4113,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); send_dcn(s); - report_tx_result(s, TRUE); + report_tx_result(s, true); break; } break; @@ -4269,7 +4151,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) s->phase_d_handler(s, s->phase_d_user_data, fcf); t4_tx_release(&s->t4.tx); /* TODO: should go back to T, and resend */ - return_to_phase_b(s, TRUE); + return_to_phase_b(s, true); break; case T30_PRI_EOP: case T30_EOP: @@ -4334,7 +4216,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) } else { - return_to_phase_b(s, TRUE); + return_to_phase_b(s, true); } break; case T30_PRI_EOP: @@ -4574,8 +4456,8 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); - report_tx_result(s, TRUE); - return_to_phase_b(s, FALSE); + report_tx_result(s, true); + return_to_phase_b(s, false); break; case T30_PRI_EOP: case T30_EOP: @@ -4584,7 +4466,7 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); send_dcn(s); - report_tx_result(s, TRUE); + report_tx_result(s, true); break; } } @@ -4678,8 +4560,8 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len) if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); - report_tx_result(s, TRUE); - return_to_phase_b(s, FALSE); + report_tx_result(s, true); + return_to_phase_b(s, false); break; case T30_PRI_EOP: case T30_EOP: @@ -4688,7 +4570,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len) s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); send_dcn(s); - report_tx_result(s, TRUE); + report_tx_result(s, true); break; } } @@ -4793,8 +4675,8 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); - report_tx_result(s, TRUE); - return_to_phase_b(s, FALSE); + report_tx_result(s, true); + return_to_phase_b(s, false); break; case T30_PRI_EOP: case T30_EOP: @@ -4803,7 +4685,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len s->phase_d_handler(s, s->phase_d_user_data, fcf); terminate_operation_in_progress(s); send_dcn(s); - report_tx_result(s, TRUE); + report_tx_result(s, true); break; } } @@ -4854,7 +4736,7 @@ static void process_state_iv_ctc(t30_state_t *s, const uint8_t *msg, int len) case T30_CTR: /* Valid response to a CTC received */ /* T.30 says we change back to long training here */ - s->short_train = FALSE; + s->short_train = false; /* Initiate resending of the remainder of the frames. */ set_state(s, T30_STATE_IV); queue_phase(s, T30_PHASE_C_ECM_TX); @@ -4980,7 +4862,7 @@ static void process_rx_control_msg(t30_state_t *s, const uint8_t *msg, int len) /* We should only get good frames here. */ print_frame(s, "Rx: ", msg, len); if (s->real_time_frame_handler) - s->real_time_frame_handler(s, s->real_time_frame_user_data, TRUE, msg, len); + s->real_time_frame_handler(s, s->real_time_frame_user_data, true, msg, len); if ((msg[1] & 0x10) == 0) { @@ -5281,42 +5163,42 @@ static void set_phase(t30_state_t *s, int phase) signal. Force the signal present indicator to off, because the receiver will never be able to. */ if (s->phase != T30_PHASE_A_CED && s->phase != T30_PHASE_A_CNG) - s->rx_signal_present = FALSE; - s->rx_trained = FALSE; - s->rx_frame_received = FALSE; + s->rx_signal_present = false; + s->rx_trained = false; + s->rx_frame_received = false; s->phase = phase; switch (phase) { case T30_PHASE_A_CED: if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, false, true); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CED, 0, FALSE, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CED, 0, false, false); break; case T30_PHASE_A_CNG: if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, false, true); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CNG, 0, FALSE, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CNG, 0, false, false); break; case T30_PHASE_B_RX: case T30_PHASE_D_RX: if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, false, true); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, false, false); break; case T30_PHASE_B_TX: case T30_PHASE_D_TX: if (!s->far_end_detected && s->timer_t0_t1 > 0) { s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T1); - s->far_end_detected = TRUE; + s->far_end_detected = true; } if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, false, false); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_V21, 300, false, true); break; case T30_PHASE_C_NON_ECM_RX: if (s->set_rx_type_handler) @@ -5324,11 +5206,11 @@ static void set_phase(t30_state_t *s, int phase) /* Momentarily stop the receive modem, so the next change is forced to happen. If we don't do this an HDLC message on the slow modem, which has disabled the fast modem, will prevent the same fast modem from restarting. */ - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, false, false); + s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, false); } if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, false, false); break; case T30_PHASE_C_NON_ECM_TX: /* Pause before switching from anything to phase C */ @@ -5340,24 +5222,24 @@ static void set_phase(t30_state_t *s, int phase) /* Momentarily stop the receive modem, so the next change is forced to happen. If we don't do this an HDLC message on the slow modem, which has disabled the fast modem, will prevent the same fast modem from restarting. */ - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, false, false); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, false, false); } if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, false); break; case T30_PHASE_C_ECM_RX: if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, TRUE); + s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, true); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, false, false); break; case T30_PHASE_C_ECM_TX: /* Pause before switching from anything to phase C */ if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, false, false); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, TRUE); + s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, true); break; case T30_PHASE_E: /* Send a little silence before ending things, to ensure the @@ -5367,15 +5249,15 @@ static void set_phase(t30_state_t *s, int phase) s->tcf_current_zeros = 0; s->tcf_most_zeros = 0; if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, false, false); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_PAUSE, 0, FINAL_FLUSH_TIME, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_PAUSE, 0, FINAL_FLUSH_TIME, false); break; case T30_PHASE_CALL_FINISHED: if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_DONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_DONE, 0, false, false); if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_DONE, 0, FALSE, FALSE); + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_DONE, 0, false, false); break; } } @@ -5422,9 +5304,9 @@ static void repeat_last_command(t30_state_t *s) switch (s->state) { case T30_STATE_R: - s->dis_received = FALSE; + s->dis_received = false; queue_phase(s, T30_PHASE_B_TX); - send_dis_or_dtc_sequence(s, TRUE); + send_dis_or_dtc_sequence(s, true); break; case T30_STATE_III_Q_MCF: queue_phase(s, T30_PHASE_D_TX); @@ -5454,7 +5336,7 @@ static void repeat_last_command(t30_state_t *s) break; case T30_STATE_D: queue_phase(s, T30_PHASE_B_TX); - send_dcs_sequence(s, TRUE); + send_dcs_sequence(s, true); break; case T30_STATE_F_FTT: queue_phase(s, T30_PHASE_B_TX); @@ -5462,13 +5344,13 @@ static void repeat_last_command(t30_state_t *s) break; case T30_STATE_F_CFR: queue_phase(s, T30_PHASE_B_TX); - send_cfr_sequence(s, TRUE); + send_cfr_sequence(s, true); break; case T30_STATE_D_POST_TCF: /* Need to send the whole training thing again */ - s->short_train = FALSE; + s->short_train = false; queue_phase(s, T30_PHASE_B_TX); - send_dcs_sequence(s, TRUE); + send_dcs_sequence(s, true); break; case T30_STATE_F_POST_RCP_RNR: /* Just ignore */ @@ -5644,8 +5526,8 @@ static void timer_t2_expired(t30_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Returning to phase B after %s\n", t30_frametype(s->next_rx_step)); set_phase(s, T30_PHASE_B_TX); timer_t2_start(s); - s->dis_received = FALSE; - send_dis_or_dtc_sequence(s, TRUE); + s->dis_received = false; + send_dis_or_dtc_sequence(s, true); return; } break; @@ -5831,7 +5713,7 @@ static int decode_nsf_nss_nsc(t30_state_t *s, uint8_t *msg[], const uint8_t *pkt { uint8_t *t; - if ((t = malloc(len - 1)) == NULL) + if ((t = span_alloc(len - 1)) == NULL) return 0; memcpy(t, pkt + 1, len - 1); *msg = t; @@ -5851,7 +5733,7 @@ static void t30_non_ecm_rx_status(void *user_data, int status) case SIG_STATUS_TRAINING_IN_PROGRESS: break; case SIG_STATUS_TRAINING_FAILED: - s->rx_trained = FALSE; + s->rx_trained = false; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ @@ -5859,16 +5741,16 @@ static void t30_non_ecm_rx_status(void *user_data, int status) s->tcf_test_bits = 0; s->tcf_current_zeros = 0; s->tcf_most_zeros = 0; - s->rx_signal_present = TRUE; - s->rx_trained = TRUE; + s->rx_signal_present = true; + s->rx_trained = true; timer_t2_t4_stop(s); break; case SIG_STATUS_CARRIER_UP: break; case SIG_STATUS_CARRIER_DOWN: was_trained = s->rx_trained; - s->rx_signal_present = FALSE; - s->rx_trained = FALSE; + s->rx_signal_present = false; + s->rx_trained = false; switch (s->state) { case T30_STATE_F_TCF: @@ -5896,11 +5778,11 @@ static void t30_non_ecm_rx_status(void *user_data, int status) else { /* The training went OK */ - s->short_train = TRUE; + s->short_train = true; rx_start_page(s); set_phase(s, T30_PHASE_B_TX); set_state(s, T30_STATE_F_CFR); - send_cfr_sequence(s, TRUE); + send_cfr_sequence(s, true); } } break; @@ -6104,15 +5986,15 @@ static void t30_hdlc_rx_status(void *user_data, int status) case SIG_STATUS_TRAINING_IN_PROGRESS: break; case SIG_STATUS_TRAINING_FAILED: - s->rx_trained = FALSE; + s->rx_trained = false; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ - s->rx_signal_present = TRUE; - s->rx_trained = TRUE; + s->rx_signal_present = true; + s->rx_trained = true; break; case SIG_STATUS_CARRIER_UP: - s->rx_signal_present = TRUE; + s->rx_signal_present = true; switch (s->timer_t2_t4_is) { case TIMER_IS_T2B: @@ -6127,8 +6009,8 @@ static void t30_hdlc_rx_status(void *user_data, int status) break; case SIG_STATUS_CARRIER_DOWN: was_trained = s->rx_trained; - s->rx_signal_present = FALSE; - s->rx_trained = FALSE; + s->rx_signal_present = false; + s->rx_trained = false; /* If a phase change has been queued to occur after the receive signal drops, its time to change. */ if (s->state == T30_STATE_F_DOC_ECM) @@ -6181,7 +6063,7 @@ static void t30_hdlc_rx_status(void *user_data, int status) if (!s->far_end_detected && s->timer_t0_t1 > 0) { s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T1); - s->far_end_detected = TRUE; + s->far_end_detected = true; if (s->phase == T30_PHASE_A_CED || s->phase == T30_PHASE_A_CNG) set_phase(s, T30_PHASE_B_RX); } @@ -6276,7 +6158,7 @@ SPAN_DECLARE_NONSTD(void) t30_hdlc_accept(void *user_data, const uint8_t *msg, i timer_t2_t4_stop(s); return; } - s->rx_frame_received = TRUE; + s->rx_frame_received = true; /* Cancel the command or response timer (if one is running) */ timer_t2_t4_stop(s); process_rx_control_msg(s, msg, len); @@ -6300,11 +6182,11 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) span_log(&s->logging, SPAN_LOG_FLOW, "Starting answer mode\n"); set_phase(s, T30_PHASE_B_TX); timer_t2_start(s); - s->dis_received = FALSE; - send_dis_or_dtc_sequence(s, TRUE); + s->dis_received = false; + send_dis_or_dtc_sequence(s, true); break; case T30_STATE_R: - if (send_dis_or_dtc_sequence(s, FALSE)) + if (send_dis_or_dtc_sequence(s, false)) { /* Wait for an acknowledgement. */ set_phase(s, T30_PHASE_B_RX); @@ -6312,7 +6194,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) } break; case T30_STATE_F_CFR: - if (send_cfr_sequence(s, FALSE)) + if (send_cfr_sequence(s, false)) { if (s->error_correcting_mode) { @@ -6432,13 +6314,13 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) } break; case T30_STATE_D: - if (send_dcs_sequence(s, FALSE)) + if (send_dcs_sequence(s, false)) { if ((s->iaf & T30_IAF_MODE_NO_TCF)) { /* Skip the trainability test */ s->retries = 0; - s->short_train = TRUE; + s->short_train = true; if (s->error_correcting_mode) { set_state(s, T30_STATE_IV); @@ -6454,7 +6336,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) { /* Do the trainability test */ /* TCF is always sent with long training */ - s->short_train = FALSE; + s->short_train = false; set_state(s, T30_STATE_D_TCF); set_phase(s, T30_PHASE_C_NON_ECM_TX); } @@ -6488,7 +6370,8 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) { /* Send the end of page or partial page message */ set_phase(s, T30_PHASE_D_TX); - s->next_tx_step = check_next_tx_step(s); + if (s->ecm_at_page_end) + s->next_tx_step = check_next_tx_step(s); if (send_pps_frame(s) == T30_NULL) set_state(s, T30_STATE_IV_PPS_NULL); else @@ -6557,7 +6440,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) default: /* Cancel any receive timeout, and declare that a receive signal is present, since the front end is explicitly telling us we have seen something. */ - s->rx_signal_present = TRUE; + s->rx_signal_present = true; timer_t2_t4_stop(s); break; } @@ -6751,9 +6634,9 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s) s->phase = T30_PHASE_IDLE; s->next_phase = T30_PHASE_IDLE; s->current_fallback = 0; - s->rx_signal_present = FALSE; - s->rx_trained = FALSE; - s->rx_frame_received = FALSE; + s->rx_signal_present = false; + s->rx_trained = false; + s->rx_frame_received = false; s->current_status = T30_ERR_OK; s->ppr_count = 0; s->ecm_progress = 0; @@ -6767,9 +6650,9 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s) s->tx_page_number = 0; s->rtn_events = 0; s->rtp_events = 0; - s->local_interrupt_pending = FALSE; - s->far_end_detected = FALSE; - s->end_of_procedure_detected = FALSE; + s->local_interrupt_pending = false; + s->far_end_detected = false; + s->end_of_procedure_detected = false; s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T0); if (s->calling_party) { @@ -6796,7 +6679,7 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s, { if (s == NULL) { - if ((s = (t30_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t30_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -6810,10 +6693,13 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s, /* Default to the basic modems. */ s->supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17; - s->supported_compressions = T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D; - s->supported_bilevel_resolutions = T4_SUPPORT_RESOLUTION_R8_STANDARD - | T4_SUPPORT_RESOLUTION_R8_FINE - | T4_SUPPORT_RESOLUTION_R8_SUPERFINE; + s->supported_compressions = T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D; + s->supported_bilevel_resolutions = T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400; s->supported_image_sizes = T4_SUPPORT_WIDTH_215MM | T4_SUPPORT_LENGTH_US_LETTER | T4_SUPPORT_LENGTH_US_LEGAL @@ -6822,7 +6708,7 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s, | T4_SUPPORT_LENGTH_UNLIMITED; /* Set the output encoding to something safe. Most things get 1D and 2D encoding right. Quite a lot get other things wrong. */ - s->supported_output_compressions = T4_COMPRESSION_T4_2D; + s->supported_output_compressions = T4_COMPRESSION_T4_2D | T4_COMPRESSION_T42_T81; s->local_min_scan_time_code = T30_MIN_SCAN_0MS; span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "T.30"); @@ -6843,7 +6729,7 @@ SPAN_DECLARE(int) t30_release(t30_state_t *s) SPAN_DECLARE(int) t30_free(t30_state_t *s) { t30_release(s); - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t30_api.c b/libs/spandsp/src/t30_api.c index af90452d91..a0a78b3164 100644 --- a/libs/spandsp/src/t30_api.c +++ b/libs/spandsp/src/t30_api.c @@ -41,10 +41,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/queue.h" @@ -277,8 +283,8 @@ SPAN_DECLARE(const char *) t30_get_rx_password(t30_state_t *s) SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len) { if (s->tx_info.nsf) - free(s->tx_info.nsf); - if (nsf && len > 0 && (s->tx_info.nsf = malloc(len + 3))) + span_free(s->tx_info.nsf); + if (nsf && len > 0 && (s->tx_info.nsf = span_alloc(len + 3))) { memcpy(s->tx_info.nsf + 3, nsf, len); s->tx_info.nsf_len = len; @@ -311,8 +317,8 @@ SPAN_DECLARE(size_t) t30_get_rx_nsf(t30_state_t *s, const uint8_t *nsf[]) SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len) { if (s->tx_info.nsc) - free(s->tx_info.nsc); - if (nsc && len > 0 && (s->tx_info.nsc = malloc(len + 3))) + span_free(s->tx_info.nsc); + if (nsc && len > 0 && (s->tx_info.nsc = span_alloc(len + 3))) { memcpy(s->tx_info.nsc + 3, nsc, len); s->tx_info.nsc_len = len; @@ -345,8 +351,8 @@ SPAN_DECLARE(size_t) t30_get_rx_nsc(t30_state_t *s, const uint8_t *nsc[]) SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len) { if (s->tx_info.nss) - free(s->tx_info.nss); - if (nss && len > 0 && (s->tx_info.nss = malloc(len + 3))) + span_free(s->tx_info.nss); + if (nss && len > 0 && (s->tx_info.nss = span_alloc(len + 3))) { memcpy(s->tx_info.nss + 3, nss, len); s->tx_info.nss_len = len; @@ -379,7 +385,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nss(t30_state_t *s, const uint8_t *nss[]) SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address, int len) { if (s->tx_info.tsa) - free(s->tx_info.tsa); + span_free(s->tx_info.tsa); if (address == NULL || len == 0) { s->tx_info.tsa = NULL; @@ -389,7 +395,7 @@ SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address, s->tx_info.tsa_type = type; if (len < 0) len = strlen(address); - if ((s->tx_info.tsa = malloc(len))) + if ((s->tx_info.tsa = span_alloc(len))) { memcpy(s->tx_info.tsa, address, len); s->tx_info.tsa_len = len; @@ -421,7 +427,7 @@ SPAN_DECLARE(size_t) t30_get_rx_tsa(t30_state_t *s, int *type, const char *addre SPAN_DECLARE(int) t30_set_tx_ira(t30_state_t *s, int type, const char *address, int len) { if (s->tx_info.ira) - free(s->tx_info.ira); + span_free(s->tx_info.ira); if (address == NULL) { s->tx_info.ira = NULL; @@ -455,7 +461,7 @@ SPAN_DECLARE(size_t) t30_get_rx_ira(t30_state_t *s, int *type, const char *addre SPAN_DECLARE(int) t30_set_tx_cia(t30_state_t *s, int type, const char *address, int len) { if (s->tx_info.cia) - free(s->tx_info.cia); + span_free(s->tx_info.cia); if (address == NULL) { s->tx_info.cia = NULL; @@ -489,7 +495,7 @@ SPAN_DECLARE(size_t) t30_get_rx_cia(t30_state_t *s, int *type, const char *addre SPAN_DECLARE(int) t30_set_tx_isp(t30_state_t *s, int type, const char *address, int len) { if (s->tx_info.isp) - free(s->tx_info.isp); + span_free(s->tx_info.isp); if (address == NULL) { s->tx_info.isp = NULL; @@ -523,7 +529,7 @@ SPAN_DECLARE(size_t) t30_get_rx_isp(t30_state_t *s, int *type, const char *addre SPAN_DECLARE(int) t30_set_tx_csa(t30_state_t *s, int type, const char *address, int len) { if (s->tx_info.csa) - free(s->tx_info.csa); + span_free(s->tx_info.csa); if (address == NULL) { s->tx_info.csa = NULL; @@ -554,7 +560,7 @@ SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *addre } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t30_set_tx_page_header_overlays_image(t30_state_t *s, int header_overlays_image) +SPAN_DECLARE(int) t30_set_tx_page_header_overlays_image(t30_state_t *s, bool header_overlays_image) { s->header_overlays_image = header_overlays_image; t4_tx_set_header_overlays_image(&s->t4.tx, s->header_overlays_image); @@ -589,7 +595,7 @@ SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring { if (tz_init(&s->tz, tzstring)) { - s->use_own_tz = TRUE; + s->use_own_tz = true; t4_tx_set_header_tz(&s->t4.tx, &s->tz); return 0; } @@ -632,13 +638,13 @@ SPAN_DECLARE(void) t30_set_tx_file(t30_state_t *s, const char *file, int start_p } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, int iaf) +SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, bool iaf) { s->iaf = iaf; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, int enabled) +SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, bool enabled) { s->ecm_allowed = enabled; t30_build_dis_or_dtc(s); @@ -685,31 +691,33 @@ SPAN_DECLARE(int) t30_set_supported_modems(t30_state_t *s, int supported_modems) SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_compressions) { /* Mask out the ones we actually support today. */ - supported_compressions &= T4_SUPPORT_COMPRESSION_T4_1D - | T4_SUPPORT_COMPRESSION_T4_2D - | T4_SUPPORT_COMPRESSION_T6 - | T4_SUPPORT_COMPRESSION_T85 - | T4_SUPPORT_COMPRESSION_T85_L0 + supported_compressions &= T4_COMPRESSION_T4_1D + | T4_COMPRESSION_T4_2D + | T4_COMPRESSION_T6 + | T4_COMPRESSION_T85 + | T4_COMPRESSION_T85_L0 #if defined(SPANDSP_SUPPORT_T88) - | T4_SUPPORT_COMPRESSION_T88 + | T4_COMPRESSION_T88 +#endif + | T4_COMPRESSION_T42_T81 +#if defined(SPANDSP_SUPPORT_SYCC_T81) + | T4_COMPRESSION_SYCC_T81 #endif - //| T4_SUPPORT_COMPRESSION_T81 #if defined(SPANDSP_SUPPORT_T43) - | T4_SUPPORT_COMPRESSION_T43 + | T4_COMPRESSION_T43 #endif #if defined(SPANDSP_SUPPORT_T45) - | T4_SUPPORT_COMPRESSION_T45 -#endif -#if 0 - | T4_SUPPORT_COMPRESSION_GRAYSCALE - | T4_SUPPORT_COMPRESSION_COLOUR - | T4_SUPPORT_COMPRESSION_12BIT - | T4_SUPPORT_COMPRESSION_COLOUR_TO_GRAY - | T4_SUPPORT_COMPRESSION_GRAY_TO_BILEVEL - | T4_SUPPORT_COMPRESSION_COLOUR_TO_BILEVEL - | T4_SUPPORT_COMPRESSION_RESCALING + | T4_COMPRESSION_T45 #endif + | T4_COMPRESSION_GRAYSCALE + | T4_COMPRESSION_COLOUR + | T4_COMPRESSION_12BIT + | T4_COMPRESSION_COLOUR_TO_GRAY + | T4_COMPRESSION_GRAY_TO_BILEVEL + | T4_COMPRESSION_COLOUR_TO_BILEVEL + | T4_COMPRESSION_RESCALING | 0; + s->supported_compressions = supported_compressions; t30_build_dis_or_dtc(s); return 0; @@ -718,23 +726,23 @@ SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_c SPAN_DECLARE(int) t30_set_supported_bilevel_resolutions(t30_state_t *s, int supported_resolutions) { - supported_resolutions &= T4_SUPPORT_RESOLUTION_R8_STANDARD - | T4_SUPPORT_RESOLUTION_R8_FINE - | T4_SUPPORT_RESOLUTION_R8_SUPERFINE - | T4_SUPPORT_RESOLUTION_R16_SUPERFINE - | T4_SUPPORT_RESOLUTION_200_100 - | T4_SUPPORT_RESOLUTION_200_200 - | T4_SUPPORT_RESOLUTION_200_400 - | T4_SUPPORT_RESOLUTION_300_300 - | T4_SUPPORT_RESOLUTION_300_600 - | T4_SUPPORT_RESOLUTION_400_400 - | T4_SUPPORT_RESOLUTION_400_800 - | T4_SUPPORT_RESOLUTION_600_600 - | T4_SUPPORT_RESOLUTION_600_1200 - | T4_SUPPORT_RESOLUTION_1200_1200; + supported_resolutions &= T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200; /* Make sure anything needed for colour is enabled as a bi-level image, as that is a rule from T.30. 100x100 is an exception, as it doesn't exist as a bi-level resolution. */ - supported_resolutions |= (s->supported_colour_resolutions & ~T4_SUPPORT_RESOLUTION_100_100); + supported_resolutions |= (s->supported_colour_resolutions & ~T4_RESOLUTION_100_100); s->supported_bilevel_resolutions = supported_resolutions; t30_build_dis_or_dtc(s); return 0; @@ -743,16 +751,16 @@ SPAN_DECLARE(int) t30_set_supported_bilevel_resolutions(t30_state_t *s, int supp SPAN_DECLARE(int) t30_set_supported_colour_resolutions(t30_state_t *s, int supported_resolutions) { - supported_resolutions &= T4_SUPPORT_RESOLUTION_100_100 - | T4_SUPPORT_RESOLUTION_200_200 - | T4_SUPPORT_RESOLUTION_300_300 - | T4_SUPPORT_RESOLUTION_400_400 - | T4_SUPPORT_RESOLUTION_600_600 - | T4_SUPPORT_RESOLUTION_1200_1200; + supported_resolutions &= T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_1200_1200; s->supported_colour_resolutions = supported_resolutions; /* Make sure anything needed for colour is enabled as a bi-level image, as that is a rule from T.30. 100x100 is an exception, as it doesn't exist as a bi-level resolution. */ - s->supported_bilevel_resolutions |= (s->supported_colour_resolutions & ~T4_SUPPORT_RESOLUTION_100_100); + s->supported_bilevel_resolutions |= (s->supported_colour_resolutions & ~T4_RESOLUTION_100_100); t30_build_dis_or_dtc(s); return 0; } diff --git a/libs/spandsp/src/t30_logging.c b/libs/spandsp/src/t30_logging.c index 33efcb9c03..ce1dc74664 100644 --- a/libs/spandsp/src/t30_logging.c +++ b/libs/spandsp/src/t30_logging.c @@ -41,6 +41,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 6a9f08d382..79ba8f5286 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -46,11 +46,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/bitstream.h" @@ -93,6 +99,7 @@ #include "spandsp/private/bitstream.h" #include "spandsp/private/t38_core.h" #include "spandsp/private/silence_gen.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/modem_connect_tones.h" #include "spandsp/private/v8.h" @@ -215,7 +222,7 @@ static int front_end_status(t31_state_t *s, int status) { at_modem_control(&s->at_state, AT_MODEM_CONTROL_HANGUP, NULL); t31_set_at_rx_mode(s, AT_MODE_ONHOOK_COMMAND); - s->at_state.do_hangup = FALSE; + s->at_state.do_hangup = false; } else { @@ -309,7 +316,7 @@ static int process_rx_missing(t38_core_state_t *t, void *user_data, int rx_seq_n t31_state_t *s; s = (t31_state_t *) user_data; - s->t38_fe.rx_data_missing = TRUE; + s->t38_fe.rx_data_missing = true; return 0; } /*- End of function --------------------------------------------------------*/ @@ -391,7 +398,7 @@ static int process_rx_indicator(t38_core_state_t *t, void *user_data, int indica } /*endswitch*/ fe->hdlc_rx.len = 0; - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; return 0; } /*- End of function --------------------------------------------------------*/ @@ -405,7 +412,7 @@ static void process_hdlc_data(t31_t38_front_end_state_t *fe, const uint8_t *buf, } else { - fe->rx_data_missing = TRUE; + fe->rx_data_missing = true; } /*endif*/ } @@ -460,7 +467,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, /* 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; + fe->rx_data_missing = true; /*endif*/ } /*endif*/ @@ -514,7 +521,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT); break; case T38_FIELD_HDLC_FCS_BAD: @@ -533,14 +540,14 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, { 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"); if (data_type == T38_DATA_V21) - hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE); + hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, false); else - hdlc_accept_t38_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE); + hdlc_accept_t38_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, false); /*endif*/ fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT); break; case T38_FIELD_HDLC_FCS_OK_SIG_END: @@ -586,7 +593,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type) { if (data_type == T38_DATA_V21) @@ -614,14 +621,14 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, { span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC bad, sig end (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean"); if (data_type == T38_DATA_V21) - hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE); + hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, false); else - hdlc_accept_t38_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE); + hdlc_accept_t38_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, false); /*endif*/ fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type) { if (data_type == T38_DATA_V21) @@ -653,7 +660,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, i.e. they send T38_FIELD_HDLC_FCS_OK, and then T38_FIELD_HDLC_SIG_END when the carrier actually drops. The other is because the HDLC signal drops unexpectedly - i.e. not just after a final frame. */ fe->hdlc_rx.len = 0; - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; fe->timeout_rx_samples = 0; if (data_type == T38_DATA_V21) hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN); @@ -669,7 +676,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (!s->at_state.rx_signal_present) { non_ecm_rx_status(s, SIG_STATUS_TRAINING_SUCCEEDED); - s->at_state.rx_signal_present = TRUE; + s->at_state.rx_signal_present = true; } /*endif*/ bit_reverse(buf2, buf, len); @@ -689,7 +696,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (!s->at_state.rx_signal_present) { non_ecm_rx_status(s, SIG_STATUS_TRAINING_SUCCEEDED); - s->at_state.rx_signal_present = TRUE; + s->at_state.rx_signal_present = true; } /*endif*/ bit_reverse(buf2, buf, len); @@ -703,7 +710,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, non_ecm_rx_status(s, SIG_STATUS_CARRIER_DOWN); } /*endif*/ - s->at_state.rx_signal_present = FALSE; + s->at_state.rx_signal_present = false; fe->timeout_rx_samples = 0; break; case T38_FIELD_CM_MESSAGE: @@ -1177,7 +1184,7 @@ static int stream_hdlc(t31_state_t *s) else { /* End of transmission */ - s->hdlc_tx.final = FALSE; + s->hdlc_tx.final = false; category = (fe->current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END; if ((res = t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK_SIG_END, NULL, 0, category)) < 0) return res; @@ -1301,7 +1308,7 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples) fe = &s->t38_fe; if (fe->current_rx_type == T30_MODEM_DONE || fe->current_tx_type == T30_MODEM_DONE) - return TRUE; + return true; /*endif*/ fe->samples += samples; @@ -1313,12 +1320,12 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples) } /*endif*/ if (fe->timed_step == T38_TIMED_STEP_NONE) - return FALSE; + 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->us_per_tx_chunk && fe->samples < fe->next_tx_samples) - return FALSE; + return false; /*endif*/ /* Its time to send something */ delay = 0; @@ -1347,7 +1354,7 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples) } /*endswitch*/ fe->next_tx_samples += us_to_samples(delay); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1369,7 +1376,7 @@ static int t31_modem_control_handler(at_state_t *s, void *user_data, int op, con case AT_MODEM_CONTROL_ONHOOK: if (t->non_ecm_tx.holding) { - t->non_ecm_tx.holding = FALSE; + t->non_ecm_tx.holding = false; /* Tell the application to release further data */ at_modem_control(&t->at_state, AT_MODEM_CONTROL_CTS, (void *) 1); } @@ -1413,15 +1420,15 @@ static void non_ecm_rx_status(void *user_data, int status) case SIG_STATUS_TRAINING_IN_PROGRESS: break; case SIG_STATUS_TRAINING_FAILED: - s->at_state.rx_trained = FALSE; - s->audio.modems.rx_trained = FALSE; + s->at_state.rx_trained = false; + s->audio.modems.rx_trained = false; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); - s->at_state.rx_signal_present = TRUE; - s->at_state.rx_trained = TRUE; - s->audio.modems.rx_trained = TRUE; + s->at_state.rx_signal_present = true; + s->at_state.rx_trained = true; + s->audio.modems.rx_trained = true; break; case SIG_STATUS_CARRIER_UP: break; @@ -1439,9 +1446,9 @@ static void non_ecm_rx_status(void *user_data, int status) t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); } /*endif*/ - s->at_state.rx_signal_present = FALSE; - s->at_state.rx_trained = FALSE; - s->audio.modems.rx_trained = FALSE; + s->at_state.rx_signal_present = false; + s->at_state.rx_trained = false; + s->audio.modems.rx_trained = false; break; default: if (s->at_state.p.result_code_format) @@ -1496,7 +1503,7 @@ static void non_ecm_put(void *user_data, const uint8_t buf[], int len) if (!s->at_state.rx_signal_present) { non_ecm_rx_status(s, SIG_STATUS_TRAINING_SUCCEEDED); - s->at_state.rx_signal_present = TRUE; + s->at_state.rx_signal_present = true; } /*endif*/ /* Ignore any fractional bytes which may have accumulated */ @@ -1546,20 +1553,20 @@ static int non_ecm_get_bit(void *user_data) release flow control. */ if (s->non_ecm_tx.out_bytes > T31_TX_BUF_LOW_TIDE) { - s->non_ecm_tx.holding = FALSE; + s->non_ecm_tx.holding = false; /* Tell the application to release further data */ at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 1); } /*endif*/ } /*endif*/ - s->non_ecm_tx.data_started = TRUE; + s->non_ecm_tx.data_started = true; } else { if (s->non_ecm_tx.final) { - s->non_ecm_tx.final = FALSE; + s->non_ecm_tx.final = false; /* This will put the modem into its shutdown sequence. When it has finally shut down, an OK response will be sent. */ return SIG_STATUS_END_OF_DATA; @@ -1603,20 +1610,20 @@ static int non_ecm_get(void *user_data, uint8_t buf[], int len) /* See if the buffer is approaching empty. It might be time to release flow control. */ if (s->non_ecm_tx.out_bytes > T31_TX_BUF_LOW_TIDE) { - s->non_ecm_tx.holding = FALSE; + s->non_ecm_tx.holding = false; /* Tell the application to release further data */ at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 1); } /*endif*/ } /*endif*/ - s->non_ecm_tx.data_started = TRUE; + s->non_ecm_tx.data_started = true; } else { if (s->non_ecm_tx.final) { - s->non_ecm_tx.final = FALSE; + s->non_ecm_tx.final = false; /* This will put the modem into its shutdown sequence. When it has finally shut down, an OK response will be sent. */ return i; @@ -1660,7 +1667,7 @@ static void hdlc_tx_underflow(void *user_data) s = (t31_state_t *) user_data; if (s->hdlc_tx.final) { - s->hdlc_tx.final = FALSE; + s->hdlc_tx.final = false; /* Schedule an orderly shutdown of the modem */ hdlc_tx_frame(&s->audio.modems.hdlc_tx, NULL, 0); } @@ -1688,21 +1695,21 @@ static void hdlc_rx_status(void *user_data, int status) case SIG_STATUS_TRAINING_IN_PROGRESS: break; case SIG_STATUS_TRAINING_FAILED: - s->at_state.rx_trained = FALSE; - s->audio.modems.rx_trained = FALSE; + s->at_state.rx_trained = false; + s->audio.modems.rx_trained = false; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ - s->at_state.rx_signal_present = TRUE; - s->at_state.rx_trained = TRUE; - s->audio.modems.rx_trained = TRUE; + s->at_state.rx_signal_present = true; + s->at_state.rx_trained = true; + s->audio.modems.rx_trained = true; break; case SIG_STATUS_CARRIER_UP: if (s->modem == FAX_MODEM_CNG_TONE_TX || s->modem == FAX_MODEM_NOCNG_TONE_TX || s->modem == FAX_MODEM_V21_RX) { - s->at_state.rx_signal_present = TRUE; - s->rx_frame_received = FALSE; - s->audio.modems.rx_frame_received = FALSE; + s->at_state.rx_signal_present = true; + s->rx_frame_received = false; + s->audio.modems.rx_frame_received = false; } /*endif*/ break; @@ -1714,14 +1721,14 @@ static void hdlc_rx_status(void *user_data, int status) if (s->at_state.ok_is_pending) { at_put_response_code(&s->at_state, AT_RESPONSE_CODE_OK); - s->at_state.ok_is_pending = FALSE; + s->at_state.ok_is_pending = false; } else { at_put_response_code(&s->at_state, AT_RESPONSE_CODE_NO_CARRIER); } /*endif*/ - s->at_state.dte_is_waiting = FALSE; + s->at_state.dte_is_waiting = false; t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); } else @@ -1732,9 +1739,9 @@ static void hdlc_rx_status(void *user_data, int status) /*endif*/ } /*endif*/ - s->at_state.rx_signal_present = FALSE; - s->at_state.rx_trained = FALSE; - s->audio.modems.rx_trained = FALSE; + s->at_state.rx_signal_present = false; + s->at_state.rx_trained = false; + s->audio.modems.rx_trained = false; break; case SIG_STATUS_FRAMING_OK: if (s->modem == FAX_MODEM_CNG_TONE_TX || s->modem == FAX_MODEM_NOCNG_TONE_TX) @@ -1742,7 +1749,7 @@ static void hdlc_rx_status(void *user_data, int status) /* Once we get any valid HDLC the CNG tone stops, and we drop to the V.21 receive modem on its own. */ s->modem = FAX_MODEM_V21_RX; - s->at_state.transmit = FALSE; + s->at_state.transmit = false; } /*endif*/ if (s->modem == FAX_MODEM_V17_RX || s->modem == FAX_MODEM_V27TER_RX || s->modem == FAX_MODEM_V29_RX) @@ -1753,12 +1760,12 @@ static void hdlc_rx_status(void *user_data, int status) V.21 receive mode. */ if (s->at_state.p.adaptive_receive) { - s->at_state.rx_signal_present = TRUE; - s->rx_frame_received = TRUE; - s->audio.modems.rx_frame_received = TRUE; + s->at_state.rx_signal_present = true; + s->rx_frame_received = true; + s->audio.modems.rx_frame_received = true; s->modem = FAX_MODEM_V21_RX; - s->at_state.transmit = FALSE; - s->at_state.dte_is_waiting = TRUE; + s->at_state.transmit = false; + s->at_state.dte_is_waiting = true; at_put_response_code(&s->at_state, AT_RESPONSE_CODE_FRH3); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); } @@ -1766,8 +1773,8 @@ static void hdlc_rx_status(void *user_data, int status) { s->modem = FAX_MODEM_SILENCE_TX; t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); - s->rx_frame_received = FALSE; - s->audio.modems.rx_frame_received = FALSE; + s->rx_frame_received = false; + s->audio.modems.rx_frame_received = false; at_put_response_code(&s->at_state, AT_RESPONSE_CODE_FCERROR); } /*endif*/ @@ -1780,8 +1787,8 @@ static void hdlc_rx_status(void *user_data, int status) { /* Report CONNECT as soon as possible to avoid a timeout. */ at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); - s->rx_frame_received = TRUE; - s->audio.modems.rx_frame_received = TRUE; + s->rx_frame_received = true; + s->audio.modems.rx_frame_received = true; } else { @@ -1824,8 +1831,8 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int { /* Report CONNECT as soon as possible to avoid a timeout. */ at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); - s->rx_frame_received = TRUE; - s->audio.modems.rx_frame_received = TRUE; + s->rx_frame_received = true; + s->audio.modems.rx_frame_received = true; } else { @@ -1859,14 +1866,14 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int { /* This is the last frame. We don't send OK until the carrier drops to avoid redetecting it later. */ - s->at_state.ok_is_pending = TRUE; + s->at_state.ok_is_pending = true; } else { at_put_response_code(&s->at_state, (ok) ? AT_RESPONSE_CODE_OK : AT_RESPONSE_CODE_ERROR); - s->at_state.dte_is_waiting = FALSE; - s->rx_frame_received = FALSE; - s->audio.modems.rx_frame_received = FALSE; + s->at_state.dte_is_waiting = false; + s->rx_frame_received = false; + s->audio.modems.rx_frame_received = false; } /*endif*/ } @@ -2014,13 +2021,13 @@ static void hdlc_accept_non_ecm_frame(void *user_data, const uint8_t *msg, int l static void t31_v21_rx(t31_state_t *s) { - s->at_state.ok_is_pending = FALSE; + s->at_state.ok_is_pending = false; s->hdlc_tx.len = 0; - s->hdlc_tx.final = FALSE; - s->dled = FALSE; - hdlc_rx_init(&s->audio.modems.hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s); + s->hdlc_tx.final = false; + s->dled = false; + hdlc_rx_init(&s->audio.modems.hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s); fax_modems_start_slow_modem(&s->audio.modems, FAX_MODEM_V21_RX); - s->at_state.transmit = TRUE; + s->at_state.transmit = true; } /*- End of function --------------------------------------------------------*/ @@ -2037,14 +2044,14 @@ static int restart_modem(t31_state_t *s, int new_modem) /*endif*/ queue_flush(s->rx_queue); s->modem = new_modem; - s->non_ecm_tx.final = FALSE; - s->at_state.rx_signal_present = FALSE; - s->at_state.rx_trained = FALSE; - s->audio.modems.rx_trained = FALSE; - s->rx_frame_received = FALSE; - s->audio.modems.rx_frame_received = FALSE; + s->non_ecm_tx.final = false; + s->at_state.rx_signal_present = false; + s->at_state.rx_trained = false; + s->audio.modems.rx_trained = false; + s->rx_frame_received = false; + s->audio.modems.rx_frame_received = false; fax_modems_set_rx_handler(t, (span_rx_handler_t) &span_dummy_rx, NULL, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); - use_hdlc = FALSE; + use_hdlc = false; switch (s->modem) { case FAX_MODEM_CNG_TONE_TX: @@ -2067,7 +2074,7 @@ static int restart_modem(t31_state_t *s, int new_modem) fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } /*endif*/ - s->at_state.transmit = TRUE; + s->at_state.transmit = true; break; case FAX_MODEM_NOCNG_TONE_TX: if (s->t38_mode) @@ -2081,7 +2088,7 @@ static int restart_modem(t31_state_t *s, int new_modem) fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); } /*endif*/ - s->at_state.transmit = FALSE; + s->at_state.transmit = false; break; case FAX_MODEM_CED_TONE_TX: if (s->t38_mode) @@ -2096,7 +2103,7 @@ static int restart_modem(t31_state_t *s, int new_modem) fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } /*endif*/ - s->at_state.transmit = TRUE; + s->at_state.transmit = true; break; case FAX_MODEM_V21_RX: if (s->t38_mode) @@ -2114,13 +2121,13 @@ static int restart_modem(t31_state_t *s, int new_modem) { s->t38_fe.next_tx_indicator = T38_IND_V21_PREAMBLE; s->t38_fe.current_tx_data_type = T38_DATA_V21; - use_hdlc = TRUE; + use_hdlc = true; s->t38_fe.timed_step = (use_hdlc) ? T38_TIMED_STEP_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM; set_octets_per_data_packet(s, 300); } else { - hdlc_tx_init(&t->hdlc_tx, FALSE, 2, FALSE, hdlc_tx_underflow, s); + hdlc_tx_init(&t->hdlc_tx, false, 2, false, hdlc_tx_underflow, s); /* The spec says 1s +-15% of preamble. So, the minimum is 32 octets. */ hdlc_tx_flags(&t->hdlc_tx, 32); fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); @@ -2129,9 +2136,9 @@ static int restart_modem(t31_state_t *s, int new_modem) } /*endif*/ s->hdlc_tx.len = 0; - s->hdlc_tx.final = FALSE; - s->dled = FALSE; - s->at_state.transmit = TRUE; + s->hdlc_tx.final = false; + s->dled = false; + s->at_state.transmit = true; break; case FAX_MODEM_V17_RX: case FAX_MODEM_V27TER_RX: @@ -2143,7 +2150,7 @@ static int restart_modem(t31_state_t *s, int new_modem) fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); } /*endif*/ - s->at_state.transmit = FALSE; + s->at_state.transmit = false; break; case FAX_MODEM_V17_TX: if (s->t38_mode) @@ -2177,8 +2184,8 @@ static int restart_modem(t31_state_t *s, int new_modem) } /*endif*/ s->non_ecm_tx.out_bytes = 0; - s->non_ecm_tx.data_started = FALSE; - s->at_state.transmit = TRUE; + s->non_ecm_tx.data_started = false; + s->at_state.transmit = true; break; case FAX_MODEM_V27TER_TX: if (s->t38_mode) @@ -2204,8 +2211,8 @@ static int restart_modem(t31_state_t *s, int new_modem) } /*endif*/ s->non_ecm_tx.out_bytes = 0; - s->non_ecm_tx.data_started = FALSE; - s->at_state.transmit = TRUE; + s->non_ecm_tx.data_started = false; + s->at_state.transmit = true; break; case FAX_MODEM_V29_TX: if (s->t38_mode) @@ -2231,8 +2238,8 @@ static int restart_modem(t31_state_t *s, int new_modem) } /*endif*/ s->non_ecm_tx.out_bytes = 0; - s->non_ecm_tx.data_started = FALSE; - s->at_state.transmit = TRUE; + s->non_ecm_tx.data_started = false; + s->at_state.transmit = true; break; case FAX_MODEM_SILENCE_TX: if (s->t38_mode) @@ -2251,7 +2258,7 @@ static int restart_modem(t31_state_t *s, int new_modem) fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } /*endif*/ - s->at_state.transmit = FALSE; + s->at_state.transmit = false; break; case FAX_MODEM_SILENCE_RX: if (!s->t38_mode) @@ -2262,7 +2269,7 @@ static int restart_modem(t31_state_t *s, int new_modem) fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } /*endif*/ - s->at_state.transmit = FALSE; + s->at_state.transmit = false; break; case FAX_MODEM_FLUSH: /* Send 200ms of silence to "push" the last audio out */ @@ -2278,7 +2285,7 @@ static int restart_modem(t31_state_t *s, int new_modem) silence_gen_alter(&t->silence_gen, ms_to_samples(200)); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - s->at_state.transmit = TRUE; + s->at_state.transmit = true; } /*endif*/ break; @@ -2300,7 +2307,7 @@ static __inline__ void dle_unstuff_hdlc(t31_state_t *s, const char *stuffed, int { if (s->dled) { - s->dled = FALSE; + s->dled = false; if (stuffed[i] == ETX) { s->hdlc_tx.final = (s->hdlc_tx.buf[1] & 0x10); @@ -2329,7 +2336,7 @@ static __inline__ void dle_unstuff_hdlc(t31_state_t *s, const char *stuffed, int else { if (stuffed[i] == DLE) - s->dled = TRUE; + s->dled = true; else s->hdlc_tx.buf[s->hdlc_tx.len++] = stuffed[i]; /*endif*/ @@ -2348,10 +2355,10 @@ static __inline__ void dle_unstuff_fake_hdlc(t31_state_t *s, const char *stuffed { if (s->dled) { - s->dled = FALSE; + s->dled = false; if (stuffed[i] == ETX) { - s->non_ecm_tx.final = TRUE; + s->non_ecm_tx.final = true; t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); return; } @@ -2369,7 +2376,7 @@ static __inline__ void dle_unstuff_fake_hdlc(t31_state_t *s, const char *stuffed else { if (stuffed[i] == DLE) - s->dled = TRUE; + s->dled = true; else hdlc_rx_put_byte(&s->t38_fe.hdlc_rx_non_ecm, bit_reverse8(stuffed[i])); /*endif*/ @@ -2388,10 +2395,10 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len) { if (s->dled) { - s->dled = FALSE; + s->dled = false; if (stuffed[i] == ETX) { - s->non_ecm_tx.final = TRUE; + s->non_ecm_tx.final = true; t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); return; } @@ -2410,7 +2417,7 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len) else { if (stuffed[i] == DLE) - s->dled = TRUE; + s->dled = true; else s->non_ecm_tx.buf[s->non_ecm_tx.in_bytes++] = stuffed[i]; /*endif*/ @@ -2430,7 +2437,7 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len) /* See if the buffer is approaching full. We might need to apply flow control. */ if (s->non_ecm_tx.in_bytes > T31_TX_BUF_HIGH_TIDE) { - s->non_ecm_tx.holding = TRUE; + s->non_ecm_tx.holding = true; /* Tell the application to hold further data */ at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 0); } @@ -2452,7 +2459,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int s = (t31_state_t *) user_data; new_transmit = direction; - immediate_response = TRUE; + immediate_response = true; switch (operation) { case 'S': @@ -2466,7 +2473,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int else silence_gen_alter(&s->audio.modems.silence_gen, ms_to_samples(val*10)); /*endif*/ - s->at_state.transmit = TRUE; + s->at_state.transmit = true; } else { @@ -2486,7 +2493,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int /*endif*/ } /*endif*/ - immediate_response = FALSE; + immediate_response = false; span_log(&s->logging, SPAN_LOG_FLOW, "Silence %dms\n", val*10); break; case 'H': @@ -2494,7 +2501,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int { case 3: new_modem = (new_transmit) ? FAX_MODEM_V21_TX : FAX_MODEM_V21_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 300; break; default: @@ -2505,7 +2512,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int if (new_modem != s->modem) { restart_modem(s, new_modem); - immediate_response = FALSE; + immediate_response = false; } /*endif*/ s->at_state.transmit = new_transmit; @@ -2520,8 +2527,8 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int { /* Send straight away, if there is something queued. */ t31_set_at_rx_mode(s, AT_MODE_DELIVERY); - s->rx_frame_received = FALSE; - s->audio.modems.rx_frame_received = FALSE; + s->rx_frame_received = false; + s->audio.modems.rx_frame_received = false; do { if (!queue_empty(s->rx_queue)) @@ -2550,7 +2557,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int } else { - s->at_state.dte_is_waiting = TRUE; + s->at_state.dte_is_waiting = true; break; } /*endif*/ @@ -2558,7 +2565,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int while (msg[0] == AT_RESPONSE_CODE_CONNECT); } /*endif*/ - immediate_response = FALSE; + immediate_response = false; break; default: switch (val) @@ -2567,84 +2574,84 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int s->t38_fe.next_tx_indicator = T38_IND_V27TER_2400_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V27TER_2400; new_modem = (new_transmit) ? FAX_MODEM_V27TER_TX : FAX_MODEM_V27TER_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 2400; break; case 48: s->t38_fe.next_tx_indicator = T38_IND_V27TER_4800_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V27TER_4800; new_modem = (new_transmit) ? FAX_MODEM_V27TER_TX : FAX_MODEM_V27TER_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 4800; break; case 72: s->t38_fe.next_tx_indicator = T38_IND_V29_7200_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V29_7200; new_modem = (new_transmit) ? FAX_MODEM_V29_TX : FAX_MODEM_V29_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 7200; break; case 96: s->t38_fe.next_tx_indicator = T38_IND_V29_9600_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V29_9600; new_modem = (new_transmit) ? FAX_MODEM_V29_TX : FAX_MODEM_V29_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 9600; break; case 73: s->t38_fe.next_tx_indicator = T38_IND_V17_7200_LONG_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_7200; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 7200; break; case 74: s->t38_fe.next_tx_indicator = T38_IND_V17_7200_SHORT_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_7200; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = TRUE; + s->short_train = true; s->bit_rate = 7200; break; case 97: s->t38_fe.next_tx_indicator = T38_IND_V17_9600_LONG_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_9600; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 9600; break; case 98: s->t38_fe.next_tx_indicator = T38_IND_V17_9600_SHORT_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_9600; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = TRUE; + s->short_train = true; s->bit_rate = 9600; break; case 121: s->t38_fe.next_tx_indicator = T38_IND_V17_12000_LONG_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_12000; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 12000; break; case 122: s->t38_fe.next_tx_indicator = T38_IND_V17_12000_SHORT_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_12000; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = TRUE; + s->short_train = true; s->bit_rate = 12000; break; case 145: s->t38_fe.next_tx_indicator = T38_IND_V17_14400_LONG_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_14400; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = FALSE; + s->short_train = false; s->bit_rate = 14400; break; case 146: s->t38_fe.next_tx_indicator = T38_IND_V17_14400_SHORT_TRAINING; s->t38_fe.current_tx_data_type = T38_DATA_V17_14400; new_modem = (new_transmit) ? FAX_MODEM_V17_TX : FAX_MODEM_V17_RX; - s->short_train = TRUE; + s->short_train = true; s->bit_rate = 14400; break; default: @@ -2663,7 +2670,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int } /*endif*/ restart_modem(s, new_modem); - immediate_response = FALSE; + immediate_response = false; break; } /*endswitch*/ @@ -2707,7 +2714,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) } /*endif*/ s->at_state.rx_data_bytes = 0; - s->at_state.transmit = FALSE; + s->at_state.transmit = false; s->modem = FAX_MODEM_SILENCE_TX; fax_modems_set_rx_handler(&s->audio.modems, (span_rx_handler_t) &span_dummy_rx, NULL, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); @@ -2900,19 +2907,19 @@ SPAN_DECLARE_NONSTD(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t31_set_transmit_on_idle(t31_state_t *s, int transmit_on_idle) +SPAN_DECLARE(void) t31_set_transmit_on_idle(t31_state_t *s, bool transmit_on_idle) { s->audio.modems.transmit_on_idle = transmit_on_idle; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, int use_tep) +SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, bool use_tep) { s->audio.modems.use_tep = use_tep; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, int without_pacing) +SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, bool without_pacing) { if (without_pacing) { @@ -2940,7 +2947,7 @@ SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, int without_pacing) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, int t38_mode) +SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, bool t38_mode) { s->t38_mode = t38_mode; span_log(&s->logging, SPAN_LOG_FLOW, "Mode set to %d\n", s->t38_mode); @@ -2992,8 +2999,8 @@ static int t31_t38_fe_init(t31_state_t *t, t->hdlc_tx.ptr = 0; - hdlc_tx_init(&s->hdlc_tx_non_ecm, FALSE, 1, FALSE, hdlc_tx_underflow2, s); - hdlc_rx_init(&s->hdlc_rx_non_ecm, FALSE, TRUE, 2, hdlc_accept_non_ecm_frame, t); + hdlc_tx_init(&s->hdlc_tx_non_ecm, false, 1, false, hdlc_tx_underflow2, s); + hdlc_rx_init(&s->hdlc_rx_non_ecm, false, true, 2, hdlc_accept_non_ecm_frame, t); return 0; } /*- End of function --------------------------------------------------------*/ @@ -3013,13 +3020,13 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, return NULL; /*endif*/ - alloced = FALSE; + alloced = false; if (s == NULL) { - if ((s = (t31_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (t31_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; /*endif*/ - alloced = TRUE; + alloced = true; } /*endif*/ memset(s, 0, sizeof(*s)); @@ -3029,7 +3036,7 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, s->modem_control_handler = modem_control_handler; s->modem_control_user_data = modem_control_user_data; fax_modems_init(&s->audio.modems, - FALSE, + false, hdlc_accept_frame, hdlc_tx_underflow, non_ecm_put_bit, @@ -3051,27 +3058,27 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, v8_parms.pstn_access = 0; v8_parms.nsf = -1; v8_parms.t66 = -1; - v8_init(&s->audio.v8, FALSE, &v8_parms, v8_handler, s); + v8_init(&s->audio.v8, false, &v8_parms, v8_handler, s); power_meter_init(&s->audio.rx_power, 4); s->audio.last_sample = 0; s->audio.silence_threshold_power = power_meter_level_dbm0(-36); - s->at_state.rx_signal_present = FALSE; - s->at_state.rx_trained = FALSE; - s->audio.modems.rx_trained = FALSE; + s->at_state.rx_signal_present = false; + s->at_state.rx_trained = false; + s->audio.modems.rx_trained = false; - s->at_state.do_hangup = FALSE; + s->at_state.do_hangup = false; s->at_state.line_ptr = 0; s->audio.silence_heard = 0; s->silence_awaited = 0; s->call_samples = 0; s->modem = FAX_MODEM_NONE; - s->at_state.transmit = TRUE; + s->at_state.transmit = true; if ((s->rx_queue = queue_init(NULL, 4096, QUEUE_WRITE_ATOMIC | QUEUE_READ_ATOMIC)) == NULL) { if (alloced) - free(s); + span_free(s); /*endif*/ return NULL; } @@ -3082,10 +3089,10 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, if (tx_t38_packet_handler) { t31_t38_fe_init(s, tx_t38_packet_handler, tx_t38_packet_user_data); - t31_set_t38_config(s, FALSE); + t31_set_t38_config(s, false); } /*endif*/ - s->t38_mode = FALSE; + s->t38_mode = false; return s; } /*- End of function --------------------------------------------------------*/ @@ -3100,7 +3107,7 @@ SPAN_DECLARE(int) t31_release(t31_state_t *s) SPAN_DECLARE(int) t31_free(t31_state_t *s) { t31_release(s); - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t35.c b/libs/spandsp/src/t35.c index 3e210854ab..ce04a6ce23 100644 --- a/libs/spandsp/src/t35.c +++ b/libs/spandsp/src/t35.c @@ -61,6 +61,11 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" #include "spandsp/bit_operations.h" @@ -86,7 +91,7 @@ typedef struct int vendor_id_len; /*! The vendor's name */ const char *vendor_name; - /*! TRUE if the station ID for this vendor is reversed */ + /*! True if the station ID for this vendor is reversed */ int inverse_station_id_order; /*! A pointer to a list of known models from this vendor */ const model_data_t *known_models; @@ -273,260 +278,260 @@ static const model_data_t Muratec48[] = static const nsf_data_t vendor_00[] = { /* Japan */ - {"\x00\x00", 2, "Unknown - indeterminate", TRUE, NULL}, - {"\x00\x01", 2, "Anritsu", FALSE, NULL}, - {"\x00\x02", 2, "Nippon Telephone", FALSE, NULL}, - {"\x00\x05", 2, "Mitsuba Electric", FALSE, NULL}, - {"\x00\x06", 2, "Master Net", FALSE, NULL}, - {"\x00\x09", 2, "Xerox/Toshiba", TRUE, Xerox}, - {"\x00\x0A", 2, "Kokusai", FALSE, NULL}, - {"\x00\x0D", 2, "Logic System International", FALSE, NULL}, - {"\x00\x0E", 2, "Panasonic", FALSE, Panasonic0E}, - {"\x00\x11", 2, "Canon", FALSE, Canon}, - {"\x00\x15", 2, "Toyotsushen Machinery", FALSE, NULL}, - {"\x00\x16", 2, "System House Mind", FALSE, NULL}, - {"\x00\x19", 2, "Xerox", TRUE, NULL}, - {"\x00\x1D", 2, "Hitachi Software", FALSE, NULL}, - {"\x00\x21", 2, "OKI Electric/Lanier", TRUE, NULL}, - {"\x00\x25", 2, "Ricoh", TRUE, Ricoh}, - {"\x00\x26", 2, "Konica", FALSE, NULL}, - {"\x00\x29", 2, "Japan Wireless", FALSE, NULL}, - {"\x00\x2D", 2, "Sony", FALSE, NULL}, - {"\x00\x31", 2, "Sharp/Olivetti", FALSE, Sharp}, - {"\x00\x35", 2, "Kogyu", FALSE, NULL}, - {"\x00\x36", 2, "Japan Telecom", FALSE, NULL}, - {"\x00\x3D", 2, "IBM Japan", FALSE, NULL}, - {"\x00\x39", 2, "Panasonic", FALSE, NULL}, - {"\x00\x41", 2, "Swasaki Communication", FALSE, NULL}, - {"\x00\x45", 2, "Muratec", FALSE, Muratec45}, - {"\x00\x46", 2, "Pheonix", FALSE, NULL}, - {"\x00\x48", 2, "Muratec", FALSE, Muratec48}, /* Not registered */ - {"\x00\x49", 2, "Japan Electric", FALSE, NULL}, - {"\x00\x4D", 2, "Okura Electric", FALSE, NULL}, - {"\x00\x51", 2, "Sanyo", FALSE, Sanyo}, - {"\x00\x55", 2, "Unknown - Japan 55", FALSE, NULL}, - {"\x00\x56", 2, "Brother", FALSE, Brother}, - {"\x00\x59", 2, "Fujitsu", FALSE, NULL}, - {"\x00\x5D", 2, "Kuoni", FALSE, NULL}, - {"\x00\x61", 2, "Casio", FALSE, NULL}, - {"\x00\x65", 2, "Tateishi Electric", FALSE, NULL}, - {"\x00\x66", 2, "Utax/Mita", TRUE, NULL}, - {"\x00\x69", 2, "Hitachi Production", FALSE, NULL}, - {"\x00\x6D", 2, "Hitachi Telecom", FALSE, NULL}, - {"\x00\x71", 2, "Tamura Electric Works", FALSE, NULL}, - {"\x00\x75", 2, "Tokyo Electric Corp.", FALSE, NULL}, - {"\x00\x76", 2, "Advance", FALSE, NULL}, - {"\x00\x79", 2, "Panasonic", FALSE, Panasonic79}, - {"\x00\x7D", 2, "Seiko", FALSE, NULL}, - {"\x08\x00", 2, "Daiko", FALSE, NULL}, - {"\x10\x00", 2, "Funai Electric", FALSE, NULL}, - {"\x20\x00", 2, "Eagle System", FALSE, NULL}, - {"\x30\x00", 2, "Nippon Business Systems", FALSE, NULL}, - {"\x40\x00", 2, "Comtron", FALSE, NULL}, - {"\x48\x00", 2, "Cosmo Consulting", FALSE, NULL}, - {"\x50\x00", 2, "Orion Electric", FALSE, NULL}, - {"\x60\x00", 2, "Nagano Nippon", FALSE, NULL}, - {"\x70\x00", 2, "Kyocera", FALSE, NULL}, - {"\x80\x00", 2, "Kanda Networks", FALSE, NULL}, - {"\x88\x00", 2, "Soft Front", FALSE, NULL}, - {"\x90\x00", 2, "Arctic", FALSE, NULL}, - {"\xA0\x00", 2, "Nakushima", FALSE, NULL}, - {"\xB0\x00", 2, "Minolta", FALSE, NULL}, - {"\xC0\x00", 2, "Tohoku Pioneer", FALSE, NULL}, - {"\xD0\x00", 2, "USC", FALSE, NULL}, - {"\xE0\x00", 2, "Hiboshi", FALSE, NULL}, - {"\xF0\x00", 2, "Sumitomo Electric", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\x00", 2, "Unknown - indeterminate", true, NULL}, + {"\x00\x01", 2, "Anritsu", false, NULL}, + {"\x00\x02", 2, "Nippon Telephone", false, NULL}, + {"\x00\x05", 2, "Mitsuba Electric", false, NULL}, + {"\x00\x06", 2, "Master Net", false, NULL}, + {"\x00\x09", 2, "Xerox/Toshiba", true, Xerox}, + {"\x00\x0A", 2, "Kokusai", false, NULL}, + {"\x00\x0D", 2, "Logic System International", false, NULL}, + {"\x00\x0E", 2, "Panasonic", false, Panasonic0E}, + {"\x00\x11", 2, "Canon", false, Canon}, + {"\x00\x15", 2, "Toyotsushen Machinery", false, NULL}, + {"\x00\x16", 2, "System House Mind", false, NULL}, + {"\x00\x19", 2, "Xerox", true, NULL}, + {"\x00\x1D", 2, "Hitachi Software", false, NULL}, + {"\x00\x21", 2, "OKI Electric/Lanier", true, NULL}, + {"\x00\x25", 2, "Ricoh", true, Ricoh}, + {"\x00\x26", 2, "Konica", false, NULL}, + {"\x00\x29", 2, "Japan Wireless", false, NULL}, + {"\x00\x2D", 2, "Sony", false, NULL}, + {"\x00\x31", 2, "Sharp/Olivetti", false, Sharp}, + {"\x00\x35", 2, "Kogyu", false, NULL}, + {"\x00\x36", 2, "Japan Telecom", false, NULL}, + {"\x00\x3D", 2, "IBM Japan", false, NULL}, + {"\x00\x39", 2, "Panasonic", false, NULL}, + {"\x00\x41", 2, "Swasaki Communication", false, NULL}, + {"\x00\x45", 2, "Muratec", false, Muratec45}, + {"\x00\x46", 2, "Pheonix", false, NULL}, + {"\x00\x48", 2, "Muratec", false, Muratec48}, /* Not registered */ + {"\x00\x49", 2, "Japan Electric", false, NULL}, + {"\x00\x4D", 2, "Okura Electric", false, NULL}, + {"\x00\x51", 2, "Sanyo", false, Sanyo}, + {"\x00\x55", 2, "Unknown - Japan 55", false, NULL}, + {"\x00\x56", 2, "Brother", false, Brother}, + {"\x00\x59", 2, "Fujitsu", false, NULL}, + {"\x00\x5D", 2, "Kuoni", false, NULL}, + {"\x00\x61", 2, "Casio", false, NULL}, + {"\x00\x65", 2, "Tateishi Electric", false, NULL}, + {"\x00\x66", 2, "Utax/Mita", true, NULL}, + {"\x00\x69", 2, "Hitachi Production", false, NULL}, + {"\x00\x6D", 2, "Hitachi Telecom", false, NULL}, + {"\x00\x71", 2, "Tamura Electric Works", false, NULL}, + {"\x00\x75", 2, "Tokyo Electric Corp.", false, NULL}, + {"\x00\x76", 2, "Advance", false, NULL}, + {"\x00\x79", 2, "Panasonic", false, Panasonic79}, + {"\x00\x7D", 2, "Seiko", false, NULL}, + {"\x08\x00", 2, "Daiko", false, NULL}, + {"\x10\x00", 2, "Funai Electric", false, NULL}, + {"\x20\x00", 2, "Eagle System", false, NULL}, + {"\x30\x00", 2, "Nippon Business Systems", false, NULL}, + {"\x40\x00", 2, "Comtron", false, NULL}, + {"\x48\x00", 2, "Cosmo Consulting", false, NULL}, + {"\x50\x00", 2, "Orion Electric", false, NULL}, + {"\x60\x00", 2, "Nagano Nippon", false, NULL}, + {"\x70\x00", 2, "Kyocera", false, NULL}, + {"\x80\x00", 2, "Kanda Networks", false, NULL}, + {"\x88\x00", 2, "Soft Front", false, NULL}, + {"\x90\x00", 2, "Arctic", false, NULL}, + {"\xA0\x00", 2, "Nakushima", false, NULL}, + {"\xB0\x00", 2, "Minolta", false, NULL}, + {"\xC0\x00", 2, "Tohoku Pioneer", false, NULL}, + {"\xD0\x00", 2, "USC", false, NULL}, + {"\xE0\x00", 2, "Hiboshi", false, NULL}, + {"\xF0\x00", 2, "Sumitomo Electric", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_20[] = { /* Germany */ - {"\x09", 1, "ITK Institut für Telekommunikation GmbH & Co KG", FALSE, NULL}, - {"\x11", 1, "Dr. Neuhaus Mikroelektronik", FALSE, NULL}, - {"\x21", 1, "ITO Communication", FALSE, NULL}, - {"\x31", 1, "mbp Kommunikationssysteme GmbH", FALSE, NULL}, - {"\x41", 1, "Siemens", FALSE, NULL}, - {"\x42", 1, "Deutsche Telekom AG", FALSE, NULL}, - {"\x51", 1, "mps Software", FALSE, NULL}, - {"\x61", 1, "Hauni Elektronik", FALSE, NULL}, - {"\x71", 1, "Digitronic computersysteme gmbh", FALSE, NULL}, - {"\x81\x00", 2, "Innovaphone GmbH", FALSE, NULL}, - {"\x81\x40", 2, "TEDAS Gesellschaft für Telekommunikations-, Daten- und Audiosysteme mbH", FALSE, NULL}, - {"\x81\x80", 2, "AVM Audiovisuelles Marketing und Computersysteme GmbH", FALSE, NULL}, - {"\x81\xC0", 2, "EICON Technology Research GmbH", FALSE, NULL}, - {"\xB1", 1, "Schneider Rundfunkwerke AG", FALSE, NULL}, - {"\xC2", 1, "Deutsche Telekom AG", FALSE, NULL}, - {"\xD1", 1, "Ferrari electronik GmbH", FALSE, NULL}, - {"\xF1", 1, "DeTeWe - Deutsche Telephonwerke AG & Co", FALSE, NULL}, - {"\xFF", 1, "Germany Regional Code", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x09", 1, "ITK Institut für Telekommunikation GmbH & Co KG", false, NULL}, + {"\x11", 1, "Dr. Neuhaus Mikroelektronik", false, NULL}, + {"\x21", 1, "ITO Communication", false, NULL}, + {"\x31", 1, "mbp Kommunikationssysteme GmbH", false, NULL}, + {"\x41", 1, "Siemens", false, NULL}, + {"\x42", 1, "Deutsche Telekom AG", false, NULL}, + {"\x51", 1, "mps Software", false, NULL}, + {"\x61", 1, "Hauni Elektronik", false, NULL}, + {"\x71", 1, "Digitronic computersysteme gmbh", false, NULL}, + {"\x81\x00", 2, "Innovaphone GmbH", false, NULL}, + {"\x81\x40", 2, "TEDAS Gesellschaft für Telekommunikations-, Daten- und Audiosysteme mbH", false, NULL}, + {"\x81\x80", 2, "AVM Audiovisuelles Marketing und Computersysteme GmbH", false, NULL}, + {"\x81\xC0", 2, "EICON Technology Research GmbH", false, NULL}, + {"\xB1", 1, "Schneider Rundfunkwerke AG", false, NULL}, + {"\xC2", 1, "Deutsche Telekom AG", false, NULL}, + {"\xD1", 1, "Ferrari electronik GmbH", false, NULL}, + {"\xF1", 1, "DeTeWe - Deutsche Telephonwerke AG & Co", false, NULL}, + {"\xFF", 1, "Germany Regional Code", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_64[] = { /* China (not Lebanon) */ - {"\x00\x00", 2, "Unknown - China 00 00", FALSE, NULL}, - {"\x01\x00", 2, "Unknown - China 01 00", FALSE, NULL}, - {"\x01\x01", 2, "Unknown - China 01 01", FALSE, NULL}, - {"\x01\x02", 2, "Unknown - China 01 02", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\x00", 2, "Unknown - China 00 00", false, NULL}, + {"\x01\x00", 2, "Unknown - China 01 00", false, NULL}, + {"\x01\x01", 2, "Unknown - China 01 01", false, NULL}, + {"\x01\x02", 2, "Unknown - China 01 02", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_61[] = { /* Korea */ - {"\x00\x7A", 2, "Xerox", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\x7A", 2, "Xerox", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_86[] = { /* Korea (not Papua New Guinea) */ - {"\x00\x02", 2, "Unknown - Korea 02", FALSE, NULL}, - {"\x00\x06", 2, "Unknown - Korea 06", FALSE, NULL}, - {"\x00\x08", 2, "Unknown - Korea 08", FALSE, NULL}, - {"\x00\x0A", 2, "Unknown - Korea 0A", FALSE, NULL}, - {"\x00\x0E", 2, "Unknown - Korea 0E", FALSE, NULL}, - {"\x00\x10", 2, "Samsung", FALSE, NULL}, - {"\x00\x11", 2, "Unknown - Korea 11", FALSE, NULL}, - {"\x00\x16", 2, "Samsung", FALSE, Samsung16}, - {"\x00\x1A", 2, "Unknown - Korea 1A", FALSE, NULL}, - {"\x00\x40", 2, "Unknown - Korea 40", FALSE, NULL}, - {"\x00\x48", 2, "Unknown - Korea 48", FALSE, NULL}, - {"\x00\x52", 2, "Unknown - Korea 52", FALSE, NULL}, - {"\x00\x5A", 2, "Samsung", FALSE, Samsung5A}, - {"\x00\x5E", 2, "Unknown - Korea 5E", FALSE, NULL}, - {"\x00\x66", 2, "Unknown - Korea 66", FALSE, NULL}, - {"\x00\x6E", 2, "Unknown - Korea 6E", FALSE, NULL}, - {"\x00\x82", 2, "Unknown - Korea 82", FALSE, NULL}, - {"\x00\x88", 2, "Unknown - Korea 88", FALSE, NULL}, - {"\x00\x8A", 2, "Unknown - Korea 8A", FALSE, NULL}, - {"\x00\x8C", 2, "Samsung", FALSE, Samsung8C}, - {"\x00\x92", 2, "Unknown - Korea 92", FALSE, NULL}, - {"\x00\x98", 2, "Samsung", FALSE, NULL}, - {"\x00\xA2", 2, "Samsung", FALSE, SamsungA2}, - {"\x00\xA4", 2, "Unknown - Korea A4", FALSE, NULL}, - {"\x00\xC2", 2, "Samsung", FALSE, NULL}, - {"\x00\xC9", 2, "Unknown - Korea C9", FALSE, NULL}, - {"\x00\xCC", 2, "Unknown - Korea CC", FALSE, NULL}, - {"\x00\xD2", 2, "Unknown - Korea D2", FALSE, NULL}, - {"\x00\xDA", 2, "Xerox", FALSE, XeroxDA}, - {"\x00\xE2", 2, "Unknown - Korea E2", FALSE, NULL}, - {"\x00\xEC", 2, "Unknown - Korea EC", FALSE, NULL}, - {"\x00\xEE", 2, "Unknown - Korea EE", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\x02", 2, "Unknown - Korea 02", false, NULL}, + {"\x00\x06", 2, "Unknown - Korea 06", false, NULL}, + {"\x00\x08", 2, "Unknown - Korea 08", false, NULL}, + {"\x00\x0A", 2, "Unknown - Korea 0A", false, NULL}, + {"\x00\x0E", 2, "Unknown - Korea 0E", false, NULL}, + {"\x00\x10", 2, "Samsung", false, NULL}, + {"\x00\x11", 2, "Unknown - Korea 11", false, NULL}, + {"\x00\x16", 2, "Samsung", false, Samsung16}, + {"\x00\x1A", 2, "Unknown - Korea 1A", false, NULL}, + {"\x00\x40", 2, "Unknown - Korea 40", false, NULL}, + {"\x00\x48", 2, "Unknown - Korea 48", false, NULL}, + {"\x00\x52", 2, "Unknown - Korea 52", false, NULL}, + {"\x00\x5A", 2, "Samsung", false, Samsung5A}, + {"\x00\x5E", 2, "Unknown - Korea 5E", false, NULL}, + {"\x00\x66", 2, "Unknown - Korea 66", false, NULL}, + {"\x00\x6E", 2, "Unknown - Korea 6E", false, NULL}, + {"\x00\x82", 2, "Unknown - Korea 82", false, NULL}, + {"\x00\x88", 2, "Unknown - Korea 88", false, NULL}, + {"\x00\x8A", 2, "Unknown - Korea 8A", false, NULL}, + {"\x00\x8C", 2, "Samsung", false, Samsung8C}, + {"\x00\x92", 2, "Unknown - Korea 92", false, NULL}, + {"\x00\x98", 2, "Samsung", false, NULL}, + {"\x00\xA2", 2, "Samsung", false, SamsungA2}, + {"\x00\xA4", 2, "Unknown - Korea A4", false, NULL}, + {"\x00\xC2", 2, "Samsung", false, NULL}, + {"\x00\xC9", 2, "Unknown - Korea C9", false, NULL}, + {"\x00\xCC", 2, "Unknown - Korea CC", false, NULL}, + {"\x00\xD2", 2, "Unknown - Korea D2", false, NULL}, + {"\x00\xDA", 2, "Xerox", false, XeroxDA}, + {"\x00\xE2", 2, "Unknown - Korea E2", false, NULL}, + {"\x00\xEC", 2, "Unknown - Korea EC", false, NULL}, + {"\x00\xEE", 2, "Unknown - Korea EE", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_bc[] = { /* France */ - {"\x53\x01", 2, "Minolta", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x53\x01", 2, "Minolta", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_ad[] = { /* United States (not Tunisia) */ - {"\x00\x00", 2, "Pitney Bowes", FALSE, PitneyBowes}, - {"\x00\x0C", 2, "Dialogic", FALSE, NULL}, - {"\x00\x15", 2, "Lexmark", FALSE, Lexmark}, - {"\x00\x16", 2, "JetFax", FALSE, JetFax}, - {"\x00\x24", 2, "Octel", FALSE, NULL}, - {"\x00\x36", 2, "HP", FALSE, HP}, - {"\x00\x42", 2, "FaxTalk", FALSE, NULL}, - {"\x00\x44", 2, NULL, TRUE, NULL}, - {"\x00\x46", 2, "BrookTrout", FALSE, NULL}, - {"\x00\x51", 2, "Telogy Networks", FALSE, NULL}, - {"\x00\x55", 2, "HylaFAX", FALSE, NULL}, - {"\x00\x5C", 2, "IBM", FALSE, NULL}, - {"\x00\x98", 2, "Unknown - USA 98", TRUE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\x00", 2, "Pitney Bowes", false, PitneyBowes}, + {"\x00\x0C", 2, "Dialogic", false, NULL}, + {"\x00\x15", 2, "Lexmark", false, Lexmark}, + {"\x00\x16", 2, "JetFax", false, JetFax}, + {"\x00\x24", 2, "Octel", false, NULL}, + {"\x00\x36", 2, "HP", false, HP}, + {"\x00\x42", 2, "FaxTalk", false, NULL}, + {"\x00\x44", 2, NULL, true, NULL}, + {"\x00\x46", 2, "BrookTrout", false, NULL}, + {"\x00\x51", 2, "Telogy Networks", false, NULL}, + {"\x00\x55", 2, "HylaFAX", false, NULL}, + {"\x00\x5C", 2, "IBM", false, NULL}, + {"\x00\x98", 2, "Unknown - USA 98", true, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_b4[] = { /* United Kingdom */ - {"\x00\xB0", 2, "DCE", FALSE, NULL}, - {"\x00\xB1", 2, "Hasler", FALSE, NULL}, - {"\x00\xB2", 2, "Interquad", FALSE, NULL}, - {"\x00\xB3", 2, "Comwave", FALSE, NULL}, - {"\x00\xB4", 2, "Iconographic", FALSE, NULL}, - {"\x00\xB5", 2, "Wordcraft", FALSE, NULL}, - {"\x00\xB6", 2, "Acorn", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\xB0", 2, "DCE", false, NULL}, + {"\x00\xB1", 2, "Hasler", false, NULL}, + {"\x00\xB2", 2, "Interquad", false, NULL}, + {"\x00\xB3", 2, "Comwave", false, NULL}, + {"\x00\xB4", 2, "Iconographic", false, NULL}, + {"\x00\xB5", 2, "Wordcraft", false, NULL}, + {"\x00\xB6", 2, "Acorn", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const nsf_data_t vendor_b5[] = { /* United States */ - {"\x00\x01", 2, "Picturetel", FALSE, NULL}, - {"\x00\x20", 2, "Conexant", FALSE, NULL}, - {"\x00\x22", 2, "Comsat", FALSE, NULL}, - {"\x00\x24", 2, "Octel", FALSE, NULL}, - {"\x00\x26", 2, "ROLM", FALSE, NULL}, - {"\x00\x28", 2, "SOFNET", FALSE, NULL}, - {"\x00\x29", 2, "TIA TR-29 Committee", FALSE, NULL}, - {"\x00\x2A", 2, "STF Tech", FALSE, NULL}, - {"\x00\x2C", 2, "HKB", FALSE, NULL}, - {"\x00\x2E", 2, "Delrina", FALSE, NULL}, - {"\x00\x30", 2, "Dialogic", FALSE, NULL}, - {"\x00\x32", 2, "Applied Synergy", FALSE, NULL}, - {"\x00\x34", 2, "Syncro Development", FALSE, NULL}, - {"\x00\x36", 2, "Genoa", FALSE, NULL}, - {"\x00\x38", 2, "Texas Instruments", FALSE, NULL}, - {"\x00\x3A", 2, "IBM", FALSE, NULL}, - {"\x00\x3C", 2, "ViaSat", FALSE, NULL}, - {"\x00\x3E", 2, "Ericsson", FALSE, NULL}, - {"\x00\x42", 2, "Bogosian", FALSE, NULL}, - {"\x00\x44", 2, "Adobe", FALSE, NULL}, - {"\x00\x46", 2, "Fremont Communications", FALSE, NULL}, - {"\x00\x48", 2, "Hayes", FALSE, NULL}, - {"\x00\x4A", 2, "Lucent", FALSE, NULL}, - {"\x00\x4C", 2, "Data Race", FALSE, NULL}, - {"\x00\x4E", 2, "TRW", FALSE, NULL}, - {"\x00\x52", 2, "Audiofax", FALSE, NULL}, - {"\x00\x54", 2, "Computer Automation", FALSE, NULL}, - {"\x00\x56", 2, "Serca", FALSE, NULL}, - {"\x00\x58", 2, "Octocom", FALSE, NULL}, - {"\x00\x5C", 2, "Power Solutions", FALSE, NULL}, - {"\x00\x5A", 2, "Digital Sound", FALSE, NULL}, - {"\x00\x5E", 2, "Pacific Data", FALSE, NULL}, - {"\x00\x60", 2, "Commetrex", FALSE, NULL}, - {"\x00\x62", 2, "BrookTrout", FALSE, NULL}, - {"\x00\x64", 2, "Gammalink", FALSE, NULL}, - {"\x00\x66", 2, "Castelle", FALSE, NULL}, - {"\x00\x68", 2, "Hybrid Fax", FALSE, NULL}, - {"\x00\x6A", 2, "Omnifax", FALSE, NULL}, - {"\x00\x6C", 2, "HP", FALSE, NULL}, - {"\x00\x6E", 2, "Microsoft", FALSE, NULL}, - {"\x00\x72", 2, "Speaking Devices", FALSE, NULL}, - {"\x00\x74", 2, "Compaq", FALSE, NULL}, - {"\x00\x76", 2, "Microsoft", FALSE, NULL}, /* uses LSB for country but MSB for manufacturer */ - {"\x00\x78", 2, "Cylink", FALSE, NULL}, - {"\x00\x7A", 2, "Pitney Bowes", FALSE, NULL}, - {"\x00\x7C", 2, "Digiboard", FALSE, NULL}, - {"\x00\x7E", 2, "Codex", FALSE, NULL}, - {"\x00\x82", 2, "Wang Labs", FALSE, NULL}, - {"\x00\x84", 2, "Netexpress Communications", FALSE, NULL}, - {"\x00\x86", 2, "Cable-Sat", FALSE, NULL}, - {"\x00\x88", 2, "MFPA", FALSE, NULL}, - {"\x00\x8A", 2, "Telogy Networks", FALSE, NULL}, - {"\x00\x8E", 2, "Telecom Multimedia Systems", FALSE, NULL}, - {"\x00\x8C", 2, "AT&T", FALSE, NULL}, - {"\x00\x92", 2, "Nuera", FALSE, NULL}, - {"\x00\x94", 2, "K56flex", FALSE, NULL}, - {"\x00\x96", 2, "MiBridge", FALSE, NULL}, - {"\x00\x98", 2, "Xerox", FALSE, NULL}, - {"\x00\x9A", 2, "Fujitsu", FALSE, NULL}, - {"\x00\x9B", 2, "Fujitsu", FALSE, NULL}, - {"\x00\x9C", 2, "Natural Microsystems", FALSE, NULL}, - {"\x00\x9E", 2, "CopyTele", FALSE, NULL}, - {"\x00\xA2", 2, "Murata", FALSE, NULL}, - {"\x00\xA4", 2, "Lanier", FALSE, NULL}, - {"\x00\xA6", 2, "Qualcomm", FALSE, NULL}, - {"\x00\xAA", 2, "HylaFAX", FALSE, NULL}, - {NULL, 0, NULL, FALSE, NULL} + {"\x00\x01", 2, "Picturetel", false, NULL}, + {"\x00\x20", 2, "Conexant", false, NULL}, + {"\x00\x22", 2, "Comsat", false, NULL}, + {"\x00\x24", 2, "Octel", false, NULL}, + {"\x00\x26", 2, "ROLM", false, NULL}, + {"\x00\x28", 2, "SOFNET", false, NULL}, + {"\x00\x29", 2, "TIA TR-29 Committee", false, NULL}, + {"\x00\x2A", 2, "STF Tech", false, NULL}, + {"\x00\x2C", 2, "HKB", false, NULL}, + {"\x00\x2E", 2, "Delrina", false, NULL}, + {"\x00\x30", 2, "Dialogic", false, NULL}, + {"\x00\x32", 2, "Applied Synergy", false, NULL}, + {"\x00\x34", 2, "Syncro Development", false, NULL}, + {"\x00\x36", 2, "Genoa", false, NULL}, + {"\x00\x38", 2, "Texas Instruments", false, NULL}, + {"\x00\x3A", 2, "IBM", false, NULL}, + {"\x00\x3C", 2, "ViaSat", false, NULL}, + {"\x00\x3E", 2, "Ericsson", false, NULL}, + {"\x00\x42", 2, "Bogosian", false, NULL}, + {"\x00\x44", 2, "Adobe", false, NULL}, + {"\x00\x46", 2, "Fremont Communications", false, NULL}, + {"\x00\x48", 2, "Hayes", false, NULL}, + {"\x00\x4A", 2, "Lucent", false, NULL}, + {"\x00\x4C", 2, "Data Race", false, NULL}, + {"\x00\x4E", 2, "TRW", false, NULL}, + {"\x00\x52", 2, "Audiofax", false, NULL}, + {"\x00\x54", 2, "Computer Automation", false, NULL}, + {"\x00\x56", 2, "Serca", false, NULL}, + {"\x00\x58", 2, "Octocom", false, NULL}, + {"\x00\x5C", 2, "Power Solutions", false, NULL}, + {"\x00\x5A", 2, "Digital Sound", false, NULL}, + {"\x00\x5E", 2, "Pacific Data", false, NULL}, + {"\x00\x60", 2, "Commetrex", false, NULL}, + {"\x00\x62", 2, "BrookTrout", false, NULL}, + {"\x00\x64", 2, "Gammalink", false, NULL}, + {"\x00\x66", 2, "Castelle", false, NULL}, + {"\x00\x68", 2, "Hybrid Fax", false, NULL}, + {"\x00\x6A", 2, "Omnifax", false, NULL}, + {"\x00\x6C", 2, "HP", false, NULL}, + {"\x00\x6E", 2, "Microsoft", false, NULL}, + {"\x00\x72", 2, "Speaking Devices", false, NULL}, + {"\x00\x74", 2, "Compaq", false, NULL}, + {"\x00\x76", 2, "Microsoft", false, NULL}, /* uses LSB for country but MSB for manufacturer */ + {"\x00\x78", 2, "Cylink", false, NULL}, + {"\x00\x7A", 2, "Pitney Bowes", false, NULL}, + {"\x00\x7C", 2, "Digiboard", false, NULL}, + {"\x00\x7E", 2, "Codex", false, NULL}, + {"\x00\x82", 2, "Wang Labs", false, NULL}, + {"\x00\x84", 2, "Netexpress Communications", false, NULL}, + {"\x00\x86", 2, "Cable-Sat", false, NULL}, + {"\x00\x88", 2, "MFPA", false, NULL}, + {"\x00\x8A", 2, "Telogy Networks", false, NULL}, + {"\x00\x8E", 2, "Telecom Multimedia Systems", false, NULL}, + {"\x00\x8C", 2, "AT&T", false, NULL}, + {"\x00\x92", 2, "Nuera", false, NULL}, + {"\x00\x94", 2, "K56flex", false, NULL}, + {"\x00\x96", 2, "MiBridge", false, NULL}, + {"\x00\x98", 2, "Xerox", false, NULL}, + {"\x00\x9A", 2, "Fujitsu", false, NULL}, + {"\x00\x9B", 2, "Fujitsu", false, NULL}, + {"\x00\x9C", 2, "Natural Microsystems", false, NULL}, + {"\x00\x9E", 2, "CopyTele", false, NULL}, + {"\x00\xA2", 2, "Murata", false, NULL}, + {"\x00\xA4", 2, "Lanier", false, NULL}, + {"\x00\xA6", 2, "Qualcomm", false, NULL}, + {"\x00\xAA", 2, "HylaFAX", false, NULL}, + {NULL, 0, NULL, false, NULL} }; static const country_code_t t35_country_codes[255] = @@ -904,7 +909,7 @@ SPAN_DECLARE(const char *) t35_vendor_to_str(const uint8_t *msg, int len) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t35_decode(const uint8_t *msg, int len, const char **country, const char **vendor, const char **model) +SPAN_DECLARE(bool) t35_decode(const uint8_t *msg, int len, const char **country, const char **vendor, const char **model) { const nsf_data_t *p; const model_data_t *pp; @@ -917,7 +922,7 @@ SPAN_DECLARE(int) t35_decode(const uint8_t *msg, int len, const char **country, *model = NULL; if ((p = find_vendor(msg, len)) == NULL) - return FALSE; + return false; if (vendor) *vendor = p->vendor_name; if (model && p->known_models) @@ -933,7 +938,7 @@ SPAN_DECLARE(int) t35_decode(const uint8_t *msg, int len, const char **country, } } } - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_core.c b/libs/spandsp/src/t38_core.c index ae6526f7e8..0bbbd18fb6 100644 --- a/libs/spandsp/src/t38_core.c +++ b/libs/spandsp/src/t38_core.c @@ -41,12 +41,18 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/t38_core.h" @@ -455,7 +461,7 @@ SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_stream(t38_core_state_t *s, const uint8 //printf("Count is %d\n", count); /* Do a dummy run through the fields to check we have a complete and uncorrupted packet. */ prev_ptr = ptr; - other_half = FALSE; + other_half = false; t30_field_type = 0; for (i = 0; i < (int) count; i++) { @@ -472,7 +478,7 @@ SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_stream(t38_core_state_t *s, const uint8 /* Decode field_type */ t30_field_type = buf[ptr] & 0x7; ptr++; - other_half = FALSE; + other_half = false; } else { @@ -482,7 +488,7 @@ SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_stream(t38_core_state_t *s, const uint8 if (field_data_present) ptr++; else - other_half = TRUE; + other_half = true; } if (t30_field_type > T38_FIELD_T4_NON_ECM_SIG_END) { @@ -537,7 +543,7 @@ SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_stream(t38_core_state_t *s, const uint8 /* Things look alright in the data, so lets run through the fields again, actually processing them. There is no need to do all the error checking along the way on this pass. */ ptr = prev_ptr; - other_half = FALSE; + other_half = false; for (i = 0; i < (int) count; i++) { if (s->t38_version == 0) @@ -551,7 +557,7 @@ SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_stream(t38_core_state_t *s, const uint8 /* Decode field_type */ t30_field_type = buf[ptr] & 0x7; ptr++; - other_half = FALSE; + other_half = false; } else { @@ -561,7 +567,7 @@ SPAN_DECLARE_NONSTD(int) t38_core_rx_ifp_stream(t38_core_state_t *s, const uint8 if (field_data_present) ptr++; else - other_half = TRUE; + other_half = true; } } else @@ -1001,19 +1007,19 @@ SPAN_DECLARE(void) t38_set_data_transport_protocol(t38_core_state_t *s, int data } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_set_fill_bit_removal(t38_core_state_t *s, int fill_bit_removal) +SPAN_DECLARE(void) t38_set_fill_bit_removal(t38_core_state_t *s, bool fill_bit_removal) { s->fill_bit_removal = fill_bit_removal; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_set_mmr_transcoding(t38_core_state_t *s, int mmr_transcoding) +SPAN_DECLARE(void) t38_set_mmr_transcoding(t38_core_state_t *s, bool mmr_transcoding) { s->mmr_transcoding = mmr_transcoding; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_set_jbig_transcoding(t38_core_state_t *s, int jbig_transcoding) +SPAN_DECLARE(void) t38_set_jbig_transcoding(t38_core_state_t *s, bool jbig_transcoding) { s->jbig_transcoding = jbig_transcoding; } @@ -1037,7 +1043,7 @@ SPAN_DECLARE(void) t38_set_t38_version(t38_core_state_t *s, int t38_version) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_set_sequence_number_handling(t38_core_state_t *s, int check) +SPAN_DECLARE(void) t38_set_sequence_number_handling(t38_core_state_t *s, bool check) { s->check_sequence_numbers = check; } @@ -1049,7 +1055,7 @@ SPAN_DECLARE(void) t38_set_pace_transmission(t38_core_state_t *s, int pace_trans } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_set_tep_handling(t38_core_state_t *s, int allow_for_tep) +SPAN_DECLARE(void) t38_set_tep_handling(t38_core_state_t *s, bool allow_for_tep) { s->allow_for_tep = allow_for_tep; } @@ -1109,7 +1115,7 @@ SPAN_DECLARE(t38_core_state_t *) t38_core_init(t38_core_state_t *s, { if (s == NULL) { - if ((s = (t38_core_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t38_core_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1120,14 +1126,14 @@ SPAN_DECLARE(t38_core_state_t *) t38_core_init(t38_core_state_t *s, T.38 domain - e.g. from SDP data. */ s->data_rate_management_method = T38_DATA_RATE_MANAGEMENT_TRANSFERRED_TCF; s->data_transport_protocol = T38_TRANSPORT_UDPTL; - s->fill_bit_removal = FALSE; - s->mmr_transcoding = FALSE; - s->jbig_transcoding = FALSE; + s->fill_bit_removal = false; + s->mmr_transcoding = false; + s->jbig_transcoding = false; s->max_buffer_size = 400; s->max_datagram_size = 100; s->t38_version = 0; - s->check_sequence_numbers = TRUE; - s->pace_transmission = TRUE; + s->check_sequence_numbers = true; + s->pace_transmission = true; /* Set some defaults */ s->category_control[T38_PACKET_CATEGORY_INDICATOR] = 1; @@ -1157,7 +1163,7 @@ SPAN_DECLARE(int) t38_core_release(t38_core_state_t *s) SPAN_DECLARE(int) t38_core_free(t38_core_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 7656332e80..78346e3ecf 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -42,6 +42,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #if defined(LOG_FAX_AUDIO) @@ -50,6 +55,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/queue.h" #include "spandsp/dc_restore.h" @@ -94,6 +100,7 @@ #include "spandsp/private/logging.h" #include "spandsp/private/silence_gen.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/v17tx.h" #include "spandsp/private/v17rx.h" @@ -270,22 +277,22 @@ static int set_next_tx_type(t38_gateway_state_t *s) || t->tx_handler == (span_tx_handler_t) &tone_gen) { - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); } else { - fax_modems_set_rx_active(t, FALSE); + fax_modems_set_rx_active(t, false); } /*endif*/ - return TRUE; + return true; } /*endif*/ u = &s->core.hdlc_to_modem; if (u->in == u->out) - return FALSE; + return false; /*endif*/ if ((u->buf[u->out].contents & FLAG_INDICATOR) == 0) - return FALSE; + return false; /*endif*/ indicator = (u->buf[u->out].contents & 0xFF); u->buf[u->out].len = 0; @@ -298,15 +305,15 @@ static int set_next_tx_type(t38_gateway_state_t *s) if (s->core.image_data_mode && s->core.ecm_mode) { span_log(&s->logging, SPAN_LOG_FLOW, "HDLC mode\n"); - hdlc_tx_init(&t->hdlc_tx, FALSE, 2, TRUE, hdlc_underflow_handler, s); + hdlc_tx_init(&t->hdlc_tx, false, 2, true, hdlc_underflow_handler, s); fax_modems_set_get_bit(t, (get_bit_func_t) hdlc_tx_get_bit, &t->hdlc_tx); - use_hdlc = TRUE; + use_hdlc = true; } else { span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM mode\n"); fax_modems_set_get_bit(t, (get_bit_func_t) t38_non_ecm_buffer_get_bit, &s->core.non_ecm_to_modem); - use_hdlc = FALSE; + use_hdlc = false; } /*endif*/ switch (indicator) @@ -317,31 +324,31 @@ static int set_next_tx_type(t38_gateway_state_t *s) //silence_gen_set(&t->silence_gen, ms_to_samples(75)); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_CNG: t->tx_bit_rate = 0; fax_modems_start_slow_modem(t, FAX_MODEM_CNG_TONE_TX); silence_gen_set(&t->silence_gen, 0); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_CED: t->tx_bit_rate = 0; fax_modems_start_slow_modem(t, FAX_MODEM_CED_TONE_TX); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_V21_PREAMBLE: t->tx_bit_rate = 300; - hdlc_tx_init(&t->hdlc_tx, FALSE, 2, TRUE, hdlc_underflow_handler, s); + hdlc_tx_init(&t->hdlc_tx, false, 2, true, hdlc_underflow_handler, s); hdlc_tx_flags(&t->hdlc_tx, 32); silence_gen_alter(&t->silence_gen, ms_to_samples(75)); u->buf[u->in].len = 0; fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &fsk_tx, &t->v21_tx); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_V27TER_2400_TRAINING: case T38_IND_V27TER_4800_TRAINING: @@ -351,7 +358,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_TX, bit_rate, s->core.short_train, use_hdlc); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_V29_7200_TRAINING: case T38_IND_V29_9600_TRAINING: @@ -361,7 +368,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) fax_modems_start_fast_modem(t, FAX_MODEM_V29_TX, bit_rate, s->core.short_train, use_hdlc); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_V17_7200_SHORT_TRAINING: case T38_IND_V17_7200_LONG_TRAINING: @@ -371,32 +378,32 @@ static int set_next_tx_type(t38_gateway_state_t *s) case T38_IND_V17_12000_LONG_TRAINING: case T38_IND_V17_14400_SHORT_TRAINING: case T38_IND_V17_14400_LONG_TRAINING: - short_train = FALSE; + short_train = false; switch (indicator) { case T38_IND_V17_7200_SHORT_TRAINING: - short_train = TRUE; + short_train = true; bit_rate = 7200; break; case T38_IND_V17_7200_LONG_TRAINING: bit_rate = 7200; break; case T38_IND_V17_9600_SHORT_TRAINING: - short_train = TRUE; + short_train = true; bit_rate = 9600; break; case T38_IND_V17_9600_LONG_TRAINING: bit_rate = 9600; break; case T38_IND_V17_12000_SHORT_TRAINING: - short_train = TRUE; + short_train = true; bit_rate = 12000; break; case T38_IND_V17_12000_LONG_TRAINING: bit_rate = 12000; break; case T38_IND_V17_14400_SHORT_TRAINING: - short_train = TRUE; + short_train = true; bit_rate = 14400; break; case T38_IND_V17_14400_LONG_TRAINING: @@ -409,7 +416,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) fax_modems_start_fast_modem(t, FAX_MODEM_V17_TX, bit_rate, short_train, use_hdlc); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); - fax_modems_set_rx_active(t, TRUE); + fax_modems_set_rx_active(t, true); break; case T38_IND_V8_ANSAM: t->tx_bit_rate = 300; @@ -441,7 +448,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) hdlc_tx_flags(&t->hdlc_tx, t->tx_bit_rate/(8*5)); /*endif*/ s->t38x.in_progress_rx_indicator = indicator; - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -509,7 +516,7 @@ static void edit_control_messages(t38_gateway_state_t *s, int from_modem, uint8_ processed, 2 machines which recognise each other might do special things we cannot handle as a middle man. */ span_log(&s->logging, SPAN_LOG_FLOW, "Corrupting %s message to prevent recognition\n", t30_frametype(buf[2])); - s->t38x.corrupt_current_frame[from_modem] = TRUE; + s->t38x.corrupt_current_frame[from_modem] = true; } /*endif*/ break; @@ -644,8 +651,8 @@ static void monitor_control_messages(t38_gateway_state_t *s, case T30_CFR: /* We are changing from TCF exchange to image exchange */ /* Successful training means we should change to short training */ - s->core.image_data_mode = TRUE; - s->core.short_train = TRUE; + s->core.image_data_mode = true; + s->core.short_train = true; span_log(&s->logging, SPAN_LOG_FLOW, "CFR - short train = %d, ECM = %d\n", s->core.short_train, s->core.ecm_mode); if (!from_modem) restart_rx_modem(s); @@ -654,14 +661,14 @@ static void monitor_control_messages(t38_gateway_state_t *s, case T30_RTN: case T30_RTP: /* We are going back to the exchange of fresh TCF */ - s->core.image_data_mode = FALSE; - s->core.short_train = FALSE; + s->core.image_data_mode = false; + s->core.short_train = false; break; case T30_CTR: /* T.30 says the first image data after this does full training, yet does not return to TCF. This seems to be the sole case of long training for image data. */ - s->core.short_train = FALSE; + s->core.short_train = false; break; case T30_DTC: case T30_DCS: @@ -670,8 +677,8 @@ static void monitor_control_messages(t38_gateway_state_t *s, correct modem. */ s->core.fast_bit_rate = 0; s->core.fast_rx_modem = FAX_MODEM_NONE; - s->core.image_data_mode = FALSE; - s->core.short_train = FALSE; + s->core.image_data_mode = false; + s->core.short_train = false; if (from_modem) s->core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_BEGIN; /*endif*/ @@ -721,13 +728,13 @@ static void monitor_control_messages(t38_gateway_state_t *s, the fast modem again, so abandon our idea of it. */ s->core.fast_bit_rate = 0; s->core.fast_rx_modem = FAX_MODEM_NONE; - s->core.image_data_mode = FALSE; - s->core.short_train = FALSE; + s->core.image_data_mode = false; + s->core.short_train = false; #endif /* Fall through */ case T30_MPS: case T30_PRI_MPS: - s->core.count_page_on_mcf = TRUE; + s->core.count_page_on_mcf = true; break; } /*endswitch*/ @@ -747,15 +754,15 @@ static void monitor_control_messages(t38_gateway_state_t *s, the fast modem again, so abandon our idea of it. */ s->core.fast_bit_rate = 0; s->core.fast_rx_modem = FAX_MODEM_NONE; - s->core.image_data_mode = FALSE; - s->core.short_train = FALSE; + s->core.image_data_mode = false; + s->core.short_train = false; #endif /* Fall through */ case T30_MPS: case T30_MPS | 1: case T30_PRI_MPS: case T30_PRI_MPS | 1: - s->core.count_page_on_mcf = TRUE; + s->core.count_page_on_mcf = true; break; case T30_MCF: case T30_MCF | 1: @@ -763,7 +770,7 @@ static void monitor_control_messages(t38_gateway_state_t *s, { s->core.pages_confirmed++; span_log(&s->logging, SPAN_LOG_FLOW, "Pages confirmed = %d\n", s->core.pages_confirmed); - s->core.count_page_on_mcf = FALSE; + s->core.count_page_on_mcf = false; } /*endif*/ break; @@ -1093,9 +1100,9 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, { if ((hdlc_buf->flags & HDLC_FLAG_MISSING_DATA) == 0) { - monitor_control_messages(s, FALSE, hdlc_buf->buf, hdlc_buf->len); + monitor_control_messages(s, false, hdlc_buf->buf, hdlc_buf->len); if (s->core.real_time_frame_handler) - s->core.real_time_frame_handler(s, s->core.real_time_frame_user_data, FALSE, hdlc_buf->buf, hdlc_buf->len); + s->core.real_time_frame_handler(s, s->core.real_time_frame_user_data, false, hdlc_buf->buf, hdlc_buf->len); /*endif*/ } /*endif*/ @@ -1106,11 +1113,11 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, long training. There has to be more than one value HDLC frame in a chunk of image data, so just setting short training mode here should be enough. */ - s->core.short_train = TRUE; + s->core.short_train = true; } /*endif*/ hdlc_buf->contents = (data_type | FLAG_DATA); - finalise_hdlc_frame(s, TRUE); + finalise_hdlc_frame(s, true); } else { @@ -1118,7 +1125,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, hdlc_buf->contents = 0; } /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; case T38_FIELD_HDLC_FCS_BAD: xx->current_rx_field_class = T38_FIELD_CLASS_HDLC; @@ -1144,7 +1151,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, } /*endif*/ hdlc_buf->contents = (data_type | FLAG_DATA); - finalise_hdlc_frame(s, FALSE); + finalise_hdlc_frame(s, false); } else { @@ -1152,7 +1159,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, hdlc_buf->contents = 0; } /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; case T38_FIELD_HDLC_FCS_OK_SIG_END: xx->current_rx_field_class = T38_FIELD_CLASS_HDLC; @@ -1181,9 +1188,9 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, { if ((hdlc_buf->flags & HDLC_FLAG_MISSING_DATA) == 0) { - monitor_control_messages(s, FALSE, hdlc_buf->buf, hdlc_buf->len); + monitor_control_messages(s, false, hdlc_buf->buf, hdlc_buf->len); if (s->core.real_time_frame_handler) - s->core.real_time_frame_handler(s, s->core.real_time_frame_user_data, FALSE, hdlc_buf->buf, hdlc_buf->len); + s->core.real_time_frame_handler(s, s->core.real_time_frame_user_data, false, hdlc_buf->buf, hdlc_buf->len); /*endif*/ } /*endif*/ @@ -1194,11 +1201,11 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, long training. There has to be more than one value HDLC frame in a chunk of image data, so just setting short training mode here should be enough. */ - s->core.short_train = TRUE; + s->core.short_train = true; } /*endif*/ hdlc_buf->contents = (data_type | FLAG_DATA); - finalise_hdlc_frame(s, TRUE); + finalise_hdlc_frame(s, true); } else { @@ -1212,7 +1219,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, xx->current_rx_field_class = T38_FIELD_CLASS_NONE; } /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; case T38_FIELD_HDLC_FCS_BAD_SIG_END: xx->current_rx_field_class = T38_FIELD_CLASS_HDLC; @@ -1238,7 +1245,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, } /*endif*/ hdlc_buf->contents = (data_type | FLAG_DATA); - finalise_hdlc_frame(s, FALSE); + finalise_hdlc_frame(s, false); } else { @@ -1252,7 +1259,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, xx->current_rx_field_class = T38_FIELD_CLASS_NONE; } /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; case T38_FIELD_HDLC_SIG_END: hdlc_buf = &s->core.hdlc_to_modem.buf[s->core.hdlc_to_modem.in]; @@ -1298,7 +1305,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, xx->current_rx_field_class = T38_FIELD_CLASS_NONE; } /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; case T38_FIELD_T4_NON_ECM_DATA: if (xx->current_rx_field_class == T38_FIELD_CLASS_NONE) @@ -1314,7 +1321,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (len > 0) t38_non_ecm_buffer_inject(&s->core.non_ecm_to_modem, buf, len); /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; case T38_FIELD_T4_NON_ECM_SIG_END: if (xx->current_rx_field_class == T38_FIELD_CLASS_NONE) @@ -1369,7 +1376,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, xx->current_rx_field_class = T38_FIELD_CLASS_NONE; } /*endif*/ - xx->corrupt_current_frame[0] = FALSE; + xx->corrupt_current_frame[0] = false; break; default: break; @@ -1520,11 +1527,11 @@ static void non_ecm_rx_status(void *user_data, int status) break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ - s->audio.modems.rx_signal_present = TRUE; - s->audio.modems.rx_trained = TRUE; + s->audio.modems.rx_signal_present = true; + s->audio.modems.rx_trained = true; s->core.timed_mode = TIMED_MODE_IDLE; s->core.samples_to_timeout = 0; - s->core.short_train = TRUE; + s->core.short_train = true; to_t38_buffer_init(&s->core.to_t38); break; case SIG_STATUS_CARRIER_UP: @@ -1700,11 +1707,11 @@ static void hdlc_rx_status(hdlc_rx_state_t *t, int status) break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained. */ - s->audio.modems.rx_signal_present = TRUE; - s->audio.modems.rx_trained = TRUE; - s->core.short_train = TRUE; + s->audio.modems.rx_signal_present = true; + s->audio.modems.rx_trained = true; + s->core.short_train = true; /* Behave like HDLC preamble has been announced. */ - t->framing_ok_announced = TRUE; + t->framing_ok_announced = true; to_t38_buffer_init(&s->core.to_t38); break; case SIG_STATUS_CARRIER_UP: @@ -1713,7 +1720,7 @@ static void hdlc_rx_status(hdlc_rx_state_t *t, int status) t->len = 0; t->num_bits = 0; t->flags_seen = 0; - t->framing_ok_announced = FALSE; + t->framing_ok_announced = false; to_t38_buffer_init(&s->core.to_t38); break; case SIG_STATUS_CARRIER_DOWN: @@ -1722,7 +1729,7 @@ static void hdlc_rx_status(hdlc_rx_state_t *t, int status) category = (s->t38x.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END; t38_core_send_data(&s->t38x.t38, s->t38x.current_tx_data_type, T38_FIELD_HDLC_SIG_END, NULL, 0, category); t38_core_send_indicator(&s->t38x.t38, T38_IND_NO_SIGNAL); - t->framing_ok_announced = FALSE; + t->framing_ok_announced = false; } /*endif*/ restart_rx_modem(s); @@ -1808,9 +1815,9 @@ static void rx_flag_or_abort(hdlc_rx_state_t *t) span_log(&s->logging, SPAN_LOG_FLOW, "HDLC frame type %s, CRC OK\n", t30_frametype(t->buffer[2])); if (s->t38x.current_tx_data_type == T38_DATA_V21) { - monitor_control_messages(s, TRUE, t->buffer, t->len - 2); + monitor_control_messages(s, true, t->buffer, t->len - 2); if (s->core.real_time_frame_handler) - s->core.real_time_frame_handler(s, s->core.real_time_frame_user_data, TRUE, t->buffer, t->len - 2); + s->core.real_time_frame_handler(s, s->core.real_time_frame_user_data, true, t->buffer, t->len - 2); /*endif*/ } else @@ -1818,7 +1825,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *t) /* Make sure we go back to short training if CTC/CTR has kicked us into long training. Any successful HDLC frame received at a rate other than V.21 is an adequate indication we should change. */ - s->core.short_train = TRUE; + s->core.short_train = true; } /*endif*/ /* It seems some boxes may not like us sending a _SIG_END here, and then another @@ -1849,13 +1856,13 @@ static void rx_flag_or_abort(hdlc_rx_state_t *t) if (s->t38x.current_tx_data_type == T38_DATA_V21) { t38_core_send_indicator(&s->t38x.t38, set_slow_packetisation(s)); - s->audio.modems.rx_signal_present = TRUE; + s->audio.modems.rx_signal_present = true; } /*endif*/ if (s->t38x.in_progress_rx_indicator == T38_IND_CNG) set_next_tx_type(s); /*endif*/ - t->framing_ok_announced = TRUE; + t->framing_ok_announced = true; } /*endif*/ } @@ -1866,7 +1873,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *t) t->num_bits = 0; u->crc = 0xFFFF; u->data_ptr = 0; - s->t38x.corrupt_current_frame[1] = FALSE; + s->t38x.corrupt_current_frame[1] = false; } /*- End of function --------------------------------------------------------*/ @@ -1961,9 +1968,9 @@ static int restart_rx_modem(t38_gateway_state_t *s) s->core.ecm_mode); t = &s->audio.modems; - hdlc_rx_init(&t->hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, NULL, s); - t->rx_signal_present = FALSE; - t->rx_trained = FALSE; + hdlc_rx_init(&t->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, NULL, s); + t->rx_signal_present = false; + t->rx_trained = false; /* Default to the transmit data being V.21, unless a faster modem pops up trained. */ s->t38x.current_tx_data_type = T38_DATA_V21; //fax_modems_start_slow_modem(t, FAX_MODEM_V21_RX); @@ -1986,13 +1993,13 @@ static int restart_rx_modem(t38_gateway_state_t *s) /*endif*/ to_t38_buffer_init(&s->core.to_t38); s->core.to_t38.octets_per_data_packet = 1; - t->deferred_rx_handler_updates = TRUE; + t->deferred_rx_handler_updates = true; switch (s->core.fast_rx_modem) { case FAX_MODEM_V27TER_RX: case FAX_MODEM_V29_RX: case FAX_MODEM_V17_RX: - fax_modems_start_fast_modem(t, s->core.fast_rx_modem, s->core.fast_bit_rate, s->core.short_train, FALSE); + fax_modems_start_fast_modem(t, s->core.fast_rx_modem, s->core.fast_bit_rate, s->core.short_train, false); s->core.fast_rx_active = s->core.fast_rx_modem; break; case FAX_MODEM_V21_RX: @@ -2157,13 +2164,13 @@ SPAN_DECLARE(logging_state_t *) t38_gateway_get_logging_state(t38_gateway_state_ } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_gateway_set_ecm_capability(t38_gateway_state_t *s, int ecm_allowed) +SPAN_DECLARE(void) t38_gateway_set_ecm_capability(t38_gateway_state_t *s, bool ecm_allowed) { s->core.ecm_allowed = ecm_allowed; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_gateway_set_transmit_on_idle(t38_gateway_state_t *s, int transmit_on_idle) +SPAN_DECLARE(void) t38_gateway_set_transmit_on_idle(t38_gateway_state_t *s, bool transmit_on_idle) { s->audio.modems.transmit_on_idle = transmit_on_idle; } @@ -2193,13 +2200,13 @@ SPAN_DECLARE(void) t38_gateway_set_nsx_suppression(t38_gateway_state_t *s, } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_gateway_set_tep_mode(t38_gateway_state_t *s, int use_tep) +SPAN_DECLARE(void) t38_gateway_set_tep_mode(t38_gateway_state_t *s, bool use_tep) { fax_modems_set_tep_mode(&s->audio.modems, use_tep); } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_gateway_set_fill_bit_removal(t38_gateway_state_t *s, int remove) +SPAN_DECLARE(void) t38_gateway_set_fill_bit_removal(t38_gateway_state_t *s, bool remove) { s->core.to_t38.fill_bit_removal = remove; } @@ -2217,7 +2224,7 @@ SPAN_DECLARE(void) t38_gateway_set_real_time_frame_handler(t38_gateway_state_t * static int t38_gateway_audio_init(t38_gateway_state_t *s) { fax_modems_init(&s->audio.modems, - FALSE, + false, NULL, hdlc_underflow_handler, non_ecm_put_bit, @@ -2226,7 +2233,7 @@ static int t38_gateway_audio_init(t38_gateway_state_t *s) s); /* We need to use progressive HDLC transmit, and a special HDLC receiver, which is different from the other uses of FAX modems. */ - hdlc_tx_init(&s->audio.modems.hdlc_tx, FALSE, 2, TRUE, hdlc_underflow_handler, s); + hdlc_tx_init(&s->audio.modems.hdlc_tx, false, 2, true, hdlc_underflow_handler, s); fsk_rx_set_put_bit(&s->audio.modems.v21_rx, (put_bit_func_t) t38_hdlc_rx_put_bit, &s->audio.modems.hdlc_rx); /* TODO: Don't use the very low cutoff levels we would like to. We get some quirks if we do. We need to sort this out. */ @@ -2267,7 +2274,7 @@ SPAN_DECLARE(t38_gateway_state_t *) t38_gateway_init(t38_gateway_state_t *s, /*endif*/ if (s == NULL) { - if ((s = (t38_gateway_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t38_gateway_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; /*endif*/ } @@ -2279,14 +2286,14 @@ SPAN_DECLARE(t38_gateway_state_t *) t38_gateway_init(t38_gateway_state_t *s, t38_gateway_audio_init(s); t38_gateway_t38_init(s, tx_packet_handler, tx_packet_user_data); - fax_modems_set_rx_active(&s->audio.modems, TRUE); + fax_modems_set_rx_active(&s->audio.modems, true); t38_gateway_set_supported_modems(s, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); t38_gateway_set_nsx_suppression(s, (const uint8_t *) "\x00\x00\x00", 3, (const uint8_t *) "\x00\x00\x00", 3); s->core.to_t38.octets_per_data_packet = 1; - s->core.ecm_allowed = TRUE; + 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); + t38_non_ecm_buffer_init(&s->core.non_ecm_to_modem, false, 0); restart_rx_modem(s); s->core.timed_mode = TIMED_MODE_STARTUP; s->core.samples_to_timeout = 1; @@ -2332,7 +2339,7 @@ SPAN_DECLARE(int) t38_gateway_release(t38_gateway_state_t *s) SPAN_DECLARE(int) t38_gateway_free(t38_gateway_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_non_ecm_buffer.c b/libs/spandsp/src/t38_non_ecm_buffer.c index cc339a0581..b5b2c8244b 100644 --- a/libs/spandsp/src/t38_non_ecm_buffer.c +++ b/libs/spandsp/src/t38_non_ecm_buffer.c @@ -42,10 +42,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/queue.h" #include "spandsp/dc_restore.h" @@ -75,7 +81,7 @@ static void restart_buffer(t38_non_ecm_buffer_state_t *s) s->out_ptr = 0; s->in_ptr = 0; s->latest_eol_ptr = 0; - s->data_finished = FALSE; + s->data_finished = false; } /*- End of function --------------------------------------------------------*/ @@ -123,7 +129,7 @@ SPAN_DECLARE(void) t38_non_ecm_buffer_push(t38_non_ecm_buffer_state_t *s) /* Don't flow control the data any more. Just push out the remainder of the data in the buffer as fast as we can, and shut down. */ s->latest_eol_ptr = s->in_ptr; - s->data_finished = TRUE; + s->data_finished = true; } /*- End of function --------------------------------------------------------*/ @@ -340,22 +346,22 @@ SPAN_DECLARE(void) t38_non_ecm_buffer_report_output_status(t38_non_ecm_buffer_st } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_non_ecm_buffer_set_mode(t38_non_ecm_buffer_state_t *s, int mode, int min_bits_per_row) +SPAN_DECLARE(void) t38_non_ecm_buffer_set_mode(t38_non_ecm_buffer_state_t *s, bool image_mode, int min_bits_per_row) { - s->image_data_mode = mode; + s->image_data_mode = image_mode; s->min_bits_per_row = min_bits_per_row; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_buffer_state_t *s, int mode, int min_bits_per_row) +SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_buffer_state_t *s, bool image_mode, int min_bits_per_row) { if (s == NULL) { - if ((s = (t38_non_ecm_buffer_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t38_non_ecm_buffer_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); - s->image_data_mode = mode; + s->image_data_mode = image_mode; s->min_bits_per_row = min_bits_per_row; restart_buffer(s); return s; @@ -371,7 +377,7 @@ SPAN_DECLARE(int) t38_non_ecm_buffer_release(t38_non_ecm_buffer_state_t *s) SPAN_DECLARE(int) t38_non_ecm_buffer_free(t38_non_ecm_buffer_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t38_terminal.c b/libs/spandsp/src/t38_terminal.c index 66938d8d24..bf6a2a9de7 100644 --- a/libs/spandsp/src/t38_terminal.c +++ b/libs/spandsp/src/t38_terminal.c @@ -41,11 +41,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/queue.h" @@ -214,7 +220,7 @@ static int process_rx_missing(t38_core_state_t *t, void *user_data, int rx_seq_n t38_terminal_state_t *s; s = (t38_terminal_state_t *) user_data; - s->t38_fe.rx_data_missing = TRUE; + s->t38_fe.rx_data_missing = true; return 0; } /*- End of function --------------------------------------------------------*/ @@ -250,7 +256,7 @@ static int process_rx_indicator(t38_core_state_t *t, void *user_data, int indica && (fe->current_rx_type == T30_MODEM_V21 || fe->current_rx_type == T30_MODEM_CNG)) { - hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, TRUE); + hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, true); } /*endif*/ fe->timeout_rx_samples = 0; @@ -303,7 +309,7 @@ static int process_rx_indicator(t38_core_state_t *t, void *user_data, int indica } /*endswitch*/ fe->hdlc_rx.len = 0; - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; return 0; } /*- End of function --------------------------------------------------------*/ @@ -327,7 +333,7 @@ static void process_hdlc_data(t38_terminal_front_end_state_t *fe, const uint8_t } else { - fe->rx_data_missing = TRUE; + fe->rx_data_missing = true; } } /*- End of function --------------------------------------------------------*/ @@ -424,7 +430,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, /* 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; + fe->rx_data_missing = true; /*endif*/ } /*endif*/ @@ -454,7 +460,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT); break; case T38_FIELD_HDLC_FCS_BAD: @@ -472,11 +478,11 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (fe->hdlc_rx.len > 0) { 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); + hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, false); fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT); break; case T38_FIELD_HDLC_FCS_OK_SIG_END: @@ -498,9 +504,9 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type) - hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, TRUE); + hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, true); /*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); @@ -520,13 +526,13 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (fe->hdlc_rx.len > 0) { span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC bad, sig end (%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); + hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, false); fe->hdlc_rx.len = 0; } /*endif*/ - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type) - hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, TRUE); + hdlc_accept_frame(s, NULL, SIG_STATUS_CARRIER_DOWN, true); /*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); @@ -551,7 +557,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, i.e. they send T38_FIELD_HDLC_FCS_OK, and then T38_FIELD_HDLC_SIG_END when the carrier actually drops. The other is because the HDLC signal drops unexpectedly - i.e. not just after a final frame. */ fe->hdlc_rx.len = 0; - fe->rx_data_missing = FALSE; + fe->rx_data_missing = false; front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE); } /*endif*/ @@ -562,7 +568,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (!fe->rx_signal_present) { t30_non_ecm_put_bit(&s->t30, SIG_STATUS_TRAINING_SUCCEEDED); - fe->rx_signal_present = TRUE; + fe->rx_signal_present = true; } /*endif*/ if (len > 0) @@ -584,7 +590,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (!fe->rx_signal_present) { t30_non_ecm_put_bit(&s->t30, SIG_STATUS_TRAINING_SUCCEEDED); - fe->rx_signal_present = TRUE; + fe->rx_signal_present = true; } /*endif*/ bit_reverse(buf2, buf, len); @@ -598,7 +604,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE); } /*endif*/ - fe->rx_signal_present = FALSE; + 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); break; @@ -1148,7 +1154,7 @@ SPAN_DECLARE(int) t38_terminal_send_timeout(t38_terminal_state_t *s, int samples fe = &s->t38_fe; if (fe->current_rx_type == T30_MODEM_DONE || fe->current_tx_type == T30_MODEM_DONE) - return TRUE; + return true; /*endif*/ fe->samples += samples; @@ -1161,12 +1167,12 @@ SPAN_DECLARE(int) t38_terminal_send_timeout(t38_terminal_state_t *s, int samples } /*endif*/ if (fe->timed_step == T38_TIMED_STEP_NONE) - return FALSE; + 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->us_per_tx_chunk && fe->samples < fe->next_tx_samples) - return FALSE; + return false; /*endif*/ /* Its time to send something */ delay = 0; @@ -1197,11 +1203,11 @@ SPAN_DECLARE(int) t38_terminal_send_timeout(t38_terminal_state_t *s, int samples if (delay < 0) { t30_terminate(&s->t30); - return TRUE; + return true; } /*endif*/ fe->next_tx_samples += us_to_samples(delay); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -1364,7 +1370,7 @@ SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int config) if ((config & T38_TERMINAL_OPTION_NO_PACING)) { /* Continuous streaming mode, as used for TPKT over TCP transport */ - t38_set_pace_transmission(&s->t38_fe.t38, FALSE); + t38_set_pace_transmission(&s->t38_fe.t38, false); s->t38_fe.hdlc_tx.extra_bits = 0; if ((config & T38_TERMINAL_OPTION_NO_INDICATORS)) t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_INDICATOR, 0); @@ -1382,7 +1388,7 @@ SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int config) else { /* Paced streaming mode, as used for UDP transports */ - t38_set_pace_transmission(&s->t38_fe.t38, TRUE); + t38_set_pace_transmission(&s->t38_fe.t38, true); s->t38_fe.hdlc_tx.extra_bits = 0; if ((config & T38_TERMINAL_OPTION_NO_INDICATORS)) t38_set_redundancy_control(&s->t38_fe.t38, T38_PACKET_CATEGORY_INDICATOR, 0); @@ -1410,7 +1416,7 @@ SPAN_DECLARE(void) t38_terminal_set_config(t38_terminal_state_t *s, int config) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_tep) +SPAN_DECLARE(void) t38_terminal_set_tep_mode(t38_terminal_state_t *s, bool use_tep) { if (use_tep) s->t38_fe.chunking_modes |= T38_CHUNKING_ALLOW_TEP_TIME; @@ -1421,7 +1427,7 @@ SPAN_DECLARE(void) t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_te } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t38_terminal_set_fill_bit_removal(t38_terminal_state_t *s, int remove) +SPAN_DECLARE(void) t38_terminal_set_fill_bit_removal(t38_terminal_state_t *s, bool remove) { if (remove) s->t38_fe.iaf |= T30_IAF_MODE_NO_FILL_BITS; @@ -1451,7 +1457,7 @@ static int t38_terminal_t38_fe_restart(t38_terminal_state_t *t) s = &t->t38_fe; t38_core_restart(&s->t38); - s->rx_signal_present = FALSE; + 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; @@ -1482,7 +1488,7 @@ static int t38_terminal_t38_fe_init(t38_terminal_state_t *t, tx_packet_user_data); t38_set_fastest_image_data_rate(&s->t38, 14400); - s->rx_signal_present = FALSE; + s->rx_signal_present = false; s->timed_step = T38_TIMED_STEP_NONE; s->queued_timed_step = T38_TIMED_STEP_NONE; //s->iaf = T30_IAF_MODE_T37 | T30_IAF_MODE_T38; @@ -1506,7 +1512,7 @@ SPAN_DECLARE(logging_state_t *) t38_terminal_get_logging_state(t38_terminal_stat /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s, - int calling_party) + bool calling_party) { t38_terminal_t38_fe_restart(s); t30_restart(&s->t30); @@ -1515,7 +1521,7 @@ SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s, /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s, - int calling_party, + bool calling_party, t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { @@ -1525,7 +1531,7 @@ SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s, if (s == NULL) { - if ((s = (t38_terminal_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t38_terminal_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; /*endif*/ } @@ -1564,7 +1570,7 @@ SPAN_DECLARE(int) t38_terminal_release(t38_terminal_state_t *s) SPAN_DECLARE(int) t38_terminal_free(t38_terminal_state_t *s) { t38_terminal_release(s); - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t42.c b/libs/spandsp/src/t42.c index 8d0023f7d7..3e7ea3070b 100644 --- a/libs/spandsp/src/t42.c +++ b/libs/spandsp/src/t42.c @@ -45,11 +45,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/saturated.h" @@ -329,7 +335,7 @@ SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *lab, int L_P, int L_Q, int a_P, lab->offset_a = a_P; lab->offset_b = b_P; - lab->ab_are_signed = FALSE; + lab->ab_are_signed = false; } /*- End of function --------------------------------------------------------*/ @@ -547,13 +553,13 @@ static int is_itu_fax(t42_decode_state_t *s, jpeg_saved_marker_ptr ptr) int ok; int val[6]; - ok = FALSE; + ok = false; for ( ; ptr; ptr = ptr->next) { if (ptr->marker != (JPEG_APP0 + 1)) continue; if (ptr->data_length < 6) - return FALSE; + return false; /* Markers are: JPEG_RST0 JPEG_EOI @@ -561,26 +567,26 @@ static int is_itu_fax(t42_decode_state_t *s, jpeg_saved_marker_ptr ptr) JPEG_COM */ data = (const uint8_t *) ptr->data; if (strncmp((const char *) data, "G3FAX", 5)) - return FALSE; + return false; switch (data[5]) { case 0: if (ptr->data_length < 6 + 4) { span_log(&s->logging, SPAN_LOG_FLOW, "Got bad G3FAX0 length - %d\n", ptr->data_length); - return FALSE; + return false; } val[0] = pack_16(&data[6]); s->spatial_resolution = pack_16(&data[6 + 2]); span_log(&s->logging, SPAN_LOG_FLOW, "Version %d, resolution %ddpi\n", val[0], s->spatial_resolution); - ok = TRUE; + ok = true; break; case 1: span_log(&s->logging, SPAN_LOG_FLOW, "Set gamut\n"); if (ptr->data_length < 6 + 12) { span_log(&s->logging, SPAN_LOG_FLOW, "Got bad G3FAX1 length - %d\n", ptr->data_length); - return FALSE; + return false; } set_gamut_from_code(&s->logging, &s->lab, &data[6]); break; @@ -589,13 +595,13 @@ static int is_itu_fax(t42_decode_state_t *s, jpeg_saved_marker_ptr ptr) if (ptr->data_length < 6 + 4) { span_log(&s->logging, SPAN_LOG_FLOW, "Got bad G3FAX2 length - %d\n", ptr->data_length); - return FALSE; + return false; } s->illuminant_colour_temperature = set_illuminant_from_code(&s->logging, &s->lab, &data[6]); break; default: span_log(&s->logging, SPAN_LOG_FLOW, "Got unexpected G3FAX%d length - %d\n", data[5], ptr->data_length); - return FALSE; + return false; } } @@ -742,7 +748,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); if (s->scan_line_out) { - free(s->scan_line_out); + span_free(s->scan_line_out); s->scan_line_out = NULL; } if (s->out) @@ -775,7 +781,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s) jpeg_set_defaults(&s->compressor); /* Limit to baseline-JPEG values */ - //jpeg_set_quality(&s->compressor, s->quality, TRUE); + //jpeg_set_quality(&s->compressor, s->quality, true); if (s->no_subsampling) { @@ -798,16 +804,16 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s) s->compressor.image_width = s->image_width; s->compressor.image_height = s->image_length; - jpeg_start_compress(&s->compressor, TRUE); + jpeg_start_compress(&s->compressor, true); set_itu_fax(s); - if ((s->scan_line_in = (JSAMPROW) malloc(s->samples_per_pixel*s->image_width)) == NULL) + if ((s->scan_line_in = (JSAMPROW) span_alloc(s->samples_per_pixel*s->image_width)) == NULL) return -1; if (s->image_type == T4_IMAGE_TYPE_COLOUR_8BIT) { - if ((s->scan_line_out = (JSAMPROW) malloc(s->samples_per_pixel*s->image_width)) == NULL) + if ((s->scan_line_out = (JSAMPROW) span_alloc(s->samples_per_pixel*s->image_width)) == NULL) return -1; for (i = 0; i < s->compressor.image_height; i++) @@ -828,7 +834,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s) if (s->scan_line_out) { - free(s->scan_line_out); + span_free(s->scan_line_out); s->scan_line_out = NULL; } jpeg_finish_compress(&s->compressor); @@ -841,13 +847,13 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s) #else s->buf_size = s->compressed_image_size = ftell(s->out); - if ((s->compressed_buf = malloc(s->compressed_image_size)) == NULL) + if ((s->compressed_buf = span_alloc(s->compressed_image_size)) == NULL) return -1; if (fseek(s->out, 0, SEEK_SET) != 0) { fclose(s->out); s->out = NULL; - free(s->compressed_buf); + span_free(s->compressed_buf); s->compressed_buf = NULL; return -1; } @@ -855,7 +861,7 @@ static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s) { fclose(s->out); s->out = NULL; - free(s->compressed_buf); + span_free(s->compressed_buf); s->compressed_buf = NULL; return -1; } @@ -936,14 +942,14 @@ SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width /* ITU-YCC */ /* Illuminant D65 */ set_lab_illuminant(&s->lab, 95.047f, 100.000f, 108.883f); - set_lab_gamut(&s->lab, 0, 100, -127, 127, -127, 127, FALSE); + set_lab_gamut(&s->lab, 0, 100, -127, 127, -127, 127, false); } else { /* ITULAB */ /* Illuminant D50 */ set_lab_illuminant(&s->lab, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, false); } s->compressed_image_size = 0; s->compressed_image_ptr = 0; @@ -986,7 +992,7 @@ SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s, { if (s == NULL) { - if ((s = (t42_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t42_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1016,7 +1022,7 @@ SPAN_DECLARE(int) t42_encode_free(t42_encode_state_t *s) int ret; ret = t42_encode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ @@ -1087,7 +1093,7 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s) span_log(&s->logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); if (s->scan_line_out) { - free(s->scan_line_out); + span_free(s->scan_line_out); s->scan_line_out = NULL; } if (s->in) @@ -1117,7 +1123,7 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s) } /* Take the header */ - jpeg_read_header(&s->decompressor, FALSE); + jpeg_read_header(&s->decompressor, false); /* Sanity check and parameter check */ if (!is_itu_fax(s, s->decompressor.marker_list)) { @@ -1155,12 +1161,12 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s) jpeg_start_decompress(&s->decompressor); - if ((s->scan_line_in = malloc(s->samples_per_pixel*s->image_width)) == NULL) + if ((s->scan_line_in = span_alloc(s->samples_per_pixel*s->image_width)) == NULL) return -1; if (s->samples_per_pixel == 3) { - if ((s->scan_line_out = malloc(s->samples_per_pixel*s->image_width)) == NULL) + if ((s->scan_line_out = span_alloc(s->samples_per_pixel*s->image_width)) == NULL) return -1; while (s->decompressor.output_scanline < s->image_length) @@ -1181,12 +1187,12 @@ static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s) if (s->scan_line_in) { - free(s->scan_line_in); + span_free(s->scan_line_in); s->scan_line_in = NULL; } if (s->scan_line_out) { - free(s->scan_line_out); + span_free(s->scan_line_out); s->scan_line_out = NULL; } jpeg_finish_decompress(&s->decompressor); @@ -1243,7 +1249,7 @@ SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], si if (s->compressed_image_size + len > s->buf_size) { - if ((buf = (uint8_t *) realloc(s->compressed_buf, s->compressed_image_size + len + 10000)) == NULL) + if ((buf = (uint8_t *) span_realloc(s->compressed_buf, s->compressed_image_size + len + 10000)) == NULL) return -1; s->buf_size = s->compressed_image_size + len + 10000; s->compressed_buf = buf; @@ -1315,14 +1321,14 @@ SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s) /* ITU-YCC */ /* Illuminant D65 */ set_lab_illuminant(&s->lab, 95.047f, 100.000f, 108.883f); - set_lab_gamut(&s->lab, 0, 100, -127, 127, -127, 127, FALSE); + set_lab_gamut(&s->lab, 0, 100, -127, 127, -127, 127, false); } else { /* ITULAB */ /* Illuminant D50 */ set_lab_illuminant(&s->lab, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, false); } s->end_of_data = 0; @@ -1340,7 +1346,7 @@ SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s, { if (s == NULL) { - if ((s = (t42_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t42_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1363,12 +1369,12 @@ SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s) { if (s->scan_line_in) { - free(s->scan_line_in); + span_free(s->scan_line_in); s->scan_line_in = NULL; } if (s->scan_line_out) { - free(s->scan_line_out); + span_free(s->scan_line_out); s->scan_line_out = NULL; } jpeg_destroy_decompress(&s->decompressor); @@ -1379,7 +1385,7 @@ SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s) } if (s->comment) { - free(s->comment); + span_free(s->comment); s->comment = NULL; } return 0; @@ -1391,7 +1397,7 @@ SPAN_DECLARE(int) t42_decode_free(t42_decode_state_t *s) int ret; ret = t42_decode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t43.c b/libs/spandsp/src/t43.c index b0e1abffb9..181226e757 100644 --- a/libs/spandsp/src/t43.c +++ b/libs/spandsp/src/t43.c @@ -39,11 +39,17 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/async.h" #include "spandsp/timezone.h" @@ -63,13 +69,6 @@ #include "t43_gray_code_tables.h" #include "t42_t43_local.h" -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - SPAN_DECLARE(const char *) t43_image_type_to_str(int type) { switch (type) @@ -133,7 +132,9 @@ static int t43_create_header(t43_encode_state_t *s, uint8_t data[], size_t len) { int pos; int val[6]; +#if 0 int bytes_per_entry; +#endif pos = 0; unpack_16(data, 0xFFA8); @@ -345,7 +346,7 @@ SPAN_DECLARE(t43_encode_state_t *) t43_encode_init(t43_encode_state_t *s, { if (s == NULL) { - if ((s = (t43_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t43_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -380,7 +381,7 @@ SPAN_DECLARE(int) t43_encode_free(t43_encode_state_t *s) t85_encode_free(&s->t85); ret = t43_encode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ @@ -700,7 +701,7 @@ static int t85_row_write_handler(void *user_data, const uint8_t buf[], size_t le if (s->buf == NULL) { image_size = s->samples_per_pixel*s->t85.xd*s->t85.yd; - if ((s->buf = malloc(image_size)) == NULL) + if ((s->buf = span_alloc(image_size)) == NULL) return -1; memset(s->buf, 0, image_size); } @@ -761,6 +762,7 @@ SPAN_DECLARE(int) t43_decode_put(t43_decode_state_t *s, const uint8_t data[], si } /* Now deal the bit-planes, one after another. */ + total_len = 0; while (s->current_bit_plane < s->t85.bit_planes) { j = s->current_bit_plane; @@ -864,7 +866,7 @@ SPAN_DECLARE(int) t43_decode_restart(t43_decode_state_t *s) /* ITULAB */ /* Illuminant D50 */ set_lab_illuminant(&s->lab, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, false); s->t85.min_bit_planes = 1; s->t85.max_bit_planes = 8; @@ -882,7 +884,7 @@ SPAN_DECLARE(t43_decode_state_t *) t43_decode_init(t43_decode_state_t *s, { if (s == NULL) { - if ((s = (t43_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t43_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -897,7 +899,7 @@ SPAN_DECLARE(t43_decode_state_t *) t43_decode_init(t43_decode_state_t *s, /* ITULAB */ /* Illuminant D50 */ set_lab_illuminant(&s->lab, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, false); s->t85.min_bit_planes = 1; s->t85.max_bit_planes = 8; @@ -922,7 +924,7 @@ SPAN_DECLARE(int) t43_decode_free(t43_decode_state_t *s) ret = t43_decode_release(s); t85_decode_free(&s->t85); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_rx.c b/libs/spandsp/src/t4_rx.c index 7723e14eb2..256e8fcdfc 100644 --- a/libs/spandsp/src/t4_rx.c +++ b/libs/spandsp/src/t4_rx.c @@ -44,10 +44,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -233,11 +239,24 @@ static int set_tiff_directory_info(t4_rx_state_t *s) #endif #if defined(SPANDSP_SUPPORT_T42) case T4_COMPRESSION_T42_T81: + output_compression = COMPRESSION_JPEG; + bits_per_sample = 8; + if (t->image_type == T4_IMAGE_TYPE_COLOUR_8BIT) + { + samples_per_pixel = 3; + photometric = PHOTOMETRIC_YCBCR; //PHOTOMETRIC_ITULAB; + } + else + { + samples_per_pixel = 1; + photometric = PHOTOMETRIC_MINISBLACK; + } + break; case T4_COMPRESSION_SYCC_T81: output_compression = COMPRESSION_JPEG; bits_per_sample = 8; samples_per_pixel = 3; - photometric = PHOTOMETRIC_ITULAB; + photometric = PHOTOMETRIC_YCBCR; break; #endif #if defined(SPANDSP_SUPPORT_T43) @@ -287,6 +306,13 @@ static int set_tiff_directory_info(t4_rx_state_t *s) TIFFSetField(t->tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(t->tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); + if (t->compression == T4_COMPRESSION_T42_T81) + { + TIFFSetField(t->tiff_file, TIFFTAG_YCBCRSUBSAMPLING, 2, 2); + //TIFFSetField(t->tiff_file, TIFFTAG_YCBCRSUBSAMPLING, 1, 1); + TIFFSetField(t->tiff_file, TIFFTAG_JPEGQUALITY, 75); + TIFFSetField(t->tiff_file, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } /* TIFFTAG_STRIPBYTECOUNTS and TIFFTAG_STRIPOFFSETS are added automatically */ x_resolution = s->metadata.x_resolution/100.0f; @@ -343,34 +369,37 @@ static int set_tiff_directory_info(t4_rx_state_t *s) is always one greater than the highest page number in the file. */ s->tiff.pages_in_file = s->current_page + 1; s->metadata.image_length = 0; - switch (s->metadata.compression) + switch (s->current_decoder) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - /* We only get bad row info from pages received in non-ECM mode. */ - if (output_compression == COMPRESSION_CCITT_T4) + case 0: + s->metadata.image_length = 1024; + break; + case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6: + if ((s->metadata.compression & (T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D))) { - if (s->decoder.t4_t6.bad_rows) + /* We only get bad row info from pages received in non-ECM mode. */ + if (output_compression == COMPRESSION_CCITT_T4) { - TIFFSetField(t->tiff_file, TIFFTAG_BADFAXLINES, s->decoder.t4_t6.bad_rows); - TIFFSetField(t->tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s->decoder.t4_t6.longest_bad_row_run); - TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED); - } - else - { - TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); + if (s->decoder.t4_t6.bad_rows) + { + TIFFSetField(t->tiff_file, TIFFTAG_BADFAXLINES, s->decoder.t4_t6.bad_rows); + TIFFSetField(t->tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s->decoder.t4_t6.longest_bad_row_run); + TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED); + } + else + { + TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); + } } } - /* Fall through */ - case T4_COMPRESSION_T6: s->metadata.image_length = t4_t6_decode_get_image_length(&s->decoder.t4_t6); break; - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: + case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0: s->metadata.image_length = t85_decode_get_image_length(&s->decoder.t85); break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + s->metadata.image_length = t88_decode_get_image_length(&s->decoder.t88); break; #endif case T4_COMPRESSION_T42_T81: @@ -383,6 +412,7 @@ static int set_tiff_directory_info(t4_rx_state_t *s) #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + s->metadata.image_length = t45_decode_get_image_length(&s->decoder.t45); break; #endif } @@ -398,6 +428,34 @@ static int set_tiff_directory_info(t4_rx_state_t *s) /* Create a placeholder for the global parameters IFD, to be filled in later */ TIFFSetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, 0); } + +#if 0 + /* Paletised image? */ + TIFFSetField(t->tiff_file, TIFFTAG_INDEXED, 1); + /* T.44 mode */ + TIFFSetField(t->tiff_file, TIFFTAG_MODENUMBER, 0); + span_log(&s->logging, SPAN_LOG_FLOW, "TIFF/FX stuff 2\n"); + { + float xxx[] = {20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0}; + TIFFSetField(t->tiff_file, TIFFTAG_DECODE, (uint16) 2*samples_per_pixel, xxx); + } + span_log(&s->logging, SPAN_LOG_FLOW, "TIFF/FX stuff 3\n"); + { + uint16_t xxx[] = {12, 34, 45, 67}; + TIFFSetField(t->tiff_file, TIFFTAG_IMAGEBASECOLOR, (uint16_t) samples_per_pixel, xxx); + } + span_log(&s->logging, SPAN_LOG_FLOW, "TIFF/FX stuff 4\n"); + TIFFSetField(t->tiff_file, TIFFTAG_T82OPTIONS, 0); + { + uint32_t xxx[] = {34, 56, 78, 90}; + TIFFSetField(t->tiff_file, TIFFTAG_STRIPROWCOUNTS, (uint16_t) 5, xxx); + } + span_log(&s->logging, SPAN_LOG_FLOW, "TIFF/FX stuff 5\n"); + { + uint32_t xxx[] = {2, 3}; + TIFFSetField(t->tiff_file, TIFFTAG_IMAGELAYER, xxx); + } +#endif #endif return 0; } @@ -447,10 +505,10 @@ static int write_tiff_t85_image(t4_rx_state_t *s) if (buf_len < image_len + 65536) { buf_len += 65536; - if ((buf2 = realloc(buf, buf_len)) == NULL) + if ((buf2 = span_realloc(buf, buf_len)) == NULL) { if (buf) - free(buf); + span_free(buf); return -1; } buf = buf2; @@ -465,7 +523,7 @@ static int write_tiff_t85_image(t4_rx_state_t *s) return -1; } t85_encode_release(&t85); - free(buf); + span_free(buf); return 0; } /*- End of function --------------------------------------------------------*/ @@ -493,10 +551,10 @@ static int write_tiff_t43_image(t4_rx_state_t *s) if (buf_len < image_len + 65536) { buf_len += 65536; - if ((buf2 = realloc(buf, buf_len)) == NULL) + if ((buf2 = span_realloc(buf, buf_len)) == NULL) { if (buf) - free(buf); + span_free(buf); return -1; } buf = buf2; @@ -508,7 +566,7 @@ static int write_tiff_t43_image(t4_rx_state_t *s) if (TIFFWriteRawStrip(s->tiff.tiff_file, 0, buf, image_len) < 0) span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", s->tiff.file); t43_encode_release(&t43); - free(buf); + span_free(buf); return 0; } /*- End of function --------------------------------------------------------*/ @@ -522,49 +580,57 @@ static int write_tiff_image(t4_rx_state_t *s) #endif t = &s->tiff; - if (t->image_buffer == NULL || t->image_size <= 0) + if (s->pre_encoded_ptr <= 0 && (t->image_buffer == NULL || t->image_size <= 0)) return -1; /* Set up the TIFF directory info... */ set_tiff_directory_info(s); /* ...Put the directory in the file before the image data, to get them in the order specified for TIFF/F files... */ - if (!TIFFCheckpointDirectory(t->tiff_file)) - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to checkpoint directory for page %d.\n", t->file, s->current_page); + //if (!TIFFCheckpointDirectory(t->tiff_file)) + // span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to checkpoint directory for page %d.\n", t->file, s->current_page); /* ...and write out the image... */ - switch (t->compression) + if (s->pre_encoded_ptr > 0) { - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: - /* We need to perform this compression here, as libtiff does not understand it. */ - if (write_tiff_t85_image(s) < 0) - return -1; - break; + if (TIFFWriteRawStrip(s->tiff.tiff_file, 0, s->pre_encoded_buf, s->pre_encoded_ptr) < 0) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", s->tiff.file); + } + else + { + switch (t->compression) + { + case T4_COMPRESSION_T85: + case T4_COMPRESSION_T85_L0: + /* We need to perform this compression here, as libtiff does not understand it. */ + if (write_tiff_t85_image(s) < 0) + return -1; + break; #if defined(SPANDSP_SUPPORT_T88) - case T4_COMPRESSION_T88: - /* We need to perform this compression here, as libtiff does not understand it. */ - if (write_tiff_t88_image(s) < 0) - return -1; - break; + case T4_COMPRESSION_T88: + /* We need to perform this compression here, as libtiff does not understand it. */ + if (write_tiff_t88_image(s) < 0) + return -1; + break; #endif #if defined(SPANDSP_SUPPORT_T43) - case T4_COMPRESSION_T43: - /* We need to perform this compression here, as libtiff does not understand it. */ - if (write_tiff_t43_image(s) < 0) - return -1; - break; + case T4_COMPRESSION_T43: + /* We need to perform this compression here, as libtiff does not understand it. */ + if (write_tiff_t43_image(s) < 0) + return -1; + break; #endif #if defined(SPANDSP_SUPPORT_T45) - case T4_COMPRESSION_T45: - /* We need to perform this compression here, as libtiff does not understand it. */ - if (write_tiff_t45_image(s) < 0) - return -1; - break; + case T4_COMPRESSION_T45: + /* We need to perform this compression here, as libtiff does not understand it. */ + if (write_tiff_t45_image(s) < 0) + return -1; + break; #endif - default: - /* Let libtiff do the compression */ - if (TIFFWriteEncodedStrip(t->tiff_file, 0, t->image_buffer, t->image_size) < 0) - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", t->file); - break; + default: + /* Let libtiff do the compression */ + if (TIFFWriteEncodedStrip(t->tiff_file, 0, t->image_buffer, t->image_size) < 0) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", t->file); + break; + } } /* ...then finalise the directory entry, and libtiff is happy. */ if (!TIFFWriteDirectory(t->tiff_file)) @@ -630,7 +696,7 @@ static int close_tiff_output_file(t4_rx_state_t *s) put in it. */ if (s->current_page == 0) remove(s->tiff.file); - free((char *) s->tiff.file); + span_free((char *) s->tiff.file); } s->tiff.file = NULL; return 0; @@ -643,7 +709,7 @@ static void tiff_rx_release(t4_rx_state_t *s) close_tiff_output_file(s); if (s->tiff.image_buffer) { - free(s->tiff.image_buffer); + span_free(s->tiff.image_buffer); s->tiff.image_buffer = NULL; s->tiff.image_size = 0; s->tiff.image_buffer_size = 0; @@ -661,31 +727,31 @@ SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit) SPAN_DECLARE(int) t4_rx_put(t4_rx_state_t *s, const uint8_t buf[], size_t len) { + uint8_t *buf2; + s->line_image_size += 8*len; - switch (s->metadata.compression) + + if (s->pre_encoded_len > 0) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: - return t4_t6_decode_put(&s->decoder.t4_t6, buf, len); - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: - return t85_decode_put(&s->decoder.t85, buf, len); -#if defined(SPANDSP_SUPPORT_T88) - case T4_COMPRESSION_T88: - break; -#endif - case T4_COMPRESSION_T42_T81: - return t42_decode_put(&s->decoder.t42, buf, len); -#if defined(SPANDSP_SUPPORT_T43) - case T4_COMPRESSION_T43: - return t43_decode_put(&s->decoder.t43, buf, len); -#endif -#if defined(SPANDSP_SUPPORT_T45) - case T4_COMPRESSION_T45: - break; -#endif + if (s->pre_encoded_len < s->pre_encoded_ptr + 65536) + { + s->pre_encoded_len += 65536; + if ((buf2 = span_realloc(s->pre_encoded_buf, s->pre_encoded_len)) == NULL) + { + if (s->pre_encoded_buf) + span_free(s->pre_encoded_buf); + return -1; + } + s->pre_encoded_buf = buf2; + } + memcpy(&s->pre_encoded_buf[s->pre_encoded_ptr], buf, len); + s->pre_encoded_ptr += len; + return T4_DECODE_MORE_DATA; } + + if (s->image_put_handler) + return s->image_put_handler((void *) &s->decoder, buf, len); + return T4_DECODE_OK; } /*- End of function --------------------------------------------------------*/ @@ -738,27 +804,35 @@ static void select_tiff_compression(t4_rx_state_t *s, int output_image_type) { /* Only provide for one form of coding throughout the file, even though the coding on the wire could change between pages. */ - if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T85)) + if ((s->supported_tiff_compressions & T4_COMPRESSION_T85)) s->tiff.compression = T4_COMPRESSION_T85; - else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T6)) + else if ((s->supported_tiff_compressions & T4_COMPRESSION_T6)) s->tiff.compression = T4_COMPRESSION_T6; - else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T4_2D)) + else if ((s->supported_tiff_compressions & T4_COMPRESSION_T4_2D)) s->tiff.compression = T4_COMPRESSION_T4_2D; - else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T4_1D)) + else if ((s->supported_tiff_compressions & T4_COMPRESSION_T4_1D)) s->tiff.compression = T4_COMPRESSION_T4_1D; } else { - if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T42_T81)) + if ((s->supported_tiff_compressions & T4_COMPRESSION_T42_T81)) s->tiff.compression = T4_COMPRESSION_T42_T81; - else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T43)) + else if ((s->supported_tiff_compressions & T4_COMPRESSION_T43)) s->tiff.compression = T4_COMPRESSION_T43; } + s->tiff.image_type = output_image_type; } /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) { +#if 0 + output_image_type = T4_IMAGE_TYPE_BILEVEL; + s->metadata.compression = compression; + select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL); + s->current_decoder = 0; + return 0; +#else switch (compression) { case T4_COMPRESSION_T4_1D: @@ -772,6 +846,7 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) break; default: t4_t6_decode_init(&s->decoder.t4_t6, compression, s->metadata.image_width, s->row_handler, s->row_handler_user_data); + s->current_decoder = T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6; break; } s->metadata.compression = compression; @@ -786,14 +861,15 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) break; default: t85_decode_init(&s->decoder.t85, s->row_handler, s->row_handler_user_data); + s->current_decoder = T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0; /* Constrain received images to the maximum width of any FAX. This will avoid one potential cause of trouble, where a bad received image has a gigantic dimension that sucks our memory dry. */ t85_decode_set_image_size_constraints(&s->decoder.t85, T4_WIDTH_1200_A3, 0); break; } - select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL); s->metadata.compression = compression; + select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL); return 0; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: @@ -802,10 +878,12 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) case T4_COMPRESSION_T88: break; default: + t88_decode_init(&s->decoder.t88, s->row_handler, s->row_handler_user_data); + s->current_decoder = T4_COMPRESSION_T88; break; } - select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL); s->metadata.compression = compression; + select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL); return 0; #endif case T4_COMPRESSION_T42_T81: @@ -817,6 +895,7 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) break; default: t42_decode_init(&s->decoder.t42, s->row_handler, s->row_handler_user_data); + s->current_decoder = T4_COMPRESSION_T42_T81; /* Constrain received images to the maximum width of any FAX. This will avoid one potential cause of trouble, where a bad received image has a gigantic dimension that sucks our memory dry. */ @@ -834,6 +913,7 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) break; default: t43_decode_init(&s->decoder.t43, s->row_handler, s->row_handler_user_data); + s->current_decoder = T4_COMPRESSION_T43; /* Constrain received images to the maximum width of any FAX. This will avoid one potential cause of trouble, where a bad received image has a gigantic dimension that sucks our memory dry. */ @@ -851,6 +931,8 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) case T4_COMPRESSION_T45: break; default: + t45_decode_init(&s->decoder.t45, s->row_handler, s->row_handler_user_data); + s->current_decoder = T4_COMPRESSION_T45; break; } s->metadata.compression = compression; @@ -860,6 +942,7 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int compression) } return -1; +#endif } /*- End of function --------------------------------------------------------*/ @@ -873,18 +956,15 @@ SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_rx_state_t *s, t4_row_write_han { s->row_handler = handler; s->row_handler_user_data = user_data; - switch (s->metadata.compression) + switch (s->current_decoder) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: + case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6: return t4_t6_decode_set_row_write_handler(&s->decoder.t4_t6, handler, user_data); - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: + case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0: return t85_decode_set_row_write_handler(&s->decoder.t85, handler, user_data); #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: - break; + return t88_decode_set_row_write_handler(&s->decoder.t88, handler, user_data); #endif case T4_COMPRESSION_T42_T81: return t42_decode_set_row_write_handler(&s->decoder.t42, handler, user_data); @@ -894,7 +974,7 @@ SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_rx_state_t *s, t4_row_write_han #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: - break; + return t45_decode_set_row_write_handler(&s->decoder.t45, handler, user_data); #endif } return -1; @@ -911,12 +991,11 @@ SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t t->image_y_resolution = s->metadata.y_resolution; t->x_resolution = s->metadata.x_resolution; t->y_resolution = s->metadata.y_resolution; + t->compression = s->metadata.compression; - switch (s->metadata.compression) + switch (s->current_decoder) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: + case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6: t->type = T4_IMAGE_TYPE_BILEVEL; t->width = t4_t6_decode_get_image_width(&s->decoder.t4_t6); t->length = t4_t6_decode_get_image_length(&s->decoder.t4_t6); @@ -927,8 +1006,7 @@ SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t t->bad_rows = s->decoder.t4_t6.bad_rows; t->longest_bad_row_run = s->decoder.t4_t6.longest_bad_row_run; break; - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: + case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0: t->type = T4_IMAGE_TYPE_BILEVEL; t->width = t85_decode_get_image_width(&s->decoder.t85); t->length = t85_decode_get_image_length(&s->decoder.t85); @@ -942,7 +1020,7 @@ SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t break; #endif case T4_COMPRESSION_T42_T81: - t->type = 0; + t->type = T4_IMAGE_TYPE_GRAY_8BIT; //T4_IMAGE_TYPE_COLOUR_8BIT; t->width = t42_decode_get_image_width(&s->decoder.t42); t->length = t42_decode_get_image_length(&s->decoder.t42); t->image_type = t->type; @@ -952,7 +1030,7 @@ SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: - t->type = 0; + t->type = T4_IMAGE_TYPE_COLOUR_8BIT; t->width = t43_decode_get_image_width(&s->decoder.t43); t->length = t43_decode_get_image_length(&s->decoder.t43); t->image_type = t->type; @@ -973,31 +1051,41 @@ SPAN_DECLARE(int) t4_rx_start_page(t4_rx_state_t *s) { span_log(&s->logging, SPAN_LOG_FLOW, "Start rx page %d - compression %s\n", s->current_page, t4_compression_to_str(s->metadata.compression)); - switch (s->metadata.compression) + switch (s->current_decoder) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: - t4_t6_decode_restart(&s->decoder.t4_t6, s->metadata.image_width); + case 0: + s->pre_encoded_ptr = 0; + s->pre_encoded_len = 0; + s->image_put_handler = NULL; break; - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: + case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6: + t4_t6_decode_restart(&s->decoder.t4_t6, s->metadata.image_width); + s->image_put_handler = (t4_image_put_handler_t) t4_t6_decode_put; + break; + case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0: t85_decode_restart(&s->decoder.t85); + s->image_put_handler = (t4_image_put_handler_t) t85_decode_put; break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + t88_decode_restart(&s->decoder.t88); + s->image_put_handler = (t4_image_put_handler_t) t88_decode_put; break; #endif case T4_COMPRESSION_T42_T81: t42_decode_restart(&s->decoder.t42); + s->image_put_handler = (t4_image_put_handler_t) t42_decode_put; break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: t43_decode_restart(&s->decoder.t43); + s->image_put_handler = (t4_image_put_handler_t) t43_decode_put; break; #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + t45_decode_restart(&s->decoder.t45); + s->image_put_handler = (t4_image_put_handler_t) t45_decode_put; break; #endif } @@ -1020,7 +1108,7 @@ static int tiff_row_write_handler(void *user_data, const uint8_t buf[], size_t l { if (s->tiff.image_size + len >= s->tiff.image_buffer_size) { - if ((t = realloc(s->tiff.image_buffer, s->tiff.image_buffer_size + 100*len)) == NULL) + if ((t = span_realloc(s->tiff.image_buffer, s->tiff.image_buffer_size + 100*len)) == NULL) return -1; s->tiff.image_buffer_size += 100*len; s->tiff.image_buffer = t; @@ -1037,35 +1125,41 @@ SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s) int length; length = 0; - switch (s->metadata.compression) + + if (s->image_put_handler) + s->image_put_handler((void *) &s->decoder, NULL, 0); + + switch (s->current_decoder) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: - t4_t6_decode_put(&s->decoder.t4_t6, NULL, 0); + case 0: + length = s->pre_encoded_ptr; + break; + case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6: length = t4_t6_decode_get_image_length(&s->decoder.t4_t6); break; - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: - t85_decode_put(&s->decoder.t85, NULL, 0); + case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0: length = t85_decode_get_image_length(&s->decoder.t85); break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + length = t88_decode_get_image_length(&s->decoder.t88); break; #endif case T4_COMPRESSION_T42_T81: - t42_decode_put(&s->decoder.t42, NULL, 0); length = t42_decode_get_image_length(&s->decoder.t42); + if (s->decoder.t42.samples_per_pixel == 3) + select_tiff_compression(s, T4_IMAGE_TYPE_COLOUR_8BIT); + else + select_tiff_compression(s, T4_IMAGE_TYPE_GRAY_8BIT); break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: - t43_decode_put(&s->decoder.t43, NULL, 0); length = t43_decode_get_image_length(&s->decoder.t43); break; #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + length = t45_decode_get_image_length(&s->decoder.t45); break; #endif } @@ -1078,6 +1172,7 @@ SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s) if (write_tiff_image(s) == 0) s->current_page++; s->tiff.image_size = 0; + s->pre_encoded_ptr = 0; } else { @@ -1095,14 +1190,14 @@ SPAN_DECLARE(logging_state_t *) t4_rx_get_logging_state(t4_rx_state_t *s) SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int supported_output_compressions) { - int allocated; + bool alloced; - allocated = FALSE; + alloced = false; if (s == NULL) { - if ((s = (t4_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t4_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; - allocated = TRUE; + alloced = true; } #if defined(SPANDSP_SUPPORT_TIFF_FX) TIFF_FX_init(); @@ -1120,6 +1215,7 @@ SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int s->metadata.y_resolution = T4_Y_RESOLUTION_FINE; s->current_page = 0; + s->current_decoder = 0; /* Default handler */ s->row_handler = tiff_row_write_handler; @@ -1130,8 +1226,8 @@ SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int s->tiff.pages_in_file = 0; if (open_tiff_output_file(s, file) < 0) { - if (allocated) - free(s); + if (alloced) + span_free(s); return NULL; } /* Save the file name for logging reports. */ @@ -1145,18 +1241,15 @@ SPAN_DECLARE(int) t4_rx_release(t4_rx_state_t *s) { if (s->tiff.file) tiff_rx_release(s); - switch (s->metadata.compression) + switch (s->current_decoder) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: + case T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6: return t4_t6_decode_release(&s->decoder.t4_t6); - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: + case T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0: return t85_decode_release(&s->decoder.t85); #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: - break; + return t88_decode_release(&s->decoder.t88); #endif case T4_COMPRESSION_T42_T81: return t42_decode_release(&s->decoder.t42); @@ -1166,7 +1259,7 @@ SPAN_DECLARE(int) t4_rx_release(t4_rx_state_t *s) #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: - break; + return t45_decode_release(&s->decoder.t45); #endif } return -1; @@ -1178,7 +1271,7 @@ SPAN_DECLARE(int) t4_rx_free(t4_rx_state_t *s) int ret; ret = t4_rx_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_t6_decode.c b/libs/spandsp/src/t4_t6_decode.c index c347dfd19a..4daf7e65c7 100644 --- a/libs/spandsp/src/t4_t6_decode.c +++ b/libs/spandsp/src/t4_t6_decode.c @@ -75,10 +75,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -138,17 +144,17 @@ static int free_buffers(t4_t6_decode_state_t *s) { if (s->cur_runs) { - free(s->cur_runs); + span_free(s->cur_runs); s->cur_runs = NULL; } if (s->ref_runs) { - free(s->ref_runs); + span_free(s->ref_runs); s->ref_runs = NULL; } if (s->row_buf) { - free(s->row_buf); + span_free(s->row_buf); s->row_buf = NULL; } s->bytes_per_row = 0; @@ -380,12 +386,12 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) need a minimum of 13 bits in the buffer to proceed with any bit stream analysis. */ if ((s->rx_bits += quantity) < 13) - return FALSE; + return false; if (s->consecutive_eols) { /* Check if the image has already terminated. */ if (s->consecutive_eols >= EOLS_TO_END_ANY_RX_PAGE) - return TRUE; + return true; /* Check if the image hasn't even started. */ if (s->consecutive_eols < 0) { @@ -396,14 +402,14 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) { s->rx_bitstream >>= 1; if (--s->rx_bits < 13) - return FALSE; + return false; } /* We have an EOL, so now the page begins and we can proceed to process the bit stream as image data. */ s->consecutive_eols = 0; if (s->encoding == T4_COMPRESSION_T4_1D) { - s->row_is_2d = FALSE; + s->row_is_2d = false; force_drop_rx_bits(s, 12); } else @@ -444,7 +450,7 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) if (s->consecutive_eols >= EOLS_TO_END_T6_RX_PAGE) { s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; - return TRUE; + return true; } } else @@ -452,7 +458,7 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) if (s->consecutive_eols >= EOLS_TO_END_T4_RX_PAGE) { s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; - return TRUE; + return true; } } } @@ -464,7 +470,7 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) add_run_to_row(s); s->consecutive_eols = 0; if (put_decoded_row(s)) - return TRUE; + return true; } if (s->encoding == T4_COMPRESSION_T4_2D) { @@ -475,7 +481,7 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) { force_drop_rx_bits(s, 12); } - s->in_black = FALSE; + s->in_black = false; s->black_white = 0; s->run_length = 0; s->row_len = 0; @@ -608,7 +614,7 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) s->a0 += t4_1d_black_table[bits].param; break; case S_TermB: - s->in_black = FALSE; + s->in_black = false; if (s->row_len < s->image_width) { s->run_length += t4_1d_black_table[bits].param; @@ -642,7 +648,7 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) s->a0 += t4_1d_white_table[bits].param; break; case S_TermW: - s->in_black = TRUE; + s->in_black = true; if (s->row_len < s->image_width) { s->run_length += t4_1d_white_table[bits].param; @@ -675,15 +681,15 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) if (s->run_length > 0) add_run_to_row(s); if (put_decoded_row(s)) - return TRUE; - s->in_black = FALSE; + return true; + s->in_black = false; s->black_white = 0; s->run_length = 0; s->row_len = 0; } } } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -714,7 +720,7 @@ SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit) if (bit < 0) { t4_t6_decode_rx_status(s, bit); - return TRUE; + return true; } s->compressed_image_size++; if (put_bits(s, bit & 1, 1)) @@ -824,10 +830,10 @@ SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width) if (s->bytes_per_row == 0 || image_width != s->image_width) { /* Allocate the space required for decoding the new row length. */ - if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) + if ((bufptr = (uint32_t *) span_realloc(s->cur_runs, run_space)) == NULL) return -1; s->cur_runs = bufptr; - if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL) + if ((bufptr = (uint32_t *) span_realloc(s->ref_runs, run_space)) == NULL) return -1; s->ref_runs = bufptr; s->image_width = image_width; @@ -835,7 +841,7 @@ SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width) bytes_per_row = (image_width + 7)/8; if (bytes_per_row != s->bytes_per_row) { - if ((bufptr8 = (uint8_t *) realloc(s->row_buf, bytes_per_row)) == NULL) + if ((bufptr8 = (uint8_t *) span_realloc(s->row_buf, bytes_per_row)) == NULL) return -1; s->row_buf = bufptr8; s->bytes_per_row = bytes_per_row; @@ -857,7 +863,7 @@ SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width) s->pixels = 8; s->row_len = 0; - s->in_black = FALSE; + s->in_black = false; s->black_white = 0; s->b_cursor = 1; s->a_cursor = 0; @@ -892,7 +898,7 @@ SPAN_DECLARE(t4_t6_decode_state_t *) t4_t6_decode_init(t4_t6_decode_state_t *s, { if (s == NULL) { - if ((s = (t4_t6_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t4_t6_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -919,7 +925,7 @@ SPAN_DECLARE(int) t4_t6_decode_free(t4_t6_decode_state_t *s) int ret; ret = t4_t6_decode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_t6_encode.c b/libs/spandsp/src/t4_t6_encode.c index ddb8b33a06..85838a0ea9 100644 --- a/libs/spandsp/src/t4_t6_encode.c +++ b/libs/spandsp/src/t4_t6_encode.c @@ -72,10 +72,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -373,17 +379,17 @@ static int free_buffers(t4_t6_encode_state_t *s) { if (s->cur_runs) { - free(s->cur_runs); + span_free(s->cur_runs); s->cur_runs = NULL; } if (s->ref_runs) { - free(s->ref_runs); + span_free(s->ref_runs); s->ref_runs = NULL; } if (s->bitstream) { - free(s->bitstream); + span_free(s->bitstream); s->bitstream = NULL; } s->bytes_per_row = 0; @@ -840,12 +846,12 @@ static int encode_row(t4_t6_encode_state_t *s, const uint8_t *row_buf, size_t le else { encode_1d_row(s, row_buf); - s->row_is_2d = TRUE; + s->row_is_2d = true; } if (s->rows_to_next_1d_row <= 0) { /* Insert a row of 1D encoding */ - s->row_is_2d = FALSE; + s->row_is_2d = false; s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1; } break; @@ -873,7 +879,7 @@ static int finalise_page(t4_t6_encode_state_t *s) else { /* Attach an RTC (return to control == 6 x EOLs) to the end of the page */ - s->row_is_2d = FALSE; + s->row_is_2d = false; for (i = 0; i < EOLS_TO_END_T4_TX_PAGE; i++) encode_eol(s); } @@ -1026,13 +1032,13 @@ SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int imag s->bytes_per_row = (s->image_width + 7)/8; run_space = (s->image_width + 4)*sizeof(uint32_t); - if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) + if ((bufptr = (uint32_t *) span_realloc(s->cur_runs, run_space)) == NULL) return -1; s->cur_runs = bufptr; - if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL) + if ((bufptr = (uint32_t *) span_realloc(s->ref_runs, run_space)) == NULL) return -1; s->ref_runs = bufptr; - if ((bufptr8 = (uint8_t *) realloc(s->bitstream, (s->image_width + 1)*sizeof(uint16_t))) == NULL) + if ((bufptr8 = (uint8_t *) span_realloc(s->bitstream, (s->image_width + 1)*sizeof(uint16_t))) == NULL) return -1; s->bitstream = bufptr8; } @@ -1040,6 +1046,12 @@ SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int imag } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) t4_t6_encode_set_image_length(t4_t6_encode_state_t *s, int image_length) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_width(t4_t6_encode_state_t *s) { return s->image_width; @@ -1098,7 +1110,7 @@ SPAN_DECLARE(void) t4_t6_encode_set_max_2d_rows_per_1d_row(t4_t6_encode_state_t } s->max_rows_to_next_1d_row = max; s->rows_to_next_1d_row = max - 1; - s->row_is_2d = FALSE; + s->row_is_2d = false; } /*- End of function --------------------------------------------------------*/ @@ -1145,7 +1157,7 @@ SPAN_DECLARE(t4_t6_encode_state_t *) t4_t6_encode_init(t4_t6_encode_state_t *s, { if (s == NULL) { - if ((s = (t4_t6_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t4_t6_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1175,7 +1187,7 @@ SPAN_DECLARE(int) t4_t6_encode_free(t4_t6_encode_state_t *s) int ret; ret = t4_t6_encode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index 90b20aeacc..5c35fdb0b4 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -44,10 +44,16 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -95,55 +101,52 @@ typedef struct int bit_mask; } packer_t; -typedef struct -{ - float resolution; - int code; -} res_table_t; +static void t4_tx_set_image_type(t4_tx_state_t *s, int image_type); +static void set_image_width(t4_tx_state_t *s, uint32_t image_width); +static void set_image_length(t4_tx_state_t *s, uint32_t image_length); -static void t4_tx_set_image_length(t4_tx_state_t *s, uint32_t image_length); - -static const res_table_t x_res_table[] = +static const float x_res_table[] = { - { 100.0f/CM_PER_INCH, T4_X_RESOLUTION_100}, - { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4}, - { 200.0f/CM_PER_INCH, T4_X_RESOLUTION_200}, - { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8}, - { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300}, - { 400.0f/CM_PER_INCH, T4_X_RESOLUTION_400}, - { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16}, - { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600}, - {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200}, - { -1.00f, -1} + 100.0f*100.0f/CM_PER_INCH, + 102.0f*100.0f/CM_PER_INCH, + 200.0f*100.0f/CM_PER_INCH, + 204.0f*100.0f/CM_PER_INCH, + 300.0f*100.0f/CM_PER_INCH, + 400.0f*100.0f/CM_PER_INCH, + 408.0f*100.0f/CM_PER_INCH, + 600.0f*100.0f/CM_PER_INCH, + 1200.0f*100.0f/CM_PER_INCH, + -1.00f }; -static const res_table_t y_res_table[] = +static const float y_res_table[] = { - { 38.50f, T4_Y_RESOLUTION_STANDARD}, - { 100.0f/CM_PER_INCH, T4_Y_RESOLUTION_100}, - { 77.00f, T4_Y_RESOLUTION_FINE}, - { 200.0f/CM_PER_INCH, T4_Y_RESOLUTION_200}, - { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300}, - { 154.00f, T4_Y_RESOLUTION_SUPERFINE}, - { 400.0f/CM_PER_INCH, T4_Y_RESOLUTION_400}, - { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600}, - { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800}, - {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200}, - { -1.00f, -1} + 38.50f*100.0f, + 100.0f*100.0f/CM_PER_INCH, + 77.00f*100.0f, + 200.0f*100.0f/CM_PER_INCH, + 300.0f*100.0f/CM_PER_INCH, + 154.00f*100.0f, + 400.0f*100.0f/CM_PER_INCH, + 600.0f*100.0f/CM_PER_INCH, + 800.0f*100.0f/CM_PER_INCH, + 1200.0f*100.0f/CM_PER_INCH, + -1.00f }; -static const int resolution_map[10][10] = +static const int resolution_map[10][9] = { - { 0, 0, 0, T4_RESOLUTION_R8_STANDARD, 0, 0, 0, 0, 0, 0}, - {T4_RESOLUTION_100_100, 0, T4_RESOLUTION_200_100, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, T4_RESOLUTION_R8_FINE, 0, 0, 0, 0, 0, 0}, - { 0, 0, T4_RESOLUTION_200_200, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, T4_RESOLUTION_300_300, 0, 0, 0, 0, 0}, - { 0, 0, 0, T4_RESOLUTION_R8_SUPERFINE, 0, 0, T4_RESOLUTION_R16_SUPERFINE, 0, 0, 0}, - { 0, 0, T4_RESOLUTION_200_400, 0, 0, T4_RESOLUTION_400_400, 0, 0, 0, 0}, - { 0, 0, 0, 0, T4_RESOLUTION_300_600, 0, 0, T4_RESOLUTION_600_600, 0, 0}, - { 0, 0, 0, 0, 0, T4_RESOLUTION_400_800, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 0, T4_RESOLUTION_600_1200, 0, T4_RESOLUTION_1200_1200}, + /* x = 100 102 200 204 300 400 408 600 1200 */ + { 0, 0, 0, T4_RESOLUTION_R8_STANDARD, 0, 0, 0, 0, 0}, /* y = 3.85/mm */ + {T4_RESOLUTION_100_100, 0, T4_RESOLUTION_200_100, 0, 0, 0, 0, 0, 0}, /* y = 100 */ + { 0, 0, 0, T4_RESOLUTION_R8_FINE, 0, 0, 0, 0, 0}, /* y = 7.7/mm */ + { 0, 0, T4_RESOLUTION_200_200, 0, 0, 0, 0, 0, 0}, /* y = 200 */ + { 0, 0, 0, 0, T4_RESOLUTION_300_300, 0, 0, 0, 0}, /* y = 300 */ + { 0, 0, 0, T4_RESOLUTION_R8_SUPERFINE, 0, 0, T4_RESOLUTION_R16_SUPERFINE, 0, 0}, /* y = 154/mm */ + { 0, 0, T4_RESOLUTION_200_400, 0, 0, T4_RESOLUTION_400_400, 0, 0, 0}, /* y = 400 */ + { 0, 0, 0, 0, T4_RESOLUTION_300_600, 0, 0, T4_RESOLUTION_600_600, 0}, /* y = 600 */ + { 0, 0, 0, 0, 0, T4_RESOLUTION_400_800, 0, 0, 0}, /* y = 800 */ + { 0, 0, 0, 0, 0, 0, 0, T4_RESOLUTION_600_1200, T4_RESOLUTION_1200_1200} /* y = 1200 */ }; #if defined(SPANDSP_SUPPORT_TIFF_FX) @@ -151,18 +154,18 @@ static const int resolution_map[10][10] = static const TIFFFieldInfo tiff_fx_tiff_field_info[] = { - {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, FIELD_CUSTOM, FALSE, FALSE, (char *) "Indexed"}, - {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, FIELD_CUSTOM, FALSE, FALSE, (char *) "GlobalParametersIFD"}, - {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "ProfileType"}, - {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "FaxProfile"}, - {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "CodingMethods"}, - {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "VersionYear"}, - {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "ModeNumber"}, - {TIFFTAG_DECODE, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SRATIONAL, FIELD_CUSTOM, FALSE, TRUE, (char *) "Decode"}, - {TIFFTAG_IMAGEBASECOLOR, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SHORT, FIELD_CUSTOM, FALSE, TRUE, (char *) "ImageBaseColor"}, - {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "T82Options"}, - {TIFFTAG_STRIPROWCOUNTS, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_LONG, FIELD_CUSTOM, FALSE, TRUE, (char *) "StripRowCounts"}, - {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "ImageLayer"}, + {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, FIELD_CUSTOM, false, false, (char *) "Indexed"}, + {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, FIELD_CUSTOM, false, false, (char *) "GlobalParametersIFD"}, + {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "ProfileType"}, + {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, FIELD_CUSTOM, false, false, (char *) "FaxProfile"}, + {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "CodingMethods"}, + {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, FIELD_CUSTOM, false, false, (char *) "VersionYear"}, + {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, FIELD_CUSTOM, false, false, (char *) "ModeNumber"}, + {TIFFTAG_DECODE, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SRATIONAL, FIELD_CUSTOM, false, true, (char *) "Decode"}, + {TIFFTAG_IMAGEBASECOLOR, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SHORT, FIELD_CUSTOM, false, true, (char *) "ImageBaseColor"}, + {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "T82Options"}, + {TIFFTAG_STRIPROWCOUNTS, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_LONG, FIELD_CUSTOM, false, true, (char *) "StripRowCounts"}, + {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "ImageLayer"}, }; #if 1 @@ -201,11 +204,11 @@ static void TIFFFXDefaultDirectory(TIFF *tif) SPAN_DECLARE(void) TIFF_FX_init(void) { - static int first_time = TRUE; + static int first_time = true; if (!first_time) return; - first_time = FALSE; + first_time = false; /* Grab the inherited method and install */ _ParentExtender = TIFFSetTagExtender(TIFFFXDefaultDirectory); @@ -213,7 +216,65 @@ SPAN_DECLARE(void) TIFF_FX_init(void) /*- End of function --------------------------------------------------------*/ #endif -static int match_resolution(int res_unit, float actual, const res_table_t table[]) +static int code_to_x_resolution(int code) +{ + static const int xxx[] = + { + T4_X_RESOLUTION_R8, /* R8 x standard */ + T4_X_RESOLUTION_R8, /* R8 x fine */ + T4_X_RESOLUTION_R8, /* R8 x superfine */ + T4_X_RESOLUTION_R16, /* R16 x superfine */ + T4_X_RESOLUTION_100, /* 100x100 */ + T4_X_RESOLUTION_200, /* 200x100 */ + T4_X_RESOLUTION_200, /* 200x200 */ + T4_X_RESOLUTION_200, /* 200x400 */ + T4_X_RESOLUTION_300, /* 300x300 */ + T4_X_RESOLUTION_300, /* 300x600 */ + T4_X_RESOLUTION_400, /* 400x400 */ + T4_X_RESOLUTION_400, /* 400x800 */ + T4_X_RESOLUTION_600, /* 600x600 */ + T4_X_RESOLUTION_600, /* 600x1200 */ + T4_X_RESOLUTION_1200 /* 1200x1200 */ + }; + int entry; + + entry = top_bit(code); + if (entry < 0 || entry > 14) + return 0; + return xxx[entry]; +} +/*- End of function --------------------------------------------------------*/ + +static int code_to_y_resolution(int code) +{ + static const int yyy[] = + { + T4_Y_RESOLUTION_STANDARD, /* R8 x standard */ + T4_Y_RESOLUTION_FINE, /* R8 x fine */ + T4_Y_RESOLUTION_SUPERFINE, /* R8 x superfine */ + T4_Y_RESOLUTION_SUPERFINE, /* R16 x superfine */ + T4_Y_RESOLUTION_100, /* 100x100 */ + T4_Y_RESOLUTION_100, /* 200x100 */ + T4_Y_RESOLUTION_200, /* 200x200 */ + T4_Y_RESOLUTION_400, /* 200x400 */ + T4_Y_RESOLUTION_300, /* 300x300 */ + T4_Y_RESOLUTION_600, /* 300x600 */ + T4_Y_RESOLUTION_400, /* 400x400 */ + T4_Y_RESOLUTION_800, /* 400x800 */ + T4_Y_RESOLUTION_600, /* 600x600 */ + T4_Y_RESOLUTION_1200, /* 600x1200 */ + T4_Y_RESOLUTION_1200 /* 1200x1200 */ + }; + int entry; + + entry = top_bit(code); + if (entry < 0 || entry > 14) + return 0; + return yyy[entry]; +} +/*- End of function --------------------------------------------------------*/ + +static int match_resolution(float actual, const float table[]) { int i; int best_entry; @@ -223,16 +284,14 @@ static int match_resolution(int res_unit, float actual, const res_table_t table[ if (actual == 0.0f) return -1; - if (res_unit == RESUNIT_INCH) - actual /= CM_PER_INCH; best_ratio = 0.0f; best_entry = -1; - for (i = 0; table[i].code > 0; i++) + for (i = 0; table[i] > 0.0f; i++) { - if (actual > table[i].resolution) - ratio = table[i].resolution/actual; + if (actual > table[i]) + ratio = table[i]/actual; else - ratio = actual/table[i].resolution; + ratio = actual/table[i]; if (ratio > best_ratio) { best_entry = i; @@ -245,7 +304,51 @@ static int match_resolution(int res_unit, float actual, const res_table_t table[ } /*- End of function --------------------------------------------------------*/ -#if 0 //defined(SPANDSP_SUPPORT_TIFF_FX) +static int best_colour_resolution(float actual, int allowed_resolutions) +{ + static const struct + { + float resolution; + int resolution_code; + } x_res_table[] = + { + { 100.0f*100.0f/CM_PER_INCH, T4_RESOLUTION_100_100}, + { 200.0f*100.0f/CM_PER_INCH, T4_RESOLUTION_200_200}, + { 300.0f*100.0f/CM_PER_INCH, T4_RESOLUTION_300_300}, + { 400.0f*100.0f/CM_PER_INCH, T4_RESOLUTION_400_400}, + { 600.0f*100.0f/CM_PER_INCH, T4_RESOLUTION_600_600}, + {1200.0f*100.0f/CM_PER_INCH, T4_RESOLUTION_1200_1200}, + { -1.00f, -1} + }; + int i; + int best_entry; + float best_ratio; + float ratio; + + if (actual == 0.0f) + return -1; + + best_ratio = 0.0f; + best_entry = -1; + for (i = 0; x_res_table[i].resolution > 0.0f; i++) + { + if (!(allowed_resolutions & x_res_table[i].resolution_code)) + continue; + if (actual > x_res_table[i].resolution) + ratio = x_res_table[i].resolution/actual; + else + ratio = actual/x_res_table[i].resolution; + if (ratio > best_ratio) + { + best_entry = i; + best_ratio = ratio; + } + } + return x_res_table[best_entry].resolution_code; +} +/*- End of function --------------------------------------------------------*/ + +#if defined(SPANDSP_SUPPORT_TIFF_FX) static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) { int i; @@ -264,7 +367,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) /* TODO: This only allows for 8 bit deep maps */ span_log(&s->logging, SPAN_LOG_FLOW, "Got a colour map\n"); s->colour_map_entries = 1 << bits_per_sample; - if ((s->colour_map = realloc(s->colour_map, 3*s->colour_map_entries)) == NULL) + if ((s->colour_map = span_realloc(s->colour_map, 3*s->colour_map_entries)) == NULL) return -1; #if 0 /* Sweep the colormap in the proper order */ @@ -284,7 +387,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) s->colour_map[2*s->colour_map_entries + i] = (map_b[i] >> 8) & 0xFF; } #endif - lab_to_srgb(&s->lab_params, s->colour_map, s->colour_map, 256); + lab_to_srgb(&s->lab_params, s->colour_map, s->colour_map, s->colour_map_entries); for (i = 0; i < s->colour_map_entries; i++) span_log(&s->logging, SPAN_LOG_FLOW, "Map %3d - %5d %5d %5d\n", i, s->colour_map[3*i], s->colour_map[3*i + 1], s->colour_map[3*i + 2]); return 0; @@ -307,8 +410,18 @@ static int get_tiff_directory_info(t4_tx_state_t *s) }; char *u; char uu[10]; + float *fl_parms; uint64_t diroff; + float lmin; + float lmax; + float amin; + float amax; + float bmin; + float bmax; uint8_t parm8; +#endif +#if defined(TIFFTAG_INDEXED) + uint16_t parm16; #endif uint32_t parm32; int best_x_entry; @@ -319,6 +432,8 @@ static int get_tiff_directory_info(t4_tx_state_t *s) uint16_t bits_per_sample; uint16_t samples_per_pixel; uint16_t res_unit; + uint16_t YCbCrSubsample_horiz; + uint16_t YCbCrSubsample_vert; t = &s->tiff; bits_per_sample = 1; @@ -329,6 +444,8 @@ static int get_tiff_directory_info(t4_tx_state_t *s) t->image_type = T4_IMAGE_TYPE_BILEVEL; else if (samples_per_pixel == 3 && bits_per_sample == 1) t->image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL; + else if (samples_per_pixel == 4 && bits_per_sample == 1) + t->image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL; else if (samples_per_pixel == 1 && bits_per_sample == 8) t->image_type = T4_IMAGE_TYPE_GRAY_8BIT; else if (samples_per_pixel == 1 && bits_per_sample > 8) @@ -339,62 +456,111 @@ static int get_tiff_directory_info(t4_tx_state_t *s) t->image_type = T4_IMAGE_TYPE_COLOUR_12BIT; else return -1; -#if 0 - /* Limit ourselves to plain black and white pages */ - if (t->image_type != T4_IMAGE_TYPE_BILEVEL) - return -1; + +#if defined(TIFFTAG_INDEXED) + parm16 = 0; + if (TIFFGetField(t->tiff_file, TIFFTAG_INDEXED, &parm16)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Indexed %s (%u)\n", (parm16) ? "palette image" : "non-palette image", parm16); + if (parm16 == 1) + { + /* Its an indexed image, so its really a colour image, even though it may have only one sample per pixel */ + if (samples_per_pixel == 1 && bits_per_sample == 8) + t->image_type = T4_IMAGE_TYPE_COLOUR_8BIT; + else if (samples_per_pixel == 1 && bits_per_sample > 8) + t->image_type = T4_IMAGE_TYPE_COLOUR_12BIT; + } + } #endif + parm32 = 0; TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32); - t->image_width = - s->metadata.image_width = parm32; + t->image_width = parm32; parm32 = 0; TIFFGetField(t->tiff_file, TIFFTAG_IMAGELENGTH, &parm32); - t->image_length = - s->metadata.image_length = parm32; + t->image_length = parm32; + x_resolution = 0.0f; TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); y_resolution = 0.0f; TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); res_unit = RESUNIT_INCH; TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); + + t->x_resolution = x_resolution*100.0f; + t->y_resolution = y_resolution*100.0f; + if (res_unit == RESUNIT_INCH) + { + t->x_resolution /= CM_PER_INCH; + t->y_resolution /= CM_PER_INCH; + } + + if (((best_x_entry = match_resolution(t->x_resolution, x_res_table)) >= 0) + && + ((best_y_entry = match_resolution(t->y_resolution, y_res_table)) >= 0)) + { + t->resolution_code = resolution_map[best_y_entry][best_x_entry]; + } + else + { + t->resolution_code = 0; + } + t->photo_metric = PHOTOMETRIC_MINISWHITE; TIFFGetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, &t->photo_metric); - set_lab_illuminant(&s->lab_params, 0.9638f, 1.0f, 0.8245f); - set_lab_gamut(&s->lab_params, 0, 100, -85, 85, -75, 125, FALSE); + /* The default luminant is D50 */ + set_lab_illuminant(&s->lab_params, 96.422f, 100.000f, 82.521f); + set_lab_gamut(&s->lab_params, 0, 100, -85, 85, -75, 125, false); t->compression = -1; TIFFGetField(t->tiff_file, TIFFTAG_COMPRESSION, &t->compression); + switch (t->compression) + { + case COMPRESSION_CCITT_T4: + span_log(&s->logging, SPAN_LOG_FLOW, "T.4\n"); + break; + case COMPRESSION_CCITT_T6: + span_log(&s->logging, SPAN_LOG_FLOW, "T.6\n"); + break; + case COMPRESSION_T85: + span_log(&s->logging, SPAN_LOG_FLOW, "T.85\n"); + break; +#if defined(SPANDSP_SUPPORT_T43) + case COMPRESSION_T43: + span_log(&s->logging, SPAN_LOG_FLOW, "T.43\n"); + break; +#endif + case COMPRESSION_JPEG: + span_log(&s->logging, SPAN_LOG_FLOW, "JPEG\n"); + if (t->photo_metric == PHOTOMETRIC_ITULAB) + span_log(&s->logging, SPAN_LOG_FLOW, "ITULAB\n"); + break; + case COMPRESSION_NONE: + span_log(&s->logging, SPAN_LOG_FLOW, "No compression\n"); + break; + default: + span_log(&s->logging, SPAN_LOG_FLOW, "Unexpected compression %d\n", t->compression); + break; + } + +#if defined(SPANDSP_SUPPORT_TIFF_FX) + read_colour_map(s, bits_per_sample); +#endif + + YCbCrSubsample_horiz = 0; + YCbCrSubsample_vert = 0; + if (TIFFGetField(t->tiff_file, TIFFTAG_YCBCRSUBSAMPLING, &YCbCrSubsample_horiz, &YCbCrSubsample_vert)) + span_log(&s->logging, SPAN_LOG_FLOW, "Subsampling %d %d\n", YCbCrSubsample_horiz, YCbCrSubsample_vert); + t->fill_order = FILLORDER_LSB2MSB; - if (res_unit == RESUNIT_INCH) - t->image_x_resolution = x_resolution*100.0f/CM_PER_INCH; - else - t->image_x_resolution = x_resolution*100.0f; - /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ - if ((best_x_entry = match_resolution(res_unit, x_resolution, x_res_table)) < 0) - best_x_entry = 3; - s->metadata.x_resolution = x_res_table[best_x_entry].code; - - if (res_unit == RESUNIT_INCH) - t->image_y_resolution = y_resolution*100.0f/CM_PER_INCH; - else - t->image_y_resolution = y_resolution*100.0f; - if ((best_y_entry = match_resolution(res_unit, y_resolution, y_res_table)) < 0) - best_y_entry = 0; - s->metadata.y_resolution = y_res_table[best_y_entry].code; - - s->metadata.resolution_code = resolution_map[best_y_entry][best_x_entry]; - - t4_tx_set_image_width(s, s->metadata.image_width); - t4_tx_set_image_length(s, s->metadata.image_length); - t4_tx_set_max_2d_rows_per_1d_row(s, -s->metadata.y_resolution); #if defined(SPANDSP_SUPPORT_TIFF_FX) if (TIFFGetField(t->tiff_file, TIFFTAG_PROFILETYPE, &parm32)) span_log(&s->logging, SPAN_LOG_FLOW, "Profile type %u\n", parm32); if (TIFFGetField(t->tiff_file, TIFFTAG_FAXPROFILE, &parm8)) span_log(&s->logging, SPAN_LOG_FLOW, "FAX profile %s (%u)\n", tiff_fx_fax_profiles[parm8], parm8); + if (TIFFGetField(t->tiff_file, TIFFTAG_CODINGMETHODS, &parm32)) span_log(&s->logging, SPAN_LOG_FLOW, "Coding methods 0x%x\n", parm32); if (TIFFGetField(t->tiff_file, TIFFTAG_VERSIONYEAR, &u)) @@ -406,11 +572,60 @@ static int get_tiff_directory_info(t4_tx_state_t *s) if (TIFFGetField(t->tiff_file, TIFFTAG_MODENUMBER, &parm8)) span_log(&s->logging, SPAN_LOG_FLOW, "Mode number %u\n", parm8); + switch (t->photo_metric) + { + case PHOTOMETRIC_ITULAB: +#if 1 + /* 8 bit version */ + lmin = 0.0f; + lmax = 100.0f; + amin = -21760.0f/255.0f; + amax = 21590.0f/255.0f; + bmin = -19200.0f/255.0f; + bmax = 31800.0f/255.0f; +#else + /* 12 bit version */ + lmin = 0.0f; + lmax = 100.0f; + amin = -348160.0f/4095.0f + amax = 347990.0f/4095.0f + bmin = -307200.0f/4095.0f + bmax = 511800.0f/4095.0f +#endif + break; + default: + lmin = 0.0f; + lmax = 0.0f; + amin = 0.0f; + amax = 0.0f; + bmin = 0.0f; + bmax = 0.0f; + break; + } + + if (TIFFGetField(t->tiff_file, TIFFTAG_DECODE, &parm16, &fl_parms)) + { + lmin = fl_parms[0]; + lmax = fl_parms[1]; + amin = fl_parms[2]; + amax = fl_parms[3]; + bmin = fl_parms[4]; + bmax = fl_parms[5]; + span_log(&s->logging, SPAN_LOG_FLOW, "Got decode tag %f %f %f %f %f %f\n", lmin, lmax, amin, amax, bmin, bmax); + } + + /* TIFFTAG_IMAGEBASECOLOR */ + + if (TIFFGetField(t->tiff_file, TIFFTAG_T82OPTIONS, &parm32)) + span_log(&s->logging, SPAN_LOG_FLOW, "T.82 options 0x%x\n", parm32); + + /* TIFFTAG_STRIPROWCOUNTS */ + /* TIFFTAG_IMAGELAYER */ + /* If global parameters are present they should only be on the first page of the file. However, as we scan the file we might as well look for them on any page. */ if (TIFFGetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, &diroff)) { - span_log(&s->logging, SPAN_LOG_FLOW, "Global parameters IFD at %" PRIu64 "\n", diroff); if (!TIFFReadCustomDirectory(t->tiff_file, diroff, &tiff_fx_field_array)) { span_log(&s->logging, SPAN_LOG_FLOW, "Global parameter read failed\n"); @@ -449,8 +664,6 @@ static int test_tiff_directory_info(t4_tx_state_t *s) uint16_t bits_per_sample; uint16_t samples_per_pixel; int image_type; - int best_x_entry; - int best_y_entry; float x_resolution; float y_resolution; t4_tx_tiff_state_t *t; @@ -464,6 +677,8 @@ static int test_tiff_directory_info(t4_tx_state_t *s) image_type = T4_IMAGE_TYPE_BILEVEL; else if (samples_per_pixel == 3 && bits_per_sample == 1) image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL; + else if (samples_per_pixel == 4 && bits_per_sample == 1) + image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL; else if (samples_per_pixel == 1 && bits_per_sample == 8) image_type = T4_IMAGE_TYPE_GRAY_8BIT; else if (samples_per_pixel == 1 && bits_per_sample > 8) @@ -474,18 +689,14 @@ static int test_tiff_directory_info(t4_tx_state_t *s) image_type = T4_IMAGE_TYPE_COLOUR_12BIT; else image_type = -1; -#if 0 - /* Limit ourselves to plain black and white pages */ - if (t->image_type != T4_IMAGE_TYPE_BILEVEL) - return -1; -#endif if (t->image_type != image_type) return 1; parm32 = 0; TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32); - if (s->metadata.image_width != (int) parm32) - return 1; + if (s->tiff.image_width != (int) parm32) + return 2; + x_resolution = 0.0f; TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); y_resolution = 0.0f; @@ -493,16 +704,17 @@ static int test_tiff_directory_info(t4_tx_state_t *s) res_unit = RESUNIT_INCH; TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); - /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ - if ((best_x_entry = match_resolution(res_unit, x_resolution, x_res_table)) < 0) - return 1; - if (s->metadata.x_resolution != x_res_table[best_x_entry].code) - return 1; - - if ((best_y_entry = match_resolution(res_unit, y_resolution, y_res_table)) < 0) - return 1; - if (s->metadata.y_resolution != y_res_table[best_y_entry].code) - return 1; + x_resolution *= 100.0f; + y_resolution *= 100.0f; + if (res_unit == RESUNIT_INCH) + { + x_resolution /= CM_PER_INCH; + y_resolution /= CM_PER_INCH; + } + if (s->tiff.x_resolution != (int) x_resolution) + return 3; + if (s->tiff.y_resolution != (int) y_resolution) + return 4; return 0; } @@ -533,6 +745,19 @@ static int open_tiff_input_file(t4_tx_state_t *s, const char *file) } /*- End of function --------------------------------------------------------*/ +static int metadata_row_read_handler(void *user_data, uint8_t buf[], size_t len) +{ + t4_tx_state_t *s; + + s = (t4_tx_state_t *) user_data; + if (s->tiff.row >= s->metadata.image_length) + return 0; + memcpy(buf, &s->tiff.image_buffer[s->tiff.row*len], len); + s->tiff.row++; + return len; +} +/*- End of function --------------------------------------------------------*/ + static int tiff_row_read_handler(void *user_data, uint8_t buf[], size_t len) { t4_tx_state_t *s; @@ -540,16 +765,21 @@ static int tiff_row_read_handler(void *user_data, uint8_t buf[], size_t len) int j; s = (t4_tx_state_t *) user_data; - if (s->tiff.row >= s->metadata.image_length) + if (s->tiff.row >= s->tiff.image_length) return 0; + if (s->tiff.image_buffer == NULL) + { + exit(2); + return 0; + } memcpy(buf, &s->tiff.image_buffer[s->tiff.row*len], len); s->tiff.row++; /* If this is a bi-level image which has more vertical resolution than the far end will accept, we need to squash it down to size. */ - for (i = 1; i < s->row_squashing_ratio && s->tiff.row < s->metadata.image_length; i++) + for (i = 1; i < s->row_squashing_ratio && s->tiff.row < s->tiff.image_length; i++) { - for (j = 0; j < s->metadata.image_width/8; j++) + for (j = 0; j < len; j++) buf[j] |= s->tiff.image_buffer[s->tiff.row*len + j]; s->tiff.row++; } @@ -557,19 +787,52 @@ static int tiff_row_read_handler(void *user_data, uint8_t buf[], size_t len) } /*- End of function --------------------------------------------------------*/ -static int row_read(void *user_data, uint8_t buf[], size_t len) +static int translate_row_read2(void *user_data, uint8_t buf[], size_t len) { t4_tx_state_t *s; + s = (t4_tx_state_t *) user_data; + memcpy(buf, &s->pack_buf[s->pack_ptr], len); + s->pack_ptr += len; + s->pack_row++; + return len; +} +/*- End of function --------------------------------------------------------*/ + +static int translate_row_read(void *user_data, uint8_t buf[], size_t len) +{ + t4_tx_state_t *s; + int i; + int j; + s = (t4_tx_state_t *) user_data; if (s->tiff.raw_row >= s->tiff.image_length) return 0; + if (TIFFReadScanline(s->tiff.tiff_file, buf, s->tiff.raw_row, 0) < 0) return 0; + s->tiff.raw_row++; + + /* If this is a bi-level image which is stretched more vertically than we are able + to send we need to squash it down to size. */ + for (i = 1; i < s->row_squashing_ratio; i++) + { +#if defined(_MSC_VER) + uint8_t *extra_buf = (uint8_t *) _alloca(len); +#else + uint8_t extra_buf[len]; +#endif + + if (TIFFReadScanline(s->tiff.tiff_file, extra_buf, s->tiff.raw_row, 0) < 0) + return 0; + s->tiff.raw_row++; + /* We know this is a bi-level image if we are squashing */ + for (j = 0; j < s->tiff.image_width/8; j++) + buf[j] |= extra_buf[s->tiff.image_width/8 + j]; + } if (s->apply_lab) lab_to_srgb(&s->lab_params, buf, buf, len/3); - s->tiff.raw_row++; return len; } /*- End of function --------------------------------------------------------*/ @@ -599,11 +862,39 @@ static int embedded_comment_handler(void *user_data, const uint8_t buf[], size_t } /*- End of function --------------------------------------------------------*/ +static int read_tiff_raw_image(t4_tx_state_t *s) +{ + int num_strips; + int total_len; + int len; + int i; + + num_strips = TIFFNumberOfStrips(s->tiff.tiff_file); + total_len = 0; + for (i = 0; i < num_strips; i++) + total_len += TIFFRawStripSize(s->tiff.tiff_file, i); + if ((s->pre_encoded_buf = span_realloc(s->pre_encoded_buf, total_len)) == NULL) + return -1; + total_len = 0; + for (i = 0; i < num_strips; i++, total_len += len) + { + len = TIFFRawStripSize(s->tiff.tiff_file, i); + if ((len = TIFFReadRawStrip(s->tiff.tiff_file, i, &s->pre_encoded_buf[total_len], len)) < 0) + { + span_log(&s->logging, SPAN_LOG_WARNING, "%s: TIFFReadRawStrip error.\n", s->tiff.file); + return -1; + } + } + s->pre_encoded_len = total_len; + s->pre_encoded_ptr = 0; + return 0; +} +/*- End of function --------------------------------------------------------*/ + static int read_tiff_t85_image(t4_tx_state_t *s) { int biggest; int num_strips; - int total_len; int len; int i; int result; @@ -614,39 +905,43 @@ static int read_tiff_t85_image(t4_tx_state_t *s) /* Size up and allocate the buffer for the raw data */ num_strips = TIFFNumberOfStrips(s->tiff.tiff_file); - biggest = TIFFRawStripSize(s->tiff.tiff_file, 0); - for (i = 1; i < num_strips; i++) + biggest = 0; + for (i = 0; i < num_strips; i++) { len = TIFFRawStripSize(s->tiff.tiff_file, i); if (len > biggest) biggest = len; } - if ((raw_data = malloc(biggest)) == NULL) + if ((raw_data = span_alloc(biggest)) == NULL) return -1; - s->tiff.image_size = s->metadata.image_length*((s->metadata.image_width + 7)/8); + s->tiff.image_size = s->tiff.image_length*((s->tiff.image_width + 7)/8); if (s->tiff.image_size >= s->tiff.image_buffer_size) { - if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + if ((t = span_realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + { + span_free(raw_data); return -1; + } s->tiff.image_buffer_size = s->tiff.image_size; s->tiff.image_buffer = t; } pack.buf = s->tiff.image_buffer; pack.ptr = 0; + pack.size = s->tiff.image_size; pack.row = 0; t85_decode_init(&t85, packing_row_write_handler, &pack); t85_decode_set_comment_handler(&t85, 1000, embedded_comment_handler, s); - total_len = 0; result = -1; - for (i = 0; i < num_strips; i++, total_len += len) + for (i = 0; i < num_strips; i++) { len = TIFFRawStripSize(s->tiff.tiff_file, i); if ((len = TIFFReadRawStrip(s->tiff.tiff_file, i, raw_data, len)) < 0) { - span_log(&s->logging, SPAN_LOG_WARNING, "%s: ReadRaw error.\n", s->tiff.file); + span_log(&s->logging, SPAN_LOG_WARNING, "%s: TIFFReadRawStrip error.\n", s->tiff.file); + span_free(raw_data); return -1; } result = t85_decode_put(&t85, raw_data, len); @@ -657,42 +952,57 @@ static int read_tiff_t85_image(t4_tx_state_t *s) result = t85_decode_put(&t85, NULL, 0); len = t85_decode_get_compressed_image_size(&t85); - span_log(&s->logging, SPAN_LOG_WARNING, "Compressed image is %d bytes, %d rows\n", len/8, s->metadata.image_length); + span_log(&s->logging, SPAN_LOG_WARNING, "Compressed image is %d bytes, %d rows\n", len/8, s->tiff.image_length); t85_decode_release(&t85); - free(raw_data); + span_free(raw_data); return 0; } /*- End of function --------------------------------------------------------*/ #if defined(SPANDSP_SUPPORT_T43) -static int read_tiff_t43_image(t4_tx_state_t *s, uint8_t **buf) +static int read_tiff_t43_image(t4_tx_state_t *s) { + int biggest; int num_strips; - int total_len; int len; int i; - int total_image_len; - int image_size; - logging_state_t *logging; + int result; + uint8_t *t; uint8_t *raw_data; + logging_state_t *logging; t43_decode_state_t t43; packer_t pack; + uint16_t bits_per_sample; + uint16_t samples_per_pixel; + + bits_per_sample = 1; + TIFFGetField(s->tiff.tiff_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); + samples_per_pixel = 3; + TIFFGetField(s->tiff.tiff_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); + + samples_per_pixel = 3; num_strips = TIFFNumberOfStrips(s->tiff.tiff_file); - total_image_len = 0; + biggest = 0; for (i = 0; i < num_strips; i++) - total_image_len += TIFFRawStripSize(s->tiff.tiff_file, i); - if ((raw_data = malloc(total_image_len)) == NULL) + { + len = TIFFRawStripSize(s->tiff.tiff_file, i); + if (len > biggest) + biggest = len; + } + if ((raw_data = span_alloc(biggest)) == NULL) return -1; - total_len = 0; - for (i = 0; i < num_strips; i++, total_len += len) + s->tiff.image_size = samples_per_pixel*s->tiff.image_width*s->tiff.image_length; + if (s->tiff.image_size >= s->tiff.image_buffer_size) { - if ((len = TIFFReadRawStrip(s->tiff.tiff_file, i, &raw_data[total_len], total_image_len - total_len)) < 0) + if ((t = span_realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) { - span_log(&s->logging, SPAN_LOG_FLOW, "TIFF read error.\n"); + span_free(raw_data); return -1; } + s->tiff.image_buffer_size = s->tiff.image_size; + s->tiff.image_buffer = t; } t43_decode_init(&t43, packing_row_write_handler, &pack); @@ -700,36 +1010,55 @@ static int read_tiff_t43_image(t4_tx_state_t *s, uint8_t **buf) logging = t43_decode_get_logging_state(&t43); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - image_size = 3*s->metadata.image_length*s->metadata.image_width; - if ((*buf = malloc(image_size)) == NULL) - return -1; - - pack.buf = *buf; + pack.buf = s->tiff.image_buffer; pack.ptr = 0; + pack.size = s->tiff.image_size; pack.row = 0; - t43_decode_put(&t43, raw_data, total_len); + + result = -1; + for (i = 0; i < num_strips; i++) + { + len = TIFFRawStripSize(s->tiff.tiff_file, i); + if ((len = TIFFReadRawStrip(s->tiff.tiff_file, i, raw_data, len)) < 0) + { + span_log(&s->logging, SPAN_LOG_WARNING, "%s: TIFFReadRawStrip error.\n", s->tiff.file); + span_free(raw_data); + return -1; + } + result = t43_decode_put(&t43, raw_data, len); + if (result != T4_DECODE_MORE_DATA) + break; + } + if (result == T4_DECODE_MORE_DATA) + result = t43_decode_put(&t43, NULL, 0); + t43_decode_release(&t43); - free(raw_data); - return image_size; + span_free(raw_data); + return s->tiff.image_size; } /*- End of function --------------------------------------------------------*/ #endif -#if 0 -static int read_tiff_t42_t81_image(t4_tx_state_t *s, uint8_t **buf) +static int read_tiff_t42_t81_image(t4_tx_state_t *s) { int total_len; int len; int i; int num_strips; int total_image_len; - int image_size; + uint8_t *t; uint8_t *raw_data; uint8_t *jpeg_table; uint32_t jpeg_table_len; - uint32_t w; - uint32_t h; - tsize_t off; + packer_t pack; + uint16_t bits_per_sample; + uint16_t samples_per_pixel; + t42_decode_state_t t42; + + bits_per_sample = 1; + TIFFGetField(s->tiff.tiff_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); + samples_per_pixel = 1; + TIFFGetField(s->tiff.tiff_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); num_strips = TIFFNumberOfStrips(s->tiff.tiff_file); total_image_len = 0; @@ -742,7 +1071,7 @@ static int read_tiff_t42_t81_image(t4_tx_state_t *s, uint8_t **buf) for (i = 0; i < num_strips; i++) total_image_len += TIFFRawStripSize(s->tiff.tiff_file, i); - if ((raw_data = malloc(total_image_len)) == NULL) + if ((raw_data = span_alloc(total_image_len)) == NULL) return -1; total_len = 0; @@ -752,7 +1081,8 @@ static int read_tiff_t42_t81_image(t4_tx_state_t *s, uint8_t **buf) { if ((len = TIFFReadRawStrip(s->tiff.tiff_file, i, &raw_data[total_len], total_image_len - total_len)) < 0) { - span_log(&s->logging, SPAN_LOG_FLOW, "TIFF read error.\n"); + span_log(&s->logging, SPAN_LOG_WARNING, "%s: TIFFReadRawStrip error.\n", s->tiff.file); + span_free(raw_data); return -1; } } @@ -762,21 +1092,32 @@ static int read_tiff_t42_t81_image(t4_tx_state_t *s, uint8_t **buf) if (total_len != total_image_len) span_log(&s->logging, SPAN_LOG_FLOW, "Size mismatch %d %d\n", (int) total_len, (int) total_image_len); - image_size = 3*s->metadata.image_length*s->metadata.image_width; - if ((*buf = malloc(image_size)) == NULL) - return -1; - - off = 0; - if (!t42_itulab_to_srgb(&s->logging, &s->lab_params, *buf, &off, raw_data, total_image_len, &w, &h)) + s->tiff.image_size = samples_per_pixel*s->tiff.image_width*s->tiff.image_length; + if (s->tiff.image_size >= s->tiff.image_buffer_size) { - span_log(&s->logging, SPAN_LOG_FLOW, "Failed to convert from ITULAB.\n"); - return -1; + if ((t = span_realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + { + span_free(raw_data); + return -1; + } + s->tiff.image_buffer_size = s->tiff.image_size; + s->tiff.image_buffer = t; } - free(raw_data); - return image_size; + + t42_decode_init(&t42, packing_row_write_handler, &pack); + + pack.buf = s->tiff.image_buffer; + pack.ptr = 0; + pack.row = 0; + + t42_decode_put(&t42, raw_data, total_image_len); + t42_decode_put(&t42, NULL, 0); + + t42_decode_release(&t42); + span_free(raw_data); + return s->tiff.image_size; } /*- End of function --------------------------------------------------------*/ -#endif static int read_tiff_decompressed_image(t4_tx_state_t *s) { @@ -788,28 +1129,27 @@ static int read_tiff_decompressed_image(t4_tx_state_t *s) /* Decode the whole image into a buffer */ /* Let libtiff handle the decompression */ - s->tiff.image_size = s->metadata.image_length*TIFFScanlineSize(s->tiff.tiff_file); + s->tiff.image_size = s->tiff.image_length*TIFFScanlineSize(s->tiff.tiff_file); if (s->tiff.image_size >= s->tiff.image_buffer_size) { - if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + if ((t = span_realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) return -1; s->tiff.image_buffer_size = s->tiff.image_size; s->tiff.image_buffer = t; } - /* Allow for the image being stored in multiple strips, although it is rare to find - a stripped image in a T.4 or T.6 encoded file. */ + /* Allow for the image being stored in multiple strips. */ num_strips = TIFFNumberOfStrips(s->tiff.tiff_file); for (i = 0, total_len = 0; i < num_strips; i++, total_len += len) { if ((len = TIFFReadEncodedStrip(s->tiff.tiff_file, i, &s->tiff.image_buffer[total_len], s->tiff.image_size - total_len)) < 0) { - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Read error.\n", s->tiff.file); + span_log(&s->logging, SPAN_LOG_WARNING, "%s: TIFFReadEncodedStrip error.\n", s->tiff.file); return -1; } } /* We might need to flip all the bits, so 1 = black and 0 = white. */ - if (s->tiff.photo_metric != PHOTOMETRIC_MINISWHITE) + if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL && s->tiff.photo_metric != PHOTOMETRIC_MINISWHITE) { span_log(&s->logging, SPAN_LOG_FLOW, "%s: Photometric needs swapping.\n", s->tiff.file); for (i = 0; i < s->tiff.image_size; i++) @@ -827,50 +1167,160 @@ static int read_tiff_image(t4_tx_state_t *s) { int total_len; int i; + int len; uint8_t *t; - image_translate_state_t *translator; + + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + image_translate_restart(&s->translator, s->tiff.image_length); + s->metadata.image_length = image_translate_get_output_length(&s->translator); + } + else + { + s->metadata.image_length = s->tiff.image_length; + } + s->pack_buf = NULL; + s->pack_ptr = 0; + s->pack_row = 0; if (s->tiff.image_type != T4_IMAGE_TYPE_BILEVEL) { - /* We need to dither this image down to pure black and white, possibly resizing it - along the way. */ - if ((translator = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, 1728, -1, s->tiff.image_type, s->metadata.image_width, s->metadata.image_length, row_read, s)) == NULL) - return -1; - s->metadata.image_width = image_translate_get_output_width(translator); - s->metadata.image_length = image_translate_get_output_length(translator); - s->metadata.x_resolution = T4_X_RESOLUTION_R8; - s->metadata.y_resolution = T4_Y_RESOLUTION_FINE; - s->metadata.resolution_code = T4_RESOLUTION_R8_FINE; - s->tiff.image_size = (s->metadata.image_width*s->metadata.image_length + 7)/8; - if (s->tiff.image_size >= s->tiff.image_buffer_size) + /* If colour/gray scale is supported we may be able to send the image as it is, perhaps after + a resizing. Otherwise we need to resize it, and squash it to a bilevel image. */ + if (s->tiff.compression == COMPRESSION_JPEG && s->tiff.photo_metric == PHOTOMETRIC_ITULAB) { - if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) - return -1; - s->tiff.image_buffer_size = s->tiff.image_size; - s->tiff.image_buffer = t; + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + if (read_tiff_t42_t81_image(s) < 0) + return -1; + + s->pack_buf = s->tiff.image_buffer; + s->pack_ptr = 0; + s->pack_row = 0; + image_translate_set_row_read_handler(&s->translator, translate_row_read2, s); + } + else + { + /* Read the raw image, and send it as is */ + if (read_tiff_raw_image(s) < 0) + return -1; + } } - s->tiff.raw_row = 0; - switch (s->tiff.photo_metric) +#if defined(SPANDSP_SUPPORT_T43) + else if (s->tiff.compression == COMPRESSION_T43) { - case PHOTOMETRIC_CIELAB: - /* The default luminant is D50 */ - set_lab_illuminant(&s->lab_params, 0.96422f, 1.0f, 0.82521f); - set_lab_gamut(&s->lab_params, 0, 100, -128, 127, -128, 127, TRUE); - s->apply_lab = TRUE; - break; - case PHOTOMETRIC_ITULAB: - set_lab_illuminant(&s->lab_params, 0.9638f, 1.0f, 0.8245f); - set_lab_gamut(&s->lab_params, 0, 100, -85, 85, -75, 125, FALSE); - s->apply_lab = TRUE; - break; - default: - s->apply_lab = FALSE; - break; + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + if ((len = read_tiff_t43_image(s)) < 0) + return -1; + + s->pack_buf = s->tiff.image_buffer; + s->pack_ptr = 0; + s->pack_row = 0; + image_translate_set_row_read_handler(&s->translator, translate_row_read2, s); + } + else + { + /* Read the raw image, and send it as is */ + if (read_tiff_raw_image(s) < 0) + return -1; + } + } +#endif +#if defined(SPANDSP_SUPPORT_T45) + else if (s->tiff.compression == COMPRESSION_T45) + { + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + if (read_tiff_t45_image(s) < 0) + return -1; + + s->pack_buf = s->tiff.image_buffer; + s->pack_ptr = 0; + s->pack_row = 0; + image_translate_set_row_read_handler(&s->translator, translate_row_read2, s); + } + else + { + /* Read the raw image, and send it as is */ + if (read_tiff_raw_image(s) < 0) + return -1; + } + } +#endif + else + { + /* Let libtiff handle the decompression */ + TIFFSetField(s->tiff.tiff_file, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + image_translate_set_row_read_handler(&s->translator, translate_row_read, s); + } + else + { + if (read_tiff_decompressed_image(s) < 0) + return -1; + } + } + set_image_width(s, s->metadata.image_width); + set_image_length(s, s->metadata.image_length); + t4_tx_set_image_type(s, s->metadata.image_type); + if (s->metadata.image_type == T4_IMAGE_TYPE_BILEVEL) + { + /* We need to dither this image down to pure black and white, possibly resizing it + along the way. */ + s->tiff.image_size = (s->metadata.image_width*s->metadata.image_length + 7)/8; + if (s->tiff.image_size >= s->tiff.image_buffer_size) + { + if ((t = span_realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + return -1; + s->tiff.image_buffer_size = s->tiff.image_size; + s->tiff.image_buffer = t; + } + s->tiff.raw_row = 0; + switch (s->tiff.photo_metric) + { + case PHOTOMETRIC_CIELAB: + /* The default luminant is D50 */ + set_lab_illuminant(&s->lab_params, 96.422f, 100.000f, 82.521f); + set_lab_gamut(&s->lab_params, 0, 100, -128, 127, -128, 127, true); + s->apply_lab = true; + break; + case PHOTOMETRIC_ITULAB: + /* The default luminant is D50 */ + set_lab_illuminant(&s->lab_params, 96.422f, 100.000f, 82.521f); + set_lab_gamut(&s->lab_params, 0, 100, -85, 85, -75, 125, false); + s->apply_lab = true; + break; + default: + s->apply_lab = false; + break; + } + total_len = 0; + for (i = 0; i < s->metadata.image_length; i++) + total_len += image_translate_row(&s->translator, &s->tiff.image_buffer[total_len], s->metadata.image_width/8); + image_translate_release(&s->translator); + s->row_handler = metadata_row_read_handler; + s->row_handler_user_data = (void *) s; + } + else + { + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + total_len = 0; + s->tiff.image_buffer = span_realloc(s->tiff.image_buffer, s->metadata.image_width*s->metadata.image_length*3); + for (i = 0; i < s->metadata.image_length; i++) + total_len += image_translate_row(&s->translator, &s->tiff.image_buffer[total_len], s->metadata.image_width); + image_translate_release(&s->translator); + s->row_handler = metadata_row_read_handler; + s->row_handler_user_data = (void *) s; + } + else + { + s->row_handler = tiff_row_read_handler; + s->row_handler_user_data = (void *) s; + } } - total_len = 0; - for (i = 0; i < s->metadata.image_length; i++) - total_len += image_translate_row(translator, &s->tiff.image_buffer[total_len], s->metadata.image_width/8); - image_translate_free(translator); } else { @@ -881,13 +1331,59 @@ static int read_tiff_image(t4_tx_state_t *s) slightly long one, but lets not bother. */ switch (s->tiff.compression) { - case COMPRESSION_T85: - /* Decode the whole image into a buffer */ - /* libtiff probably cannot decompress T.85, so we must handle it ourselves */ - /* Decode the whole image into a buffer */ - if (read_tiff_t85_image(s) < 0) - return -1; +#if defined(SPANDSP_SUPPORT_T88) + case COMPRESSION_T88: + switch (s->metadata.compression) + { + case T4_COMPRESSION_T88: + /* Read the raw image, and send it as is */ + if (read_tiff_raw_image(s) < 0) + return -1; + break; + default: + /* libtiff probably cannot decompress T.88, so we must handle it ourselves */ + /* Decode the whole image into a buffer */ + if (read_tiff_t88_image(s) < 0) + return -1; + break; + } break; +#endif + case COMPRESSION_T85: + switch (s->metadata.compression) + { + case T4_COMPRESSION_T85: + case T4_COMPRESSION_T85_L0: + /* Read the raw image, and send it as is */ + if (read_tiff_raw_image(s) < 0) + return -1; + break; + default: + /* libtiff probably cannot decompress T.85, so we must handle it ourselves */ + /* Decode the whole image into a buffer */ + if (read_tiff_t85_image(s) < 0) + return -1; + break; + } + break; +#if 0 + case COMPRESSION_CCITT_T6: + switch (s->metadata.compression) + { + case T4_COMPRESSION_T6: + /* Read the raw image, and send it as is */ + if (read_tiff_raw_image(s) < 0) + return -1; + break; + default: + /* Decode the whole image into a buffer */ + /* Let libtiff handle the decompression */ + if (read_tiff_decompressed_image(s) < 0) + return -1; + break; + } + break; +#endif default: /* Decode the whole image into a buffer */ /* Let libtiff handle the decompression */ @@ -908,12 +1404,12 @@ static void tiff_tx_release(t4_tx_state_t *s) TIFFClose(s->tiff.tiff_file); s->tiff.tiff_file = NULL; if (s->tiff.file) - free((char *) s->tiff.file); + span_free((char *) s->tiff.file); s->tiff.file = NULL; } if (s->tiff.image_buffer) { - free(s->tiff.image_buffer); + span_free(s->tiff.image_buffer); s->tiff.image_buffer = NULL; s->tiff.image_size = 0; s->tiff.image_buffer_size = 0; @@ -934,7 +1430,7 @@ static int set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, return t85_encode_set_row_read_handler(&s->encoder.t85, handler, user_data); #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: - break; + return t88_encode_set_row_read_handler(&s->encoder.t88, handler, user_data); #endif case T4_COMPRESSION_T42_T81: case T4_COMPRESSION_SYCC_T81: @@ -945,7 +1441,7 @@ static int set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: - break; + return t45_encode_set_row_read_handler(&s->encoder.t45, handler, user_data); #endif } return -1; @@ -964,7 +1460,7 @@ static int make_header(t4_tx_state_t *s) if (s->header_text == NULL) { - if ((s->header_text = malloc(132 + 1)) == NULL) + if ((s->header_text = span_alloc(132 + 1)) == NULL) return -1; } /* This is very English oriented, but then most FAX machines are, too. Some @@ -996,39 +1492,79 @@ static int make_header(t4_tx_state_t *s) static int header_row_read_handler(void *user_data, uint8_t buf[], size_t len) { - int repeats; + int x_repeats; + int y_repeats; int pattern; int pos; int row; + int i; char *t; t4_tx_state_t *s; s = (t4_tx_state_t *) user_data; - switch (s->metadata.y_resolution) + switch (s->metadata.resolution_code) { - case T4_Y_RESOLUTION_1200: - repeats = 12; - break; - case T4_Y_RESOLUTION_800: - repeats = 8; - break; - case T4_Y_RESOLUTION_600: - repeats = 6; - break; - case T4_Y_RESOLUTION_SUPERFINE: - repeats = 4; - break; - case T4_Y_RESOLUTION_300: - repeats = 3; - break; - case T4_Y_RESOLUTION_FINE: - repeats = 2; - break; default: - repeats = 1; + case T4_RESOLUTION_100_100: + x_repeats = 1; + y_repeats = 1; + break; + case T4_RESOLUTION_R8_STANDARD: + case T4_RESOLUTION_200_100: + x_repeats = 2; + y_repeats = 1; + break; + case T4_RESOLUTION_R8_FINE: + case T4_RESOLUTION_200_200: + x_repeats = 2; + y_repeats = 2; + break; + case T4_RESOLUTION_300_300: + x_repeats = 3; + y_repeats = 3; + break; + case T4_RESOLUTION_R8_SUPERFINE: + case T4_RESOLUTION_200_400: + x_repeats = 2; + y_repeats = 4; + break; + case T4_RESOLUTION_R16_SUPERFINE: + case T4_RESOLUTION_400_400: + x_repeats = 4; + y_repeats = 4; + break; + case T4_RESOLUTION_400_800: + x_repeats = 4; + y_repeats = 8; + break; + case T4_RESOLUTION_300_600: + x_repeats = 3; + y_repeats = 6; + break; + case T4_RESOLUTION_600_600: + x_repeats = 6; + y_repeats = 6; + break; + case T4_RESOLUTION_600_1200: + x_repeats = 6; + y_repeats = 12; + break; + case T4_RESOLUTION_1200_1200: + x_repeats = 12; + y_repeats = 12; + break; + } + switch (s->metadata.width_code) + { + case T4_SUPPORT_WIDTH_215MM: + break; + case T4_SUPPORT_WIDTH_255MM: + x_repeats *= 2; + break; + case T4_SUPPORT_WIDTH_303MM: + x_repeats *= 3; break; } - repeats /= s->row_squashing_ratio; if (s->header_overlays_image) { /* Read and dump a row of the real image, allowing for the possibility @@ -1039,18 +1575,62 @@ static int header_row_read_handler(void *user_data, uint8_t buf[], size_t len) return len; } } - row = s->header_row/repeats; + t = s->header_text; + row = s->header_row/y_repeats; pos = 0; - for (t = s->header_text; *t && pos <= len - 2; t++) + switch (s->metadata.image_type) { - pattern = header_font[(uint8_t) *t][row]; - buf[pos++] = (uint8_t) (pattern >> 8); - buf[pos++] = (uint8_t) (pattern & 0xFF); + case T4_IMAGE_TYPE_BILEVEL: + for ( ; *t && pos <= len - 2; t++) + { + pattern = header_font[(uint8_t) *t][row]; + buf[pos++] = (uint8_t) (pattern >> 8); + buf[pos++] = (uint8_t) (pattern & 0xFF); + } + if (pos < len) + memset(&buf[pos], 0, len - pos); + break; + case T4_IMAGE_TYPE_GRAY_8BIT: + for ( ; *t && pos <= len - 2; t++) + { + pattern = header_font[(uint8_t) *t][row]; + for (i = 0; i < 16; i++) + { + buf[pos + i] = (pattern & 0x8000) ? 0 : 0xFF; + pattern <<= 1; + } + pos += 16; + } + if (pos < len) + memset(&buf[pos], 0xFF, len - pos); + break; + case T4_IMAGE_TYPE_COLOUR_8BIT: + for ( ; *t && pos <= len - 2; t++) + { + pattern = header_font[(uint8_t) *t][row]; + for (i = 0; i < 16; i++) + { + buf[pos + 3*i + 0] = + buf[pos + 3*i + 1] = + buf[pos + 3*i + 2] = (pattern & 0x8000) ? 0 : 0xFF; + pattern <<= 1; + } + pos += 3*16; + } + if (pos < len) + memset(&buf[pos], 0xFF, len - pos); + break; + case T4_IMAGE_TYPE_COLOUR_BILEVEL: + case T4_IMAGE_TYPE_4COLOUR_BILEVEL: + case T4_IMAGE_TYPE_GRAY_12BIT: + case T4_IMAGE_TYPE_4COLOUR_8BIT: + case T4_IMAGE_TYPE_COLOUR_12BIT: + case T4_IMAGE_TYPE_4COLOUR_12BIT: + default: + memset(buf, 0xFF, len); } - while (pos < len) - buf[pos++] = 0; s->header_row++; - if (s->header_row >= 16*repeats) + if (s->header_row >= 16*y_repeats) { /* End of header. Change to normal image row data. */ set_row_read_handler(s, s->row_handler, s->row_handler_user_data); @@ -1059,12 +1639,6 @@ static int header_row_read_handler(void *user_data, uint8_t buf[], size_t len) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t4_tx_set_row_squashing_ratio(t4_tx_state_t *s, int row_squashing_ratio) -{ - s->row_squashing_ratio = row_squashing_ratio; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_tx_state_t *s) { span_log(&s->logging, SPAN_LOG_FLOW, "Checking for the existence of page %d\n", s->current_page + 1); @@ -1088,10 +1662,374 @@ SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_tx_state_t *s, t4_row_read_handl } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) +SPAN_DECLARE(int) t4_tx_set_tx_image_format(t4_tx_state_t *s, + int supported_compressions, + int supported_image_sizes, + int supported_bilevel_resolutions, + int supported_colour_resolutions) { + static const struct { - switch (encoding) + int width; + int width_code; + int res_code; /* Correct resolution code */ + int alt_res_code; /* Fallback resolution code, where a metric/inch swap is possible */ + } width_info[] = + { + { T4_WIDTH_100_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_100_100, 0}, + { T4_WIDTH_100_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_100_100, 0}, + { T4_WIDTH_100_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_100_100, 0}, + { T4_WIDTH_200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_200_100, T4_RESOLUTION_R8_STANDARD}, + { T4_WIDTH_200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_200_200, T4_RESOLUTION_R8_FINE}, + { T4_WIDTH_200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_200_400, T4_RESOLUTION_R8_SUPERFINE}, + { T4_WIDTH_200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_R8_STANDARD, T4_RESOLUTION_200_100}, + { T4_WIDTH_200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_R8_FINE, T4_RESOLUTION_200_200}, + { T4_WIDTH_200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_R8_SUPERFINE, T4_RESOLUTION_200_400}, + { T4_WIDTH_200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_200_100, T4_RESOLUTION_R8_STANDARD}, + { T4_WIDTH_200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_200_200, T4_RESOLUTION_R8_FINE}, + { T4_WIDTH_200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_200_400, T4_RESOLUTION_R8_SUPERFINE}, + { T4_WIDTH_200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_R8_STANDARD, T4_RESOLUTION_200_100}, + { T4_WIDTH_200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_R8_FINE, T4_RESOLUTION_200_200}, + { T4_WIDTH_200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_R8_SUPERFINE, T4_RESOLUTION_200_400}, + { T4_WIDTH_200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_200_100, T4_RESOLUTION_R8_STANDARD}, + { T4_WIDTH_200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_200_200, T4_RESOLUTION_R8_FINE}, + { T4_WIDTH_200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_200_400, T4_RESOLUTION_R8_SUPERFINE}, + { T4_WIDTH_200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_R8_STANDARD, T4_RESOLUTION_200_100}, + { T4_WIDTH_200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_R8_FINE, T4_RESOLUTION_200_200}, + { T4_WIDTH_200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_R8_SUPERFINE, T4_RESOLUTION_200_400}, + { T4_WIDTH_300_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_300_300, 0}, + { T4_WIDTH_300_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_300_600, 0}, + { T4_WIDTH_300_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_300_300, 0}, + { T4_WIDTH_300_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_300_600, 0}, + { T4_WIDTH_400_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_400_400, T4_RESOLUTION_R16_SUPERFINE}, + { T4_WIDTH_400_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_400_800, 0}, + { T4_WIDTH_400_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_R16_SUPERFINE, T4_RESOLUTION_400_400}, + { T4_WIDTH_300_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_300_300, 0}, + { T4_WIDTH_300_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_300_600, 0}, + { T4_WIDTH_400_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_400_400, T4_RESOLUTION_R16_SUPERFINE}, + { T4_WIDTH_400_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_400_800, 0}, + { T4_WIDTH_400_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_R16_SUPERFINE, T4_RESOLUTION_400_400}, + { T4_WIDTH_400_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_400_400, T4_RESOLUTION_R16_SUPERFINE}, + { T4_WIDTH_400_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_400_800, 0}, + { T4_WIDTH_400_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_R16_SUPERFINE, T4_RESOLUTION_400_400}, + { T4_WIDTH_600_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_600_600, 0}, + { T4_WIDTH_600_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_600_1200, 0}, + { T4_WIDTH_600_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_600_600, 0}, + { T4_WIDTH_600_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_600_1200, 0}, + { T4_WIDTH_600_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_600_600, 0}, + { T4_WIDTH_600_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_600_1200, 0}, + {T4_WIDTH_1200_A4, T4_SUPPORT_WIDTH_215MM, T4_RESOLUTION_1200_1200, 0}, + {T4_WIDTH_1200_B4, T4_SUPPORT_WIDTH_255MM, T4_RESOLUTION_1200_1200, 0}, + {T4_WIDTH_1200_A3, T4_SUPPORT_WIDTH_303MM, T4_RESOLUTION_1200_1200, 0}, + {0x7FFFFFFF, -1, -1, -1} + }; + + static const struct + { + int resolution; + struct + { + int resolution; + int squashing_factor; + } fallback[4]; + } squashable[4] = + { + { + T4_RESOLUTION_200_400, + { + {T4_RESOLUTION_200_200, 2}, + {T4_RESOLUTION_R8_FINE, 2}, + {T4_RESOLUTION_200_100, 4}, + {T4_RESOLUTION_R8_STANDARD, 4} + } + }, + { + T4_RESOLUTION_200_200, + { + {T4_RESOLUTION_200_100, 2}, + {T4_RESOLUTION_R8_STANDARD, 2}, + {0, 0}, + {0, 0} + } + }, + { + T4_RESOLUTION_R8_SUPERFINE, + { + {T4_RESOLUTION_R8_FINE, 2}, + {T4_RESOLUTION_200_200, 2}, + {T4_RESOLUTION_R8_STANDARD, 4}, + {T4_RESOLUTION_200_100, 4} + } + }, + { + T4_RESOLUTION_R8_FINE, + { + {T4_RESOLUTION_R8_STANDARD, 2}, + {T4_RESOLUTION_200_100, 2}, + {0, 0}, + {0, 0} + } + } + }; + + int i; + int j; + int entry; + int compression; + int res; + + compression = -1; + s->metadata.image_type = s->tiff.image_type; + if (s->tiff.image_type != T4_IMAGE_TYPE_BILEVEL) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Non-bi-level image\n"); + /* Can we send this page as it is? */ + if (supported_colour_resolutions + && + (supported_compressions & (T4_COMPRESSION_T42_T81 | T4_COMPRESSION_T43 | T4_COMPRESSION_T45 | T4_COMPRESSION_SYCC_T81)) + && + (((s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_BILEVEL || s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_8BIT || s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_12BIT) + && + (supported_compressions & T4_COMPRESSION_COLOUR)) + || + ((s->tiff.image_type == T4_IMAGE_TYPE_GRAY_8BIT || s->tiff.image_type == T4_IMAGE_TYPE_GRAY_12BIT) + && + (supported_compressions & T4_COMPRESSION_GRAYSCALE)))) + { + /* Gray-scale/colour is possible */ + span_log(&s->logging, SPAN_LOG_FLOW, "Gray-scale/colour is allowed\n"); + if (s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_BILEVEL + || + s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_8BIT + || + s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_12BIT) + { + if (!(supported_compressions & T4_COMPRESSION_COLOUR)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Colour is not allowed\n"); + return T4_IMAGE_FORMAT_INCOMPATIBLE; + } + } + else if (s->tiff.image_type == T4_IMAGE_TYPE_GRAY_8BIT + || + s->tiff.image_type == T4_IMAGE_TYPE_GRAY_12BIT) + { + if (!(supported_compressions & T4_COMPRESSION_GRAYSCALE)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Gray-scale is not allowed\n"); + return T4_IMAGE_FORMAT_INCOMPATIBLE; + } + } + /* Choose the best gray-scale/colour encoding available to us */ + if (s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_BILEVEL && (supported_compressions & T4_COMPRESSION_T43)) + compression = T4_COMPRESSION_T43; + else if ((supported_compressions & T4_COMPRESSION_T42_T81)) + compression = T4_COMPRESSION_T42_T81; + else if ((supported_compressions & T4_COMPRESSION_T43)) + compression = T4_COMPRESSION_T43; + else if ((supported_compressions & T4_COMPRESSION_T45)) + compression = T4_COMPRESSION_T45; + else if ((supported_compressions & T4_COMPRESSION_SYCC_T81)) + compression = T4_COMPRESSION_SYCC_T81; + + //best_colour_resolution(s->tiff.x_resolution, supported_colour_resolutions); + } + else + { + /* Gray-scale/colour is not possible. Can we flatten the image to send it? */ + span_log(&s->logging, SPAN_LOG_FLOW, "Gray-scale/colour is not allowed\n"); + if (s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_BILEVEL + || + s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_8BIT + || + s->tiff.image_type == T4_IMAGE_TYPE_COLOUR_12BIT) + { + if (!(supported_compressions & T4_COMPRESSION_COLOUR_TO_BILEVEL)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Flattening is not allowed\n"); + return T4_IMAGE_FORMAT_INCOMPATIBLE; + } + s->metadata.image_type = T4_IMAGE_TYPE_BILEVEL; + } + else if (s->tiff.image_type == T4_IMAGE_TYPE_GRAY_8BIT + || + s->tiff.image_type == T4_IMAGE_TYPE_GRAY_12BIT) + { + if (!(supported_compressions & T4_COMPRESSION_GRAY_TO_BILEVEL)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Flattening is not allowed\n"); + return T4_IMAGE_FORMAT_INCOMPATIBLE; + } + s->metadata.image_type = T4_IMAGE_TYPE_BILEVEL; + } + /* Squashing to a bi-level image is possible */ + span_log(&s->logging, SPAN_LOG_FLOW, "The image may be flattened to %d\n", s->metadata.image_type); + } + } + + if (s->metadata.image_type == T4_IMAGE_TYPE_BILEVEL) + { + /* Choose the best bi-level encoding available to us */ + if ((supported_compressions & T4_COMPRESSION_T85_L0)) + compression = T4_COMPRESSION_T85_L0; + else if ((supported_compressions & T4_COMPRESSION_T85)) + compression = T4_COMPRESSION_T85; + else if ((supported_compressions & T4_COMPRESSION_T6)) + compression = T4_COMPRESSION_T6; + else if ((supported_compressions & T4_COMPRESSION_T4_2D)) + compression = T4_COMPRESSION_T4_2D; + else + compression = T4_COMPRESSION_T4_1D; + } + + /* Deal with the image width/resolution combination. */ + /* Look for a pattern that matches the image */ + res = T4_IMAGE_FORMAT_NOSIZESUPPORT; + for (entry = 0; s->tiff.image_width >= width_info[entry].width; entry++) + { + if (s->tiff.image_width == width_info[entry].width && s->tiff.resolution_code == width_info[entry].res_code) + { + res = T4_IMAGE_FORMAT_OK; + break; + } + } + + s->metadata.width_code = width_info[entry].width_code; + + s->row_squashing_ratio = 1; + if (res == T4_IMAGE_FORMAT_OK) + { + /* We have a valid width/resolution combination */ + + /* Check if this width/resolution combination is supported */ + if (!(supported_image_sizes & width_info[entry].width_code)) + return T4_IMAGE_FORMAT_NOSIZESUPPORT; + + /* No resize necessary */ + s->metadata.image_width = s->tiff.image_width; + s->metadata.image_length = s->tiff.image_length; + + res = T4_IMAGE_FORMAT_NORESSUPPORT; + if (s->metadata.image_type == T4_IMAGE_TYPE_BILEVEL) + { + if ((width_info[entry].res_code & supported_bilevel_resolutions)) + { + /* We can use the resolution of the original image */ + s->metadata.resolution_code = s->tiff.resolution_code; + s->metadata.x_resolution = code_to_x_resolution(s->metadata.resolution_code); + s->metadata.y_resolution = code_to_y_resolution(s->metadata.resolution_code); + res = T4_IMAGE_FORMAT_OK; + } + else + { + /* The resolution is not supported, but there might be an approximation, or a length + squashing that might work. */ + if ((width_info[entry].alt_res_code & supported_bilevel_resolutions)) + { + /* We can do a metric/imperial swap, and have a usable resolution */ + span_log(&s->logging, + SPAN_LOG_FLOW, + "Image resolution %s falls back to %s\n", + t4_image_resolution_to_str(s->tiff.resolution_code), + t4_image_resolution_to_str(width_info[entry].alt_res_code)); + s->metadata.resolution_code = width_info[entry].alt_res_code; + s->metadata.x_resolution = code_to_x_resolution(s->metadata.resolution_code); + s->metadata.y_resolution = code_to_y_resolution(s->metadata.resolution_code); + res = T4_IMAGE_FORMAT_OK; + } + else + { + if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL) + { + if ((s->tiff.resolution_code & (T4_RESOLUTION_200_400 | T4_RESOLUTION_200_200 | T4_RESOLUTION_R8_SUPERFINE | T4_RESOLUTION_R8_FINE))) + { + /* This might be a resolution we can squash down to something which is supported */ + for (i = 0; i < 4; i++) + { + if ((s->tiff.resolution_code & squashable[i].resolution)) + break; + } + if (i < 4) + { + /* This is a squashable resolution, so let's see if there is a valid + fallback we can squash the image to, scanning through the entries + in their order of preference. */ + for (j = 0; j < 4; j++) + { + if ((supported_bilevel_resolutions & squashable[i].fallback[j].resolution)) + { + span_log(&s->logging, + SPAN_LOG_FLOW, + "Image resolution %s falls back to %s\n", + t4_image_resolution_to_str(s->tiff.resolution_code), + t4_image_resolution_to_str(squashable[i].fallback[j].resolution)); + s->row_squashing_ratio = squashable[i].fallback[j].squashing_factor; + s->metadata.resolution_code = squashable[i].fallback[j].resolution; + s->metadata.x_resolution = code_to_x_resolution(s->metadata.resolution_code); + s->metadata.y_resolution = code_to_y_resolution(s->metadata.resolution_code); + res = T4_IMAGE_FORMAT_OK; + break; + } + } + } + } + } + } + } + /* If we have not succeeded in matching up the size and resolution, the next step will + depend on whether the original was a bi-level image. If it was we are stuck, as you can't + really resize those. If it was not, a resize might be possible */ + if (res != T4_IMAGE_FORMAT_OK) + { + if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL) + return T4_IMAGE_FORMAT_NORESSUPPORT; + if (!(supported_compressions & T4_COMPRESSION_RESCALING)) + return T4_IMAGE_FORMAT_NORESSUPPORT; + } + /* TODO */ + } + else + { + if ((width_info[entry].res_code & supported_bilevel_resolutions)) + { + if ((s->tiff.resolution_code & supported_colour_resolutions)) + { + /* We can use the resolution of the original image */ + s->metadata.resolution_code = width_info[entry].res_code; + s->metadata.x_resolution = code_to_x_resolution(s->metadata.resolution_code); + s->metadata.y_resolution = code_to_y_resolution(s->metadata.resolution_code); + res = T4_IMAGE_FORMAT_OK; + } + } + } + } + else + { + /* Can we rework the image to fit? */ + /* We can't rework a bilevel image that fits none of the patterns */ + if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL) + return T4_IMAGE_FORMAT_NORESSUPPORT; + res = T4_IMAGE_FORMAT_OK; + /* Any other kind of image might be resizable */ + s->metadata.image_width = T4_WIDTH_200_A4; + s->metadata.resolution_code = T4_RESOLUTION_200_200; + s->metadata.x_resolution = code_to_x_resolution(s->metadata.resolution_code); + s->metadata.y_resolution = code_to_y_resolution(s->metadata.resolution_code); + } + + if (res != T4_IMAGE_FORMAT_OK) + return res; + + if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width) + { + if (image_translate_init(&s->translator, s->metadata.image_type, s->metadata.image_width, -1, s->tiff.image_type, s->tiff.image_width, s->tiff.image_length, translate_row_read2, s) == NULL) + return T4_IMAGE_FORMAT_INCOMPATIBLE; + s->metadata.image_length = image_translate_get_output_length(&s->translator); + } + + if (compression != s->metadata.compression) + { + switch (compression) { case T4_COMPRESSION_T4_1D: case T4_COMPRESSION_T4_2D: @@ -1103,14 +2041,14 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) case T4_COMPRESSION_T6: break; default: - t4_t6_encode_init(&s->encoder.t4_t6, encoding, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); - t4_t6_encode_set_max_2d_rows_per_1d_row(&s->encoder.t4_t6, -s->metadata.y_resolution); + t4_t6_encode_init(&s->encoder.t4_t6, compression, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); break; } - s->metadata.compression = encoding; - if (t4_t6_encode_set_encoding(&s->encoder.t4_t6, encoding)) - return -1; - return s->metadata.compression; + s->metadata.compression = compression; + res = T4_IMAGE_FORMAT_OK; + if (t4_t6_encode_set_encoding(&s->encoder.t4_t6, compression)) + res = -1; + break; case T4_COMPRESSION_T85: case T4_COMPRESSION_T85_L0: switch (s->metadata.compression) @@ -1122,8 +2060,9 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) t85_encode_init(&s->encoder.t85, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); break; } - s->metadata.compression = encoding; - return s->metadata.compression; + s->metadata.compression = compression; + res = T4_IMAGE_FORMAT_OK; + break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: switch (s->metadata.compression) @@ -1131,10 +2070,12 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) case T4_COMPRESSION_T88: break; default: + t88_encode_init(&s->encoder.t88, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); break; } - s->metadata.compression = encoding; - return s->metadata.compression; + s->metadata.compression = compression; + res = T4_IMAGE_FORMAT_OK; + break; #endif case T4_COMPRESSION_T42_T81: case T4_COMPRESSION_SYCC_T81: @@ -1147,8 +2088,9 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) t42_encode_init(&s->encoder.t42, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); break; } - s->metadata.compression = encoding; - return s->metadata.compression; + s->metadata.compression = compression; + res = T4_IMAGE_FORMAT_OK; + break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: switch (s->metadata.compression) @@ -1159,8 +2101,9 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) t43_encode_init(&s->encoder.t43, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); break; } - s->metadata.compression = encoding; - return s->metadata.compression; + s->metadata.compression = compression; + res = T4_IMAGE_FORMAT_OK; + break; #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: @@ -1169,31 +2112,75 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) case T4_COMPRESSION_T45: break; default: + t45_encode_init(&s->encoder.t45, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data); break; } - s->metadata.compression = encoding; - return s->metadata.compression; + s->metadata.compression = compression; + res = T4_IMAGE_FORMAT_OK; + break; #endif } } - return -1; -} -/*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits) -{ switch (s->metadata.compression) { case T4_COMPRESSION_T4_1D: case T4_COMPRESSION_T4_2D: case T4_COMPRESSION_T6: - t4_t6_encode_set_min_bits_per_row(&s->encoder.t4_t6, bits); + t4_t6_encode_set_max_2d_rows_per_1d_row(&s->encoder.t4_t6, -s->metadata.y_resolution); break; } + + set_image_width(s, s->metadata.image_width); + set_image_length(s, s->metadata.image_length); + t4_tx_set_image_type(s, s->metadata.image_type); + return res; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width) +SPAN_DECLARE(int) t4_tx_get_tx_compression(t4_tx_state_t *s) +{ + return s->metadata.compression; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_tx_image_type(t4_tx_state_t *s) +{ + return s->metadata.image_type; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_tx_resolution(t4_tx_state_t *s) +{ + return s->metadata.resolution_code; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_tx_x_resolution(t4_tx_state_t *s) +{ + return s->metadata.x_resolution; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_tx_y_resolution(t4_tx_state_t *s) +{ + return s->metadata.y_resolution; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_tx_image_width(t4_tx_state_t *s) +{ + return s->metadata.image_width; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_tx_image_width_code(t4_tx_state_t *s) +{ + return s->metadata.width_code; +} +/*- End of function --------------------------------------------------------*/ + +static void set_image_width(t4_tx_state_t *s, uint32_t image_width) { s->metadata.image_width = image_width; switch (s->metadata.compression) @@ -1209,6 +2196,7 @@ SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width) break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + t88_encode_set_image_width(&s->encoder.t88, image_width); break; #endif case T4_COMPRESSION_T42_T81: @@ -1222,23 +2210,30 @@ SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width) #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + t45_encode_set_image_width(&s->encoder.t45, image_width); break; #endif } } /*- End of function --------------------------------------------------------*/ -static void t4_tx_set_image_length(t4_tx_state_t *s, uint32_t image_length) +static void set_image_length(t4_tx_state_t *s, uint32_t image_length) { s->metadata.image_length = image_length; switch (s->metadata.compression) { + case T4_COMPRESSION_T4_1D: + case T4_COMPRESSION_T4_2D: + case T4_COMPRESSION_T6: + t4_t6_encode_set_image_length(&s->encoder.t4_t6, image_length); + break; case T4_COMPRESSION_T85: case T4_COMPRESSION_T85_L0: t85_encode_set_image_length(&s->encoder.t85, image_length); break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + t88_encode_set_image_length(&s->encoder.t88, image_length); break; #endif case T4_COMPRESSION_T42_T81: @@ -1252,12 +2247,54 @@ static void t4_tx_set_image_length(t4_tx_state_t *s, uint32_t image_length) #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + t45_encode_set_image_length(&s->encoder.t45, image_length); break; #endif } } /*- End of function --------------------------------------------------------*/ +static void t4_tx_set_image_type(t4_tx_state_t *s, int image_type) +{ + s->metadata.image_type = image_type; + switch (s->metadata.compression) + { +#if defined(SPANDSP_SUPPORT_T88) + case T4_COMPRESSION_T88: + t88_encode_set_image_type(&s->encoder.t88, image_type); + break; +#endif + case T4_COMPRESSION_T42_T81: + case T4_COMPRESSION_SYCC_T81: + t42_encode_set_image_type(&s->encoder.t42, image_type); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_T43: + t43_encode_set_image_type(&s->encoder.t43, image_type); + break; +#endif +#if defined(SPANDSP_SUPPORT_T45) + case T4_COMPRESSION_T45: + t45_encode_set_image_type(&s->encoder.t45, image_type); + break; +#endif + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits) +{ + switch (s->metadata.compression) + { + case T4_COMPRESSION_T4_1D: + case T4_COMPRESSION_T4_2D: + case T4_COMPRESSION_T6: + t4_t6_encode_set_min_bits_per_row(&s->encoder.t4_t6, bits); + break; + } +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(void) t4_tx_set_max_2d_rows_per_1d_row(t4_tx_state_t *s, int max) { switch (s->metadata.compression) @@ -1271,13 +2308,7 @@ SPAN_DECLARE(void) t4_tx_set_max_2d_rows_per_1d_row(t4_tx_state_t *s, int max) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_get_image_width(t4_tx_state_t *s) -{ - return s->metadata.image_width; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, int header_overlays_image) +SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, bool header_overlays_image) { s->header_overlays_image = header_overlays_image; } @@ -1301,30 +2332,6 @@ SPAN_DECLARE(void) t4_tx_set_header_tz(t4_tx_state_t *s, struct tz_s *tz) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_tx_state_t *s) -{ - return s->metadata.y_resolution; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_tx_state_t *s) -{ - return s->metadata.x_resolution; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_resolution(t4_tx_state_t *s) -{ - return s->metadata.resolution_code; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_image_type(t4_tx_state_t *s) -{ - return s->metadata.image_type; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_tx_state_t *s) { int max; @@ -1354,50 +2361,55 @@ SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t t->image_type = s->tiff.image_type; t->image_width = s->tiff.image_width; t->image_length = s->tiff.image_length; - t->image_x_resolution = s->tiff.image_x_resolution; - t->image_y_resolution = s->tiff.image_y_resolution; + t->image_x_resolution = s->tiff.x_resolution; + t->image_y_resolution = s->tiff.y_resolution; t->x_resolution = s->metadata.x_resolution; - t->y_resolution = s->metadata.y_resolution/s->row_squashing_ratio; + t->y_resolution = s->metadata.y_resolution; + + t->type = s->metadata.image_type; t->compression = s->metadata.compression; + switch (s->metadata.compression) { case T4_COMPRESSION_T4_1D: case T4_COMPRESSION_T4_2D: case T4_COMPRESSION_T6: - t->type = T4_IMAGE_TYPE_BILEVEL; t->width = t4_t6_encode_get_image_width(&s->encoder.t4_t6); - t->length = t4_t6_encode_get_image_length(&s->encoder.t4_t6)/s->row_squashing_ratio; + t->length = t4_t6_encode_get_image_length(&s->encoder.t4_t6); t->line_image_size = t4_t6_encode_get_compressed_image_size(&s->encoder.t4_t6)/8; break; case T4_COMPRESSION_T85: case T4_COMPRESSION_T85_L0: - t->type = T4_IMAGE_TYPE_BILEVEL; t->width = t85_encode_get_image_width(&s->encoder.t85); - t->length = t85_encode_get_image_length(&s->encoder.t85)/s->row_squashing_ratio; + t->length = t85_encode_get_image_length(&s->encoder.t85); t->line_image_size = t85_encode_get_compressed_image_size(&s->encoder.t85)/8; break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + t->width = t88_encode_get_image_width(&s->encoder.t88); + t->length = t88_encode_get_image_length(&s->encoder.t88); + t->line_image_size = t88_encode_get_compressed_image_size(&s->encoder.t88)/8; break; #endif case T4_COMPRESSION_T42_T81: case T4_COMPRESSION_SYCC_T81: - t->type = 0; t->width = t42_encode_get_image_width(&s->encoder.t42); - t->length = t42_encode_get_image_length(&s->encoder.t42)/s->row_squashing_ratio; + t->length = t42_encode_get_image_length(&s->encoder.t42); t->line_image_size = t42_encode_get_compressed_image_size(&s->encoder.t42)/8; break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: - t->type = 0; t->width = t43_encode_get_image_width(&s->encoder.t43); - t->length = t43_encode_get_image_length(&s->encoder.t43)/s->row_squashing_ratio; + t->length = t43_encode_get_image_length(&s->encoder.t43); t->line_image_size = t43_encode_get_compressed_image_size(&s->encoder.t43)/8; break; #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + t->width = t45_encode_get_image_width(&s->encoder.t45); + t->length = t45_encode_get_image_length(&s->encoder.t45); + t->line_image_size = t45_encode_get_compressed_image_size(&s->encoder.t45)/8; break; #endif } @@ -1406,6 +2418,13 @@ SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s) { + if (s->pre_encoded_len > 0) + { + if (s->pre_encoded_ptr >= s->pre_encoded_len) + return SIG_STATUS_END_OF_DATA; + return 0; + } + switch (s->metadata.compression) { case T4_COMPRESSION_T4_1D: @@ -1417,7 +2436,7 @@ SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s) return t85_encode_image_complete(&s->encoder.t85); #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: - break; + return t88_encode_image_complete(&s->encoder.t88); #endif case T4_COMPRESSION_T42_T81: case T4_COMPRESSION_SYCC_T81: @@ -1428,7 +2447,7 @@ SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s) #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: - break; + return t45_encode_image_complete(&s->encoder.t45); #endif } return SIG_STATUS_END_OF_DATA; @@ -1437,38 +2456,39 @@ SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s) SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s) { + int bit; + /* We only get bit by bit for T.4 1D and T.4 2-D. */ + if (s->pre_encoded_len > 0) + { + if (s->pre_encoded_ptr >= s->pre_encoded_len) + return SIG_STATUS_END_OF_DATA; + bit = (s->pre_encoded_buf[s->pre_encoded_ptr] >> s->pre_encoded_bit) & 1; + if (++s->pre_encoded_bit >= 8) + { + s->pre_encoded_bit = 0; + s->pre_encoded_ptr++; + } + return bit; + } return t4_t6_encode_get_bit(&s->encoder.t4_t6); } /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len) { - switch (s->metadata.compression) + if (s->pre_encoded_len > 0) { - case T4_COMPRESSION_T4_1D: - case T4_COMPRESSION_T4_2D: - case T4_COMPRESSION_T6: - return t4_t6_encode_get(&s->encoder.t4_t6, buf, max_len); - case T4_COMPRESSION_T85: - case T4_COMPRESSION_T85_L0: - return t85_encode_get(&s->encoder.t85, buf, max_len); -#if defined(SPANDSP_SUPPORT_T88) - case T4_COMPRESSION_T88: - break; -#endif - case T4_COMPRESSION_T42_T81: - case T4_COMPRESSION_SYCC_T81: - return t42_encode_get(&s->encoder.t42, buf, max_len); -#if defined(SPANDSP_SUPPORT_T43) - case T4_COMPRESSION_T43: - return t43_encode_get(&s->encoder.t43, buf, max_len); -#endif -#if defined(SPANDSP_SUPPORT_T45) - case T4_COMPRESSION_T45: - break; -#endif + if (max_len > (s->pre_encoded_len - s->pre_encoded_ptr)) + max_len = s->pre_encoded_len - s->pre_encoded_ptr; + memcpy(buf, &s->pre_encoded_buf[s->pre_encoded_ptr], max_len); + s->pre_encoded_ptr += max_len; + return max_len; } + + if (s->image_get_handler) + return s->image_get_handler((void *) &s->encoder, buf, max_len); + return 0; } /*- End of function --------------------------------------------------------*/ @@ -1497,31 +2517,44 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s) case T4_COMPRESSION_T4_2D: case T4_COMPRESSION_T6: t4_t6_encode_restart(&s->encoder.t4_t6, s->metadata.image_width, s->metadata.image_length); + s->image_get_handler = (t4_image_get_handler_t) t4_t6_encode_get; break; case T4_COMPRESSION_T85: case T4_COMPRESSION_T85_L0: t85_encode_restart(&s->encoder.t85, s->metadata.image_width, s->metadata.image_length); + s->image_get_handler = (t4_image_get_handler_t) t85_encode_get; break; #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: + t88_encode_restart(&s->encoder.t88, s->metadata.image_width, s->metadata.image_length); + s->image_get_handler = (t4_image_get_handler_t) t88_encode_get; break; #endif case T4_COMPRESSION_T42_T81: case T4_COMPRESSION_SYCC_T81: t42_encode_restart(&s->encoder.t42, s->metadata.image_width, s->metadata.image_length); + s->image_get_handler = (t4_image_get_handler_t) t42_encode_get; break; #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_T43: t43_encode_restart(&s->encoder.t43, s->metadata.image_width, s->metadata.image_length); + s->image_get_handler = (t4_image_get_handler_t) t43_encode_get; break; #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: + t45_encode_restart(&s->encoder.t45, s->metadata.image_width, s->metadata.image_length); + s->image_get_handler = (t4_image_get_handler_t) t45_encode_get; break; #endif + default: + s->image_get_handler = NULL; + break; } + /* If there is a page header, create that first */ - if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL && s->header_info && s->header_info[0] && make_header(s) == 0) + //if (s->metadata.image_type == T4_IMAGE_TYPE_BILEVEL && s->header_info && s->header_info[0] && make_header(s) == 0) + if (s->header_info && s->header_info[0] && make_header(s) == 0) { s->header_row = 0; set_row_read_handler(s, header_row_read_handler, (void *) s); @@ -1559,12 +2592,12 @@ SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int { int allocated; - allocated = FALSE; + allocated = false; if (s == NULL) { - if ((s = (t4_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t4_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; - allocated = TRUE; + allocated = true; } memset(s, 0, sizeof(*s)); #if defined(SPANDSP_SUPPORT_TIFF_FX) @@ -1590,7 +2623,7 @@ SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int if (open_tiff_input_file(s, file) < 0) { if (allocated) - free(s); + span_free(s); return NULL; } s->tiff.file = strdup(file); @@ -1601,7 +2634,7 @@ SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int { tiff_tx_release(s); if (allocated) - free(s); + span_free(s); return NULL; } } @@ -1615,12 +2648,12 @@ SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s) tiff_tx_release(s); if (s->header_text) { - free(s->header_text); + span_free(s->header_text); s->header_text = NULL; } if (s->colour_map) { - free(s->colour_map); + span_free(s->colour_map); s->colour_map = NULL; } switch (s->metadata.compression) @@ -1634,7 +2667,7 @@ SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s) return t85_encode_release(&s->encoder.t85); #if defined(SPANDSP_SUPPORT_T88) case T4_COMPRESSION_T88: - break; + return t88_encode_release(&s->encoder.t88); #endif case T4_COMPRESSION_T42_T81: case T4_COMPRESSION_SYCC_T81: @@ -1645,7 +2678,7 @@ SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s) #endif #if defined(SPANDSP_SUPPORT_T45) case T4_COMPRESSION_T45: - break; + return t45_encode_release(&s->encoder.t45); #endif } return -1; @@ -1657,7 +2690,7 @@ SPAN_DECLARE(int) t4_tx_free(t4_tx_state_t *s) int ret; ret = t4_tx_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t81_t82_arith_coding.c b/libs/spandsp/src/t81_t82_arith_coding.c index 86e7e0271f..f9c1408c66 100644 --- a/libs/spandsp/src/t81_t82_arith_coding.c +++ b/libs/spandsp/src/t81_t82_arith_coding.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/t81_t82_arith_coding.h" #include "spandsp/private/t81_t82_arith_coding.h" @@ -45,9 +51,6 @@ compression schemes, such as T.81. However, this code has not been checked to see if it follows the letter of any spec other than T.82. */ -#define FALSE 0 -#define TRUE (!FALSE) - /* Code bytes which must trigger stuffing */ enum { @@ -341,14 +344,14 @@ SPAN_DECLARE(t81_t82_arith_encode_state_t *) t81_t82_arith_encode_init(t81_t82_a { if (s == NULL) { - if ((s = (t81_t82_arith_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t81_t82_arith_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); s->output_byte_handler = output_byte_handler; s->user_data = user_data; - t81_t82_arith_encode_restart(s, FALSE); + t81_t82_arith_encode_restart(s, false); return s; } /*- End of function --------------------------------------------------------*/ @@ -364,7 +367,7 @@ SPAN_DECLARE(int) t81_t82_arith_encode_free(t81_t82_arith_encode_state_t *s) int ret; ret = t81_t82_arith_encode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ @@ -399,7 +402,7 @@ SPAN_DECLARE(int) t81_t82_arith_decode(t81_t82_arith_decode_state_t *s, int cx) if (s->nopadding) { /* Subsequent symbols might depend on zero padding */ - s->nopadding = FALSE; + s->nopadding = false; return -2; } } @@ -415,7 +418,7 @@ SPAN_DECLARE(int) t81_t82_arith_decode(t81_t82_arith_decode_state_t *s, int cx) if (s->ct >= 0) s->ct--; if (s->a == 0x10000) - s->startup = FALSE; + s->startup = false; } /* T.82 figure 32 - DECODE */ @@ -471,8 +474,8 @@ SPAN_DECLARE(int) t81_t82_arith_decode_restart(t81_t82_arith_decode_state_t *s, s->c = 0; s->a = 1; s->ct = 0; - s->startup = TRUE; - s->nopadding = FALSE; + s->startup = true; + s->nopadding = false; return 0; } /*- End of function --------------------------------------------------------*/ @@ -481,12 +484,12 @@ SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_a { if (s == NULL) { - if ((s = (t81_t82_arith_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t81_t82_arith_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); - t81_t82_arith_decode_restart(s, FALSE); + t81_t82_arith_decode_restart(s, false); return s; } /*- End of function --------------------------------------------------------*/ @@ -502,7 +505,7 @@ SPAN_DECLARE(int) t81_t82_arith_decode_free(t81_t82_arith_decode_state_t *s) int ret; ret = t81_t82_arith_decode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t85_decode.c b/libs/spandsp/src/t85_decode.c index 93efc06e81..8af029d3a0 100644 --- a/libs/spandsp/src/t85_decode.c +++ b/libs/spandsp/src/t85_decode.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/async.h" #include "spandsp/timezone.h" @@ -47,9 +53,6 @@ #include "spandsp/private/t81_t82_arith_coding.h" #include "spandsp/private/t85.h" -#define FALSE 0 -#define TRUE (!FALSE) - static __inline__ int32_t pack_32(uint8_t *s) { int32_t value; @@ -78,7 +81,7 @@ static size_t decode_pscd(t85_decode_state_t *s, const uint8_t data[], size_t le s->s.pscd_ptr = data; s->s.pscd_end = data + len; - for (s->interrupt = FALSE; s->i < s->l0 && s->y < s->yd && !s->interrupt; s->i++, s->y++) + for (s->interrupt = false; s->i < s->l0 && s->y < s->yd && !s->interrupt; s->i++, s->y++) { /* Point to the current image bytes */ for (i = 0; i < 3; i++) @@ -126,7 +129,7 @@ static size_t decode_pscd(t85_decode_state_t *s, const uint8_t data[], size_t le } /* This row is 'not typical' and has to be coded completely */ } - s->pseudo = FALSE; + s->pseudo = false; if (s->x == 0) { @@ -223,7 +226,7 @@ static size_t decode_pscd(t85_decode_state_t *s, const uint8_t data[], size_t le *(hp[0] - 1) <<= (s->bytes_per_row*8 - s->xd); s->interrupt = s->row_write_handler(s->row_write_user_data, &s->row_buf[s->p[0]*s->bytes_per_row], s->bytes_per_row); s->x = 0; - s->pseudo = TRUE; + s->pseudo = true; /* Shuffle the row buffers */ s->p[2] = s->p[1]; s->p[1] = s->p[0]; @@ -237,7 +240,7 @@ static size_t decode_pscd(t85_decode_state_t *s, const uint8_t data[], size_t le static int finish_sde(t85_decode_state_t *s) { /* Decode final pixels based on trailing zero bytes */ - s->s.nopadding = FALSE; + s->s.nopadding = false; if (decode_pscd(s, s->buffer, 2) != 2 && s->interrupt) return 1; @@ -247,12 +250,12 @@ static int finish_sde(t85_decode_state_t *s) s->x = 0; s->i = 0; - s->pseudo = TRUE; + s->pseudo = true; s->at_moves = 0; if (s->buffer[1] == T82_SDRST) { s->tx = 0; - s->lntp = TRUE; + s->lntp = true; s->p[0] = 0; s->p[1] = -1; s->p[2] = -1; @@ -399,7 +402,7 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si if (min_len > s->row_buf_len) { /* We need to expand the 3 row buffer */ - if ((buf = (uint8_t *) realloc(s->row_buf, min_len)) == NULL) + if ((buf = (uint8_t *) span_realloc(s->row_buf, min_len)) == NULL) return T4_DECODE_NOMEM; s->row_buf = buf; s->row_buf_len = min_len; @@ -409,7 +412,7 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si s->s.nopadding = s->options & T85_VLENGTH; if (s->comment) { - free(s->comment); + span_free(s->comment); s->comment = NULL; } s->comment_len = 0; @@ -419,10 +422,10 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si s->x = 0; s->y = 0; s->i = 0; - s->pseudo = TRUE; + s->pseudo = true; s->at_moves = 0; s->tx = 0; - s->lntp = TRUE; + s->lntp = true; s->bytes_per_row = bytes_per_row; s->p[0] = 0; s->p[1] = -1; @@ -455,7 +458,7 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si s->interrupt = s->comment_handler(s->comment_user_data, s->comment, s->comment_len); if (s->comment) { - free(s->comment); + span_free(s->comment); s->comment = NULL; } s->comment_len = 0; @@ -506,12 +509,12 @@ SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], si s->comment_len = pack_32(&s->buffer[2]); /* Only try to buffer and process the comment's contents if we have a defined callback routine to do something with it. */ - /* If this malloc fails we carry on working just fine, and don't try to + /* If this allocate fails we carry on working just fine, and don't try to process the contents of the comment. That is fairly benign, as the comments are not generally of critical importance, so let's not worry. */ if (s->comment_handler && s->comment_len > 0 && s->comment_len <= s->max_comment_len) - s->comment = malloc(s->comment_len); + s->comment = span_alloc(s->comment_len); s->comment_progress = 0; continue; case T82_ATMOVE: @@ -732,20 +735,20 @@ SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s) memset(s->at_row, 0, sizeof(s->at_row)); memset(s->at_tx, 0, sizeof(s->at_tx)); memset(s->row_h, 0, sizeof(s->row_h)); - s->pseudo = FALSE; - s->lntp = FALSE; - s->interrupt = FALSE; + s->pseudo = false; + s->lntp = false; + s->interrupt = false; s->end_of_data = 0; if (s->comment) { - free(s->comment); + span_free(s->comment); s->comment = NULL; } s->comment_len = 0; s->comment_progress = 0; s->compressed_image_size = 0; - t81_t82_arith_decode_restart(&s->s, FALSE); + t81_t82_arith_decode_restart(&s->s, false); s->s.nopadding = s->options & T85_VLENGTH; s->buf_len = 0; @@ -753,10 +756,10 @@ SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s) s->x = 0; s->y = 0; s->i = 0; - s->pseudo = TRUE; + s->pseudo = true; s->at_moves = 0; s->tx = 0; - s->lntp = TRUE; + s->lntp = true; s->p[0] = 0; s->p[1] = -1; s->p[2] = -1; @@ -780,20 +783,20 @@ SPAN_DECLARE(int) t85_decode_restart(t85_decode_state_t *s) memset(s->at_row, 0, sizeof(s->at_row)); memset(s->at_tx, 0, sizeof(s->at_tx)); memset(s->row_h, 0, sizeof(s->row_h)); - s->pseudo = FALSE; - s->lntp = FALSE; - s->interrupt = FALSE; + s->pseudo = false; + s->lntp = false; + s->interrupt = false; s->end_of_data = 0; if (s->comment) { - free(s->comment); + span_free(s->comment); s->comment = NULL; } s->comment_len = 0; s->comment_progress = 0; s->compressed_image_size = 0; - t81_t82_arith_decode_restart(&s->s, FALSE); + t81_t82_arith_decode_restart(&s->s, false); return 0; } @@ -811,7 +814,7 @@ SPAN_DECLARE(t85_decode_state_t *) t85_decode_init(t85_decode_state_t *s, { if (s == NULL) { - if ((s = (t85_decode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t85_decode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -837,12 +840,12 @@ SPAN_DECLARE(int) t85_decode_release(t85_decode_state_t *s) { if (s->row_buf) { - free(s->row_buf); + span_free(s->row_buf); s->row_buf = NULL; } if (s->comment) { - free(s->comment); + span_free(s->comment); s->comment = NULL; } return 0; @@ -854,7 +857,7 @@ SPAN_DECLARE(int) t85_decode_free(t85_decode_state_t *s) int ret; ret = t85_decode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t85_encode.c b/libs/spandsp/src/t85_encode.c index ed8e47364f..ed4d1adaff 100644 --- a/libs/spandsp/src/t85_encode.c +++ b/libs/spandsp/src/t85_encode.c @@ -33,8 +33,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/async.h" #include "spandsp/timezone.h" @@ -78,7 +84,7 @@ static void put_stuff(t85_encode_state_t *s, const uint8_t buf[], int len) /* The number of uncompressed bytes per row seems like a reasonable measure of what to expect as a poor case for a compressed row. */ bytes_per_row = (s->xd + 7) >> 3; - if ((new_buf = realloc(s->bitstream, s->bitstream_len + len + bytes_per_row)) == NULL) + if ((new_buf = span_realloc(s->bitstream, s->bitstream_len + len + bytes_per_row)) == NULL) return; s->bitstream = new_buf; s->bitstream_len += (len + bytes_per_row); @@ -278,7 +284,7 @@ static int get_next_row(t85_encode_state_t *s) return 0; /* We can't clip the image to the current length. We will have to continue up to the original length with blank (all white) rows. */ - s->fill_with_white = TRUE; + s->fill_with_white = true; memset(s->prev_row[0], 0, bytes_per_row); } } @@ -311,11 +317,11 @@ static int get_next_row(t85_encode_state_t *s) for (i = 0; i <= s->mx; i++) s->c[i] = 0; } - t81_t82_arith_encode_restart(&s->s, TRUE); + t81_t82_arith_encode_restart(&s->s, true); } /* Typical prediction */ - ltp = FALSE; + ltp = false; if ((s->options & T85_TPBON)) { /* Look for a match between the rows */ @@ -518,7 +524,7 @@ SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t ima return -1; s->xd = image_width; bytes_per_row = (s->xd + 7) >> 3; - if ((t = (uint8_t *) realloc(s->row_buf, 3*bytes_per_row)) == NULL) + if ((t = (uint8_t *) span_realloc(s->row_buf, 3*bytes_per_row)) == NULL) return -1; s->row_buf = t; memset(s->row_buf, 0, 3*bytes_per_row); @@ -658,16 +664,16 @@ SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s, uint32_t image_width s->newlen = NEWLEN_NONE; s->new_tx = -1; s->tx = 0; - s->prev_ltp = FALSE; + s->prev_ltp = false; s->bitstream_iptr = 0; s->bitstream_optr = 0; if (s->bitstream) { - free(s->bitstream); + span_free(s->bitstream); s->bitstream = NULL; } s->bitstream_len = 0; - s->fill_with_white = FALSE; + s->fill_with_white = false; s->compressed_image_size = 0; t81_t82_arith_encode_init(&s->s, output_byte, s); @@ -689,7 +695,7 @@ SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s, { if (s == NULL) { - if ((s = (t85_encode_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (t85_encode_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -722,12 +728,12 @@ SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s) { if (s->row_buf) { - free(s->row_buf); + span_free(s->row_buf); s->row_buf = NULL; } if (s->bitstream) { - free(s->bitstream); + span_free(s->bitstream); s->bitstream = NULL; s->bitstream_len = 0; } @@ -740,7 +746,7 @@ SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s) int ret; ret = t85_encode_release(s); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/time_scale.c b/libs/spandsp/src/time_scale.c index 5b2a64a66b..1096ca3e32 100644 --- a/libs/spandsp/src/time_scale.c +++ b/libs/spandsp/src/time_scale.c @@ -42,9 +42,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/time_scale.h" #include "spandsp/saturated.h" @@ -125,17 +131,17 @@ SPAN_DECLARE(int) time_scale_rate(time_scale_state_t *s, float playout_rate) SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sample_rate, float playout_rate) { - int alloced; + bool alloced; if (sample_rate > TIME_SCALE_MAX_SAMPLE_RATE) return NULL; - alloced = FALSE; + alloced = false; if (s == NULL) { - if ((s = (time_scale_state_t *) malloc(sizeof (*s))) == NULL) + if ((s = (time_scale_state_t *) span_alloc(sizeof (*s))) == NULL) return NULL; /*endif*/ - alloced = TRUE; + alloced = true; } /*endif*/ s->sample_rate = sample_rate; @@ -145,7 +151,7 @@ SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sa if (time_scale_rate(s, playout_rate)) { if (alloced) - free(s); + span_free(s); return NULL; } /*endif*/ @@ -164,7 +170,7 @@ SPAN_DECLARE(int) time_scale_release(time_scale_state_t *s) SPAN_DECLARE(int) time_scale_free(time_scale_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/timezone.c b/libs/spandsp/src/timezone.c index 79966f1d4c..cd84dc42e2 100644 --- a/libs/spandsp/src/timezone.c +++ b/libs/spandsp/src/timezone.c @@ -44,21 +44,19 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/timezone.h" #include "spandsp/private/timezone.h" -#if !defined(FALSE) -#define FALSE 0 -#endif - -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - #define SECS_PER_MIN 60 #define MINS_PER_HOUR 60 #define HOURS_PER_DAY 24 @@ -644,7 +642,7 @@ static int tzparse(const char *name, struct tz_state_s * const sp, const int las } } /* Initially we're assumed to be in standard time. */ - isdst = FALSE; + isdst = false; theiroffset = theirstdoffset; /* Now juggle transition times and types tracking offsets as you do. */ for (i = 0; i < sp->timecnt; i++) @@ -680,10 +678,10 @@ static int tzparse(const char *name, struct tz_state_s * const sp, const int las } /* Finally, fill in ttis. ttisstd and ttisgmt need not be handled. */ sp->ttis[0].gmtoff = -stdoffset; - sp->ttis[0].isdst = FALSE; + sp->ttis[0].isdst = false; sp->ttis[0].abbrind = 0; sp->ttis[1].gmtoff = -dstoffset; - sp->ttis[1].isdst = TRUE; + sp->ttis[1].isdst = true; sp->ttis[1].abbrind = stdlen + 1; sp->typecnt = 2; } @@ -741,9 +739,9 @@ static void tz_set(tz_t *tz, const char *tzstring) lclptr->ttis[0].abbrind = 0; strcpy(lclptr->chars, gmt); } - else if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) + else if (name[0] == ':' || tzparse(name, lclptr, false) != 0) { - tzparse(gmt, lclptr, TRUE); + tzparse(gmt, lclptr, true); } set_tzname(tz); } @@ -796,7 +794,7 @@ SPAN_DECLARE(tz_t *) tz_init(tz_t *tz, const char *tzstring) { if (tz == NULL) { - if ((tz = (tz_t *) malloc(sizeof(*tz))) == NULL) + if ((tz = (tz_t *) span_alloc(sizeof(*tz))) == NULL) return NULL; } memset(tz, 0, sizeof(*tz)); @@ -816,7 +814,7 @@ SPAN_DECLARE(int) tz_release(tz_t *tz) SPAN_DECLARE(int) tz_free(tz_t *tz) { if (tz) - free(tz); + span_free(tz); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/tone_detect.c b/libs/spandsp/src/tone_detect.c index 4dfea5d5bf..2865ba40d8 100644 --- a/libs/spandsp/src/tone_detect.c +++ b/libs/spandsp/src/tone_detect.c @@ -44,6 +44,7 @@ #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/complex.h" #include "spandsp/complex_vector_float.h" #include "spandsp/tone_detect.h" @@ -72,7 +73,7 @@ SPAN_DECLARE(goertzel_state_t *) goertzel_init(goertzel_state_t *s, { if (s == NULL) { - if ((s = (goertzel_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (goertzel_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } #if defined(SPANDSP_USE_FIXED_POINT) @@ -98,7 +99,7 @@ SPAN_DECLARE(int) goertzel_release(goertzel_state_t *s) SPAN_DECLARE(int) goertzel_free(goertzel_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/tone_generate.c b/libs/spandsp/src/tone_generate.c index 21285f6a96..be3f6854a4 100644 --- a/libs/spandsp/src/tone_generate.c +++ b/libs/spandsp/src/tone_generate.c @@ -44,6 +44,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/complex.h" #include "spandsp/dds.h" @@ -69,7 +70,7 @@ SPAN_DECLARE(tone_gen_descriptor_t *) tone_gen_descriptor_init(tone_gen_descript { if (s == NULL) { - if ((s = (tone_gen_descriptor_t *) malloc(sizeof(*s))) == NULL) + if ((s = (tone_gen_descriptor_t *) span_alloc(sizeof(*s))) == NULL) { return NULL; } @@ -114,7 +115,7 @@ SPAN_DECLARE(tone_gen_descriptor_t *) tone_gen_descriptor_init(tone_gen_descript SPAN_DECLARE(void) tone_gen_descriptor_free(tone_gen_descriptor_t *s) { - free(s); + span_free(s); } /*- End of function --------------------------------------------------------*/ @@ -220,7 +221,7 @@ SPAN_DECLARE(tone_gen_state_t *) tone_gen_init(tone_gen_state_t *s, tone_gen_des if (s == NULL) { - if ((s = (tone_gen_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (tone_gen_state_t *) span_alloc(sizeof(*s))) == NULL) { return NULL; } @@ -252,7 +253,7 @@ SPAN_DECLARE(int) tone_gen_release(tone_gen_state_t *s) SPAN_DECLARE(int) tone_gen_free(tone_gen_state_t *s) { if (s) - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v17rx.c b/libs/spandsp/src/v17rx.c index 256d71a14c..bfc701a597 100644 --- a/libs/spandsp/src/v17rx.c +++ b/libs/spandsp/src/v17rx.c @@ -40,9 +40,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/math_fixed.h" @@ -63,6 +69,7 @@ #include "spandsp/v17rx.h" #include "spandsp/private/logging.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/v17rx.h" #if defined(SPANDSP_USE_FIXED_POINTx) @@ -1117,7 +1124,7 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) s->signal_present = 60; equalizer_save(s); s->carrier_phase_rate_save = s->carrier_phase_rate; - s->short_train = TRUE; + s->short_train = true; s->training_stage = TRAINING_STAGE_NORMAL_OPERATION; } else @@ -1212,7 +1219,7 @@ static __inline__ int signal_detect(v17_rx_state_t *s, int16_t amp) } #if defined(IAXMODEM_STUFF) /* Carrier has dropped, but the put_bit is pending the signal_present delay. */ - s->carrier_drop_pending = TRUE; + s->carrier_drop_pending = true; #endif } } @@ -1223,7 +1230,7 @@ static __inline__ int signal_detect(v17_rx_state_t *s, int16_t amp) return 0; s->signal_present = 1; #if defined(IAXMODEM_STUFF) - s->carrier_drop_pending = FALSE; + s->carrier_drop_pending = false; #endif report_status_change(s, SIG_STATUS_CARRIER_UP); } @@ -1386,7 +1393,7 @@ SPAN_DECLARE(logging_state_t *) v17_rx_get_logging_state(v17_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_train) +SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, bool short_train) { int i; @@ -1440,7 +1447,7 @@ SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_trai #if defined(IAXMODEM_STUFF) s->high_sample = 0; s->low_samples = 0; - s->carrier_drop_pending = FALSE; + s->carrier_drop_pending = false; #endif if (short_train != 2) s->short_train = short_train; @@ -1526,7 +1533,7 @@ SPAN_DECLARE(v17_rx_state_t *) v17_rx_init(v17_rx_state_t *s, int bit_rate, put_ } if (s == NULL) { - if ((s = (v17_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v17_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1534,7 +1541,7 @@ SPAN_DECLARE(v17_rx_state_t *) v17_rx_init(v17_rx_state_t *s, int bit_rate, put_ span_log_set_protocol(&s->logging, "V.17 RX"); s->put_bit = put_bit; s->put_bit_user_data = user_data; - s->short_train = FALSE; + s->short_train = false; s->scrambler_tap = 18 - 1; v17_rx_signal_cutoff(s, -45.5f); s->carrier_phase_rate_save = DDS_PHASE_RATE(CARRIER_NOMINAL_FREQ); @@ -1551,7 +1558,7 @@ SPAN_DECLARE(int) v17_rx_release(v17_rx_state_t *s) SPAN_DECLARE(int) v17_rx_free(v17_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v17tx.c b/libs/spandsp/src/v17tx.c index fe361d7744..cbe261a6cf 100644 --- a/libs/spandsp/src/v17tx.c +++ b/libs/spandsp/src/v17tx.c @@ -39,9 +39,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/complex.h" @@ -251,7 +257,7 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s) { /* Training finished - commence normal operation. */ s->current_get_bit = s->get_bit; - s->in_training = FALSE; + s->in_training = false; } } else @@ -279,7 +285,7 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s) if (s->status_handler) s->status_handler(s->status_user_data, SIG_STATUS_END_OF_DATA); s->current_get_bit = fake_get_bit; - s->in_training = TRUE; + s->in_training = true; bit = 1; } bits |= (scramble(s, bit) << i); @@ -380,7 +386,7 @@ SPAN_DECLARE(logging_state_t *) v17_tx_get_logging_state(v17_tx_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int short_train) +SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, bool tep, bool short_train) { switch (bit_rate) { @@ -422,7 +428,7 @@ SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int s s->rrc_filter_step = 0; s->convolution = 0; s->scramble_reg = 0x2ECDD5; - s->in_training = TRUE; + s->in_training = true; s->short_train = short_train; s->training_step = (tep) ? V17_TRAINING_SEG_TEP_A : V17_TRAINING_SEG_1; s->carrier_phase = 0; @@ -433,7 +439,7 @@ SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int s } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data) +SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, bool tep, get_bit_func_t get_bit, void *user_data) { switch (bit_rate) { @@ -449,7 +455,7 @@ SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int } if (s == NULL) { - if ((s = (v17_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v17_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -460,7 +466,7 @@ SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int s->scrambler_tap = 18 - 1; s->carrier_phase_rate = dds_phase_ratef(CARRIER_NOMINAL_FREQ); v17_tx_power(s, -14.0f); - v17_tx_restart(s, bit_rate, tep, FALSE); + v17_tx_restart(s, bit_rate, tep, false); return s; } /*- End of function --------------------------------------------------------*/ @@ -473,7 +479,7 @@ SPAN_DECLARE(int) v17_tx_release(v17_tx_state_t *s) SPAN_DECLARE(int) v17_tx_free(v17_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v18.c b/libs/spandsp/src/v18.c index 16f5da5ac6..c1a0e89c4f 100644 --- a/libs/spandsp/src/v18.c +++ b/libs/spandsp/src/v18.c @@ -40,9 +40,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/queue.h" #include "spandsp/async.h" @@ -62,6 +68,7 @@ #include "spandsp/private/queue.h" #include "spandsp/private/tone_generate.h" #include "spandsp/private/async.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/dtmf.h" #include "spandsp/private/modem_connect_tones.h" @@ -78,13 +85,13 @@ Silence for 0.5s then send TXP DTMF Proceed as Annex B - 1650Hz (V21 ch 2 low) + 1650Hz (V21 ch 2 low) [1650Hz +-12Hz] Proceed as Annex F in call mode - 1300Hz (Calling tone) + 1300Hz (Calling tone) [1300Hz +-16Hz] Proceed as Annex E in call mode - 1400Hz/1800Hz (Weitbrecht) + 1400Hz/1800Hz (Weitbrecht) [1400Hz +-5% and 1800Hz +-5%] Detect rate and proceed as Annex A - 980Hz/1180Hz (V21 ch 1) + 980Hz/1180Hz (V21 ch 1) [980Hz +-12Hz, 1180Hz +-12Hz] Start timer Tr 2225Hz (Bell ANS) Proceed as Annex D call mode @@ -98,21 +105,21 @@ Monitor as caller for 980Hz or 1300Hz CI/XCI Respond with ANSam - 1300Hz + 1300Hz [1300Hz +-16Hz] Probe Timer Ta (3s) Probe - 1400Hz/1800Hz (Weitbrecht) + 1400Hz/1800Hz (Weitbrecht) [1400Hz +-5% and 1800Hz +-5%] Detect rate and proceed as Annex A DTMF Proceed as Annex B - 980Hz (V21 ch 1 low) + 980Hz (V21 ch 1 low) [980Hz +-12Hz] Start timer Te 1270Hz (Bell103 ch 2 high) Proceed as Annex D answer mode 2225Hz (Bell ANS) Proceed as Annex D call mode - 1650Hz (V21 ch 2 low) + 1650Hz (V21 ch 2 low) [1650Hz +-12Hz] Proceed as Annex F answer mode ANSam Proceed as V.8 caller Annex G @@ -131,6 +138,7 @@ struct dtmf_to_ascii_s static const struct dtmf_to_ascii_s dtmf_to_ascii[] = { + {"###0", '!'}, {"###1", 'C'}, {"###2", 'F'}, {"###3", 'I'}, @@ -140,7 +148,6 @@ static const struct dtmf_to_ascii_s dtmf_to_ascii[] = {"###7", 'U'}, {"###8", 'X'}, {"###9", ';'}, - {"###0", '!'}, {"##*1", 'A'}, {"##*2", 'D'}, {"##*3", 'G'}, @@ -373,71 +380,174 @@ static const uint8_t txp[] = "1111111111000101011100001101110000010101"; 100 ms mark. */ static const uint8_t xci[] = "01111111110111111111"; -static int cmp(const void *s, const void *t) +/* The entries here must match the order in which the related names are defined in v18.h */ +static const int automoding_sequences[][6] = { - const char *ss; - struct dtmf_to_ascii_s *tt; - - ss = (const char *) s; - tt = (struct dtmf_to_ascii_s *) t; - return strncmp(ss, tt->dtmf, strlen(tt->dtmf)); -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[]) -{ - const char *t; - const char *v; - char *u; - - t = msg; - u = dtmf; - while (*t) { - v = ascii_to_dtmf[*t & 0x7F]; - while (*v) - *u++ = *v++; - t++; - } - *u = '\0'; - - return u - dtmf; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[]) -{ - int entries; - const char *t; - char *u; - struct dtmf_to_ascii_s *ss; - - entries = sizeof(dtmf_to_ascii)/sizeof(dtmf_to_ascii[0]) - 1; - t = dtmf; - u = msg; - while (*t) + /* Dummy entry 0 */ + V18_MODE_5BIT_4545, + V18_MODE_BELL103, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF + }, { - ss = bsearch(t, dtmf_to_ascii, entries, sizeof(dtmf_to_ascii[0]), cmp); - if (ss) - { - t += strlen(ss->dtmf); - *u++ = ss->ascii; - } - else - { - /* Can't match the code. Let's assume this is a code we just don't know, and skip over it */ - while (*t == '#' || *t == '*') - t++; - if (*t) - t++; - } + /* Australia */ + V18_MODE_5BIT_50, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Ireland */ + V18_MODE_5BIT_50, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Germany */ + V18_MODE_EDT, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_5BIT_50, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Switzerland */ + V18_MODE_EDT, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_5BIT_50, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Italy */ + V18_MODE_EDT, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_5BIT_50, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Spain */ + V18_MODE_EDT, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_5BIT_50, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Austria */ + V18_MODE_EDT, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_5BIT_50, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* Netherlands */ + V18_MODE_DTMF, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_5BIT_50, + V18_MODE_EDT, + V18_MODE_BELL103 + }, + { + /* Iceland */ + V18_MODE_V21TEXTPHONE, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_EDT, + V18_MODE_V23VIDEOTEX, + V18_MODE_BELL103 + }, + { + /* Norway */ + V18_MODE_V21TEXTPHONE, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_EDT, + V18_MODE_V23VIDEOTEX, + V18_MODE_BELL103 + }, + { + /* Sweden */ + V18_MODE_V21TEXTPHONE, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_EDT, + V18_MODE_V23VIDEOTEX, + V18_MODE_BELL103 + }, + { + /* Finland */ + V18_MODE_V21TEXTPHONE, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_EDT, + V18_MODE_V23VIDEOTEX, + V18_MODE_BELL103 + }, + { + /* Denmark */ + V18_MODE_V21TEXTPHONE, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_EDT, + V18_MODE_V23VIDEOTEX, + V18_MODE_BELL103 + }, + { + /* UK */ + V18_MODE_V21TEXTPHONE, + V18_MODE_5BIT_50, + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF, + V18_MODE_BELL103 + }, + { + /* USA */ + V18_MODE_5BIT_4545, + V18_MODE_BELL103, + V18_MODE_V21TEXTPHONE, + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF + }, + { + /* France */ + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_V21TEXTPHONE, + V18_MODE_BELL103 + }, + { + /* Belgium */ + V18_MODE_V23VIDEOTEX, + V18_MODE_EDT, + V18_MODE_DTMF, + V18_MODE_5BIT_50, + V18_MODE_V21TEXTPHONE, + V18_MODE_BELL103 } - *u = '\0'; - return u - msg; -} -/*- End of function --------------------------------------------------------*/ +}; -SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch) +static uint16_t encode_baudot(v18_state_t *s, uint8_t ch) { static const uint8_t conv[128] = { @@ -449,7 +559,7 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch) 0xFF, /* ENQ */ 0xFF, /* ACK */ 0xFF, /* BEL */ - 0x00, /* BS */ + 0x40, /* BS */ 0x44, /* HT >> SPACE */ 0x42, /* LF */ 0x42, /* VT >> LF */ @@ -572,14 +682,7 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch) }; uint16_t shift; - if (ch == 0x7F) - { - /* DLE is a special character meaning "force a - change to the letter character set */ - shift = BAUDOT_LETTER_SHIFT; - return 0; - } - ch = conv[ch]; + ch = conv[ch & 0x7F]; /* Is it a non-existant code? */ if (ch == 0xFF) return 0; @@ -605,7 +708,7 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch) +static uint8_t decode_baudot(v18_state_t *s, uint8_t ch) { static const uint8_t conv[2][32] = { @@ -624,8 +727,8 @@ SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch) default: return conv[s->baudot_rx_shift][ch]; } - /* return 0 if we did not produce a character */ - return 0; + /* Return 0xFF if we did not produce a character */ + return 0xFF; } /*- End of function --------------------------------------------------------*/ @@ -644,14 +747,34 @@ static int v18_tdd_get_async_byte(void *user_data) s->next_byte = (uint8_t) 0xFF; return x; } - if ((ch = queue_read_byte(&s->queue.queue)) >= 0) - return ch; - if (s->tx_signal_on) + for (;;) { - /* The FSK should now be switched off. */ - s->tx_signal_on = FALSE; + if ((ch = queue_read_byte(&s->queue.queue)) < 0) + { + if (s->tx_signal_on) + { + /* The FSK should now be switched off. */ + s->tx_signal_on = 0; + } + async_tx_presend_bits(&s->async_tx, 42); + return SIG_STATUS_LINK_IDLE; + } + if ((x = encode_baudot(s, ch)) != 0) + break; } - return 0x1F; + s->rx_suppression = (300*SAMPLE_RATE)/1000; + if (s->tx_signal_on == 1) + { + async_tx_presend_bits(&s->async_tx, 7); + s->tx_signal_on = 2; + } + if ((x & 0x3E0)) + { + s->next_byte = (uint8_t) (x & 0x1F); + return (uint8_t) ((x >> 5) & 0x1F); + } + s->next_byte = (uint8_t) 0xFF; + return (uint8_t) (x & 0x1F); } /*- End of function --------------------------------------------------------*/ @@ -659,14 +782,16 @@ static void v18_dtmf_get(void *user_data) { v18_state_t *s; int ch; - const char *v; + int len; + const char *t; s = (v18_state_t *) user_data; if ((ch = queue_read_byte(&s->queue.queue)) >= 0) { - v = ascii_to_dtmf[ch & 0x7F]; - dtmf_tx_put(&s->dtmftx, v, strlen(v)); - s->rx_suppression = ((300 + 100*strlen(v))*SAMPLE_RATE)/1000; + t = ascii_to_dtmf[ch & 0x7F]; + len = strlen(t); + dtmf_tx_put(&s->dtmf_tx, t, len); + s->rx_suppression = ((300 + 100*len)*SAMPLE_RATE)/1000; } } /*- End of function --------------------------------------------------------*/ @@ -685,7 +810,7 @@ static int v18_edt_get_async_byte(void *user_data) if (s->tx_signal_on) { /* The FSK should now be switched off. */ - s->tx_signal_on = FALSE; + s->tx_signal_on = 0; } return 0; } @@ -725,10 +850,15 @@ static void v18_tdd_put_async_byte(void *user_data, int byte) } return; } + if (s->rx_suppression > 0) + return; span_log(&s->logging, SPAN_LOG_FLOW, "Rx byte %x\n", byte); - if ((octet = v18_decode_baudot(s, byte))) + if ((octet = decode_baudot(s, byte)) != 0xFF) + { s->rx_msg[s->rx_msg_len++] = octet; - if (s->rx_msg_len >= 256) + span_log(&s->logging, SPAN_LOG_FLOW, "Rx byte 0x%x '%c'\n", octet, octet); + } + if (s->rx_msg_len > 0) //= 256) { s->rx_msg[s->rx_msg_len] = '\0'; if (s->put_msg) @@ -738,11 +868,55 @@ static void v18_tdd_put_async_byte(void *user_data, int byte) } /*- End of function --------------------------------------------------------*/ +static int decode_dtmf_cmp(const void *s, const void *t) +{ + const char *ss; + struct dtmf_to_ascii_s *tt; + + ss = (const char *) s; + tt = (struct dtmf_to_ascii_s *) t; + return strncmp(ss, tt->dtmf, strlen(tt->dtmf)); +} +/*- End of function --------------------------------------------------------*/ + +static int decode_dtmf(v18_state_t *s, char msg[], const char dtmf[]) +{ + int entries; + int len; + const char *t; + char *u; + struct dtmf_to_ascii_s *ss; + + entries = sizeof(dtmf_to_ascii)/sizeof(dtmf_to_ascii[0]) - 1; + t = dtmf; + u = msg; + while (*t) + { + ss = bsearch(t, dtmf_to_ascii, entries, sizeof(dtmf_to_ascii[0]), decode_dtmf_cmp); + if (ss) + { + len = strlen(ss->dtmf); + t += len; + *u++ = ss->ascii; + return len; + } + /* Can't match the code. Let's assume this is a code we just don't know, and skip over it */ + while (*t == '#' || *t == '*') + t++; + if (*t) + t++; + } + *u = '\0'; + return u - msg; +} +/*- End of function --------------------------------------------------------*/ + static void v18_dtmf_put(void *user_data, const char dtmf[], int len) { v18_state_t *s; char buf[128]; int i; + int matched; s = (v18_state_t *) user_data; if (s->rx_suppression > 0) @@ -753,11 +927,17 @@ static void v18_dtmf_put(void *user_data, const char dtmf[], int len) if (dtmf[i] >= '0' && dtmf[i] <= '9') { s->rx_msg[s->rx_msg_len] = '\0'; - if (v18_decode_dtmf(s, buf, (const char *) s->rx_msg) > 0) + if ((matched = decode_dtmf(s, buf, (const char *) s->rx_msg)) > 0) + { + buf[1] = '\0'; s->put_msg(s->user_data, (const uint8_t *) buf, 1); - s->rx_msg_len = 0; + } + if (s->rx_msg_len > matched) + memcpy(&s->rx_msg[0], &s->rx_msg[matched], s->rx_msg_len - matched); + s->rx_msg_len -= matched; } } + s->in_progress = 5*SAMPLE_RATE; } /*- End of function --------------------------------------------------------*/ @@ -809,13 +989,13 @@ SPAN_DECLARE_NONSTD(int) v18_tx(v18_state_t *s, int16_t *amp, int max_len) { case V18_MODE_DTMF: if (len < max_len) - len += dtmf_tx(&s->dtmftx, amp, max_len - len); + len += dtmf_tx(&s->dtmf_tx, amp, max_len - len); break; default: if (len < max_len) { - if ((lenx = fsk_tx(&s->fsktx, amp + len, max_len - len)) <= 0) - s->tx_signal_on = FALSE; + if ((lenx = fsk_tx(&s->fsk_tx, amp + len, max_len - len)) <= 0) + s->tx_signal_on = 0; len += lenx; } break; @@ -834,18 +1014,23 @@ SPAN_DECLARE_NONSTD(int) v18_rx(v18_state_t *s, const int16_t amp[], int len) else s->rx_suppression = 0; } - switch (s->mode) + if ((s->mode & V18_MODE_DTMF)) { - case V18_MODE_DTMF: /* Apply a message timeout. */ - s->in_progress -= len; - if (s->in_progress <= 0) - s->rx_msg_len = 0; - dtmf_rx(&s->dtmfrx, amp, len); - break; - default: - fsk_rx(&s->fskrx, amp, len); - break; + if (s->in_progress) + { + s->in_progress -= len; + if (s->in_progress <= 0) + { + s->in_progress = 0; + s->rx_msg_len = 0; + } + } + dtmf_rx(&s->dtmf_rx, amp, len); + } + if ((s->mode & (V18_MODE_5BIT_4545 | V18_MODE_5BIT_476 | V18_MODE_5BIT_50))) + { + fsk_rx(&s->fsk_rx, amp, len); } return 0; } @@ -860,18 +1045,23 @@ SPAN_DECLARE_NONSTD(int) v18_rx_fillin(v18_state_t *s, int len) else s->rx_suppression = 0; } - switch (s->mode) + if ((s->mode & V18_MODE_DTMF)) { - case V18_MODE_DTMF: /* Apply a message timeout. */ - //s->in_progress -= len; - //if (s->in_progress <= 0) - // s->rx_msg_len = 0; - dtmf_rx_fillin(&s->dtmfrx, len); - break; - default: - fsk_rx_fillin(&s->fskrx, len); - break; + if (s->in_progress) + { + s->in_progress -= len; + if (s->in_progress <= 0) + { + s->in_progress = 0; + s->rx_msg_len = 0; + } + } + dtmf_rx_fillin(&s->dtmf_rx, len); + } + if ((s->mode & (V18_MODE_5BIT_4545 | V18_MODE_5BIT_476 | V18_MODE_5BIT_50))) + { + fsk_rx_fillin(&s->fsk_rx, len); } return 0; } @@ -879,9 +1069,6 @@ SPAN_DECLARE_NONSTD(int) v18_rx_fillin(v18_state_t *s, int len) SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len) { - char buf[256 + 1]; - int x; - int n; int i; /* This returns the number of characters that would not fit in the buffer. @@ -892,40 +1079,24 @@ SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len) if ((len = strlen(msg)) == 0) return 0; } - switch (s->mode) - { - case V18_MODE_5BIT_45: - case V18_MODE_5BIT_50: - for (i = 0; i < len; i++) - { - n = 0; - if ((x = v18_encode_baudot(s, msg[i]))) - { - if ((x & 0x3E0)) - buf[n++] = (uint8_t) ((x >> 5) & 0x1F); - buf[n++] = (uint8_t) (x & 0x1F); - /* TODO: Deal with out of space condition */ - if (queue_write(&s->queue.queue, (const uint8_t *) buf, n) < 0) - return i; - s->tx_signal_on = TRUE; - } - } - return len; - case V18_MODE_DTMF: - break; - } - return -1; + /* TODO: Deal with out of space condition */ + if ((i = queue_write(&s->queue.queue, (const uint8_t *) msg, len)) < 0) + return i; + s->tx_signal_on = 1; + return i; } /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(const char *) v18_mode_to_str(int mode) { - switch ((mode & 0xFF)) + switch ((mode & 0xFFF)) { case V18_MODE_NONE: return "None"; - case V18_MODE_5BIT_45: + case V18_MODE_5BIT_4545: return "Weitbrecht TDD (45.45bps)"; + case V18_MODE_5BIT_476: + return "Weitbrecht TDD (47.6bps)"; case V18_MODE_5BIT_50: return "Weitbrecht TDD (50bps)"; case V18_MODE_DTMF: @@ -952,78 +1123,95 @@ SPAN_DECLARE(logging_state_t *) v18_get_logging_state(v18_state_t *s) /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s, - int calling_party, + bool calling_party, int mode, + int nation, put_msg_func_t put_msg, void *user_data) { + if (nation < 0 || nation >= V18_AUTOMODING_END) + return NULL; + if (s == NULL) { - if ((s = (v18_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v18_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); s->calling_party = calling_party; - s->mode = mode & 0xFF; + s->mode = mode & ~V18_MODE_REPETITIVE_SHIFTS_OPTION; s->put_msg = put_msg; s->user_data = user_data; switch (s->mode) { - case V18_MODE_5BIT_45: - s->repeat_shifts = mode & 0x100; - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_WEITBRECHT], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s); + case V18_MODE_5BIT_4545: + s->repeat_shifts = mode & V18_MODE_REPETITIVE_SHIFTS_OPTION; + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_WEITBRECHT_4545], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 5, ASYNC_PARITY_NONE, 2, false, v18_tdd_get_async_byte, s); /* Schedule an explicit shift at the start of baudot transmission */ s->baudot_tx_shift = 2; /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and ride over the fraction. */ - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_WEITBRECHT], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_WEITBRECHT_4545], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); + s->baudot_rx_shift = 0; + s->next_byte = (uint8_t) 0xFF; + break; + case V18_MODE_5BIT_476: + s->repeat_shifts = mode & V18_MODE_REPETITIVE_SHIFTS_OPTION; + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_WEITBRECHT_476], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 5, ASYNC_PARITY_NONE, 2, false, v18_tdd_get_async_byte, s); + /* Schedule an explicit shift at the start of baudot transmission */ + s->baudot_tx_shift = 2; + /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and + ride over the fraction. */ + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_WEITBRECHT_476], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); s->baudot_rx_shift = 0; s->next_byte = (uint8_t) 0xFF; break; case V18_MODE_5BIT_50: - s->repeat_shifts = mode & 0x100; - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_WEITBRECHT50], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s); + s->repeat_shifts = mode & V18_MODE_REPETITIVE_SHIFTS_OPTION; + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_WEITBRECHT_50], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 5, ASYNC_PARITY_NONE, 2, false, v18_tdd_get_async_byte, s); /* Schedule an explicit shift at the start of baudot transmission */ s->baudot_tx_shift = 2; /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and ride over the fraction. */ - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_WEITBRECHT50], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_WEITBRECHT_50], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); s->baudot_rx_shift = 0; s->next_byte = (uint8_t) 0xFF; break; case V18_MODE_DTMF: - dtmf_tx_init(&s->dtmftx, v18_dtmf_get, s); - dtmf_rx_init(&s->dtmfrx, v18_dtmf_put, s); + dtmf_tx_init(&s->dtmf_tx, v18_dtmf_get, s); + dtmf_rx_init(&s->dtmf_rx, v18_dtmf_put, s); break; case V18_MODE_EDT: - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V21CH1_110], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 2, FALSE, v18_edt_get_async_byte, s); - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V21CH1_110], FSK_FRAME_MODE_7E2_FRAMES, v18_edt_put_async_byte, s); + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_V21CH1_110], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 7, ASYNC_PARITY_EVEN, 2, false, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_V21CH1_110], FSK_FRAME_MODE_7E2_FRAMES, v18_edt_put_async_byte, s); break; case V18_MODE_BELL103: - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_BELL103CH1], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_BELL103CH2], FSK_FRAME_MODE_7E1_FRAMES, v18_bell103_put_async_byte, s); + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_BELL103CH1], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 7, ASYNC_PARITY_EVEN, 1, false, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_BELL103CH2], FSK_FRAME_MODE_7E1_FRAMES, v18_bell103_put_async_byte, s); break; case V18_MODE_V23VIDEOTEX: - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V23CH1], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V23CH2], FSK_FRAME_MODE_7E1_FRAMES, v18_videotex_put_async_byte, s); + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_V23CH1], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 7, ASYNC_PARITY_EVEN, 1, false, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_V23CH2], FSK_FRAME_MODE_7E1_FRAMES, v18_videotex_put_async_byte, s); break; case V18_MODE_V21TEXTPHONE: - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V21CH1], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V21CH1], FSK_FRAME_MODE_7E1_FRAMES, v18_textphone_put_async_byte, s); + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_V21CH1], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 7, ASYNC_PARITY_EVEN, 1, false, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_V21CH1], FSK_FRAME_MODE_7E1_FRAMES, v18_textphone_put_async_byte, s); break; case V18_MODE_V18TEXTPHONE: - fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V21CH1], async_tx_get_bit, &s->asynctx); - async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); - fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V21CH1], FSK_FRAME_MODE_7E1_FRAMES, v18_textphone_put_async_byte, s); + fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_V21CH1], async_tx_get_bit, &s->async_tx); + async_tx_init(&s->async_tx, 7, ASYNC_PARITY_EVEN, 1, false, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_V21CH1], FSK_FRAME_MODE_7E1_FRAMES, v18_textphone_put_async_byte, s); break; } + s->nation = nation; queue_init(&s->queue.queue, 128, QUEUE_READ_ATOMIC | QUEUE_WRITE_ATOMIC); return s; } @@ -1037,7 +1225,7 @@ SPAN_DECLARE(int) v18_release(v18_state_t *s) SPAN_DECLARE(int) v18_free(v18_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v22bis_rx.c b/libs/spandsp/src/v22bis_rx.c index 099eb8bff0..aba3dd2980 100644 --- a/libs/spandsp/src/v22bis_rx.c +++ b/libs/spandsp/src/v22bis_rx.c @@ -48,6 +48,11 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" @@ -70,6 +75,7 @@ #include "spandsp/v22bis.h" #include "spandsp/private/logging.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/v22bis.h" #if defined(SPANDSP_USE_FIXED_POINT) @@ -711,7 +717,7 @@ static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sa if (s->rx.training_count >= ms_to_symbols(100 + 450)) { span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting 16 way decisions (caller)\n"); - s->rx.sixteen_way_decisions = TRUE; + s->rx.sixteen_way_decisions = true; s->rx.training = V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400; s->rx.pattern_repeats = 0; #if defined(SPANDSP_USE_FIXED_POINT) @@ -726,7 +732,7 @@ static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sa if (s->rx.training_count >= ms_to_symbols(450)) { span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting 16 way decisions (answerer)\n"); - s->rx.sixteen_way_decisions = TRUE; + s->rx.sixteen_way_decisions = true; s->rx.training = V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400; s->rx.pattern_repeats = 0; } @@ -839,7 +845,7 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l /* Look for power exceeding the carrier on point */ if (power < s->rx.carrier_on_power) continue; - s->rx.signal_present = TRUE; + s->rx.signal_present = true; v22bis_report_status_change(s, SIG_STATUS_CARRIER_UP); } /* Only spend effort processing this data if the modem is not parked, after @@ -952,7 +958,7 @@ int v22bis_rx_restart(v22bis_state_t *s) s->rx.scrambler_pattern_count = 0; s->rx.training = V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION; s->rx.training_count = 0; - s->rx.signal_present = FALSE; + s->rx.signal_present = false; s->rx.carrier_phase_rate = (s->calling_party) ? DDS_PHASE_RATE(2400.0f) : DDS_PHASE_RATE(1200.0f); s->rx.carrier_phase = 0; @@ -965,7 +971,7 @@ int v22bis_rx_restart(v22bis_state_t *s) #endif s->rx.constellation_state = 0; - s->rx.sixteen_way_decisions = FALSE; + s->rx.sixteen_way_decisions = false; equalizer_reset(s); diff --git a/libs/spandsp/src/v22bis_tx.c b/libs/spandsp/src/v22bis_tx.c index bb18b77b26..15d31cb9d7 100644 --- a/libs/spandsp/src/v22bis_tx.c +++ b/libs/spandsp/src/v22bis_tx.c @@ -42,9 +42,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/complex.h" @@ -60,6 +66,7 @@ #include "spandsp/v22bis.h" #include "spandsp/private/logging.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/v22bis.h" #if defined(SPANDSP_USE_FIXED_POINT) @@ -668,7 +675,7 @@ SPAN_DECLARE(int) v22bis_request_retrain(v22bis_state_t *s, int bit_rate) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v22bis_remote_loopback(v22bis_state_t *s, int enable) +SPAN_DECLARE(int) v22bis_remote_loopback(v22bis_state_t *s, bool enable) { /* TODO: */ return -1; @@ -684,7 +691,7 @@ SPAN_DECLARE(int) v22bis_get_current_bit_rate(v22bis_state_t *s) SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s, int bit_rate, int guard, - int calling_party, + bool calling_party, get_bit_func_t get_bit, void *get_bit_user_data, put_bit_func_t put_bit, @@ -700,7 +707,7 @@ SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s, } if (s == NULL) { - if ((s = (v22bis_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v22bis_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -748,7 +755,7 @@ SPAN_DECLARE(int) v22bis_release(v22bis_state_t *s) SPAN_DECLARE(int) v22bis_free(v22bis_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v27ter_rx.c b/libs/spandsp/src/v27ter_rx.c index 5dabe1c6f0..228c5e4d77 100644 --- a/libs/spandsp/src/v27ter_rx.c +++ b/libs/spandsp/src/v27ter_rx.c @@ -40,9 +40,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/math_fixed.h" @@ -62,6 +68,7 @@ #include "spandsp/v27ter_rx.h" #include "spandsp/private/logging.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/v27ter_rx.h" #if defined(SPANDSP_USE_FIXED_POINT) @@ -782,13 +789,13 @@ static __inline__ int signal_detect(v27ter_rx_state_t *s, int16_t amp) { /* Count down a short delay, to ensure we push the last few bits through the filters before stopping. */ - v27ter_rx_restart(s, s->bit_rate, FALSE); + v27ter_rx_restart(s, s->bit_rate, false); report_status_change(s, SIG_STATUS_CARRIER_DOWN); return 0; } #if defined(IAXMODEM_STUFF) /* Carrier has dropped, but the put_bit is pending the signal_present delay. */ - s->carrier_drop_pending = TRUE; + s->carrier_drop_pending = true; #endif } } @@ -799,7 +806,7 @@ static __inline__ int signal_detect(v27ter_rx_state_t *s, int16_t amp) return 0; s->signal_present = 1; #if defined(IAXMODEM_STUFF) - s->carrier_drop_pending = FALSE; + s->carrier_drop_pending = false; #endif report_status_change(s, SIG_STATUS_CARRIER_UP); } @@ -1007,7 +1014,7 @@ SPAN_DECLARE(logging_state_t *) v27ter_rx_get_logging_state(v27ter_rx_state_t *s } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_train) +SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, bool old_train) { span_log(&s->logging, SPAN_LOG_FLOW, "Restarting V.27ter\n"); if (bit_rate != 4800 && bit_rate != 2400) @@ -1031,7 +1038,7 @@ SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_ #if defined(IAXMODEM_STUFF) s->high_sample = 0; s->low_samples = 0; - s->carrier_drop_pending = FALSE; + s->carrier_drop_pending = false; #endif vec_zeroi32(s->diff_angles, 16); @@ -1087,7 +1094,7 @@ SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_r } if (s == NULL) { - if ((s = (v27ter_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v27ter_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1097,7 +1104,7 @@ SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_r s->put_bit = put_bit; s->put_bit_user_data = user_data; - v27ter_rx_restart(s, bit_rate, FALSE); + v27ter_rx_restart(s, bit_rate, false); return s; } /*- End of function --------------------------------------------------------*/ @@ -1110,7 +1117,7 @@ SPAN_DECLARE(int) v27ter_rx_release(v27ter_rx_state_t *s) SPAN_DECLARE(int) v27ter_rx_free(v27ter_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v27ter_tx.c b/libs/spandsp/src/v27ter_tx.c index f1d7ce263d..1cb724b42e 100644 --- a/libs/spandsp/src/v27ter_tx.c +++ b/libs/spandsp/src/v27ter_tx.c @@ -39,9 +39,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/complex.h" @@ -128,7 +134,7 @@ static __inline__ int get_scrambled_bit(v27ter_tx_state_t *s) if (s->status_handler) s->status_handler(s->status_user_data, SIG_STATUS_END_OF_DATA); s->current_get_bit = fake_get_bit; - s->in_training = TRUE; + s->in_training = true; bit = 1; } return scramble(s, bit); @@ -208,7 +214,7 @@ static complexf_t getbaud(v27ter_tx_state_t *s) /* Switch from the fake get_bit routine, to the user supplied real one, and we are up and running. */ s->current_get_bit = s->get_bit; - s->in_training = FALSE; + s->in_training = false; } if (s->training_step == V27TER_TRAINING_SHUTDOWN_END) { @@ -367,7 +373,7 @@ SPAN_DECLARE(logging_state_t *) v27ter_tx_get_logging_state(v27ter_tx_state_t *s } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep) +SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, bool tep) { if (bit_rate != 4800 && bit_rate != 2400) return -1; @@ -382,7 +388,7 @@ SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep) s->rrc_filter_step = 0; s->scramble_reg = 0x3C; s->scrambler_pattern_count = 0; - s->in_training = TRUE; + s->in_training = true; s->training_step = (tep) ? V27TER_TRAINING_SEG_1 : V27TER_TRAINING_SEG_2; s->carrier_phase = 0; s->baud_phase = 0; @@ -392,7 +398,7 @@ SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data) +SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_rate, bool tep, get_bit_func_t get_bit, void *user_data) { switch (bit_rate) { @@ -404,7 +410,7 @@ SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_r } if (s == NULL) { - if ((s = (v27ter_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v27ter_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -427,7 +433,7 @@ SPAN_DECLARE(int) v27ter_tx_release(v27ter_tx_state_t *s) SPAN_DECLARE(int) v27ter_tx_free(v27ter_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v29rx.c b/libs/spandsp/src/v29rx.c index 3bb476726d..8431ffbfd7 100644 --- a/libs/spandsp/src/v29rx.c +++ b/libs/spandsp/src/v29rx.c @@ -40,9 +40,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/math_fixed.h" @@ -61,6 +67,7 @@ #include "spandsp/v29rx.h" #include "spandsp/private/logging.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/v29rx.h" #if defined(SPANDSP_USE_FIXED_POINT) @@ -860,14 +867,14 @@ static __inline__ int signal_detect(v29_rx_state_t *s, int16_t amp) { /* Count down a short delay, to ensure we push the last few bits through the filters before stopping. */ - v29_rx_restart(s, s->bit_rate, FALSE); + v29_rx_restart(s, s->bit_rate, false); report_status_change(s, SIG_STATUS_CARRIER_DOWN); return 0; } #if defined(IAXMODEM_STUFF) /* Carrier has dropped, but the put_bit is pending the signal_present delay. */ - s->carrier_drop_pending = TRUE; + s->carrier_drop_pending = true; #endif } } @@ -878,7 +885,7 @@ static __inline__ int signal_detect(v29_rx_state_t *s, int16_t amp) return 0; s->signal_present = 1; #if defined(IAXMODEM_STUFF) - s->carrier_drop_pending = FALSE; + s->carrier_drop_pending = false; #endif report_status_change(s, SIG_STATUS_CARRIER_UP); } @@ -1047,7 +1054,7 @@ SPAN_DECLARE(logging_state_t *) v29_rx_get_logging_state(v29_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) +SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, bool old_train) { int i; @@ -1082,7 +1089,7 @@ SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) #if defined(IAXMODEM_STUFF) s->high_sample = 0; s->low_samples = 0; - s->carrier_drop_pending = FALSE; + s->carrier_drop_pending = false; #endif s->old_train = old_train; vec_zeroi32(s->diff_angles, 16); @@ -1148,7 +1155,7 @@ SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int bit_rate, put_ } if (s == NULL) { - if ((s = (v29_rx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v29_rx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1163,7 +1170,7 @@ SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int bit_rate, put_ /* The thresholds should be on at -26dBm0 and off at -31dBm0 */ v29_rx_signal_cutoff(s, -28.5f); - v29_rx_restart(s, bit_rate, FALSE); + v29_rx_restart(s, bit_rate, false); return s; } /*- End of function --------------------------------------------------------*/ @@ -1176,7 +1183,7 @@ SPAN_DECLARE(int) v29_rx_release(v29_rx_state_t *s) SPAN_DECLARE(int) v29_rx_free(v29_rx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v29tx.c b/libs/spandsp/src/v29tx.c index 3eac97e1bc..749047f099 100644 --- a/libs/spandsp/src/v29tx.c +++ b/libs/spandsp/src/v29tx.c @@ -39,9 +39,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/complex.h" @@ -106,7 +112,7 @@ static __inline__ int get_scrambled_bit(v29_tx_state_t *s) if (s->status_handler) s->status_handler(s->status_user_data, SIG_STATUS_END_OF_DATA); s->current_get_bit = fake_get_bit; - s->in_training = TRUE; + s->in_training = true; bit = 1; } out_bit = (bit ^ (s->scramble_reg >> (18 - 1)) ^ (s->scramble_reg >> (23 - 1))) & 1; @@ -174,7 +180,7 @@ static __inline__ complexf_t getbaud(v29_tx_state_t *s) /* Switch from the fake get_bit routine, to the user supplied real one, and we are up and running. */ s->current_get_bit = s->get_bit; - s->in_training = FALSE; + s->in_training = false; } if (s->training_step == V29_TRAINING_SHUTDOWN_END) { @@ -336,7 +342,7 @@ SPAN_DECLARE(logging_state_t *) v29_tx_get_logging_state(v29_tx_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep) +SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, bool tep) { span_log(&s->logging, SPAN_LOG_FLOW, "Restarting V.29\n"); s->bit_rate = bit_rate; @@ -365,7 +371,7 @@ SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep) s->rrc_filter_step = 0; s->scramble_reg = 0; s->training_scramble_reg = 0x2A; - s->in_training = TRUE; + s->in_training = true; s->training_step = (tep) ? V29_TRAINING_SEG_TEP : V29_TRAINING_SEG_1; s->carrier_phase = 0; s->baud_phase = 0; @@ -375,7 +381,7 @@ SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data) +SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, bool tep, get_bit_func_t get_bit, void *user_data) { switch (bit_rate) { @@ -388,7 +394,7 @@ SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, int } if (s == NULL) { - if ((s = (v29_tx_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v29_tx_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -411,7 +417,7 @@ SPAN_DECLARE(int) v29_tx_release(v29_tx_state_t *s) SPAN_DECLARE(int) v29_tx_free(v29_tx_state_t *s) { - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v42.c b/libs/spandsp/src/v42.c index 29255eea07..c52a9676a2 100644 --- a/libs/spandsp/src/v42.c +++ b/libs/spandsp/src/v42.c @@ -38,9 +38,15 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -51,9 +57,6 @@ #include "spandsp/private/hdlc.h" #include "spandsp/private/v42.h" -#define FALSE 0 -#define TRUE (!FALSE) - /* Detection phase timer */ #define T_400 750 /* Acknowledgement timer - 1 second between SABME's */ @@ -625,30 +628,30 @@ static int tx_information_frame(v42_state_t *ss) s = &ss->lapm; if (s->far_busy || ((s->vs - s->va) & 0x7F) >= s->tx_window_size_k) - return FALSE; + return false; if (s->info_get != s->info_put) - return TRUE; + return true; if ((info_put_next = s->info_put + 1) >= V42_INFO_FRAMES) info_put_next = 0; if (info_put_next == s->info_get || info_put_next == s->info_acked) - return FALSE; + return false; f = &s->info_buf[s->info_put]; buf = f->buf; if (s->iframe_get == NULL) - return FALSE; + return false; n = s->iframe_get(s->iframe_get_user_data, buf + 3, s->tx_n401); if (n < 0) { /* Error */ report_rx_status_change(ss, SIG_STATUS_LINK_ERROR); - return FALSE; + return false; } if (n == 0) - return FALSE; + return false; f->len = n + 3; s->info_put = info_put_next; - return TRUE; + return true; } /*- End of function --------------------------------------------------------*/ @@ -767,11 +770,11 @@ static void receive_information_frame(v42_state_t *ss, const uint8_t *frame, int if (!s->rejected) { tx_supervisory_frame(s, s->rsp_addr, LAPM_S_REJ, (frame[2] & 0x1)); - s->rejected = TRUE; + s->rejected = true; } return; } - s->rejected = FALSE; + s->rejected = false; s->iframe_put(s->iframe_put_user_data, frame + 3, len - 3); /* Increment vr */ @@ -789,20 +792,20 @@ static void rx_supervisory_cmd_frame(v42_state_t *ss, const uint8_t *frame, int switch (frame[1] & 0x0C) { case LAPM_S_RR: - s->far_busy = FALSE; + s->far_busy = false; ack_info(ss, frame[2] >> 1); /* If p = 1 may be used for status checking? */ tx_information_rr_rnr_response(ss, frame, len); break; case LAPM_S_RNR: - s->far_busy = TRUE; + s->far_busy = true; ack_info(ss, frame[2] >> 1); /* If p = 1 may be used for status checking? */ if ((frame[2] & 0x1)) tx_supervisory_frame(s, s->rsp_addr, (s->local_busy) ? LAPM_S_RNR : LAPM_S_RR, 1); break; case LAPM_S_REJ: - s->far_busy = FALSE; + s->far_busy = false; ack_info(ss, frame[2] >> 1); if (s->retry_count == 0) { @@ -831,7 +834,7 @@ static void rx_supervisory_rsp_frame(v42_state_t *ss, const uint8_t *frame, int switch (frame[1] & 0x0C) { case LAPM_S_RR: - s->far_busy = FALSE; + s->far_busy = false; ack_info(ss, frame[2] >> 1); if (s->retry_count && (frame[2] & 0x1)) { @@ -840,7 +843,7 @@ static void rx_supervisory_rsp_frame(v42_state_t *ss, const uint8_t *frame, int } break; case LAPM_S_RNR: - s->far_busy = TRUE; + s->far_busy = true; ack_info(ss, frame[2] >> 1); if (s->retry_count && (frame[2] & 0x1)) { @@ -851,7 +854,7 @@ static void rx_supervisory_rsp_frame(v42_state_t *ss, const uint8_t *frame, int t401_start(ss); break; case LAPM_S_REJ: - s->far_busy = FALSE; + s->far_busy = false; ack_info(ss, frame[2] >> 1); if (s->retry_count == 0 || (frame[2] & 0x1)) { @@ -997,7 +1000,7 @@ static int rx_unnumbered_rsp_frame(v42_state_t *ss, const uint8_t *frame, int le if (s->configuring) { receive_xid(ss, frame, len); - s->configuring = FALSE; + s->configuring = false; t401_stop(ss); switch (s->state) { @@ -1005,7 +1008,7 @@ static int rx_unnumbered_rsp_frame(v42_state_t *ss, const uint8_t *frame, int le lapm_connect(ss); break; case LAPM_DATA: - s->local_busy = FALSE; + s->local_busy = false; tx_supervisory_frame(s, s->cmd_addr, LAPM_S_RR, 0); break; } @@ -1140,10 +1143,10 @@ static int lapm_config(v42_state_t *ss) lapm_state_t *s; s = &ss->lapm; - s->configuring = TRUE; + s->configuring = true; if (s->state == LAPM_DATA) { - s->local_busy = TRUE; + s->local_busy = true; tx_supervisory_frame(s, s->cmd_addr, LAPM_S_RNR, 1); } transmit_xid(ss, s->cmd_addr); @@ -1158,8 +1161,8 @@ static void reset_lapm(v42_state_t *ss) s = &ss->lapm; /* Reset the LAP.M state */ - s->local_busy = FALSE; - s->far_busy = FALSE; + s->local_busy = false; + s->far_busy = false; s->vs = 0; s->va = 0; s->vr = 0; @@ -1320,7 +1323,7 @@ static void negotiation_rx_bit(v42_state_t *s, int new_bit) } else { - s->neg.odp_seen = TRUE; + s->neg.odp_seen = true; } /*endif*/ break; @@ -1471,8 +1474,8 @@ SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, modem_status_func_t s SPAN_DECLARE(void) v42_restart(v42_state_t *s) { - hdlc_tx_init(&s->lapm.hdlc_tx, FALSE, 1, TRUE, lapm_hdlc_underflow, s); - hdlc_rx_init(&s->lapm.hdlc_rx, FALSE, FALSE, 1, lapm_receive, s); + hdlc_tx_init(&s->lapm.hdlc_tx, false, 1, true, lapm_hdlc_underflow, s); + hdlc_rx_init(&s->lapm.hdlc_rx, false, false, 1, lapm_receive, s); if (s->detect) { @@ -1484,7 +1487,7 @@ SPAN_DECLARE(void) v42_restart(v42_state_t *s) s->neg.rxoks = 0; s->neg.txadps = 0; s->neg.rx_negotiation_step = 0; - s->neg.odp_seen = FALSE; + s->neg.odp_seen = false; t400_start(s); s->lapm.state = LAPM_DETECT; } @@ -1499,8 +1502,8 @@ SPAN_DECLARE(void) v42_restart(v42_state_t *s) /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *ss, - int calling_party, - int detect, + bool calling_party, + bool detect, get_msg_func_t iframe_get, put_msg_func_t iframe_put, void *user_data) @@ -1509,7 +1512,7 @@ SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *ss, if (ss == NULL) { - if ((ss = (v42_state_t *) malloc(sizeof(*ss))) == NULL) + if ((ss = (v42_state_t *) span_alloc(sizeof(*ss))) == NULL) return NULL; } memset(ss, 0, sizeof(*ss)); @@ -1523,8 +1526,8 @@ SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *ss, s->iframe_put_user_data = user_data; s->state = (ss->detect) ? LAPM_DETECT : LAPM_IDLE; - s->local_busy = FALSE; - s->far_busy = FALSE; + s->local_busy = false; + s->far_busy = false; /* The address octet is: Data link connection identifier (0) @@ -1564,7 +1567,7 @@ SPAN_DECLARE(int) v42_release(v42_state_t *s) SPAN_DECLARE(int) v42_free(v42_state_t *s) { v42_release(s); - free(s); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v42bis.c b/libs/spandsp/src/v42bis.c index fec129a6f2..3ca07fc493 100644 --- a/libs/spandsp/src/v42bis.c +++ b/libs/spandsp/src/v42bis.c @@ -37,8 +37,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" @@ -170,8 +176,8 @@ static void dictionary_init(v42bis_comp_state_t *s) s->flushed_length = 0; s->string_length = 0; s->escape_code = 0; - s->transparent = TRUE; - s->escaped = FALSE; + s->transparent = true; + s->escaped = false; s->compression_performance = COMPRESSIBILITY_MONITOR; } /*- End of function --------------------------------------------------------*/ @@ -329,7 +335,7 @@ static void go_compressed(v42bis_state_t *ss) push_octet(s, s->escape_code); push_octet(s, V42BIS_ECM); s->bit_buffer = 0; - s->transparent = FALSE; + s->transparent = false; } /*- End of function --------------------------------------------------------*/ @@ -352,7 +358,7 @@ static void go_transparent(v42bis_state_t *ss) s->last_added = 0; push_compressed_code(s, V42BIS_ETM); push_octet_alignment(s); - s->transparent = TRUE; + s->transparent = true; } /*- End of function --------------------------------------------------------*/ @@ -534,14 +540,14 @@ SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *ss, const uint8_t buf[], int if (s->escaped) { /* Command */ - s->escaped = FALSE; + s->escaped = false; switch (in) { case V42BIS_ECM: /* Enter compressed mode */ span_log(&ss->logging, SPAN_LOG_FLOW, "Hit V42BIS_ECM\n"); send_string(s); - s->transparent = FALSE; + s->transparent = false; s->update_at = s->last_matched; s->last_matched = 0; i++; @@ -567,12 +573,12 @@ SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *ss, const uint8_t buf[], int } else if (in == s->escape_code) { - s->escaped = TRUE; + s->escaped = true; i++; continue; } - yyy = TRUE; + yyy = true; for (j = 0; j < 2 && yyy; j++) { if (s->update_at) @@ -605,7 +611,7 @@ SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *ss, const uint8_t buf[], int s->last_matched = 0; } i++; - yyy = FALSE; + yyy = false; } } } @@ -632,7 +638,7 @@ SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *ss, const uint8_t buf[], int /* Enter transparent mode */ span_log(&ss->logging, SPAN_LOG_FLOW, "Hit V42BIS_ETM\n"); s->bit_count = 0; - s->transparent = TRUE; + s->transparent = true; s->last_matched = 0; s->last_added = 0; break; @@ -729,7 +735,7 @@ SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s, return NULL; if (s == NULL) { - if ((s = (v42bis_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v42bis_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -760,6 +766,7 @@ SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s) { comp_exit(&s->compress); comp_exit(&s->decompress); + span_free(s); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v8.c b/libs/spandsp/src/v8.c index 3cf63ceacb..464d90b0fe 100644 --- a/libs/spandsp/src/v8.c +++ b/libs/spandsp/src/v8.c @@ -39,9 +39,15 @@ #if defined(HAVE_MATH_H) #include #endif +#if defined(HAVE_STDBOOL_H) +#include +#else +#include "spandsp/stdbool.h" +#endif #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/alloc.h" #include "spandsp/logging.h" #include "spandsp/queue.h" #include "spandsp/async.h" @@ -57,6 +63,7 @@ #include "spandsp/v8.h" #include "spandsp/private/logging.h" +#include "spandsp/private/power_meter.h" #include "spandsp/private/fsk.h" #include "spandsp/private/modem_connect_tones.h" #include "spandsp/private/v8.h" @@ -426,7 +433,7 @@ static void cm_jm_decode(v8_state_t *s) return; } /* We have a matching pair of CMs or JMs, so we are happy this is correct. */ - s->got_cm_jm = TRUE; + s->got_cm_jm = true; span_log(&s->logging, SPAN_LOG_FLOW, "Decoding\n"); @@ -576,7 +583,7 @@ static void put_bit(void *user_data, int bit) if (data == 0) { if (++s->zero_byte_count == 3) - s->got_cj = TRUE; + s->got_cj = true; } else { @@ -602,8 +609,8 @@ static void v8_decode_init(v8_state_t *s) s->preamble_type = V8_SYNC_UNKNOWN; s->bit_stream = 0; s->cm_jm_len = 0; - s->got_cm_jm = FALSE; - s->got_cj = FALSE; + s->got_cm_jm = false; + s->got_cj = false; s->zero_byte_count = 0; s->rx_data_ptr = 0; } @@ -750,7 +757,7 @@ SPAN_DECLARE_NONSTD(int) v8_tx(v8_state_t *s, int16_t *amp, int max_len) if (len < max_len) { span_log(&s->logging, SPAN_LOG_FLOW, "FSK ends\n"); - s->fsk_tx_on = FALSE; + s->fsk_tx_on = false; } } return len; @@ -831,7 +838,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) fsk_tx_restart(&s->v21tx, &preset_fsk_specs[FSK_V21CH1]); send_ci(s); s->state = V8_CI_ON; - s->fsk_tx_on = TRUE; + s->fsk_tx_on = true; break; case V8_CI_ON: residual_samples = modem_connect_tones_rx(&s->ansam_rx, amp, len); @@ -872,7 +879,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) fsk_tx_restart(&s->v21tx, &preset_fsk_specs[FSK_V21CH1]); send_ci(s); s->state = V8_CI_ON; - s->fsk_tx_on = TRUE; + s->fsk_tx_on = true; } } break; @@ -893,7 +900,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) send_v92(s); send_cm_jm(s); s->state = V8_CM_ON; - s->fsk_tx_on = TRUE; + s->fsk_tx_on = true; } break; case V8_CM_ON: @@ -907,7 +914,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) for (i = 0; i < 3; i++) v8_put_byte(s, 0); s->state = V8_CJ_ON; - s->fsk_tx_on = TRUE; + s->fsk_tx_on = true; break; } if ((s->negotiation_timer -= len) <= 0) @@ -960,7 +967,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) s->state = V8_JM_ON; send_cm_jm(s); s->modem_connect_tone_tx_on = ms_to_samples(75); - s->fsk_tx_on = TRUE; + s->fsk_tx_on = true; break; } if ((s->negotiation_timer -= len) <= 0) @@ -1023,7 +1030,7 @@ SPAN_DECLARE(logging_state_t *) v8_get_logging_state(v8_state_t *s) } /*- 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, bool calling_party, v8_parms_t *parms) { memcpy(&s->parms, parms, sizeof(s->parms)); memset(&s->result, 0, sizeof(s->result)); @@ -1071,14 +1078,14 @@ SPAN_DECLARE(int) v8_restart(v8_state_t *s, int calling_party, v8_parms_t *parms /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s, - int calling_party, + bool calling_party, v8_parms_t *parms, v8_result_handler_t result_handler, void *user_data) { if (s == NULL) { - if ((s = (v8_state_t *) malloc(sizeof(*s))) == NULL) + if ((s = (v8_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); @@ -1103,7 +1110,7 @@ SPAN_DECLARE(int) v8_free(v8_state_t *s) int ret; ret = queue_free(s->tx_queue); - free(s); + span_free(s); return ret; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c index c862a2ba80..be425bb765 100644 --- a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c +++ b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c @@ -63,7 +63,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 1002, COMPRESSION_CCITT_T4, 0 }, @@ -72,7 +72,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 1002, COMPRESSION_CCITT_T4, 1 }, @@ -81,7 +81,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 237, COMPRESSION_CCITT_T4, 2 }, @@ -90,7 +90,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 237, COMPRESSION_CCITT_T4, 3 }, @@ -99,7 +99,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 400, COMPRESSION_CCITT_T4, 4 }, @@ -108,7 +108,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 1079, COMPRESSION_CCITT_T4, 5 }, @@ -117,7 +117,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 1728, COMPRESSION_CCITT_T4, 6 }, @@ -153,7 +153,7 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100, + 1079, COMPRESSION_CCITT_T4, 5 }, @@ -178,12 +178,6 @@ struct int photo_metric = PHOTOMETRIC_MINISWHITE; int fill_order = FILLORDER_LSB2MSB; -static void clear_row(uint8_t buf[], int width) -{ - memset(buf, 0, width/8 + 1); -} -/*- End of function --------------------------------------------------------*/ - static void set_pixel(uint8_t buf[], int row, int pixel) { row--; @@ -191,13 +185,6 @@ static void set_pixel(uint8_t buf[], int row, int pixel) } /*- End of function --------------------------------------------------------*/ -static void clear_pixel(uint8_t buf[], int row, int pixel) -{ - row--; - buf[row*1728/8 + pixel/8] &= ~(0x80 >> (pixel & 0x07)); -} -/*- End of function --------------------------------------------------------*/ - static void set_pixel_range(uint8_t buf[], int row, int start, int end) { int i; @@ -207,6 +194,13 @@ static void set_pixel_range(uint8_t buf[], int row, int start, int end) } /*- End of function --------------------------------------------------------*/ +static void clear_pixel(uint8_t buf[], int row, int pixel) +{ + row--; + buf[row*1728/8 + pixel/8] &= ~(0x80 >> (pixel & 0x07)); +} +/*- End of function --------------------------------------------------------*/ + static void clear_pixel_range(uint8_t buf[], int row, int start, int end) { int i; @@ -216,6 +210,12 @@ static void clear_pixel_range(uint8_t buf[], int row, int start, int end) } /*- End of function --------------------------------------------------------*/ +static void clear_row(uint8_t buf[], int width) +{ + memset(buf, 0, width/8 + 1); +} +/*- End of function --------------------------------------------------------*/ + static int create_white_page(TIFF *tiff_file) { uint8_t image_buffer[8192]; @@ -593,7 +593,6 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, photo_metric); TIFFSetField(tiff_file, TIFFTAG_FILLORDER, fill_order); @@ -625,6 +624,7 @@ int main(int argc, char *argv[]) image_length = sequence[i].length; TIFFSetField(tiff_file, TIFFTAG_PAGENUMBER, 0, 1); TIFFSetField(tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); + TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, 128); TIFFSetField(tiff_file, TIFFTAG_IMAGELENGTH, image_length); TIFFCheckpointDirectory(tiff_file); @@ -665,7 +665,11 @@ int main(int argc, char *argv[]) break; } /* ....then the directory entry, and libtiff is happy. */ - TIFFSetField(tiff_file, TIFFTAG_IMAGELENGTH, image_length); + if (image_length != sequence[i].length) + { + printf("Length mismatch - %d: %d vs %d\n", i, image_length, sequence[i].length); + exit(2); + } TIFFWriteDirectory(tiff_file); } diff --git a/libs/spandsp/test-data/itu/fax/generate_dithered_tif.c b/libs/spandsp/test-data/itu/fax/generate_dithered_tif.c index 550d4e1e21..857ccbee72 100644 --- a/libs/spandsp/test-data/itu/fax/generate_dithered_tif.c +++ b/libs/spandsp/test-data/itu/fax/generate_dithered_tif.c @@ -63,7 +63,6 @@ int main(int argc, char *argv[]) { int image_width; int row; - int resunit; int output_compression; int output_t4_options; uint8_t image_buffer[1024]; @@ -99,7 +98,6 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); @@ -108,16 +106,15 @@ int main(int argc, char *argv[]) y_resolution = y_res/100.0f; TIFFSetField(tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*2.54f + 0.5f)); TIFFSetField(tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*2.54f + 0.5f)); - resunit = RESUNIT_INCH; - TIFFSetField(tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit); + TIFFSetField(tiff_file, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "spandsp"); if (gethostname(buf, sizeof(buf)) == 0) TIFFSetField(tiff_file, TIFFTAG_HOSTCOMPUTER, buf); + TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "Spandsp"); TIFFSetField(tiff_file, TIFFTAG_IMAGEDESCRIPTION, "Checkerboard or dithered ones"); TIFFSetField(tiff_file, TIFFTAG_MAKE, "soft-switch.org"); - TIFFSetField(tiff_file, TIFFTAG_MODEL, "test data"); + TIFFSetField(tiff_file, TIFFTAG_MODEL, "testy"); time(&now); tm = localtime(&now); @@ -131,6 +128,7 @@ int main(int argc, char *argv[]) tm->tm_sec); TIFFSetField(tiff_file, TIFFTAG_DATETIME, buf); + TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, image_length); TIFFSetField(tiff_file, TIFFTAG_IMAGELENGTH, image_length); TIFFSetField(tiff_file, TIFFTAG_PAGENUMBER, 0, 1); TIFFSetField(tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); diff --git a/libs/spandsp/test-data/itu/fax/generate_sized_pages.c b/libs/spandsp/test-data/itu/fax/generate_sized_pages.c index 66932c6e82..dcede55457 100644 --- a/libs/spandsp/test-data/itu/fax/generate_sized_pages.c +++ b/libs/spandsp/test-data/itu/fax/generate_sized_pages.c @@ -2,7 +2,7 @@ * SpanDSP - a series of DSP components for telephony * * generate_sized_pages.c - Create a series of TIFF files in the various page sizes - * and resolutions. + * and resolutions. * * Written by Steve Underwood * @@ -55,6 +55,7 @@ struct int y_res; int width; int length; + int squashing_factor; } sequence[] = { { @@ -62,304 +63,531 @@ struct T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, - 1100 + 1100, + 1 }, { "bilevel_R8_385_B4.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_B4, - 1200 + 1200, + 1 }, { "bilevel_R8_385_A3.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A3, - 1556 + 1556, + 1 }, { "bilevel_R8_77_A4.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_FINE, T4_WIDTH_R8_A4, - 1100*2 + 1100*2, + 1 }, { "bilevel_R8_77_B4.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_FINE, T4_WIDTH_R8_B4, - 1200*2 + 1200*2, + 1 }, { "bilevel_R8_77_A3.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_FINE, T4_WIDTH_R8_A3, - 1556*2 + 1556*2, + 1 }, { "bilevel_R8_154_A4.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_SUPERFINE, T4_WIDTH_R8_A4, - 1100*4 + 1100*4, + 1 }, { "bilevel_R8_154_B4.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_SUPERFINE, T4_WIDTH_R8_B4, - 1200*4 + 1200*4, + 1 }, { "bilevel_R8_154_A3.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_SUPERFINE, T4_WIDTH_R8_A3, - 1556*4 + 1556*4, + 1 }, { "bilevel_R16_154_A4.tif", T4_X_RESOLUTION_R16, T4_Y_RESOLUTION_SUPERFINE, T4_WIDTH_R16_A4, - 1100*4 + 1100*4, + 1 }, { "bilevel_R16_154_B4.tif", T4_X_RESOLUTION_R16, T4_Y_RESOLUTION_SUPERFINE, T4_WIDTH_R16_B4, - 1200*4 + 1200*4, + 1 }, { "bilevel_R16_154_A3.tif", T4_X_RESOLUTION_R16, T4_Y_RESOLUTION_SUPERFINE, T4_WIDTH_R16_A3, - 1556*4 + 1556*4, + 1 }, { "bilevel_200_100_A4.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_100, T4_WIDTH_200_A4, - 1100 + 1100, + 1 }, { "bilevel_200_100_B4.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_100, T4_WIDTH_200_B4, - 1200 + 1200, + 1 }, { "bilevel_200_100_A3.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_100, T4_WIDTH_200_A3, - 1556 + 1556, + 1 }, { "bilevel_200_200_A4.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_200, T4_WIDTH_200_A4, - 1100*2 + 1100*2, + 1 }, { "bilevel_200_200_B4.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_200, T4_WIDTH_200_B4, - 1200*2 + 1200*2, + 1 }, { "bilevel_200_200_A3.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_200, T4_WIDTH_200_A3, - 1556*2 + 1556*2, + 1 }, { "bilevel_200_400_A4.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_400, T4_WIDTH_200_A4, - 1100*4 + 1100*4, + 1 }, { "bilevel_200_400_B4.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_400, T4_WIDTH_200_B4, - 1200*4 + 1200*4, + 1 }, { "bilevel_200_400_A3.tif", T4_X_RESOLUTION_200, T4_Y_RESOLUTION_400, T4_WIDTH_200_A3, - 1556*4 + 1556*4, + 1 }, { "bilevel_300_300_A4.tif", T4_X_RESOLUTION_300, T4_Y_RESOLUTION_300, T4_WIDTH_300_A4, - 1100*3 + 1100*3, + 1 }, { "bilevel_300_300_B4.tif", T4_X_RESOLUTION_300, T4_Y_RESOLUTION_300, T4_WIDTH_300_B4, - 1200*3 + 1200*3, + 1 }, { "bilevel_300_300_A3.tif", T4_X_RESOLUTION_300, T4_Y_RESOLUTION_300, T4_WIDTH_300_A3, - 1556*3 + 1556*3, + 1 }, { "bilevel_300_600_A4.tif", T4_X_RESOLUTION_300, T4_Y_RESOLUTION_600, T4_WIDTH_300_A4, - 1100*6 + 1100*6, + 1 }, { "bilevel_300_600_B4.tif", T4_X_RESOLUTION_300, T4_Y_RESOLUTION_600, T4_WIDTH_300_B4, - 1200*6 + 1200*6, + 1 }, { "bilevel_300_600_A3.tif", T4_X_RESOLUTION_300, T4_Y_RESOLUTION_600, T4_WIDTH_300_A3, - 1556*6 + 1556*6, + 1 }, { "bilevel_400_400_A4.tif", T4_X_RESOLUTION_400, T4_Y_RESOLUTION_400, T4_WIDTH_400_A4, - 1100*4 + 1100*4, + 1 }, { "bilevel_400_400_B4.tif", T4_X_RESOLUTION_400, T4_Y_RESOLUTION_400, T4_WIDTH_400_B4, - 1200*4 + 1200*4, + 1 }, { "bilevel_400_400_A3.tif", T4_X_RESOLUTION_400, T4_Y_RESOLUTION_400, T4_WIDTH_400_A3, - 1556*4 + 1556*4, + 1 }, { "bilevel_400_800_A4.tif", T4_X_RESOLUTION_400, T4_Y_RESOLUTION_800, T4_WIDTH_400_A4, - 1100*8 + 1100*8, + 1 }, { "bilevel_400_800_B4.tif", T4_X_RESOLUTION_400, T4_Y_RESOLUTION_800, T4_WIDTH_400_B4, - 1200*8 + 1200*8, + 1 }, { "bilevel_400_800_A3.tif", T4_X_RESOLUTION_400, T4_Y_RESOLUTION_800, T4_WIDTH_400_A3, - 1556*8 + 1556*8, + 1 }, { "bilevel_600_600_A4.tif", T4_X_RESOLUTION_600, T4_Y_RESOLUTION_600, T4_WIDTH_600_A4, - 1100*6 + 1100*6, + 1 }, { "bilevel_600_600_B4.tif", T4_X_RESOLUTION_600, T4_Y_RESOLUTION_600, T4_WIDTH_600_B4, - 1200*6 + 1200*6, + 1 }, { "bilevel_600_600_A3.tif", T4_X_RESOLUTION_600, T4_Y_RESOLUTION_600, T4_WIDTH_600_A3, - 1556*6 + 1556*6, + 1 }, { "bilevel_600_1200_A4.tif", T4_X_RESOLUTION_600, T4_Y_RESOLUTION_1200, T4_WIDTH_600_A4, - 1100*12 + 1100*12, + 1 }, { "bilevel_600_1200_B4.tif", T4_X_RESOLUTION_600, T4_Y_RESOLUTION_1200, T4_WIDTH_600_B4, - 1200*12 + 1200*12, + 1 }, { "bilevel_600_1200_A3.tif", T4_X_RESOLUTION_600, T4_Y_RESOLUTION_1200, T4_WIDTH_600_A3, - 1556*12 + 1556*12, + 1 }, { "bilevel_1200_1200_A4.tif", T4_X_RESOLUTION_1200, T4_Y_RESOLUTION_1200, T4_WIDTH_1200_A4, - 1100*12 + 1100*12, + 1 }, { "bilevel_1200_1200_B4.tif", T4_X_RESOLUTION_1200, T4_Y_RESOLUTION_1200, T4_WIDTH_1200_B4, - 1200*12 + 1200*12, + 1 }, { "bilevel_1200_1200_A3.tif", T4_X_RESOLUTION_1200, T4_Y_RESOLUTION_1200, T4_WIDTH_1200_A3, - 1556*12 + 1556*12, + 1 + }, + { + "bilevel_R8_77SQ_A4.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A4, + 1100, + 2 + }, + { + "bilevel_R8_77SQ_B4.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_B4, + 1200, + 2 + }, + { + "bilevel_R8_77SQ_A3.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A3, + 1556, + 2 + }, + { + "bilevel_R8_154SQSQ_A4.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A4, + 1100, + 4 + }, + { + "bilevel_R8_154SQSQ_B4.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_B4, + 1200, + 4 + }, + { + "bilevel_R8_154SQSQ_A3.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A3, + 1556, + 4 + }, + { + "bilevel_R8_154SQ_A4.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_FINE, + T4_WIDTH_R8_A4, + 1100*2, + 2 + }, + { + "bilevel_R8_154SQ_B4.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_FINE, + T4_WIDTH_R8_B4, + 1200*2, + 2 + }, + { + "bilevel_R8_154SQ_A3.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_FINE, + T4_WIDTH_R8_A3, + 1556*2, + 2 + }, + { + "bilevel_200_200SQ_A4.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_100, + T4_WIDTH_200_A4, + 1100, + 2 + }, + { + "bilevel_200_200SQ_B4.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_100, + T4_WIDTH_200_B4, + 1200, + 2 + }, + { + "bilevel_200_200SQ_A3.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_100, + T4_WIDTH_200_A3, + 1556, + 2 + }, + { + "bilevel_200_400SQSQ_A4.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_100, + T4_WIDTH_200_A4, + 1100, + 4 + }, + { + "bilevel_200_400SQSQ_B4.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_100, + T4_WIDTH_200_B4, + 1200, + 4 + }, + { + "bilevel_200_400SQSQ_A3.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_100, + T4_WIDTH_200_A3, + 1556, + 4 + }, + { + "bilevel_200_400SQ_A4.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_200, + T4_WIDTH_200_A4, + 1100*2, + 2 + }, + { + "bilevel_200_400SQ_B4.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_200, + T4_WIDTH_200_B4, + 1200*2, + 2 + }, + { + "bilevel_200_400SQ_A3.tif", + T4_X_RESOLUTION_200, + T4_Y_RESOLUTION_200, + T4_WIDTH_200_A3, + 1556*2, + 2 }, { NULL, 0, 0, 0, + 0, 0 }, }; +static void set_pixel(uint8_t buf[], int row, int pixel) +{ + row--; + buf[row*1728/8 + pixel/8] |= (0x80 >> (pixel & 0x07)); +} +/*- End of function --------------------------------------------------------*/ + +static void set_pixel_range(uint8_t buf[], int row, int start, int end) +{ + int i; + + for (i = start; i <= end; i++) + set_pixel(buf, row, i); +} +/*- End of function --------------------------------------------------------*/ + +#if 0 +static void clear_pixel(uint8_t buf[], int row, int pixel) +{ + row--; + buf[row*1728/8 + pixel/8] &= ~(0x80 >> (pixel & 0x07)); +} +/*- End of function --------------------------------------------------------*/ + +static void clear_pixel_range(uint8_t buf[], int row, int start, int end) +{ + int i; + + for (i = start; i <= end; i++) + clear_pixel(buf, row, i); +} +/*- End of function --------------------------------------------------------*/ +#endif + +static void clear_row(uint8_t buf[], int width) +{ + memset(buf, 0, width/8 + 1); +} +/*- End of function --------------------------------------------------------*/ + int main(int argc, char *argv[]) { int row; @@ -371,6 +599,8 @@ int main(int argc, char *argv[]) float x_resolution; float y_resolution; int i; + int j; + int k; int opt; int compression; int photo_metric; @@ -424,7 +654,6 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); TIFFSetField(tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tiff_file, TIFFTAG_PHOTOMETRIC, photo_metric); TIFFSetField(tiff_file, TIFFTAG_FILLORDER, fill_order); @@ -435,13 +664,13 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*2.54f + 0.5f)); TIFFSetField(tiff_file, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "spandsp"); if (gethostname(buf, sizeof(buf)) == 0) TIFFSetField(tiff_file, TIFFTAG_HOSTCOMPUTER, buf); - TIFFSetField(tiff_file, TIFFTAG_IMAGEDESCRIPTION, "Blank test image"); + TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "Spandsp"); + TIFFSetField(tiff_file, TIFFTAG_IMAGEDESCRIPTION, "Diagonally striped test image"); TIFFSetField(tiff_file, TIFFTAG_MAKE, "soft-switch.org"); - TIFFSetField(tiff_file, TIFFTAG_MODEL, "test data"); + TIFFSetField(tiff_file, TIFFTAG_MODEL, "testy"); time(&now); tm = localtime(&now); @@ -455,6 +684,7 @@ int main(int argc, char *argv[]) tm->tm_sec); TIFFSetField(tiff_file, TIFFTAG_DATETIME, buf); + TIFFSetField(tiff_file, TIFFTAG_ROWSPERSTRIP, sequence[i].length); TIFFSetField(tiff_file, TIFFTAG_IMAGELENGTH, sequence[i].length); TIFFSetField(tiff_file, TIFFTAG_PAGENUMBER, 0, 1); TIFFSetField(tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); @@ -462,9 +692,18 @@ int main(int argc, char *argv[]) TIFFCheckpointDirectory(tiff_file); /* Write the image first.... */ + /* Produce a pattern of diagonal bands */ for (row = 0; row < sequence[i].length; row++) { - memset(image_buffer, 0, sequence[i].width/8 + 1); + clear_row(image_buffer, sequence[i].width); + for (j = 0; j < sequence[i].squashing_factor; j++) + { + k = row*sequence[i].squashing_factor + j; + if (((k/sequence[i].width) & 1) == 0) + set_pixel_range(image_buffer, 1, k%sequence[i].width, sequence[i].width - 1); + else + set_pixel_range(image_buffer, 1, 0, k%sequence[i].width); + } if (TIFFWriteScanline(tiff_file, image_buffer, row, 0) < 0) { printf("Write error at row %d.\n", row); diff --git a/libs/spandsp/test-data/itu/fax/generate_striped_pages.c b/libs/spandsp/test-data/itu/fax/generate_striped_pages.c index 1232ca6896..8ad5098ca4 100644 --- a/libs/spandsp/test-data/itu/fax/generate_striped_pages.c +++ b/libs/spandsp/test-data/itu/fax/generate_striped_pages.c @@ -81,11 +81,14 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_XRESOLUTION, 204.0f); TIFFSetField(tiff_file, TIFFTAG_YRESOLUTION, 196.0f); TIFFSetField(tiff_file, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "Spandsp"); - TIFFSetField(tiff_file, TIFFTAG_HOSTCOMPUTER, "host"); TIFFSetField(tiff_file, TIFFTAG_FAXSUBADDRESS, "1111"); + + if (gethostname(buf, sizeof(buf)) == 0) + TIFFSetField(tiff_file, TIFFTAG_HOSTCOMPUTER, buf); + + TIFFSetField(tiff_file, TIFFTAG_SOFTWARE, "Spandsp"); TIFFSetField(tiff_file, TIFFTAG_IMAGEDESCRIPTION, "Image in stripes"); - TIFFSetField(tiff_file, TIFFTAG_MAKE, "spandsp"); + TIFFSetField(tiff_file, TIFFTAG_MAKE, "soft-switch.org"); TIFFSetField(tiff_file, TIFFTAG_MODEL, "testy"); time(&now); diff --git a/libs/spandsp/test-data/local/lenna-colour-bilevel.tif b/libs/spandsp/test-data/local/lenna-colour-bilevel.tif new file mode 100644 index 0000000000..9d79aa868e Binary files /dev/null and b/libs/spandsp/test-data/local/lenna-colour-bilevel.tif differ diff --git a/libs/spandsp/tests/Makefile.am b/libs/spandsp/tests/Makefile.am index e35408c3b7..881a4839b5 100644 --- a/libs/spandsp/tests/Makefile.am +++ b/libs/spandsp/tests/Makefile.am @@ -46,12 +46,13 @@ EXTRA_DIST = fax_tests.sh \ MAINTAINERCLEANFILES = Makefile.in -INCLUDES = -I$(top_builddir)/src -I$(top_builddir)/spandsp-sim -DDATADIR="\"$(pkgdatadir)\"" +AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_builddir)/spandsp-sim -DDATADIR="\"$(pkgdatadir)\"" LIBDIR = -L$(top_builddir)/src noinst_PROGRAMS = ademco_contactid_tests \ adsi_tests \ + alloc_tests \ async_tests \ at_interpreter_tests \ awgn_tests \ @@ -146,6 +147,9 @@ ademco_contactid_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIB adsi_tests_SOURCES = adsi_tests.c adsi_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp +alloc_tests_SOURCES = alloc_tests.c +alloc_tests_LDADD = $(LIBDIR) -lspandsp + async_tests_SOURCES = async_tests.c async_tests_LDADD = $(LIBDIR) -lspandsp diff --git a/libs/spandsp/tests/ademco_contactid_tests.c b/libs/spandsp/tests/ademco_contactid_tests.c index a54b22c6e9..936fd557de 100644 --- a/libs/spandsp/tests/ademco_contactid_tests.c +++ b/libs/spandsp/tests/ademco_contactid_tests.c @@ -75,17 +75,17 @@ static int reports_entry = 0; static int16_t amp[1000000]; -int tx_callback_reported = FALSE; -int rx_callback_reported = FALSE; +bool tx_callback_reported = false; +bool rx_callback_reported = false; -int sending_complete = FALSE; +bool sending_complete = false; SNDFILE *outhandle; static void talkoff_tx_callback(void *user_data, int tone, int level, int duration) { printf("Ademco sender report %d\n", tone); - tx_callback_reported = TRUE; + tx_callback_reported = true; } static int mitel_cm7291_side_2_and_bellcore_tests(void) @@ -102,7 +102,7 @@ static int mitel_cm7291_side_2_and_bellcore_tests(void) span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "Ademco-tx"); - tx_callback_reported = FALSE; + tx_callback_reported = false; /* The remainder of the Mitel tape is the talk-off test */ /* Here we use the Bellcore test tapes (much tougher), in six @@ -153,7 +153,7 @@ static void rx_callback(void *user_data, const ademco_contactid_report_t *report printf("Report mismatch\n"); exit(2); } - rx_callback_reported = TRUE; + rx_callback_reported = true; } /*- End of function --------------------------------------------------------*/ @@ -174,11 +174,11 @@ static void tx_callback(void *user_data, int tone, int level, int duration) if (++reports_entry < 5) ademco_contactid_sender_put(sender, &reports[reports_entry]); else - sending_complete = TRUE; + sending_complete = true; break; case 0: /* Sending failed after retries */ - sending_complete = TRUE; + sending_complete = true; break; } } @@ -223,8 +223,8 @@ static int end_to_end_tests(void) awgn_init_dbm0(&noise_source, 1234567, -50); munge = codec_munge_init(MUNGE_CODEC_ALAW, 0); - sending_complete = FALSE; - rx_callback_reported = FALSE; + sending_complete = false; + rx_callback_reported = false; for (i = 0; i < 1000; i++) { diff --git a/libs/spandsp/tests/adsi_tests.c b/libs/spandsp/tests/adsi_tests.c index 17be38bcc4..500bbf0858 100644 --- a/libs/spandsp/tests/adsi_tests.c +++ b/libs/spandsp/tests/adsi_tests.c @@ -70,16 +70,16 @@ const char *bellcore_files[] = char *decode_test_file = NULL; int errors = 0; -int basic_testing = FALSE; +bool basic_testing = false; adsi_rx_state_t *rx_adsi; adsi_tx_state_t *tx_adsi; int current_standard = 0; int good_message_received; -int log_audio = FALSE; +bool log_audio = false; SNDFILE *outhandle = NULL; -int short_preamble = FALSE; +bool short_preamble = false; static int adsi_create_message(adsi_tx_state_t *s, uint8_t *msg) { @@ -235,7 +235,7 @@ static void put_adsi_msg(void *user_data, const uint8_t *msg, int len) uint8_t body[256]; printf("Good message received (%d bytes)\n", len); - good_message_received = TRUE; + good_message_received = true; for (i = 0; i < len; i++) { printf("%02x ", msg[i]); @@ -625,7 +625,7 @@ static void basic_tests(int standard) int push; int i; - basic_testing = TRUE; + basic_testing = true; printf("Testing %s\n", adsi_standard_to_str(standard)); tx_adsi = adsi_tx_init(NULL, standard); if (short_preamble) @@ -633,7 +633,7 @@ static void basic_tests(int standard) rx_adsi = adsi_rx_init(NULL, standard, put_adsi_msg, NULL); /* Fake an OK condition for the first message test */ - good_message_received = TRUE; + good_message_received = true; push = 0; for (i = 0; i < 100000; i++) { @@ -653,7 +653,7 @@ static void basic_tests(int standard) printf("No message received %s (%d)\n", adsi_standard_to_str(standard), i); exit(2); } - good_message_received = FALSE; + good_message_received = false; adsi_msg_len = adsi_create_message(tx_adsi, adsi_msg); adsi_msg_len = adsi_tx_put_message(tx_adsi, adsi_msg, adsi_msg_len); } @@ -678,7 +678,7 @@ static void basic_tests(int standard) } adsi_rx_free(rx_adsi); adsi_tx_free(tx_adsi); - basic_testing = FALSE; + basic_testing = false; } /*- End of function --------------------------------------------------------*/ @@ -734,28 +734,28 @@ int main(int argc, char *argv[]) int enable_basic_tests; int enable_talkoff_tests; - log_audio = FALSE; + log_audio = false; decode_test_file = NULL; test_standard = -1; - short_preamble = FALSE; - enable_basic_tests = TRUE; - enable_talkoff_tests = FALSE; + short_preamble = false; + enable_basic_tests = true; + enable_talkoff_tests = false; while ((opt = getopt(argc, argv, "bd:lps:t")) != -1) { switch (opt) { case 'b': - enable_basic_tests = TRUE; - enable_talkoff_tests = FALSE; + enable_basic_tests = true; + enable_talkoff_tests = false; break; case 'd': decode_test_file = optarg; break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'p': - short_preamble = TRUE; + short_preamble = true; break; case 's': if (strcasecmp("CLASS", optarg) == 0) @@ -774,8 +774,8 @@ int main(int argc, char *argv[]) test_standard = atoi(optarg); break; case 't': - enable_basic_tests = FALSE; - enable_talkoff_tests = TRUE; + enable_basic_tests = false; + enable_talkoff_tests = true; break; default: //usage(); diff --git a/libs/spandsp/tests/alloc_tests.c b/libs/spandsp/tests/alloc_tests.c new file mode 100644 index 0000000000..0e8177ae29 --- /dev/null +++ b/libs/spandsp/tests/alloc_tests.c @@ -0,0 +1,78 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * alloc_tests.c - memory allocation handling tests. + * + * Written by Steve Underwood + * + * Copyright (C) 2013 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 */ + +/*! \page alloc_tests_page Memory allocation tests +\section alloc_tests_page_sec_1 What does it do? +???. + +\section alloc_tests_page_sec_2 How does it work? +???. +*/ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "spandsp.h" + +int main(int argc, char *argv[]) +{ + void *a; + void *b; + void *c; + + if (span_mem_allocators(memalign, + malloc, + realloc, + free)) + { + printf("Failed\n"); + exit(2); + } + a = span_aligned_alloc(8, 42); + b = span_alloc(42); + c = span_realloc(NULL, 42); + printf("%p %p %p\n", a, b, c); + span_free(a); + span_free(b); + span_free(c); +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/async_tests.c b/libs/spandsp/tests/async_tests.c index 49010c3a73..48c96e4d36 100644 --- a/libs/spandsp/tests/async_tests.c +++ b/libs/spandsp/tests/async_tests.c @@ -128,8 +128,8 @@ int main(int argc, char *argv[]) int bit; printf("Test with async 8N1\n"); - async_tx_init(&tx_async, 8, ASYNC_PARITY_NONE, 1, FALSE, test_get_async_byte, NULL); - async_rx_init(&rx_async, 8, ASYNC_PARITY_NONE, 1, FALSE, test_put_async_byte, NULL); + async_tx_init(&tx_async, 8, ASYNC_PARITY_NONE, 1, false, test_get_async_byte, NULL); + async_rx_init(&rx_async, 8, ASYNC_PARITY_NONE, 1, false, test_put_async_byte, NULL); tx_async_chars = 0; rx_async_chars = 0; rx_async_char_mask = 0xFF; @@ -150,8 +150,8 @@ int main(int argc, char *argv[]) } printf("Test with async 7E1\n"); - async_tx_init(&tx_async, 7, ASYNC_PARITY_EVEN, 1, FALSE, test_get_async_byte, NULL); - async_rx_init(&rx_async, 7, ASYNC_PARITY_EVEN, 1, FALSE, test_put_async_byte, NULL); + async_tx_init(&tx_async, 7, ASYNC_PARITY_EVEN, 1, false, test_get_async_byte, NULL); + async_rx_init(&rx_async, 7, ASYNC_PARITY_EVEN, 1, false, test_put_async_byte, NULL); tx_async_chars = 0; rx_async_chars = 0; rx_async_char_mask = 0x7F; @@ -172,8 +172,8 @@ int main(int argc, char *argv[]) } printf("Test with async 8O1\n"); - async_tx_init(&tx_async, 8, ASYNC_PARITY_ODD, 1, FALSE, test_get_async_byte, NULL); - async_rx_init(&rx_async, 8, ASYNC_PARITY_ODD, 1, FALSE, test_put_async_byte, NULL); + async_tx_init(&tx_async, 8, ASYNC_PARITY_ODD, 1, false, test_get_async_byte, NULL); + async_rx_init(&rx_async, 8, ASYNC_PARITY_ODD, 1, false, test_put_async_byte, NULL); tx_async_chars = 0; rx_async_chars = 0; rx_async_char_mask = 0xFF; @@ -194,8 +194,8 @@ int main(int argc, char *argv[]) } printf("Test with async 8O1 and V.14\n"); - async_tx_init(&tx_async, 8, ASYNC_PARITY_ODD, 1, TRUE, test_get_async_byte, NULL); - async_rx_init(&rx_async, 8, ASYNC_PARITY_ODD, 1, TRUE, test_put_async_byte, NULL); + async_tx_init(&tx_async, 8, ASYNC_PARITY_ODD, 1, true, test_get_async_byte, NULL); + async_rx_init(&rx_async, 8, ASYNC_PARITY_ODD, 1, true, test_put_async_byte, NULL); tx_async_chars = 0; rx_async_chars = 0; rx_async_char_mask = 0xFF; @@ -216,8 +216,8 @@ int main(int argc, char *argv[]) } printf("Test with async 5N2\n"); - async_tx_init(&tx_async, 5, ASYNC_PARITY_NONE, 2, FALSE, test_get_async_byte, NULL); - async_rx_init(&rx_async, 5, ASYNC_PARITY_NONE, 2, FALSE, test_put_async_byte, NULL); + async_tx_init(&tx_async, 5, ASYNC_PARITY_NONE, 2, false, test_get_async_byte, NULL); + async_rx_init(&rx_async, 5, ASYNC_PARITY_NONE, 2, false, test_put_async_byte, NULL); tx_async_chars = 0; rx_async_chars = 0; rx_async_char_mask = 0x1F; diff --git a/libs/spandsp/tests/bell_mf_rx_tests.c b/libs/spandsp/tests/bell_mf_rx_tests.c index ed33c95d35..0c938caa01 100644 --- a/libs/spandsp/tests/bell_mf_rx_tests.c +++ b/libs/spandsp/tests/bell_mf_rx_tests.c @@ -112,7 +112,7 @@ static tone_gen_descriptor_t my_mf_digit_tones[16]; static char bell_mf_tone_codes[] = "1234567890CA*B#"; -int callback_ok; +bool callback_ok; int callback_roll; static void my_mf_gen_init(float low_fudge, @@ -139,7 +139,7 @@ static void my_mf_gen_init(float low_fudge, gap, 0, 0, - FALSE); + false); } } /*- End of function --------------------------------------------------------*/ @@ -188,10 +188,10 @@ static void digit_delivery(void *data, const char *digits, int len) if (data != (void *) 0x12345678) { - callback_ok = FALSE; + callback_ok = false; return; } - callback_ok = TRUE; + callback_ok = true; t = s + callback_roll; seg = 15 - callback_roll; for (i = 0; i < len; i += seg, seg = 15) @@ -200,7 +200,7 @@ static void digit_delivery(void *data, const char *digits, int len) seg = len - i; if (memcmp(digits + i, t, seg)) { - callback_ok = FALSE; + callback_ok = false; printf("Fail at %d %d\n", i, seg); break; } @@ -522,7 +522,7 @@ int main(int argc, char *argv[]) /* Test the callback mode for delivering detected digits */ printf("Test: Callback digit delivery mode.\n"); - callback_ok = FALSE; + callback_ok = false; callback_roll = 0; mf_state = bell_mf_rx_init(NULL, digit_delivery, (void *) 0x12345678); my_mf_gen_init(0.0, -10, 0.0, -10, 68, 68); diff --git a/libs/spandsp/tests/bert_tests.c b/libs/spandsp/tests/bert_tests.c index 6818f61889..5b6bb6151f 100644 --- a/libs/spandsp/tests/bert_tests.c +++ b/libs/spandsp/tests/bert_tests.c @@ -210,18 +210,18 @@ int main(int argc, char *argv[]) bert_put_bit(rx_bert, bit); test[tx_bert->tx.reg]++; } - failed = FALSE; + failed = false; if (test[0] != 0) { printf("XXX %d %d\n", 0, test[0]); - failed = TRUE; + failed = true; } for (i = 1; i < 0x200; i++) { if (test[i] != 2) { printf("XXX %d %d\n", i, test[i]); - failed = TRUE; + failed = true; } } bert_result(rx_bert, &bert_results); @@ -254,18 +254,18 @@ int main(int argc, char *argv[]) bert_put_bit(rx_bert, bit); test[tx_bert->tx.reg]++; } - failed = FALSE; + failed = false; if (test[0] != 0) { printf("XXX %d %d\n", 0, test[0]); - failed = TRUE; + failed = true; } for (i = 1; i < 0x800; i++) { if (test[i] != 2) { printf("XXX %d %d\n", i, test[i]); - failed = TRUE; + failed = true; } } bert_result(rx_bert, &bert_results); @@ -298,18 +298,18 @@ int main(int argc, char *argv[]) bert_put_bit(rx_bert, bit); test[tx_bert->tx.reg]++; } - failed = FALSE; + failed = false; if (test[0] != 0) { printf("XXX %d %d\n", 0, test[0]); - failed = TRUE; + failed = true; } for (i = 1; i < 0x8000; i++) { if (test[i] != 2) { printf("XXX %d %d\n", i, test[i]); - failed = TRUE; + failed = true; } } bert_result(rx_bert, &bert_results); @@ -342,11 +342,11 @@ int main(int argc, char *argv[]) bert_put_bit(rx_bert, bit); test[tx_bert->tx.reg]++; } - failed = FALSE; + failed = false; if (test[0] != 0) { printf("XXX %d %d\n", 0, test[0]); - failed = TRUE; + failed = true; } for (i = 1; i < 0x100000; i++) { @@ -383,11 +383,11 @@ int main(int argc, char *argv[]) bert_put_bit(rx_bert, bit); test[tx_bert->tx.reg]++; } - failed = FALSE; + failed = false; if (test[0] != 0) { printf("XXX %d %d\n", 0, test[0]); - failed = TRUE; + failed = true; } for (i = 1; i < 0x800000; i++) { diff --git a/libs/spandsp/tests/bitstream_tests.c b/libs/spandsp/tests/bitstream_tests.c index 2d70cd0029..3e7b441a55 100644 --- a/libs/spandsp/tests/bitstream_tests.c +++ b/libs/spandsp/tests/bitstream_tests.c @@ -45,7 +45,7 @@ uint8_t buffer[256]; -#define PATTERN 0x11111111 +#define PATTERN 0x1111111 #define SEQUENCE_LENGTH 17 uint8_t left[] = @@ -106,12 +106,12 @@ int main(int argc, char *argv[]) unsigned int x; int total_bits; - s = bitstream_init(&state, TRUE); + s = bitstream_init(&state, true); w = buffer; total_bits = 0; for (i = 0; i < SEQUENCE_LENGTH; i++) { - bitstream_put(s, &w, PATTERN*i, i + 1); + bitstream_put(s, &w, i*PATTERN, i + 1); total_bits += (i + 1); } bitstream_flush(s, &w); @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) exit(2); } - s = bitstream_init(&state, TRUE); + s = bitstream_init(&state, true); r = buffer; for (i = 0; i < SEQUENCE_LENGTH; i++) { @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) } } - s = bitstream_init(&state, FALSE); + s = bitstream_init(&state, false); w = buffer; total_bits = 0; for (i = 0; i < SEQUENCE_LENGTH; i++) @@ -167,7 +167,7 @@ int main(int argc, char *argv[]) exit(2); } - s = bitstream_init(&state, FALSE); + s = bitstream_init(&state, false); r = buffer; for (i = 0; i < SEQUENCE_LENGTH; i++) { diff --git a/libs/spandsp/tests/dtmf_rx_tests.c b/libs/spandsp/tests/dtmf_rx_tests.c index 89a456bd82..ef44e0d5b6 100644 --- a/libs/spandsp/tests/dtmf_rx_tests.c +++ b/libs/spandsp/tests/dtmf_rx_tests.c @@ -145,15 +145,15 @@ float dtmf_col[] = char dtmf_positions[] = "123A" "456B" "789C" "*0#D"; -int callback_hit; -int callback_ok; +bool callback_hit; +bool callback_ok; int callback_roll; int step; float max_forward_twist; float max_reverse_twist; -int use_dialtone_filter = FALSE; +bool use_dialtone_filter = false; char *decode_test_file = NULL; @@ -185,7 +185,7 @@ static void my_dtmf_gen_init(float low_fudge, gap, 0, 0, - FALSE); + false); } } } @@ -219,7 +219,7 @@ static void digit_delivery(void *data, const char *digits, int len) const char *s = ALL_POSSIBLE_DIGITS; const char *t; - callback_hit = TRUE; + callback_hit = true; if (data == (void *) 0x12345678) { t = s + callback_roll; @@ -230,7 +230,7 @@ static void digit_delivery(void *data, const char *digits, int len) seg = len - i; if (memcmp(digits + i, t, seg)) { - callback_ok = FALSE; + callback_ok = false; printf("Fail at %d %d\n", i, seg); break; } @@ -240,7 +240,7 @@ static void digit_delivery(void *data, const char *digits, int len) } else { - callback_ok = FALSE; + callback_ok = false; } } /*- End of function --------------------------------------------------------*/ @@ -250,10 +250,10 @@ static void digit_status(void *data, int signal, int level, int delay) const char *s = ALL_POSSIBLE_DIGITS; int len; static int last_step = 0; - static int first = TRUE; + static int first = true; //printf("Digit status %d %d %d\n", signal, level, delay); - callback_hit = TRUE; + callback_hit = true; len = step - last_step; if (data == (void *) 0x12345678) { @@ -262,12 +262,12 @@ static void digit_status(void *data, int signal, int level, int delay) if (first) { /* At the beginning the apparent duration is expected to be wrong */ - first = FALSE; + first = false; } else { printf("Failed for signal %s length %d at %d\n", (callback_roll & 1) ? "on" : "off", len, step); - callback_ok = FALSE; + callback_ok = false; } } if (callback_roll & 1) @@ -275,7 +275,7 @@ static void digit_status(void *data, int signal, int level, int delay) if (signal != 0) { printf("Failed for signal 0x%X instead of 0\n", signal); - callback_ok = FALSE; + callback_ok = false; } } else @@ -283,12 +283,12 @@ static void digit_status(void *data, int signal, int level, int delay) if (signal != s[callback_roll >> 1]) { printf("Failed for signal 0x%X instead of 0x%X\n", signal, s[callback_roll >> 1]); - callback_ok = FALSE; + callback_ok = false; } if (level < DEFAULT_DTMF_TX_LEVEL + 3 - 1 || level > DEFAULT_DTMF_TX_LEVEL + 3 + 1) { printf("Failed for level %d instead of %d\n", level, DEFAULT_DTMF_TX_LEVEL + 3); - callback_ok = FALSE; + callback_ok = false; } } if (++callback_roll >= 32) @@ -296,7 +296,7 @@ static void digit_status(void *data, int signal, int level, int delay) } else { - callback_ok = FALSE; + callback_ok = false; } last_step = step; } @@ -714,7 +714,7 @@ static void dial_tone_tolerance_tests(void) for (j = -30; j < -3; j++) { - tone_gen_descriptor_init(&dial_tone_desc, 350, j, 440, j, 1, 0, 0, 0, TRUE); + tone_gen_descriptor_init(&dial_tone_desc, 350, j, 440, j, 1, 0, 0, 0, true); tone_gen_init(&dial_tone, &dial_tone_desc); for (i = 0; i < 10; i++) { @@ -755,8 +755,8 @@ static void callback_function_tests(void) /* Test the callback mode for delivering detected digits */ printf("Test: Callback digit delivery mode.\n"); - callback_hit = FALSE; - callback_ok = TRUE; + callback_hit = false; + callback_ok = true; callback_roll = 0; dtmf_state = dtmf_rx_init(NULL, digit_delivery, (void *) 0x12345678); if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) @@ -784,8 +784,8 @@ static void callback_function_tests(void) /* Test the realtime callback mode for reporting detected digits */ printf("Test: Realtime callback digit delivery mode.\n"); - callback_hit = FALSE; - callback_ok = TRUE; + callback_hit = false; + callback_ok = true; callback_roll = 0; dtmf_rx_init(dtmf_state, NULL, NULL); dtmf_rx_set_realtime_callback(dtmf_state, digit_status, (void *) 0x12345678); @@ -867,7 +867,7 @@ int main(int argc, char *argv[]) int channel_codec; int opt; - use_dialtone_filter = FALSE; + use_dialtone_filter = false; channel_codec = MUNGE_CODEC_NONE; decode_test_file = NULL; max_forward_twist = -1.0f; @@ -886,7 +886,7 @@ int main(int argc, char *argv[]) max_forward_twist = atof(optarg); break; case 'f': - use_dialtone_filter = TRUE; + use_dialtone_filter = true; break; case 'R': max_reverse_twist = atof(optarg); diff --git a/libs/spandsp/tests/dtmf_tx_tests.c b/libs/spandsp/tests/dtmf_tx_tests.c index 176cf1783b..3f6f234ce7 100644 --- a/libs/spandsp/tests/dtmf_tx_tests.c +++ b/libs/spandsp/tests/dtmf_tx_tests.c @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) exit(2); } - add_digits = TRUE; + add_digits = true; do { len = dtmf_tx(gen, amp, 160); @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) if (dtmf_tx_put(gen, "1234567890", -1)) { printf("Digit buffer full\n"); - add_digits = FALSE; + add_digits = false; } } } diff --git a/libs/spandsp/tests/echo_tests.c b/libs/spandsp/tests/echo_tests.c index aba34d92b9..93d496e302 100644 --- a/libs/spandsp/tests/echo_tests.c +++ b/libs/spandsp/tests/echo_tests.c @@ -616,7 +616,7 @@ static void run_test(echo_can_state_t *ctx, int16_t (*tx_source)(void), int16_t static void print_test_title(const char *title) { - if (quiet == FALSE) + if (quiet == false) printf(title); } /*- End of function --------------------------------------------------------*/ @@ -1567,23 +1567,23 @@ int main(int argc, char *argv[]) int i; time_t now; int simulate; - int cng; - int hpf; - int two_channel_file; int opt; int mode; + bool cng; + bool hpf; + bool two_channel_file; /* Check which tests we should run */ if (argc < 2) fprintf(stderr, "Usage: echo tests [-g] [-m ] [-s] \n"); line_model_no = 0; supp_line_model_no = 0; - cng = FALSE; - hpf = FALSE; - use_gui = FALSE; - simulate = FALSE; + cng = false; + hpf = false; + use_gui = false; + simulate = false; munger = -1; - two_channel_file = FALSE; + two_channel_file = false; erl = -12.0f; while ((opt = getopt(argc, argv, "2ace:ghm:M:su")) != -1) @@ -1591,13 +1591,13 @@ int main(int argc, char *argv[]) switch (opt) { case '2': - two_channel_file = TRUE; + two_channel_file = true; break; case 'a': munger = G711_ALAW; break; case 'c': - cng = TRUE; + cng = true; break; case 'e': /* Allow for ERL being entered as x or -x */ @@ -1605,14 +1605,14 @@ int main(int argc, char *argv[]) break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); #endif break; case 'h': - hpf = TRUE; + hpf = true; break; case 'm': line_model_no = atoi(optarg); @@ -1621,7 +1621,7 @@ int main(int argc, char *argv[]) supp_line_model_no = atoi(optarg); break; case 's': - simulate = TRUE; + simulate = true; break; case 'u': munger = G711_ULAW; diff --git a/libs/spandsp/tests/fax_decode.c b/libs/spandsp/tests/fax_decode.c index 6bfc14d37a..9fedc23c66 100644 --- a/libs/spandsp/tests/fax_decode.c +++ b/libs/spandsp/tests/fax_decode.c @@ -83,12 +83,12 @@ static const struct { 0, 0, 0, 0} }; -int decode_test = FALSE; +bool decode_test = false; int rx_bits = 0; t30_state_t t30_dummy; t4_rx_state_t t4_rx_state; -int t4_up = FALSE; +bool t4_up = false; hdlc_rx_state_t hdlcrx; @@ -102,9 +102,9 @@ int x_resolution = T4_X_RESOLUTION_R8; int y_resolution = T4_Y_RESOLUTION_STANDARD; int image_width = 1728; int octets_per_ecm_frame = 256; -int error_correcting_mode = FALSE; +bool error_correcting_mode = false; int current_fallback = 0; -int end_of_page_detected = FALSE; +bool end_of_page_detected = false; static void decode_20digit_msg(const uint8_t *pkt, int len) { @@ -294,8 +294,8 @@ static void t4_begin(void) t4_rx_set_image_width(&t4_rx_state, image_width); t4_rx_start_page(&t4_rx_state); - t4_up = TRUE; - end_of_page_detected = FALSE; + t4_up = true; + end_of_page_detected = false; for (i = 0; i < 256; i++) ecm_len[i] = -1; @@ -326,7 +326,7 @@ static void t4_end(void) fprintf(stderr, "Image resolution = %dx%d\n", stats.x_resolution, stats.y_resolution); fprintf(stderr, "Bad rows = %d\n", stats.bad_rows); fprintf(stderr, "Longest bad row run = %d\n", stats.longest_bad_row_run); - t4_up = FALSE; + t4_up = false; } /*- End of function --------------------------------------------------------*/ @@ -381,7 +381,7 @@ static void v17_put_bit(void *user_data, int bit) t4_end(); if (!end_of_page_detected) fprintf(stderr, "End of page detected\n"); - end_of_page_detected = TRUE; + end_of_page_detected = true; } } //printf("V.17 Rx bit %d - %d\n", rx_bits++, bit); @@ -419,7 +419,7 @@ static void v29_put_bit(void *user_data, int bit) t4_end(); if (!end_of_page_detected) fprintf(stderr, "End of page detected\n"); - end_of_page_detected = TRUE; + end_of_page_detected = true; } } //printf("V.29 Rx bit %d - %d\n", rx_bits++, bit); @@ -457,7 +457,7 @@ static void v27ter_put_bit(void *user_data, int bit) t4_end(); if (!end_of_page_detected) fprintf(stderr, "End of page detected\n"); - end_of_page_detected = TRUE; + end_of_page_detected = true; } } //printf("V.27ter Rx bit %d - %d\n", rx_bits++, bit); @@ -504,7 +504,7 @@ int main(int argc, char *argv[]) span_log_init(&t30_dummy.logging, SPAN_LOG_FLOW, NULL); span_log_set_protocol(&t30_dummy.logging, "T.30"); - hdlc_rx_init(&hdlcrx, FALSE, TRUE, 5, hdlc_accept, NULL); + hdlc_rx_init(&hdlcrx, false, true, 5, hdlc_accept, NULL); fsk = fsk_rx_init(NULL, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, v21_put_bit, NULL); v17 = v17_rx_init(NULL, 14400, v17_put_bit, NULL); v29 = v29_rx_init(NULL, 9600, v29_put_bit, NULL); diff --git a/libs/spandsp/tests/fax_tester.c b/libs/spandsp/tests/fax_tester.c index d42ea3a074..77016202a5 100644 --- a/libs/spandsp/tests/fax_tester.c +++ b/libs/spandsp/tests/fax_tester.c @@ -239,23 +239,23 @@ static void non_ecm_rx_status(void *user_data, int status) switch (status) { case SIG_STATUS_TRAINING_FAILED: - s->modems.rx_trained = FALSE; + s->modems.rx_trained = false; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ - s->modems.rx_trained = TRUE; + s->modems.rx_trained = true; break; case SIG_STATUS_CARRIER_UP: - s->modems.rx_signal_present = TRUE; + s->modems.rx_signal_present = true; break; case SIG_STATUS_CARRIER_DOWN: if (s->modems.rx_trained) { if (s->real_time_frame_handler) - s->real_time_frame_handler(s, s->real_time_frame_user_data, TRUE, NULL, 0); + s->real_time_frame_handler(s, s->real_time_frame_user_data, true, NULL, 0); } - s->modems.rx_signal_present = FALSE; - s->modems.rx_trained = FALSE; + s->modems.rx_signal_present = false; + s->modems.rx_trained = false; break; } } @@ -280,18 +280,18 @@ static void hdlc_rx_status(void *user_data, int status) switch (status) { case SIG_STATUS_TRAINING_FAILED: - s->modems.rx_trained = FALSE; + s->modems.rx_trained = false; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ - s->modems.rx_trained = TRUE; + s->modems.rx_trained = true; break; case SIG_STATUS_CARRIER_UP: - s->modems.rx_signal_present = TRUE; + s->modems.rx_signal_present = true; break; case SIG_STATUS_CARRIER_DOWN: - s->modems.rx_signal_present = FALSE; - s->modems.rx_trained = FALSE; + s->modems.rx_signal_present = false; + s->modems.rx_trained = false; break; } } @@ -308,7 +308,7 @@ static void hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok) } s = (faxtester_state_t *) user_data; if (s->real_time_frame_handler) - s->real_time_frame_handler(s, s->real_time_frame_user_data, TRUE, msg, len); + s->real_time_frame_handler(s, s->real_time_frame_user_data, true, msg, len); } /*- End of function --------------------------------------------------------*/ @@ -325,7 +325,7 @@ int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len) { if (!s->modems.rx_signal_present) { - s->wait_for_silence = FALSE; + s->wait_for_silence = false; front_end_step_complete(s); } } @@ -371,7 +371,7 @@ int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len) void faxtest_set_rx_silence(faxtester_state_t *s) { - s->wait_for_silence = TRUE; + s->wait_for_silence = true; } /*- End of function --------------------------------------------------------*/ @@ -387,7 +387,7 @@ void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_tr return; s->current_rx_type = type; if (use_hdlc) - hdlc_rx_init(&t->hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, s); + hdlc_rx_init(&t->hdlc_rx, false, false, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, s); switch (type) { case T30_MODEM_CED: @@ -449,18 +449,18 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr case T30_MODEM_PAUSE: silence_gen_alter(&t->silence_gen, ms_to_samples(short_train)); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); - s->transmit = TRUE; + s->transmit = true; break; case T30_MODEM_CED: case T30_MODEM_CNG: tone = (type == T30_MODEM_CED) ? MODEM_CONNECT_TONES_FAX_CED : MODEM_CONNECT_TONES_FAX_CNG; fax_modems_start_slow_modem(t, tone); - s->transmit = TRUE; + s->transmit = true; break; case T30_MODEM_V21: fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); fsk_tx_set_modem_status_handler(&t->v21_tx, modem_tx_status, (void *) s); - s->transmit = TRUE; + s->transmit = true; break; case T30_MODEM_V27TER: fax_modems_set_get_bit(t, get_bit_func, get_bit_user_data); @@ -468,7 +468,7 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr v27ter_tx_set_modem_status_handler(&t->fast_modems.v27ter_tx, modem_tx_status, (void *) s); /* For any fast modem, set 200ms of preamble flags */ hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); - s->transmit = TRUE; + s->transmit = true; break; case T30_MODEM_V29: fax_modems_set_get_bit(t, get_bit_func, get_bit_user_data); @@ -476,7 +476,7 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr v29_tx_set_modem_status_handler(&t->fast_modems.v29_tx, modem_tx_status, (void *) s); /* For any fast modem, set 200ms of preamble flags */ hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); - s->transmit = TRUE; + s->transmit = true; break; case T30_MODEM_V17: fax_modems_set_get_bit(t, get_bit_func, get_bit_user_data); @@ -484,7 +484,7 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr v17_tx_set_modem_status_handler(&t->fast_modems.v17_tx, modem_tx_status, (void *) s); /* For any fast modem, set 200ms of preamble flags */ hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); - s->transmit = TRUE; + s->transmit = true; break; case T30_MODEM_DONE: span_log(&s->logging, SPAN_LOG_FLOW, "FAX exchange complete\n"); @@ -492,7 +492,7 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr default: silence_gen_alter(&t->silence_gen, 0); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); - s->transmit = FALSE; + s->transmit = false; break; } s->current_tx_type = type; @@ -553,17 +553,17 @@ faxtester_state_t *faxtester_init(faxtester_state_t *s, int calling_party) span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "TST"); fax_modems_init(&s->modems, - FALSE, + false, NULL, hdlc_underflow_handler, non_ecm_put_bit, t38_non_ecm_buffer_get_bit, tone_detected, s); - fax_modems_set_tep_mode(&s->modems, FALSE); - fax_modems_set_rx_active(&s->modems, TRUE); + fax_modems_set_tep_mode(&s->modems, false); + fax_modems_set_rx_active(&s->modems, true); faxtester_set_timeout(s, -1); - faxtester_set_tx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); + faxtester_set_tx_type(s, T30_MODEM_NONE, 0, false, false); return s; } diff --git a/libs/spandsp/tests/fax_tester.h b/libs/spandsp/tests/fax_tester.h index 45054ec7ec..bcfcb1d085 100644 --- a/libs/spandsp/tests/fax_tester.h +++ b/libs/spandsp/tests/fax_tester.h @@ -44,7 +44,7 @@ typedef void (*faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, \brief FAX tester real time frame handler. \param s The FAX tester context. \param user_data An opaque pointer. - \param direction TRUE for incoming, FALSE for outgoing. + \param direction True for incoming, false for outgoing. \param msg The HDLC message. \param len The length of the message. */ @@ -94,11 +94,11 @@ struct faxtester_state_s /*! \brief CED or CNG detector */ modem_connect_tones_rx_state_t connect_rx; - /*! If TRUE, transmission is in progress */ - int transmit; + /*! If true, transmission is in progress */ + bool transmit; - /*! \brief TRUE is the short training sequence should be used. */ - int short_train; + /*! \brief true if the short training sequence should be used. */ + bool short_train; /*! \brief The currently select receiver type */ int current_rx_type; @@ -157,7 +157,7 @@ void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t /*! 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. \param s The FAX tester context. - \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is + \param transmit_on_idle true if silent audio should be output when the FAX transmitter is idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default behaviour is FALSE. */ @@ -166,7 +166,7 @@ void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle); /*! Select whether talker echo protection tone will be sent for the image modems. \brief Select whether TEP will be sent for the image modems. \param s The FAX tester context. - \param use_tep TRUE if TEP should be sent. + \param use_tep true if TEP should be sent. */ void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep); @@ -185,7 +185,7 @@ void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, in /*! Initialise a FAX context. \brief Initialise a FAX context. \param s The FAX tester context. - \param calling_party TRUE if the context is for a calling party. FALSE if the + \param calling_party true if the context is for a calling party. FALSE if the context is for an answering party. \return A pointer to the FAX context, or NULL if there was a problem. */ diff --git a/libs/spandsp/tests/fax_tests.c b/libs/spandsp/tests/fax_tests.c index bea71ca2db..8e417adf9b 100644 --- a/libs/spandsp/tests/fax_tests.c +++ b/libs/spandsp/tests/fax_tests.c @@ -116,16 +116,16 @@ int t38_subst_seq[2] = {0, 0}; t30_exchanged_info_t expected_rx_info[2]; -int use_receiver_not_ready = FALSE; -int test_local_interrupt = FALSE; +bool use_receiver_not_ready = false; +bool test_local_interrupt = false; double when = 0.0; -int phase_e_reached[2] = {FALSE, FALSE}; -int completed[2] = {FALSE, FALSE}; -int succeeded[2] = {FALSE, FALSE}; +bool phase_e_reached[2] = {false, false}; +bool completed[2] = {false, false}; +bool succeeded[2] = {false, false}; -int t38_simulate_incrementing_repeats = FALSE; +bool t38_simulate_incrementing_repeats = false; static int phase_b_handler(t30_state_t *s, void *user_data, int result) { @@ -316,7 +316,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) if (i == 'A') { printf("%c: Initiating interrupt request\n", i); - t30_local_interrupt_request(s, TRUE); + t30_local_interrupt_request(s, true); } else { @@ -327,7 +327,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) case T30_PRI_EOM: case T30_PRI_EOP: printf("%c: Accepting interrupt request\n", i); - t30_local_interrupt_request(s, TRUE); + t30_local_interrupt_request(s, true); break; case T30_PIN: break; @@ -352,13 +352,13 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) fax_log_rx_parameters(s, tag); t30_get_transfer_statistics(s, &t); succeeded[i] = (result == T30_ERR_OK); - phase_e_reached[i] = TRUE; + phase_e_reached[i] = true; } /*- End of function --------------------------------------------------------*/ static void real_time_frame_handler(t30_state_t *s, void *user_data, - int direction, + bool incoming, const uint8_t *msg, int len) { @@ -367,7 +367,7 @@ static void real_time_frame_handler(t30_state_t *s, i = (intptr_t) user_data; printf("%c: Real time frame handler - %s, %s, length = %d\n", i + 'A', - (direction) ? "line->T.30" : "T.30->line", + (incoming) ? "line->T.30" : "T.30->line", t30_frametype(msg[2]), len); } @@ -379,7 +379,7 @@ static int document_handler(t30_state_t *s, void *user_data, int event) i = (intptr_t) user_data; printf("%c: Document handler - event %d\n", i + 'A', event); - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -395,7 +395,7 @@ static void set_t30_callbacks(t30_state_t *t30, int chan) static void real_time_gateway_frame_handler(t38_gateway_state_t *s, void *user_data, - int direction, + bool incoming, const uint8_t *msg, int len) { @@ -404,7 +404,7 @@ static void real_time_gateway_frame_handler(t38_gateway_state_t *s, i = (intptr_t) user_data; printf("%c: Real time gateway frame handler - %s, %s, length = %d\n", i + 'A', - (direction) ? "PSTN->T.38" : "T.38->PSTN", + (incoming) ? "PSTN->T.38" : "T.38->PSTN", t30_frametype(msg[2]), len); } @@ -490,6 +490,7 @@ int main(int argc, char *argv[]) int noise_level; int code_to_look_up; int scan_line_time; + int allowed_bilevel_resolutions; int colour_enabled; t38_stats_t t38_stats; t30_stats_t t30_stats; @@ -504,19 +505,19 @@ int main(int argc, char *argv[]) #endif #if defined(ENABLE_GUI) - use_gui = FALSE; + use_gui = false; #endif - log_audio = FALSE; - use_ecm = FALSE; + log_audio = false; + use_ecm = false; t38_version = 1; input_tiff_file_name = INPUT_TIFF_FILE_NAME; - t38_simulate_incrementing_repeats = FALSE; + t38_simulate_incrementing_repeats = false; g1050_model_no = 0; g1050_speed_pattern_no = 1; - remove_fill_bits = FALSE; - use_tep = FALSE; - feedback_audio = FALSE; - use_transmit_on_idle = TRUE; + remove_fill_bits = false; + use_tep = false; + feedback_audio = false; + use_transmit_on_idle = true; supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17; page_header_info = NULL; page_header_tz = NULL; @@ -529,17 +530,21 @@ int main(int argc, char *argv[]) scan_line_time = 0; decode_file_name = NULL; code_to_look_up = -1; - colour_enabled = FALSE; + allowed_bilevel_resolutions = 0; + colour_enabled = false; t38_transport = T38_TRANSPORT_UDPTL; - while ((opt = getopt(argc, argv, "c:Cd:D:efFgH:i:Ilm:M:n:p:s:S:tT:u:v:z:")) != -1) + while ((opt = getopt(argc, argv, "b:c:Cd:D:efFgH:i:Ilm:M:n:p:s:S:tT:u:v:z:")) != -1) { switch (opt) { + case 'b': + allowed_bilevel_resolutions = atoi(optarg); + break; case 'c': code_to_look_up = atoi(optarg); break; case 'C': - colour_enabled = TRUE; + colour_enabled = true; break; case 'd': decode_file_name = optarg; @@ -549,17 +554,17 @@ int main(int argc, char *argv[]) drop_frame = atoi(optarg); break; case 'e': - use_ecm = TRUE; + use_ecm = true; break; case 'f': - feedback_audio = TRUE; + feedback_audio = true; break; case 'F': - remove_fill_bits = TRUE; + remove_fill_bits = true; break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); @@ -572,10 +577,10 @@ int main(int argc, char *argv[]) input_tiff_file_name = optarg; break; case 'I': - t38_simulate_incrementing_repeats = TRUE; + t38_simulate_incrementing_repeats = true; break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': supported_modems = atoi(optarg); @@ -625,7 +630,7 @@ int main(int argc, char *argv[]) scan_line_time = atoi(optarg); break; case 't': - use_tep = TRUE; + use_tep = true; break; case 'T': start_page = 0; @@ -850,64 +855,98 @@ int main(int argc, char *argv[]) | T4_SUPPORT_LENGTH_US_LETTER | T4_SUPPORT_LENGTH_US_LEGAL | T4_SUPPORT_LENGTH_UNLIMITED); -#if 1 - t30_set_supported_bilevel_resolutions(t30_state[i], - T4_SUPPORT_RESOLUTION_R8_STANDARD - | T4_SUPPORT_RESOLUTION_R8_FINE - | T4_SUPPORT_RESOLUTION_R8_SUPERFINE - | T4_SUPPORT_RESOLUTION_R16_SUPERFINE - | T4_SUPPORT_RESOLUTION_200_100 - | T4_SUPPORT_RESOLUTION_200_200 - | T4_SUPPORT_RESOLUTION_200_400 - | T4_SUPPORT_RESOLUTION_300_300 - | T4_SUPPORT_RESOLUTION_300_600 - | T4_SUPPORT_RESOLUTION_400_400 - | T4_SUPPORT_RESOLUTION_400_800 - | T4_SUPPORT_RESOLUTION_600_600 - | T4_SUPPORT_RESOLUTION_600_1200 - | T4_SUPPORT_RESOLUTION_1200_1200); -#elif 0 - t30_set_supported_bilevel_resolutions(t30_state[i], - T4_SUPPORT_RESOLUTION_R8_STANDARD - | T4_SUPPORT_RESOLUTION_R8_FINE - | T4_SUPPORT_RESOLUTION_R8_SUPERFINE - | T4_SUPPORT_RESOLUTION_R16_SUPERFINE); -#else - t30_set_supported_bilevel_resolutions(t30_state[i], - T4_SUPPORT_RESOLUTION_200_100 - | T4_SUPPORT_RESOLUTION_200_200 - | T4_SUPPORT_RESOLUTION_200_400 - | T4_SUPPORT_RESOLUTION_300_300 - | T4_SUPPORT_RESOLUTION_300_600 - | T4_SUPPORT_RESOLUTION_400_400 - | T4_SUPPORT_RESOLUTION_400_800 - | T4_SUPPORT_RESOLUTION_600_600 - | T4_SUPPORT_RESOLUTION_600_1200 - | T4_SUPPORT_RESOLUTION_1200_1200); -#endif + switch (allowed_bilevel_resolutions) + { + case 0: + /* Allow anything */ + t30_set_supported_bilevel_resolutions(t30_state[i], + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200); + break; + case 1: + /* Allow anything metric */ + t30_set_supported_bilevel_resolutions(t30_state[i], + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE); + break; + case 2: + /* Allow anything inch based */ + t30_set_supported_bilevel_resolutions(t30_state[i], + T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200); + break; + case 3: + /* Allow only restricted length resolution */ + t30_set_supported_bilevel_resolutions(t30_state[i], + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200); + break; + case 4: + /* Allow only more restricted length resolution */ + t30_set_supported_bilevel_resolutions(t30_state[i], + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_200_100); + break; + } if (colour_enabled) { t30_set_supported_colour_resolutions(t30_state[i], - T4_SUPPORT_RESOLUTION_100_100 - | T4_SUPPORT_RESOLUTION_200_200 - | T4_SUPPORT_RESOLUTION_300_300 - | T4_SUPPORT_RESOLUTION_400_400 - | T4_SUPPORT_RESOLUTION_600_600 - | T4_SUPPORT_RESOLUTION_1200_1200); + T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_1200_1200); } else { t30_set_supported_colour_resolutions(t30_state[i], 0); } - t30_set_supported_output_compressions(t30_state[i], T4_SUPPORT_COMPRESSION_T4_2D); + //t30_set_supported_output_compressions(t30_state[i], T4_COMPRESSION_T85); t30_set_ecm_capability(t30_state[i], use_ecm); t30_set_supported_compressions(t30_state[i], - T4_SUPPORT_COMPRESSION_T4_1D - | T4_SUPPORT_COMPRESSION_T4_2D - | T4_SUPPORT_COMPRESSION_T6 - //| T4_SUPPORT_COMPRESSION_t42_T81 - | T4_SUPPORT_COMPRESSION_T85 - | T4_SUPPORT_COMPRESSION_T85_L0); + T4_COMPRESSION_T4_1D + | T4_COMPRESSION_T4_2D + | T4_COMPRESSION_T6 + | T4_COMPRESSION_T85 + | T4_COMPRESSION_T85_L0 + //| T4_COMPRESSION_T88 + | T4_COMPRESSION_T43 + | T4_COMPRESSION_T45 + | T4_COMPRESSION_T42_T81 + | T4_COMPRESSION_SYCC_T81 + | T4_COMPRESSION_GRAYSCALE + | T4_COMPRESSION_COLOUR + | T4_COMPRESSION_12BIT + | T4_COMPRESSION_COLOUR_TO_GRAY + | T4_COMPRESSION_GRAY_TO_BILEVEL + | T4_COMPRESSION_COLOUR_TO_BILEVEL + | T4_COMPRESSION_RESCALING + | 0); t30_set_minimum_scan_line_time(t30_state[i], scan_line_time); if (mode[i] == T38_GATEWAY_FAX) @@ -936,9 +975,9 @@ int main(int argc, char *argv[]) break; case T38_TRANSPORT_TCP: case T38_TRANSPORT_TCP_TPKT: - t38_terminal_set_fill_bit_removal(t38_state[i], TRUE); + t38_terminal_set_fill_bit_removal(t38_state[i], true); t38_terminal_set_config(t38_state[i], T38_TERMINAL_OPTION_NO_PACING | T38_TERMINAL_OPTION_NO_INDICATORS); - t38_terminal_set_tep_mode(t38_state[i], FALSE); + t38_terminal_set_tep_mode(t38_state[i], false); break; } } @@ -990,7 +1029,7 @@ int main(int argc, char *argv[]) fax_rx(fax_state[i], fax_rx_buf[i], SAMPLES_PER_CHUNK); if (!t30_call_active(t30_state[i])) { - completed[i] = TRUE; + completed[i] = true; continue; } diff --git a/libs/spandsp/tests/fax_tests.sh b/libs/spandsp/tests/fax_tests.sh index 4d4d1bc4e5..b09609e3f3 100755 --- a/libs/spandsp/tests/fax_tests.sh +++ b/libs/spandsp/tests/fax_tests.sh @@ -39,6 +39,31 @@ run_fax_test() echo tested ${FILE} } +run_fax_squash_test() +{ + # Test with lengthwise squashing of a bilevel image + rm -f fax_tests.tif + echo ./fax_tests -b ${SQ} ${OPTS} -i ${IN_FILE} + ./fax_tests -b ${SQ} ${OPTS} -i ${IN_FILE} >xyzzy 2>xyzzy2 + RETVAL=$? + if [ $RETVAL != 0 ] + then + echo fax_tests failed! + exit $RETVAL + fi + # Now use tiffcmp to check the results. It will return non-zero if any page images differ. The -t + # option means the normal differences in tags will be ignored. + tiffcmp -t ${OUT_FILE} fax_tests.tif >/dev/null + RETVAL=$? + if [ $RETVAL != 0 ] + then + echo fax_tests failed! + exit $RETVAL + fi + rm -f fax_tests.tif + echo tested ${FILE} +} + run_colour_fax_test() { rm -f fax_tests.tif @@ -70,49 +95,154 @@ LOCALTESTS_DIR=../test-data/local # Colour/gray -> bilevel by not allowing ECM for OPTS in "-p AA" "-p TT" "-p GG" "-p TG" "-p GT" do - IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif" - OUT_FILE="${LOCALTESTS_DIR}/lenna-colour-bilevel.tif" - run_colour_fax_test + echo Colour to bi-level tests disabled +# IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif" +# OUT_FILE="${LOCALTESTS_DIR}/lenna-colour-bilevel.tif" +# run_colour_fax_test - IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif" - OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif" - run_colour_fax_test +# IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif" +# OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif" +# run_colour_fax_test - IN_FILE="${TIFFFX_DIR}/c03x_02x.tif" - OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif" - run_colour_fax_test +# IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif" +# OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif" +# run_colour_fax_test - IN_FILE="${TIFFFX_DIR}/l02x_02x.tif" - OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif" - run_colour_fax_test +# IN_FILE="${TIFFFX_DIR}/c03x_02x.tif" +# OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif" +# run_colour_fax_test - IN_FILE="${TIFFFX_DIR}/l04x_02x.tif" - OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif" - run_colour_fax_test +# IN_FILE="${TIFFFX_DIR}/l02x_02x.tif" +# OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif" +# run_colour_fax_test + +# IN_FILE="${TIFFFX_DIR}/l04x_02x.tif" +# OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif" +# run_colour_fax_test done -# Colour/gray -> colour/gray by allowing ECM +# Colour/gray -> colour/gray for OPTS in "-p AA -C -e" "-p TT -C -e" "-p GG -C -e" "-p TG -C -e" "-p GT -C -e" do - IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif" - OUT_FILE="${LOCALTESTS_DIR}/lenna-colour.tif" - run_colour_fax_test + echo Colour to colour tests disabled +# IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif" +# OUT_FILE="${LOCALTESTS_DIR}/lenna-colour-out.tif" +# run_colour_fax_test - IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif" - OUT_FILE="${LOCALTESTS_DIR}/lenna-bw.tif" - run_colour_fax_test +# IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif" +# OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-out.tif" +# run_colour_fax_test - IN_FILE="${TIFFFX_DIR}/c03x_02x.tif" - OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif" - run_colour_fax_test +# IN_FILE="${TIFFFX_DIR}/c03x_02x.tif" +# OUT_FILE="${TIFFFX_DIR}/c03x_02x-out.tif" +# run_colour_fax_test - IN_FILE="${TIFFFX_DIR}/l02x_02x.tif" - OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif" - run_colour_fax_test +# IN_FILE="${TIFFFX_DIR}/l02x_02x.tif" +# OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif" +# run_colour_fax_test - IN_FILE="${TIFFFX_DIR}/l04x_02x.tif" - OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif" - run_colour_fax_test +# IN_FILE="${TIFFFX_DIR}/l04x_02x.tif" +# OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif" +# run_colour_fax_test +done + +# Bi-level tests with image squashing +for OPTS in "-p AA" "-p AA -e" "-p TT" "-p TT -e" "-p GG" "-p GG -e" "-p TG" "-p TG -e" "-p GT" "-p GT -e" +do + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_77_A4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_77SQ_A4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_77_B4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_77SQ_B4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_77_A3.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_77SQ_A3.tif" + SQ=4 + run_fax_squash_test + + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_154_A4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_154SQ_A4.tif" + SQ=3 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_154_B4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_154SQ_B4.tif" + SQ=3 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_154_A3.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_154SQ_A3.tif" + SQ=3 + run_fax_squash_test + + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_154_A4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_154SQSQ_A4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_154_B4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_154SQSQ_B4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_R8_154_A3.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_R8_154SQSQ_A3.tif" + SQ=4 + run_fax_squash_test + + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_200_A4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_200SQ_A4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_200_B4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_200SQ_B4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_200_A3.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_200SQ_A3.tif" + SQ=4 + run_fax_squash_test + + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_400_A4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_400SQ_A4.tif" + SQ=3 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_400_B4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_400SQ_B4.tif" + SQ=3 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_400_A3.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_400SQ_A3.tif" + SQ=3 + run_fax_squash_test + + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_400_A4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_400SQSQ_A4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_400_B4.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_400SQSQ_B4.tif" + SQ=4 + run_fax_squash_test + + IN_FILE="${ITUTESTS_DIR}/bilevel_200_400_A3.tif" + OUT_FILE="${ITUTESTS_DIR}/bilevel_200_400SQSQ_A3.tif" + SQ=4 + run_fax_squash_test done # Bi-level tests diff --git a/libs/spandsp/tests/fsk_tests.c b/libs/spandsp/tests/fsk_tests.c index 9cd69f5865..db8a1335a7 100644 --- a/libs/spandsp/tests/fsk_tests.c +++ b/libs/spandsp/tests/fsk_tests.c @@ -61,7 +61,7 @@ These tests allow either: char *decode_test_file = NULL; both_ways_line_model_state_t *model; int rx_bits = 0; -int cutoff_test_carrier = FALSE; +bool cutoff_test_carrier = false; static void rx_status(void *user_data, int status) { @@ -93,10 +93,10 @@ static void cutoff_test_rx_status(void *user_data, int status) switch (status) { case SIG_STATUS_CARRIER_UP: - cutoff_test_carrier = TRUE; + cutoff_test_carrier = true; break; case SIG_STATUS_CARRIER_DOWN: - cutoff_test_carrier = FALSE; + cutoff_test_carrier = false; break; } } @@ -186,23 +186,23 @@ int main(int argc, char *argv[]) int modem_under_test_1; int modem_under_test_2; int modems_set; - int log_audio; int channel_codec; int rbs_pattern; int on_at; int off_at; + int opt; + bool log_audio; tone_gen_descriptor_t tone_desc; tone_gen_state_t tone_tx; - int opt; channel_codec = MUNGE_CODEC_NONE; rbs_pattern = 0; line_model_no = 0; decode_test_file = NULL; - noise_sweep = FALSE; + noise_sweep = false; modem_under_test_1 = FSK_V21CH1; modem_under_test_2 = FSK_V21CH2; - log_audio = FALSE; + log_audio = false; modems_set = 0; while ((opt = getopt(argc, argv, "c:d:lm:nr:s:")) != -1) { @@ -215,13 +215,13 @@ int main(int argc, char *argv[]) decode_test_file = optarg; break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': line_model_no = atoi(optarg); break; case 'n': - noise_sweep = TRUE; + noise_sweep = true; break; case 'r': rbs_pattern = atoi(optarg); @@ -315,7 +315,7 @@ int main(int argc, char *argv[]) 0, 0, 0, - TRUE); + true); tone_gen_init(&tone_tx, &tone_desc); for (j = 0; j < 10; j++) { @@ -338,7 +338,7 @@ int main(int argc, char *argv[]) 0, 0, 0, - TRUE); + true); tone_gen_init(&tone_tx, &tone_desc); for (j = 0; j < 10; j++) { diff --git a/libs/spandsp/tests/g1050_tests.c b/libs/spandsp/tests/g1050_tests.c index b9d87f5dd3..a7919e9575 100644 --- a/libs/spandsp/tests/g1050_tests.c +++ b/libs/spandsp/tests/g1050_tests.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) #endif #if defined(ENABLE_GUI) - use_gui = FALSE; + use_gui = false; #endif model_no = MODEL_NO; speed_pattern_no = SPEED_PATTERN_NO; @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) { case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); diff --git a/libs/spandsp/tests/g168_tests.c b/libs/spandsp/tests/g168_tests.c index 8a1fbabbc0..41351496c6 100644 --- a/libs/spandsp/tests/g168_tests.c +++ b/libs/spandsp/tests/g168_tests.c @@ -38,9 +38,6 @@ #include "spandsp/g168models.h" #include "spandsp-sim.h" -#define FALSE 0 -#define TRUE (!FALSE) - typedef struct { const char *name; @@ -158,7 +155,7 @@ int main(int argc, char *argv[]) 0, 0, 0, - TRUE); + true); tone_gen_init(&tone_state, &tone_desc); tone_gen(&tone_state, amp, 8000); for (i = 0; i < 10; i++) diff --git a/libs/spandsp/tests/g711_tests.c b/libs/spandsp/tests/g711_tests.c index bb0956d677..c6ef2b1f78 100644 --- a/libs/spandsp/tests/g711_tests.c +++ b/libs/spandsp/tests/g711_tests.c @@ -353,10 +353,10 @@ int main(int argc, char *argv[]) int16_t outdata[BLOCK_LEN]; uint8_t g711data[BLOCK_LEN]; - basic_tests = TRUE; + basic_tests = true; law = G711_ALAW; - encode = FALSE; - decode = FALSE; + encode = false; + decode = false; in_file = NULL; out_file = NULL; while ((opt = getopt(argc, argv, "ad:e:l:u")) != -1) @@ -365,24 +365,24 @@ int main(int argc, char *argv[]) { case 'a': law = G711_ALAW; - basic_tests = FALSE; + basic_tests = false; break; case 'd': in_file = optarg; - basic_tests = FALSE; - decode = TRUE; + basic_tests = false; + decode = true; break; case 'e': in_file = optarg; - basic_tests = FALSE; - encode = TRUE; + basic_tests = false; + encode = true; break; case 'l': out_file = optarg; break; case 'u': law = G711_ULAW; - basic_tests = FALSE; + basic_tests = false; break; default: //usage(); @@ -392,14 +392,14 @@ int main(int argc, char *argv[]) if (basic_tests) { - compliance_tests(TRUE); + compliance_tests(true); } else { if (!decode && !encode) { decode = - encode = TRUE; + encode = true; } if (in_file == NULL) { diff --git a/libs/spandsp/tests/g722_tests.c b/libs/spandsp/tests/g722_tests.c index dff1b959d2..daafaef6d6 100644 --- a/libs/spandsp/tests/g722_tests.c +++ b/libs/spandsp/tests/g722_tests.c @@ -258,7 +258,7 @@ static void itu_compliance_tests(void) } len = j - i; enc_state = g722_encode_init(NULL, 64000, 0); - enc_state->itu_test_mode = TRUE; + enc_state->itu_test_mode = true; len2 = g722_encode(enc_state, compressed, itu_data + i, len); /* Check the result against the ITU's reference output data */ @@ -324,7 +324,7 @@ static void itu_compliance_tests(void) compressed[k] = itu_data[k + i] >> ((mode == 3) ? 10 : (mode == 2) ? 9 : 8); dec_state = g722_decode_init(NULL, (mode == 3) ? 48000 : (mode == 2) ? 56000 : 64000, 0); - dec_state->itu_test_mode = TRUE; + dec_state->itu_test_mode = true; len2 = g722_decode(dec_state, decompressed, compressed, len); /* Check the result against the ITU's reference output data */ @@ -358,8 +358,8 @@ static void signal_to_distortion_tests(void) g722_encode_state_t *enc_state; g722_decode_state_t *dec_state; swept_tone_state_t *swept; - power_meter_t in_meter; - power_meter_t out_meter; + power_meter_t *in_meter; + power_meter_t *out_meter; int16_t original[1024]; uint8_t compressed[1024]; int16_t decompressed[1024]; @@ -374,32 +374,32 @@ static void signal_to_distortion_tests(void) Figure 16/G.722, Figure A.1/G.722, and Figure A.2/G.722 */ enc_state = g722_encode_init(NULL, 64000, 0); dec_state = g722_decode_init(NULL, 64000, 0); - power_meter_init(&in_meter, 7); - power_meter_init(&out_meter, 7); + in_meter = power_meter_init(NULL, 7); + out_meter = power_meter_init(NULL, 7); /* First some silence */ len = 1024; memset(original, 0, len*sizeof(original[0])); for (i = 0; i < len; i++) - in_level = power_meter_update(&in_meter, original[i]); + in_level = power_meter_update(in_meter, original[i]); len2 = g722_encode(enc_state, compressed, original, len); len3 = g722_decode(dec_state, decompressed, compressed, len2); out_level = 0; for (i = 0; i < len3; i++) - out_level = power_meter_update(&out_meter, decompressed[i]); + out_level = power_meter_update(out_meter, decompressed[i]); printf("Silence produces %d at the output\n", out_level); /* Now a swept tone test */ - swept = swept_tone_init(NULL, 25.0f, 3500.0f, -10.0f, 60*16000, FALSE); + swept = swept_tone_init(NULL, 25.0f, 3500.0f, -10.0f, 60*16000, false); do { len = swept_tone(swept, original, 1024); for (i = 0; i < len; i++) - in_level = power_meter_update(&in_meter, original[i]); + in_level = power_meter_update(in_meter, original[i]); len2 = g722_encode(enc_state, compressed, original, len); len3 = g722_decode(dec_state, decompressed, compressed, len2); for (i = 0; i < len3; i++) - out_level = power_meter_update(&out_meter, decompressed[i]); + out_level = power_meter_update(out_meter, decompressed[i]); printf("%10d, %10d, %f\n", in_level, out_level, (float) out_level/in_level); } while (len > 0); @@ -437,12 +437,12 @@ int main(int argc, char *argv[]) int32_t tone_phase_rate; bit_rate = 64000; - eight_k_in = FALSE; - eight_k_out = FALSE; - itutests = TRUE; - encode = FALSE; - decode = FALSE; - tone_test = FALSE; + eight_k_in = false; + eight_k_out = false; + itutests = true; + encode = false; + decode = false; + tone_test = false; in_file = NULL; out_file = NULL; while ((opt = getopt(argc, argv, "b:d:e:i:l:o:t")) != -1) @@ -456,17 +456,17 @@ int main(int argc, char *argv[]) fprintf(stderr, "Invalid bit rate selected. Only 48000, 56000 and 64000 are valid.\n"); exit(2); } - itutests = FALSE; + itutests = false; break; case 'd': in_file = optarg; - decode = TRUE; - itutests = FALSE; + decode = true; + itutests = false; break; case 'e': in_file = optarg; - encode = TRUE; - itutests = FALSE; + encode = true; + itutests = false; break; case 'i': i = atoi(optarg); @@ -492,8 +492,8 @@ int main(int argc, char *argv[]) eight_k_out = (i == 8000); break; case 't': - tone_test = TRUE; - itutests = FALSE; + tone_test = true; + itutests = false; break; default: //usage(); @@ -514,7 +514,7 @@ int main(int argc, char *argv[]) if (!decode && !encode) { decode = - encode = TRUE; + encode = true; } if (in_file == NULL) { diff --git a/libs/spandsp/tests/g726_tests.c b/libs/spandsp/tests/g726_tests.c index 4fba66021e..0bba6e2fcc 100644 --- a/libs/spandsp/tests/g726_tests.c +++ b/libs/spandsp/tests/g726_tests.c @@ -1196,7 +1196,7 @@ int main(int argc, char *argv[]) g726_state_t enc_state; g726_state_t dec_state; int opt; - int itutests; + bool itutests; int bit_rate; SNDFILE *inhandle; SNDFILE *outhandle; @@ -1206,7 +1206,7 @@ int main(int argc, char *argv[]) int packing; bit_rate = 32000; - itutests = TRUE; + itutests = true; packing = G726_PACKING_NONE; while ((opt = getopt(argc, argv, "b:LR")) != -1) { @@ -1219,7 +1219,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Invalid bit rate selected. Only 16000, 24000, 32000 and 40000 are valid.\n"); exit(2); } - itutests = FALSE; + itutests = false; break; case 'L': packing = G726_PACKING_LEFT; diff --git a/libs/spandsp/tests/gsm0610_tests.c b/libs/spandsp/tests/gsm0610_tests.c index 9993a39260..346f574e99 100644 --- a/libs/spandsp/tests/gsm0610_tests.c +++ b/libs/spandsp/tests/gsm0610_tests.c @@ -512,21 +512,21 @@ static int perform_pack_unpack_test(void) static void etsi_compliance_tests(void) { - perform_linear_test(TRUE, 1, "Seq01"); - perform_linear_test(TRUE, 1, "Seq02"); - perform_linear_test(TRUE, 1, "Seq03"); - perform_linear_test(TRUE, 1, "Seq04"); - perform_linear_test(FALSE, 1, "Seq05"); - perform_law_test(TRUE, 'a', "Seq01"); - perform_law_test(TRUE, 'a', "Seq02"); - perform_law_test(TRUE, 'a', "Seq03"); - perform_law_test(TRUE, 'a', "Seq04"); - perform_law_test(FALSE, 'a', "Seq05"); - perform_law_test(TRUE, 'u', "Seq01"); - perform_law_test(TRUE, 'u', "Seq02"); - perform_law_test(TRUE, 'u', "Seq03"); - perform_law_test(TRUE, 'u', "Seq04"); - perform_law_test(FALSE, 'u', "Seq05"); + perform_linear_test(true, 1, "Seq01"); + perform_linear_test(true, 1, "Seq02"); + perform_linear_test(true, 1, "Seq03"); + perform_linear_test(true, 1, "Seq04"); + perform_linear_test(false, 1, "Seq05"); + perform_law_test(true, 'a', "Seq01"); + perform_law_test(true, 'a', "Seq02"); + perform_law_test(true, 'a', "Seq03"); + perform_law_test(true, 'a', "Seq04"); + perform_law_test(false, 'a', "Seq05"); + perform_law_test(true, 'u', "Seq01"); + perform_law_test(true, 'u', "Seq02"); + perform_law_test(true, 'u', "Seq03"); + perform_law_test(true, 'u', "Seq04"); + perform_law_test(false, 'u', "Seq05"); /* This is not actually an ETSI test */ perform_pack_unpack_test(); @@ -549,14 +549,14 @@ int main(int argc, char *argv[]) int etsitests; int packing; - etsitests = TRUE; + etsitests = true; packing = GSM0610_PACKING_NONE; while ((opt = getopt(argc, argv, "lp:")) != -1) { switch (opt) { case 'l': - etsitests = FALSE; + etsitests = false; break; case 'p': packing = atoi(optarg); diff --git a/libs/spandsp/tests/hdlc_tests.c b/libs/spandsp/tests/hdlc_tests.c index 70df13425c..93a364f4f5 100644 --- a/libs/spandsp/tests/hdlc_tests.c +++ b/libs/spandsp/tests/hdlc_tests.c @@ -46,13 +46,13 @@ using both 16 and 32 bit CRCs. int ref_len; uint8_t buf[1000]; -int abort_reported; -int frame_handled; -int frame_failed; +bool abort_reported; +bool frame_handled; +bool frame_failed; int frame_len_errors; int frame_data_errors; -int underflow_reported; -int framing_ok_reported; +bool underflow_reported; +bool framing_ok_reported; int framing_ok_reports; hdlc_rx_state_t rx; @@ -96,11 +96,11 @@ static void frame_handler(void *user_data, const uint8_t *pkt, int len, int ok) switch (len) { case SIG_STATUS_FRAMING_OK: - framing_ok_reported = TRUE; + framing_ok_reported = true; framing_ok_reports++; break; case SIG_STATUS_ABORT: - abort_reported = TRUE; + abort_reported = true; break; } return; @@ -119,11 +119,11 @@ static void frame_handler(void *user_data, const uint8_t *pkt, int len, int ok) frame_data_errors++; return; } - frame_handled = TRUE; + frame_handled = true; } else { - frame_failed = TRUE; + frame_failed = true; } } /*- End of function --------------------------------------------------------*/ @@ -131,7 +131,7 @@ static void frame_handler(void *user_data, const uint8_t *pkt, int len, int ok) static void underflow_handler(void *user_data) { //printf("Underflow reported\n"); - underflow_reported = TRUE; + underflow_reported = true; } /*- End of function --------------------------------------------------------*/ @@ -183,17 +183,17 @@ static int test_hdlc_modes(void) printf("Testing with CRC-16 (byte by byte)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 1, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, FALSE, 5, frame_handler, NULL); - underflow_reported = FALSE; + hdlc_tx_init(&tx, false, 1, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, false, 5, frame_handler, NULL); + underflow_reported = false; start = rdtscll(); hdlc_tx_flags(&tx, 40); /* Push an initial message so we should NOT get an underflow after the preamble. */ ref_len = cook_up_msg(buf); hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; - frame_failed = FALSE; + frame_handled = false; + frame_failed = false; frames_sent = 0; bytes_sent = 0; for (i = 0; i < 1000000; i++) @@ -202,7 +202,7 @@ static int test_hdlc_modes(void) hdlc_rx_put_byte(&rx, nextbyte); if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; nextbyte = hdlc_tx_get_byte(&tx); hdlc_rx_put_byte(&rx, nextbyte); frames_sent++; @@ -214,7 +214,7 @@ static int test_hdlc_modes(void) } ref_len = cook_up_msg(buf); hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; + frame_handled = false; } } end = rdtscll(); @@ -224,17 +224,17 @@ static int test_hdlc_modes(void) printf("Testing with CRC-16 (chunk by chunk)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 1, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, FALSE, 5, frame_handler, NULL); - underflow_reported = FALSE; + hdlc_tx_init(&tx, false, 1, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, false, 5, frame_handler, NULL); + underflow_reported = false; start = rdtscll(); hdlc_tx_flags(&tx, 40); /* Push an initial message so we should NOT get an underflow after the preamble. */ ref_len = cook_up_msg(buf); hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; - frame_failed = FALSE; + frame_handled = false; + frame_failed = false; frames_sent = 0; bytes_sent = 0; for (i = 0; i < 10000; i++) @@ -243,7 +243,7 @@ static int test_hdlc_modes(void) hdlc_rx_put(&rx, bufx, len); if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; len = hdlc_tx_get(&tx, bufx, 100); hdlc_rx_put(&rx, bufx, len); frames_sent++; @@ -255,7 +255,7 @@ static int test_hdlc_modes(void) } ref_len = cook_up_msg(buf); hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; + frame_handled = false; } } end = rdtscll(); @@ -265,16 +265,16 @@ static int test_hdlc_modes(void) printf("Testing with CRC-16 (bit by bit)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 2, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, FALSE, 5, frame_handler, NULL); - underflow_reported = FALSE; + hdlc_tx_init(&tx, false, 2, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, false, 5, frame_handler, NULL); + underflow_reported = false; start = rdtscll(); hdlc_tx_flags(&tx, 40); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; frames_sent = 0; bytes_sent = 0; ref_len = 0; @@ -284,7 +284,7 @@ static int test_hdlc_modes(void) hdlc_rx_put_bit(&rx, nextbyte); if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; for (j = 0; j < 20; j++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -302,7 +302,7 @@ static int test_hdlc_modes(void) } ref_len = cook_up_msg(buf); hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; + frame_handled = false; } } end = rdtscll(); @@ -312,16 +312,16 @@ static int test_hdlc_modes(void) printf("Testing with CRC-32 (byte by byte)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, TRUE, 1, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, TRUE, FALSE, 1, frame_handler, NULL); - underflow_reported = FALSE; + hdlc_tx_init(&tx, true, 1, false, underflow_handler, NULL); + hdlc_rx_init(&rx, true, false, 1, frame_handler, NULL); + underflow_reported = false; start = rdtscll(); hdlc_tx_flags(&tx, 40); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; frames_sent = 0; bytes_sent = 0; ref_len = 0; @@ -331,7 +331,7 @@ static int test_hdlc_modes(void) hdlc_rx_put_byte(&rx, nextbyte); if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; nextbyte = hdlc_tx_get_byte(&tx); hdlc_rx_put_byte(&rx, nextbyte); if (ref_len) @@ -346,7 +346,7 @@ static int test_hdlc_modes(void) } ref_len = cook_up_msg(buf); hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; + frame_handled = false; } } end = rdtscll(); @@ -356,16 +356,16 @@ static int test_hdlc_modes(void) printf("Testing progressive mode with CRC-16 (byte by byte)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, TRUE, 1, TRUE, underflow_handler, NULL); - hdlc_rx_init(&rx, TRUE, FALSE, 1, frame_handler, NULL); - underflow_reported = FALSE; + hdlc_tx_init(&tx, true, 1, true, underflow_handler, NULL); + hdlc_rx_init(&rx, true, false, 1, frame_handler, NULL); + underflow_reported = false; start = rdtscll(); hdlc_tx_flags(&tx, 40); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; progress = 9999; progress_delay = 9999; frames_sent = 0; @@ -377,7 +377,7 @@ static int test_hdlc_modes(void) hdlc_rx_put_byte(&rx, nextbyte); if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; nextbyte = hdlc_tx_get_byte(&tx); hdlc_rx_put_byte(&rx, nextbyte); if (ref_len) @@ -394,7 +394,7 @@ static int test_hdlc_modes(void) hdlc_tx_frame(&tx, buf, 10); progress = 10; progress_delay = 8; - frame_handled = FALSE; + frame_handled = false; } if (progress < ref_len && progress_delay-- <= 0) { @@ -424,18 +424,18 @@ static int test_hdlc_frame_length_error_handling(void) printf("Testing frame length error handling using CRC-16 (bit by bit)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 2, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, TRUE, 5, frame_handler, NULL); + hdlc_tx_init(&tx, false, 2, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, true, 5, frame_handler, NULL); hdlc_rx_set_max_frame_len(&rx, 100); - underflow_reported = FALSE; - framing_ok_reported = FALSE; + underflow_reported = false; + framing_ok_reported = false; framing_ok_reports = 0; hdlc_tx_flags(&tx, 10); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; frames_sent = 0; bytes_sent = 0; ref_len = 0; @@ -446,11 +446,11 @@ static int test_hdlc_frame_length_error_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d)\n", i, framing_ok_reports); - framing_ok_reported = FALSE; + framing_ok_reported = false; } if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; for (j = 0; j < 20; j++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -458,7 +458,7 @@ static int test_hdlc_frame_length_error_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d) - %d\n", i, framing_ok_reports, frame_handled); - framing_ok_reported = FALSE; + framing_ok_reported = false; } } if (ref_len) @@ -490,7 +490,7 @@ static int test_hdlc_frame_length_error_handling(void) } ref_len++; hdlc_tx_frame(&tx, buf, ref_len); - frame_handled = FALSE; + frame_handled = false; } } /* We shouldn't reach here */ @@ -509,21 +509,21 @@ static int test_hdlc_crc_error_handling(void) printf("Testing CRC error handling using CRC-16 (bit by bit)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 2, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, TRUE, 5, frame_handler, NULL); - underflow_reported = FALSE; - framing_ok_reported = FALSE; + hdlc_tx_init(&tx, false, 2, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, true, 5, frame_handler, NULL); + underflow_reported = false; + framing_ok_reported = false; framing_ok_reports = 0; hdlc_tx_flags(&tx, 10); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; frames_sent = 0; bytes_sent = 0; ref_len = 100; - corrupt = FALSE; + corrupt = false; for (i = 0; i < 8*1000000; i++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -531,11 +531,11 @@ static int test_hdlc_crc_error_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d)\n", i, framing_ok_reports); - framing_ok_reported = FALSE; + framing_ok_reported = false; } if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; for (j = 0; j < 20; j++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -543,7 +543,7 @@ static int test_hdlc_crc_error_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d) - %d\n", i, framing_ok_reports, frame_handled); - framing_ok_reported = FALSE; + framing_ok_reported = false; } } if (ref_len) @@ -571,7 +571,7 @@ static int test_hdlc_crc_error_handling(void) hdlc_tx_frame(&tx, buf, ref_len); if ((corrupt = rand() & 1)) hdlc_tx_corrupt_frame(&tx); - frame_handled = FALSE; + frame_handled = false; } } @@ -590,22 +590,22 @@ static int test_hdlc_abort_handling(void) printf("Testing abort handling using CRC-16 (bit by bit)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 2, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, TRUE, 0, frame_handler, NULL); - underflow_reported = FALSE; - framing_ok_reported = FALSE; + hdlc_tx_init(&tx, false, 2, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, true, 0, frame_handler, NULL); + underflow_reported = false; + framing_ok_reported = false; framing_ok_reports = 0; hdlc_tx_flags(&tx, 10); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; frames_sent = 0; bytes_sent = 0; ref_len = 0; - abort = FALSE; - abort_reported = FALSE; + abort = false; + abort_reported = false; for (i = 0; i < 8*1000000; i++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -613,11 +613,11 @@ static int test_hdlc_abort_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d)\n", i, framing_ok_reports); - framing_ok_reported = FALSE; + framing_ok_reported = false; } if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; for (j = 0; j < 20; j++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -625,7 +625,7 @@ static int test_hdlc_abort_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d) - %d\n", i, framing_ok_reports, frame_handled); - framing_ok_reported = FALSE; + framing_ok_reported = false; } } if (ref_len) @@ -667,8 +667,8 @@ static int test_hdlc_abort_handling(void) hdlc_tx_frame(&tx, buf, ref_len); if ((abort = rand() & 1)) hdlc_tx_abort(&tx); - frame_handled = FALSE; - abort_reported = FALSE; + frame_handled = false; + abort_reported = false; } } @@ -687,19 +687,19 @@ static int test_hdlc_octet_count_handling(void) printf("Testing the octet_counting handling using CRC-16 (bit by bit)\n"); frame_len_errors = 0; frame_data_errors = 0; - hdlc_tx_init(&tx, FALSE, 2, FALSE, underflow_handler, NULL); - hdlc_rx_init(&rx, FALSE, TRUE, 0, frame_handler, NULL); + hdlc_tx_init(&tx, false, 2, false, underflow_handler, NULL); + hdlc_rx_init(&rx, false, true, 0, frame_handler, NULL); //hdlc_rx_set_max_frame_len(&rx, 50); hdlc_rx_set_octet_counting_report_interval(&rx, 16); - underflow_reported = FALSE; - framing_ok_reported = FALSE; + underflow_reported = false; + framing_ok_reported = false; framing_ok_reports = 0; hdlc_tx_flags(&tx, 10); /* Don't push an initial message so we should get an underflow after the preamble. */ /* Lie for the first message, as there isn't really one */ - frame_handled = TRUE; - frame_failed = FALSE; + frame_handled = true; + frame_failed = false; frames_sent = 0; bytes_sent = 0; ref_len = 0; @@ -710,11 +710,11 @@ static int test_hdlc_octet_count_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d)\n", i, framing_ok_reports); - framing_ok_reported = FALSE; + framing_ok_reported = false; } if (underflow_reported) { - underflow_reported = FALSE; + underflow_reported = false; for (j = 0; j < 20; j++) { nextbyte = hdlc_tx_get_bit(&tx); @@ -722,7 +722,7 @@ static int test_hdlc_octet_count_handling(void) if (framing_ok_reported) { printf("Framing OK reported at bit %d (%d) - %d\n", i, framing_ok_reports, frame_handled); - framing_ok_reported = FALSE; + framing_ok_reported = false; } } if (ref_len) @@ -741,7 +741,7 @@ static int test_hdlc_octet_count_handling(void) hdlc_tx_frame(&tx, buf, ref_len); hdlc_tx_abort(&tx); //hdlc_tx_corrupt_frame(&tx); - frame_handled = FALSE; + frame_handled = false; } } @@ -825,7 +825,7 @@ static void decode_bitstream(const char *in_file_name) exit(2); } - hdlc_rx_init(&rx, FALSE, TRUE, 2, decode_handler, NULL); + hdlc_rx_init(&rx, false, true, 2, decode_handler, NULL); while (fgets(buf, 1024, in)) { if (sscanf(buf, "Rx bit %d - %d", &num, &bit) == 2) diff --git a/libs/spandsp/tests/ima_adpcm_tests.c b/libs/spandsp/tests/ima_adpcm_tests.c index dcf2a6a4cb..e080330313 100644 --- a/libs/spandsp/tests/ima_adpcm_tests.c +++ b/libs/spandsp/tests/ima_adpcm_tests.c @@ -80,18 +80,18 @@ int main(int argc, char *argv[]) int total_pre_samples; int total_compressed_bytes; int total_post_samples; - const char *in_file_name; int variant; int chunk_size; int enc_chunk_size; - int log_encoded_data; int opt; + bool log_encoded_data; + const char *in_file_name; variant = IMA_ADPCM_DVI4; in_file_name = IN_FILE_NAME; chunk_size = 160; enc_chunk_size = 0; - log_encoded_data = FALSE; + log_encoded_data = false; while ((opt = getopt(argc, argv, "ac:i:lv")) != -1) { switch (opt) @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) in_file_name = optarg; break; case 'l': - log_encoded_data = TRUE; + log_encoded_data = true; break; case 'v': variant = IMA_ADPCM_VDVI; diff --git a/libs/spandsp/tests/image_translate_tests.c b/libs/spandsp/tests/image_translate_tests.c index 51807f10c7..7b4fa9d3d3 100644 --- a/libs/spandsp/tests/image_translate_tests.c +++ b/libs/spandsp/tests/image_translate_tests.c @@ -493,27 +493,27 @@ static void translate_tests_gray8(void) printf("Dithering from a 8 bit per sample gray scale to bi-level\n"); create_undithered_50_by_50(&im, image, 1); s = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, -1, -1, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, row_read, &im); - get_bilevel_image(s, TRUE); + get_bilevel_image(s, true); printf("Scrunching from a 8 bit per sample gray scale to 8 bit per sample gray scale\n"); create_undithered_50_by_50(&im, image, 1); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, row_read, &im); - get_gray8_image(s, TRUE); + get_gray8_image(s, true); printf("Scrunching from a 8 bit per sample gray scale to 16 bit per sample gray scale\n"); create_undithered_50_by_50(&im, image, 1); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, row_read, &im); - get_gray16_image(s, TRUE); + get_gray16_image(s, true); printf("Scrunching from a 8 bit per sample gray scale to 3x8 bit per sample colour\n"); create_undithered_50_by_50(&im, image, 1); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, row_read, &im); - get_colour8_image(s, TRUE); + get_colour8_image(s, true); printf("Scrunching from a 8 bit per sample gray scale to 3x16 bit per sample colour\n"); create_undithered_50_by_50(&im, image, 1); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, row_read, &im); - get_colour16_image(s, TRUE); + get_colour16_image(s, true); image_translate_free(s); } @@ -528,27 +528,27 @@ static void translate_tests_gray16(void) printf("Dithering from a 16 bit per sample gray scale to bi-level\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 2); s = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, -1, -1, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, row_read, &im); - get_bilevel_image(s, TRUE); + get_bilevel_image(s, true); printf("Scrunching from a 16 bit per sample gray scale to 8 bit per sample gray scale\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 2); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, row_read, &im); - get_gray8_image(s, TRUE); + get_gray8_image(s, true); printf("Scrunching from a 16 bit per sample gray scale to 16 bit per sample gray scale\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 2); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, row_read, &im); - get_gray16_image(s, TRUE); + get_gray16_image(s, true); printf("Scrunching from a 16 bit per sample gray scale to 3x8 bit per sample colour\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 2); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, row_read, &im); - get_colour8_image(s, TRUE); + get_colour8_image(s, true); printf("Scrunching from a 16 bit per sample gray scale to 3x16 bit per sample colour\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 2); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, row_read, &im); - get_colour16_image(s, TRUE); + get_colour16_image(s, true); image_translate_free(s); } @@ -563,27 +563,27 @@ static void translate_tests_colour8(void) printf("Dithering from a 3x8 bit per sample colour to bi-level\n"); create_undithered_50_by_50(&im, image, 3); s = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, -1, -1, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, row_read, &im); - get_bilevel_image(s, TRUE); + get_bilevel_image(s, true); printf("Scrunching from a 3x8 bit per sample colour to 8 bit per sample gray scale\n"); create_undithered_50_by_50(&im, image, 3); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, row_read, &im); - get_gray8_image(s, TRUE); + get_gray8_image(s, true); printf("Scrunching from a 3x8 bit per sample colour to 16 bit per sample gray scale\n"); create_undithered_50_by_50(&im, image, 3); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, row_read, &im); - get_gray16_image(s, TRUE); + get_gray16_image(s, true); printf("Scrunching from a 3x8 bit per sample colour to 3x8 bit per sample colour\n"); create_undithered_50_by_50(&im, image, 3); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, row_read, &im); - get_colour8_image(s, TRUE); + get_colour8_image(s, true); printf("Scrunching from a 3x8 bit per sample colour to 3x16 bit per sample colour\n"); create_undithered_50_by_50(&im, image, 3); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, row_read, &im); - get_colour16_image(s, TRUE); + get_colour16_image(s, true); image_translate_free(s); } @@ -598,27 +598,27 @@ static void translate_tests_colour16(void) printf("Dithering from a 3x16 bit per sample colour to bi-level\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 6); s = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, -1, -1, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, row_read, &im); - get_bilevel_image(s, TRUE); + get_bilevel_image(s, true); printf("Scrunching from a 3x16 bit per sample colour to 8 bit per sample gray scale\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 6); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, row_read, &im); - get_gray8_image(s, TRUE); + get_gray8_image(s, true); printf("Scrunching from a 3x16 bit per sample colour to 16 bit per sample gray scale\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 6); s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, row_read, &im); - get_gray16_image(s, TRUE); + get_gray16_image(s, true); printf("Scrunching from a 3x16 bit per sample colour to 3x8 bit per sample colour\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 6); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, row_read, &im); - get_colour8_image(s, TRUE); + get_colour8_image(s, true); printf("Scrunching from a 3x16 bit per sample colour to 3x16 bit per sample colour\n"); create_undithered_50_by_50(&im, (uint8_t *) image, 6); s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, row_read, &im); - get_colour16_image(s, TRUE); + get_colour16_image(s, true); image_translate_free(s); } @@ -634,7 +634,7 @@ static void grow_tests_colour8(void) create_undithered_50_by_50(&im, image, 3); s = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, 200, -1, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, row_read, &im); - get_bilevel_image(s, FALSE); + get_bilevel_image(s, false); image_translate_free(s); } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/line_model_tests.c b/libs/spandsp/tests/line_model_tests.c index 8f2091e3fb..8d31413cd4 100644 --- a/libs/spandsp/tests/line_model_tests.c +++ b/libs/spandsp/tests/line_model_tests.c @@ -363,13 +363,13 @@ static void test_line_filter(int line_model_no) int main(int argc, char *argv[]) { int line_model_no; - int speech_test; int opt; + bool speech_test; channel_codec = MUNGE_CODEC_NONE; line_model_no = 0; rbs_pattern = 0; - speech_test = FALSE; + speech_test = false; while ((opt = getopt(argc, argv, "c:m:r:s:")) != -1) { switch (opt) diff --git a/libs/spandsp/tests/logging_tests.c b/libs/spandsp/tests/logging_tests.c index 085fd0ecbc..666fc1e9bb 100644 --- a/libs/spandsp/tests/logging_tests.c +++ b/libs/spandsp/tests/logging_tests.c @@ -42,12 +42,12 @@ #include "spandsp.h" -static int tests_failed = FALSE; +static bool tests_failed = false; static int msg_step = 0; static int msg2_step = 0; -static int msg_done = FALSE; -static int msg2_done = FALSE; +static bool msg_done = false; +static bool msg2_done = false; static void message_handler(void *user_data, int level, const char *text) { @@ -78,10 +78,10 @@ static void message_handler(void *user_data, int level, const char *text) if (strcmp(ref[msg_step], text)) { printf(">>>: %s", ref[msg_step]); - tests_failed = TRUE; + tests_failed = true; } if (ref[++msg_step][0] == '\0') - msg_done = TRUE; + msg_done = true; printf("MSG: %s", text); } /*- End of function --------------------------------------------------------*/ @@ -92,10 +92,10 @@ static void message_handler2(void *user_data, int level, const char *text) if (strcmp(" FLOW Protocol NewTag Date/time tagged log 1 2 3\n", text + 23)) { printf(">>>: %s", text + 23); - tests_failed = TRUE; + tests_failed = true; } if (++msg2_step == 10) - msg2_done = TRUE; + msg2_done = true; printf("MSG: %s", text); } /*- End of function --------------------------------------------------------*/ @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) if (!span_log_test(log, i)) { if (i != 6) - tests_failed = TRUE; + tests_failed = true; break; } } diff --git a/libs/spandsp/tests/lpc10_tests.c b/libs/spandsp/tests/lpc10_tests.c index dee9a624e1..0ecacfb847 100644 --- a/libs/spandsp/tests/lpc10_tests.c +++ b/libs/spandsp/tests/lpc10_tests.c @@ -79,9 +79,9 @@ int main(int argc, char *argv[]) lpc10_decode_state_t *lpc10_dec_state; int i; int block_no; - int log_error; - int compress; - int decompress; + bool log_error; + bool compress; + bool decompress; const char *in_file_name; int compress_file; int decompress_file; @@ -90,25 +90,25 @@ int main(int argc, char *argv[]) int enc_len; int dec_len; - compress = FALSE; - decompress = FALSE; - log_error = TRUE; + compress = false; + decompress = false; + log_error = true; in_file_name = IN_FILE_NAME; while ((opt = getopt(argc, argv, "cdi:l")) != -1) { switch (opt) { case 'c': - compress = TRUE; + compress = true; break; case 'd': - decompress = TRUE; + decompress = true; break; case 'i': in_file_name = optarg; break; case 'l': - log_error = FALSE; + log_error = false; break; default: //usage(); @@ -150,13 +150,13 @@ int main(int argc, char *argv[]) exit(2); } - if ((lpc10_enc_state = lpc10_encode_init(NULL, TRUE)) == NULL) + if ((lpc10_enc_state = lpc10_encode_init(NULL, true)) == NULL) { fprintf(stderr, " Cannot create encoder\n"); exit(2); } - if ((lpc10_dec_state = lpc10_decode_init(NULL, TRUE)) == NULL) + if ((lpc10_dec_state = lpc10_decode_init(NULL, true)) == NULL) { fprintf(stderr, " Cannot create decoder\n"); exit(2); diff --git a/libs/spandsp/tests/modem_connect_tones_tests.c b/libs/spandsp/tests/modem_connect_tones_tests.c index fd7f104992..1f99201b55 100644 --- a/libs/spandsp/tests/modem_connect_tones_tests.c +++ b/libs/spandsp/tests/modem_connect_tones_tests.c @@ -49,9 +49,6 @@ These tests... #define MITEL_DIR "../test-data/mitel/" #define BELLCORE_DIR "../test-data/bellcore/" -#define FALSE 0 -#define TRUE (!FALSE) - #define LEVEL_MAX -5 #define LEVEL_MIN -48 #define LEVEL_MIN_ACCEPT -43 @@ -230,13 +227,13 @@ int main(int argc, char *argv[]) int frames; int samples; int hit; - int false_hit; - int false_miss; int level2; int max_level2; int tone_type; int test_list; int opt; + bool false_hit; + bool false_miss; char *decode_test_file; fsk_tx_state_t preamble_tx; @@ -480,8 +477,8 @@ int main(int argc, char *argv[]) printf("Test 2a: CNG detection with frequency\n"); tone_type = MODEM_CONNECT_TONES_FAX_CNG; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 1100 - 500; pitch <= 1100 + 500; pitch++) { /* Use the transmitter to test the receiver */ @@ -509,13 +506,13 @@ int main(int argc, char *argv[]) if (pitch < (1100 - CED_FREQ_BLACKOUT) || pitch > (1100 + CED_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (1100 - CED_FREQ_TOLERANCE) && pitch < (1100 + CED_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -538,8 +535,8 @@ int main(int argc, char *argv[]) { printf("Test 2b: CED/ANS detection with frequency\n"); awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - 500; pitch < 2100 + 500; pitch++) { /* Use the transmitter to test the receiver */ @@ -560,13 +557,13 @@ int main(int argc, char *argv[]) if (pitch < (2100 - CNG_FREQ_BLACKOUT) || pitch > (2100 + CNG_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (2100 - CNG_FREQ_TOLERANCE) && pitch < (2100 + CNG_FREQ_TOLERANCE)) { if (hit != MODEM_CONNECT_TONES_FAX_CED) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -589,8 +586,8 @@ int main(int argc, char *argv[]) printf("Test 2c: ANSam detection with frequency\n"); tone_type = MODEM_CONNECT_TONES_ANSAM; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - 100; pitch <= 2100 + 100; pitch++) { /* Use the transmitter to test the receiver */ @@ -611,13 +608,13 @@ int main(int argc, char *argv[]) if (pitch < (2100 - CNG_FREQ_BLACKOUT) || pitch > (2100 + CNG_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (2100 - CNG_FREQ_TOLERANCE) && pitch < (2100 + CNG_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -641,8 +638,8 @@ int main(int argc, char *argv[]) printf("Test 2d: ANS/ (EC-disable) detection with frequency\n"); tone_type = MODEM_CONNECT_TONES_ANS_PR; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - 100; pitch <= 2100 + 100; pitch++) { /* Use the transmitter to test the receiver */ @@ -663,13 +660,13 @@ int main(int argc, char *argv[]) if (pitch < (2100 - CNG_FREQ_BLACKOUT) || pitch > (2100 + CNG_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (2100 - CNG_FREQ_TOLERANCE) && pitch < (2100 + CNG_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -693,8 +690,8 @@ int main(int argc, char *argv[]) printf("Test 2e: ANSam/ (Modulated EC-disable) detection with frequency\n"); tone_type = MODEM_CONNECT_TONES_ANSAM_PR; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - 100; pitch <= 2100 + 100; pitch++) { /* Use the transmitter to test the receiver */ @@ -715,13 +712,13 @@ int main(int argc, char *argv[]) if (pitch < (2100 - CNG_FREQ_BLACKOUT) || pitch > (2100 + CNG_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (2100 - CNG_FREQ_TOLERANCE) && pitch < (2100 + CNG_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -745,8 +742,8 @@ int main(int argc, char *argv[]) printf("Test 2f: Bell answer tone detection with frequency\n"); tone_type = MODEM_CONNECT_TONES_BELL_ANS; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2225 - 500; pitch <= 2225 + 500; pitch++) { /* Use the transmitter to test the receiver */ @@ -774,13 +771,13 @@ int main(int argc, char *argv[]) if (pitch < (2225 - BELL_ANS_FREQ_BLACKOUT) || pitch > (2225 + BELL_ANS_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (2225 - BELL_ANS_FREQ_TOLERANCE) && pitch < (2225 + BELL_ANS_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -804,8 +801,8 @@ int main(int argc, char *argv[]) printf("Test 2g: Calling tone detection with frequency\n"); tone_type = MODEM_CONNECT_TONES_CALLING_TONE; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 1300 - 500; pitch <= 1300 + 500; pitch++) { /* Use the transmitter to test the receiver */ @@ -833,13 +830,13 @@ int main(int argc, char *argv[]) if (pitch < (1300 - CALLING_TONE_FREQ_BLACKOUT) || pitch > (1300 + CALLING_TONE_FREQ_BLACKOUT)) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (1300 - CALLING_TONE_FREQ_TOLERANCE) && pitch < (1300 + CALLING_TONE_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -863,8 +860,8 @@ int main(int argc, char *argv[]) printf("Test 3a: CNG detection with level\n"); tone_type = MODEM_CONNECT_TONES_FAX_CNG; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 1100 - CED_FREQ_TOLERANCE; pitch <= 1100 + CED_FREQ_TOLERANCE; pitch += 2*CED_FREQ_TOLERANCE) { for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -888,13 +885,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -920,8 +917,8 @@ int main(int argc, char *argv[]) printf("Test 3b: CED/ANS detection with level\n"); tone_type = MODEM_CONNECT_TONES_ANS; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - CNG_FREQ_TOLERANCE; pitch <= 2100 + CNG_FREQ_TOLERANCE; pitch += 2*CNG_FREQ_TOLERANCE) { for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -945,13 +942,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -977,8 +974,8 @@ int main(int argc, char *argv[]) printf("Test 3c: ANSam detection with level\n"); tone_type = MODEM_CONNECT_TONES_ANSAM; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - CNG_FREQ_TOLERANCE; pitch <= 2100 + CNG_FREQ_TOLERANCE; pitch += 2*CNG_FREQ_TOLERANCE) { //for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -1004,13 +1001,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1036,8 +1033,8 @@ int main(int argc, char *argv[]) printf("Test 3d: ANS/ (EC-disable) detection with level\n"); tone_type = MODEM_CONNECT_TONES_ANS_PR; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - CNG_FREQ_TOLERANCE; pitch <= 2100 + CNG_FREQ_TOLERANCE; pitch += 2*CNG_FREQ_TOLERANCE) { for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -1061,13 +1058,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1093,8 +1090,8 @@ int main(int argc, char *argv[]) printf("Test 3e: ANSam/ (Modulated EC-disable) detection with level\n"); tone_type = MODEM_CONNECT_TONES_ANSAM_PR; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2100 - CNG_FREQ_TOLERANCE; pitch <= 2100 + CNG_FREQ_TOLERANCE; pitch += 2*CNG_FREQ_TOLERANCE) { for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -1119,13 +1116,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1151,8 +1148,8 @@ int main(int argc, char *argv[]) printf("Test 3f: Bell answer tone detection with level\n"); tone_type = MODEM_CONNECT_TONES_BELL_ANS; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 2225 - BELL_ANS_FREQ_TOLERANCE; pitch <= 2225 + BELL_ANS_FREQ_TOLERANCE; pitch += 2*BELL_ANS_FREQ_TOLERANCE) { for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -1176,13 +1173,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1208,8 +1205,8 @@ int main(int argc, char *argv[]) printf("Test 3g: Calling tone detection with level\n"); tone_type = MODEM_CONNECT_TONES_CALLING_TONE; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 1300 - CALLING_TONE_FREQ_TOLERANCE; pitch <= 1300 + CALLING_TONE_FREQ_TOLERANCE; pitch += 2*CALLING_TONE_FREQ_TOLERANCE) { for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) @@ -1233,13 +1230,13 @@ int main(int argc, char *argv[]) if (level < LEVEL_MIN_REJECT) { if (hit != MODEM_CONNECT_TONES_NONE) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (level > LEVEL_MIN_ACCEPT) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1263,8 +1260,8 @@ int main(int argc, char *argv[]) if ((test_list & PERFORM_TEST_4)) { printf("Test 4: CED detection, when stimulated with V.21 preamble\n"); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; /* Send 255 bits of preamble (0.85s, the minimum specified preamble for T.30), and then some random bits. Check the preamble detector comes on, and goes off at reasonable times. */ @@ -1299,8 +1296,8 @@ int main(int argc, char *argv[]) printf("Test 5A: ANS and ANS/ detection with reversal interval\n"); tone_type = MODEM_CONNECT_TONES_ANS_PR; awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (interval = 400; interval < 800; interval++) { printf("Reversal interval = %d\n", interval); @@ -1331,13 +1328,13 @@ int main(int argc, char *argv[]) if (interval < (450 - 25) || interval > (450 + 25)) { if (hits != 0) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (interval > (450 - 25) && interval < (450 + 25)) { if (hits == 0) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1361,8 +1358,8 @@ int main(int argc, char *argv[]) printf("Test 5B: ANS and ANS/ detection with mixed reversal intervals\n"); awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); tone_type = MODEM_CONNECT_TONES_ANS_PR; - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; interval = 450; printf("Reversal interval = %d\n", interval); /* Use the transmitter to test the receiver */ @@ -1410,8 +1407,8 @@ int main(int argc, char *argv[]) printf("Test 6a: ANSam detection with AM pitch\n"); tone_type = MODEM_CONNECT_TONES_ANSAM; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 5; pitch < 25; pitch++) { /* Use the transmitter to test the receiver */ @@ -1432,13 +1429,13 @@ int main(int argc, char *argv[]) if (pitch < (15 - 10) || pitch > (15 + 10)) { if (hit == tone_type) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (15 - AM_FREQ_TOLERANCE) && pitch < (15 + AM_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1462,8 +1459,8 @@ int main(int argc, char *argv[]) printf("Test 6b: ANSam/ (Modulated EC-disable) detection with AM pitch\n"); tone_type = MODEM_CONNECT_TONES_ANSAM_PR; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (pitch = 5; pitch < 25; pitch++) { /* Use the transmitter to test the receiver */ @@ -1484,13 +1481,13 @@ int main(int argc, char *argv[]) if (pitch < (15 - 10) || pitch > (15 + 10)) { if (hit == tone_type) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (pitch > (15 - AM_FREQ_TOLERANCE) && pitch < (15 + AM_FREQ_TOLERANCE)) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1515,8 +1512,8 @@ int main(int argc, char *argv[]) tone_type = MODEM_CONNECT_TONES_ANSAM; pitch = 2100; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (depth = 0; depth < 40; depth++) { /* Use the transmitter to test the receiver */ @@ -1537,13 +1534,13 @@ int main(int argc, char *argv[]) if (depth < 10) { if (hit == tone_type) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (depth > 15) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ @@ -1568,8 +1565,8 @@ int main(int argc, char *argv[]) tone_type = MODEM_CONNECT_TONES_ANSAM_PR; pitch = 2100; awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); - false_hit = FALSE; - false_miss = FALSE; + false_hit = false; + false_miss = false; for (depth = 0; depth < 40; depth++) { /* Use the transmitter to test the receiver */ @@ -1590,13 +1587,13 @@ int main(int argc, char *argv[]) if (depth < 10) { if (hit == tone_type) - false_hit = TRUE; + false_hit = true; /*endif*/ } else if (depth > 15) { if (hit != tone_type) - false_miss = TRUE; + false_miss = true; /*endif*/ } /*endif*/ diff --git a/libs/spandsp/tests/modem_echo_tests.c b/libs/spandsp/tests/modem_echo_tests.c index c6ce135a02..2cc50f4294 100644 --- a/libs/spandsp/tests/modem_echo_tests.c +++ b/libs/spandsp/tests/modem_echo_tests.c @@ -118,8 +118,8 @@ fir32_state_t line_model; SNDFILE *resulthandle; int16_t residue_sound[8000]; int residue_cur = 0; -int do_codec_munge = TRUE; -int use_gui = FALSE; +int do_codec_munge = true; +int use_gui = false; static const int16_t tone_1khz[] = {10362, 7327, 0, -7327, -10362, -7327, 0, 7327}; @@ -268,12 +268,12 @@ int main(int argc, char *argv[]) #endif line_model_no = 0; - use_gui = FALSE; + use_gui = false; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-g") == 0) { - use_gui = TRUE; + use_gui = true; continue; } line_model_no = atoi(argv[1]); @@ -307,7 +307,7 @@ int main(int argc, char *argv[]) power_meter_init(&power_after, 5); /* Measure the echo power before adaption */ - modem_echo_can_adaption_mode(ctx, FALSE); + modem_echo_can_adaption_mode(ctx, false); for (i = 0; i < 8000*5; i++) { tx = tone_1khz[i & 7]; @@ -322,7 +322,7 @@ int main(int argc, char *argv[]) /* Converge the canceller */ signal_restart(&local_css); - modem_echo_can_adaption_mode(ctx, TRUE); + modem_echo_can_adaption_mode(ctx, true); for (i = 0; i < 800*2; i++) { clean = modem_echo_can_update(ctx, 0, 0); @@ -352,7 +352,7 @@ int main(int argc, char *argv[]) } /* Now lets see how well adapted we are */ - modem_echo_can_adaption_mode(ctx, FALSE); + modem_echo_can_adaption_mode(ctx, false); for (i = 0; i < 8000*5; i++) { tx = tone_1khz[i & 7]; diff --git a/libs/spandsp/tests/oki_adpcm_tests.c b/libs/spandsp/tests/oki_adpcm_tests.c index ff87b20605..f41208239c 100644 --- a/libs/spandsp/tests/oki_adpcm_tests.c +++ b/libs/spandsp/tests/oki_adpcm_tests.c @@ -88,13 +88,13 @@ int main(int argc, char *argv[]) int encoded_fd; const char *encoded_file_name; const char *in_file_name; - int log_encoded_data; + bool log_encoded_data; int opt; bit_rate = 32000; encoded_file_name = NULL; in_file_name = IN_FILE_NAME; - log_encoded_data = FALSE; + log_encoded_data = false; while ((opt = getopt(argc, argv, "2d:i:l")) != -1) { switch (opt) @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) in_file_name = optarg; break; case 'l': - log_encoded_data = TRUE; + log_encoded_data = true; break; default: //usage(); diff --git a/libs/spandsp/tests/plc_tests.c b/libs/spandsp/tests/plc_tests.c index 4e97d96321..78e645d317 100644 --- a/libs/spandsp/tests/plc_tests.c +++ b/libs/spandsp/tests/plc_tests.c @@ -70,18 +70,18 @@ int main(int argc, char *argv[]) int block_len; int loss_rate; int dropit; - int block_real; - int block_synthetic; int tone; int i; + int opt; + bool block_real; + bool block_synthetic; uint32_t phase_acc; int32_t phase_rate; - int opt; loss_rate = 25; block_len = 160; - block_real = FALSE; - block_synthetic = FALSE; + block_real = false; + block_synthetic = false; tone = -1; while ((opt = getopt(argc, argv, "b:l:rst:")) != -1) { @@ -94,10 +94,10 @@ int main(int argc, char *argv[]) loss_rate = atoi(optarg); break; case 'r': - block_real = TRUE; + block_real = true; break; case 's': - block_synthetic = TRUE; + block_synthetic = true; break; case 't': tone = atoi(optarg); diff --git a/libs/spandsp/tests/power_meter_tests.c b/libs/spandsp/tests/power_meter_tests.c index 0dd04c7424..da04372778 100644 --- a/libs/spandsp/tests/power_meter_tests.c +++ b/libs/spandsp/tests/power_meter_tests.c @@ -75,7 +75,7 @@ static int power_surge_detector_tests(void) exit(2); } sig = power_surge_detector_init(NULL, -50.0f, 5.0f); - prev_signal_present = FALSE; + prev_signal_present = false; phase_rate = dds_phase_rate(450.0f); phase_acc = 0; @@ -178,7 +178,7 @@ static int power_surge_detector_file_test(const char *file) exit(2); } sig = power_surge_detector_init(NULL, -50.0f, 6.0f); - prev_signal_present = FALSE; + prev_signal_present = false; sample = 0; while ((inframes = sf_readf_short(inhandle, amp, 8000))) @@ -271,7 +271,7 @@ static int power_meter_tests(void) 0, 0, 0, - TRUE); + true); tone_gen_init(&gen, &tone_desc); len = tone_gen(&gen, amp, 1000); for (i = 0; i < len; i++) @@ -335,13 +335,13 @@ static int power_meter_tests(void) int main(int argc, char *argv[]) { - int basic_tests; - int decode; + bool basic_tests; + bool decode; int opt; const char *in_file; - basic_tests = TRUE; - decode = FALSE; + basic_tests = true; + decode = false; in_file = IN_FILE_NAME; while ((opt = getopt(argc, argv, "d:")) != -1) { @@ -349,8 +349,8 @@ int main(int argc, char *argv[]) { case 'd': in_file = optarg; - basic_tests = FALSE; - decode = TRUE; + basic_tests = false; + decode = true; break; default: //usage(); diff --git a/libs/spandsp/tests/pseudo_terminals.c b/libs/spandsp/tests/pseudo_terminals.c index f973801d13..c7bc2e67eb 100644 --- a/libs/spandsp/tests/pseudo_terminals.c +++ b/libs/spandsp/tests/pseudo_terminals.c @@ -172,7 +172,7 @@ int psuedo_terminal_create(modem_t *modem) psuedo_terminal_close(modem); return -1; } - modem->threadAbort = CreateEvent(NULL, TRUE, FALSE, NULL); + modem->threadAbort = CreateEvent(NULL, true, false, NULL); #else modem->slot = next_id++; snprintf(modem->devlink, sizeof(modem->devlink), "/dev/spandsp/%d", modem->slot); diff --git a/libs/spandsp/tests/queue_tests.c b/libs/spandsp/tests/queue_tests.c index d01aa60ec9..f648b155f8 100644 --- a/libs/spandsp/tests/queue_tests.c +++ b/libs/spandsp/tests/queue_tests.c @@ -691,21 +691,21 @@ static void functional_message_tests(void) int main(int argc, char *argv[]) { - int threaded_messages; - int threaded_streams; + bool threaded_messages; + bool threaded_streams; int opt; - threaded_messages = FALSE; - threaded_streams = FALSE; + threaded_messages = false; + threaded_streams = false; while ((opt = getopt(argc, argv, "ms")) != -1) { switch (opt) { case 'm': - threaded_messages = TRUE; + threaded_messages = true; break; case 's': - threaded_streams = TRUE; + threaded_streams = true; break; } } diff --git a/libs/spandsp/tests/r2_mf_rx_tests.c b/libs/spandsp/tests/r2_mf_rx_tests.c index 6fb9b0781d..2402634131 100644 --- a/libs/spandsp/tests/r2_mf_rx_tests.c +++ b/libs/spandsp/tests/r2_mf_rx_tests.c @@ -165,7 +165,7 @@ static void my_mf_gen_init(float low_fudge, 0, 0, 0, - FALSE); + false); } } /*- End of function --------------------------------------------------------*/ @@ -205,7 +205,7 @@ static void digit_delivery(void *data, int digit, int level, int delay) if (data != (void *) 0x12345678) { - callback_ok = FALSE; + callback_ok = false; return; } if ((callback_roll & 1)) @@ -213,13 +213,13 @@ static void digit_delivery(void *data, int digit, int level, int delay) else ch = r2_mf_tone_codes[callback_roll >> 1]; if (ch == digit) - callback_ok = TRUE; + callback_ok = true; else - callback_ok = FALSE; + callback_ok = false; if (r2_mf_tone_codes[callback_roll >> 1]) callback_roll++; else - callback_ok = FALSE; + callback_ok = false; } /*- End of function --------------------------------------------------------*/ @@ -539,7 +539,7 @@ static int test_a_tone_set(int fwd) printf(" Passed\n"); printf("Test 8: Callback digit delivery mode.\n"); - callback_ok = FALSE; + callback_ok = false; callback_roll = 0; mf_state = r2_mf_rx_init(NULL, fwd, digit_delivery, (void *) 0x12345678); my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd); @@ -583,9 +583,9 @@ int main(int argc, char *argv[]) now = time(NULL); printf("R2 forward tones\n"); - test_a_tone_set(TRUE); + test_a_tone_set(true); printf("R2 backward tones\n"); - test_a_tone_set(FALSE); + test_a_tone_set(false); duration = time(NULL) - now; printf("Tests passed in %lds\n", duration); return 0; diff --git a/libs/spandsp/tests/r2_mf_tx_tests.c b/libs/spandsp/tests/r2_mf_tx_tests.c index ff6c5b82d5..0348f799e8 100644 --- a/libs/spandsp/tests/r2_mf_tx_tests.c +++ b/libs/spandsp/tests/r2_mf_tx_tests.c @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) exit(2); } - r2_mf_tx_init(&gen, FALSE); + r2_mf_tx_init(&gen, false); for (digit = 0; digits[digit]; digit++) { r2_mf_tx_put(&gen, digits[digit]); @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) sf_writef_short(outhandle, amp, len); } - r2_mf_tx_init(&gen, TRUE); + r2_mf_tx_init(&gen, true); for (digit = 0; digits[digit]; digit++) { r2_mf_tx_put(&gen, digits[digit]); diff --git a/libs/spandsp/tests/regression_tests.sh b/libs/spandsp/tests/regression_tests.sh index 31aeb5a952..949eca3fcf 100755 --- a/libs/spandsp/tests/regression_tests.sh +++ b/libs/spandsp/tests/regression_tests.sh @@ -43,6 +43,15 @@ then fi echo adsi_tests completed OK +./alloc_tests >$STDOUT_DEST 2>$STDERR_DEST +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo alloc_tests failed! + exit $RETVAL +fi +echo alloc_tests completed OK + ./async_tests >$STDOUT_DEST 2>$STDERR_DEST RETVAL=$? if [ $RETVAL != 0 ] diff --git a/libs/spandsp/tests/rfc2198_sim_tests.c b/libs/spandsp/tests/rfc2198_sim_tests.c index 2c2700fc44..95d8f6b971 100644 --- a/libs/spandsp/tests/rfc2198_sim_tests.c +++ b/libs/spandsp/tests/rfc2198_sim_tests.c @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) #endif #if defined(ENABLE_GUI) - use_gui = FALSE; + use_gui = false; #endif model_no = MODEL_NO; speed_pattern_no = SPEED_PATTERN_NO; @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) { case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); diff --git a/libs/spandsp/tests/sig_tone_tests.c b/libs/spandsp/tests/sig_tone_tests.c index 4288891e57..00af89eeba 100644 --- a/libs/spandsp/tests/sig_tone_tests.c +++ b/libs/spandsp/tests/sig_tone_tests.c @@ -83,7 +83,7 @@ static int dial_pulses = 0; static int rx_handler_callbacks = 0; static int tx_handler_callbacks = 0; -static int use_gui = FALSE; +static bool use_gui = false; static void plot_frequency_response(void) { @@ -522,13 +522,13 @@ int main(int argc, char *argv[]) template_t template[10]; int opt; - use_gui = FALSE; + use_gui = false; while ((opt = getopt(argc, argv, "g")) != -1) { switch (opt) { case 'g': - use_gui = TRUE; + use_gui = true; break; default: //usage(); diff --git a/libs/spandsp/tests/swept_tone_tests.c b/libs/spandsp/tests/swept_tone_tests.c index 9ff6bc462f..aebc54a409 100644 --- a/libs/spandsp/tests/swept_tone_tests.c +++ b/libs/spandsp/tests/swept_tone_tests.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) } printf("Test with swept tone.\n"); - s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, TRUE); + s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, true); for (j = 0; j < 60*SAMPLE_RATE; j += BLOCK_LEN) { len = swept_tone(s, buf, BLOCK_LEN); diff --git a/libs/spandsp/tests/t31_pseudo_terminal_tests.c b/libs/spandsp/tests/t31_pseudo_terminal_tests.c index da32c80c9f..7c0825e4b5 100644 --- a/libs/spandsp/tests/t31_pseudo_terminal_tests.c +++ b/libs/spandsp/tests/t31_pseudo_terminal_tests.c @@ -80,14 +80,14 @@ g1050_state_t *path_b_to_a; double when = 0.0; -int t38_mode = FALSE; +int t38_mode = false; struct modem_s modem[10]; char *decode_test_file = NULL; int countdown = 0; int answered = 0; -int done = FALSE; +int done = false; int test_seq_ptr = 0; @@ -155,7 +155,7 @@ printf("\n"); modem = (modem_t *) user_data; #if defined(WIN32) - o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + o.hEvent = CreateEvent(NULL, true, false, NULL); /* Initialize the rest of the OVERLAPPED structure to zero. */ o.Internal = 0; o.InternalHigh = 0; @@ -163,7 +163,7 @@ printf("\n"); o.OffsetHigh = 0; assert(o.hEvent); if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o)) - GetOverlappedResult(modem->master, &o, &res, TRUE); + GetOverlappedResult(modem->master, &o, &res, true); CloseHandle(o.hEvent); #else res = write(modem->master, buf, len); @@ -205,7 +205,7 @@ static int t31_call_control(t31_state_t *s, void *user_data, int op, const char answered = 1; break; case AT_MODEM_CONTROL_HANGUP: - //done = TRUE; + //done = true; break; case AT_MODEM_CONTROL_OFFHOOK: break; @@ -302,7 +302,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags) ret = MODEM_POLL_ERROR; arHandles[0] = modem->threadAbort; - o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + o.hEvent = CreateEvent(NULL, true, false, NULL); arHandles[1] = o.hEvent; /* Initialize the rest of the OVERLAPPED structure to zero. */ @@ -323,7 +323,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags) else { /* IO is pending, wait for it to finish */ - dwWait = WaitForMultipleObjects(2, arHandles, FALSE, INFINITE); + dwWait = WaitForMultipleObjects(2, arHandles, false, INFINITE); if (dwWait == WAIT_OBJECT_0 + 1 && !modem->block_read) ret = MODEM_POLL_READ; } @@ -415,8 +415,8 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int /* Set up the test environment */ t38_version = 1; - without_pacing = FALSE; - use_tep = FALSE; + without_pacing = false; + use_tep = false; wave_handle = NULL; if (log_audio) @@ -456,7 +456,7 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int { if (t38_mode) { - if ((t38_state = t38_terminal_init(NULL, FALSE, t38_tx_packet_handler, t31_state)) == NULL) + if ((t38_state = t38_terminal_init(NULL, false, t38_tx_packet_handler, t31_state)) == NULL) { fprintf(stderr, "Cannot start the T.38 channel\n"); exit(2); @@ -465,7 +465,7 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int } else { - fax_state = fax_init(NULL, FALSE); + fax_state = fax_init(NULL, false); t30 = fax_get_t30_state(fax_state); } t30_set_rx_file(t30, OUTPUT_FILE_NAME, -1); @@ -475,7 +475,7 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int { if (t38_mode) { - if ((t38_state = t38_terminal_init(NULL, TRUE, t38_tx_packet_handler, t31_state)) == NULL) + if ((t38_state = t38_terminal_init(NULL, true, t38_tx_packet_handler, t31_state)) == NULL) { fprintf(stderr, "Cannot start the T.38 channel\n"); exit(2); @@ -484,7 +484,7 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int } else { - fax_state = fax_init(NULL, TRUE); + fax_state = fax_init(NULL, true); t30 = fax_get_t30_state(fax_state); } t30_set_tx_file(t30, INPUT_FILE_NAME, -1, -1); @@ -559,7 +559,7 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME); span_log_set_tag(logging, "T.31"); - t31_set_mode(t31_state, TRUE); + t31_set_mode(t31_state, true); t38_set_t38_version(t38_core, t38_version); } @@ -606,7 +606,7 @@ printf("ZZZ\n"); if ((ret & MODEM_POLL_READ)) { #if defined(WIN32) - o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + o.hEvent = CreateEvent(NULL, true, false, NULL); /* Initialize the rest of the OVERLAPPED structure to zero. */ o.Internal = 0; @@ -615,7 +615,7 @@ printf("ZZZ\n"); o.OffsetHigh = 0; assert(o.hEvent); if (!ReadFile(modem->master, buf, avail, &read_bytes, &o)) - GetOverlappedResult(modem->master, &o, &read_bytes, TRUE); + GetOverlappedResult(modem->master, &o, &read_bytes, true); CloseHandle (o.hEvent); if ((len = read_bytes)) #else @@ -767,11 +767,11 @@ int main(int argc, char *argv[]) #endif decode_test_file = NULL; - log_audio = FALSE; - test_sending = FALSE; - t38_mode = FALSE; - use_ecm = FALSE; - use_gui = FALSE; + log_audio = false; + test_sending = false; + t38_mode = false; + use_ecm = false; + use_gui = false; g1050_model_no = 0; g1050_speed_pattern_no = 1; while ((opt = getopt(argc, argv, "d:eglM:rS:st")) != -1) @@ -782,33 +782,33 @@ int main(int argc, char *argv[]) decode_test_file = optarg; break; case 'e': - use_ecm = TRUE; + use_ecm = true; break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); #endif break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'M': g1050_model_no = optarg[0] - 'A' + 1; break; case 'r': - test_sending = FALSE; + test_sending = false; break; case 'S': g1050_speed_pattern_no = atoi(optarg); break; case 's': - test_sending = TRUE; + test_sending = true; break; case 't': - t38_mode = TRUE; + t38_mode = true; break; default: //usage(); diff --git a/libs/spandsp/tests/t31_tests.c b/libs/spandsp/tests/t31_tests.c index a002aa73bc..12c3426b4d 100644 --- a/libs/spandsp/tests/t31_tests.c +++ b/libs/spandsp/tests/t31_tests.c @@ -82,7 +82,7 @@ g1050_state_t *path_b_to_a; double when = 0.0; -int t38_mode = FALSE; +int t38_mode = false; #define EXCHANGE(a,b) {a, sizeof(a) - 1, b, sizeof(b) - 1} #define RESPONSE(b) {"", 0, b, sizeof(b) - 1} @@ -106,9 +106,9 @@ static const struct command_response_s fax_send_test_seq[] = EXCHANGE("AT+FRH=3\r", "\r\nCONNECT\r\n"), // #if 1 - RESPONSE("\xFF\x13\x80\x00\xEE\xF8\x80\x80\x89\x80\x80\x80\x18\x18\xB9\x10\x03"), // For audio FAXing + RESPONSE("\xFF\x13\x80\x00\xEE\xF8\x80\x80\x99\x80\x80\x80\x18\x58\x0D\x10\x03"), // For audio FAXing #else - RESPONSE("\xFF\x13\x80\x04\xEE\xF8\x80\x80\x89\x80\x80\x80\x18\x84\x09\x10\x03"), // For T.38 FAXing + RESPONSE("\xFF\x13\x80\x04\xEE\xF8\x80\x80\x99\x80\x80\x80\x18\xC4\xBD\x10\x03"), // For T.38 FAXing #endif RESPONSE("\r\nOK\r\n"), //EXCHANGE("AT+FRH=3\r", "\r\nNO CARRIER\r\n"), @@ -268,11 +268,11 @@ int countdown = 0; int command_response_test_step = -1; char response_buf[1000]; int response_buf_ptr = 0; -int answered = FALSE; -int kick = FALSE; -int dled = FALSE; -int done = FALSE; -int sequence_terminated = FALSE; +int answered = false; +int kick = false; +int dled = false; +int done = false; +int sequence_terminated = false; static const struct command_response_s *fax_test_seq; @@ -333,10 +333,10 @@ static int modem_call_control(t31_state_t *s, void *user_data, int op, const cha t31_call_event(t31_state, AT_CALL_EVENT_CONNECTED); break; case AT_MODEM_CONTROL_ANSWER: - answered = TRUE; + answered = true; break; case AT_MODEM_CONTROL_HANGUP: - done = TRUE; + done = true; break; case AT_MODEM_CONTROL_OFFHOOK: break; @@ -393,17 +393,17 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz response_buf[response_buf_ptr] = '\0'; test_seq_ptr++; if (fax_test_seq[test_seq_ptr].command == NULL && fax_test_seq[test_seq_ptr].command == NULL) - sequence_terminated = TRUE; + sequence_terminated = true; if (fax_test_seq[test_seq_ptr].command) - kick = TRUE; + kick = true; break; } - dled = FALSE; + dled = false; } else { if (buf[i] == DLE) - dled = TRUE; + dled = true; } } i++; @@ -432,13 +432,13 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz printf("\nMatched\n"); test_seq_ptr++; if (fax_test_seq[test_seq_ptr].command == NULL && fax_test_seq[test_seq_ptr].command == NULL) - sequence_terminated = TRUE; + sequence_terminated = true; response_buf_ptr = 0; response_buf[response_buf_ptr] = '\0'; if (fax_test_seq[test_seq_ptr].command) - kick = TRUE; + kick = true; else - dled = FALSE; + dled = false; } return 0; } @@ -511,8 +511,8 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, /* Set up the test environment */ t38_version = 1; - without_pacing = FALSE; - use_tep = FALSE; + without_pacing = false; + use_tep = false; wave_handle = NULL; if (log_audio) @@ -552,7 +552,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, { if (t38_mode) { - if ((t38_state = t38_terminal_init(NULL, FALSE, t38_tx_packet_handler, t31_state)) == NULL) + if ((t38_state = t38_terminal_init(NULL, false, t38_tx_packet_handler, t31_state)) == NULL) { fprintf(stderr, "Cannot start the T.38 channel\n"); exit(2); @@ -561,7 +561,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, } else { - fax_state = fax_init(NULL, FALSE); + fax_state = fax_init(NULL, false); t30 = fax_get_t30_state(fax_state); } t30_set_rx_file(t30, OUTPUT_FILE_NAME, -1); @@ -572,7 +572,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, { if (t38_mode) { - if ((t38_state = t38_terminal_init(NULL, TRUE, t38_tx_packet_handler, t31_state)) == NULL) + if ((t38_state = t38_terminal_init(NULL, true, t38_tx_packet_handler, t31_state)) == NULL) { fprintf(stderr, "Cannot start the T.38 channel\n"); exit(2); @@ -581,7 +581,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, } else { - fax_state = fax_init(NULL, TRUE); + fax_state = fax_init(NULL, true); t30 = fax_get_t30_state(fax_state); } t30_set_tx_file(t30, INPUT_FILE_NAME, -1, -1); @@ -652,14 +652,14 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME); span_log_set_tag(logging, "T.31"); - t31_set_mode(t31_state, TRUE); + t31_set_mode(t31_state, true); t38_set_t38_version(t38_core, t38_version); } - fast_send = FALSE; - fast_send_tcf = TRUE; + fast_send = false; + fast_send_tcf = true; fast_blocks = 0; - kick = TRUE; + kick = true; #if defined(ENABLE_GUI) if (use_gui) start_media_monitor(); @@ -684,7 +684,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, if (kick) { /* Work through the script */ - kick = FALSE; + kick = false; if (fax_test_seq[test_seq_ptr].command > (const char *) 2) { if (fax_test_seq[test_seq_ptr].command[0]) @@ -698,15 +698,15 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, if (fax_test_seq[test_seq_ptr].command == (const char *) 2) { printf("Fast send TCF\n"); - fast_send = TRUE; - fast_send_tcf = TRUE; + fast_send = true; + fast_send_tcf = true; fast_blocks = 100; } else { printf("Fast send image\n"); - fast_send = TRUE; - fast_send_tcf = FALSE; + fast_send = true; + fast_send_tcf = false; fast_blocks = 100; } } @@ -756,7 +756,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, } t31_at_rx(t31_state, (char *) fast_buf, 36); if (--fast_blocks == 0) - fast_send = FALSE; + fast_send = false; } if (t38_mode) @@ -888,10 +888,10 @@ int main(int argc, char *argv[]) int opt; decode_test_file = NULL; - log_audio = FALSE; - test_sending = FALSE; - t38_mode = FALSE; - use_gui = FALSE; + log_audio = false; + test_sending = false; + t38_mode = false; + use_gui = false; g1050_model_no = 0; g1050_speed_pattern_no = 1; while ((opt = getopt(argc, argv, "d:glM:rS:st")) != -1) @@ -903,29 +903,29 @@ int main(int argc, char *argv[]) break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); #endif break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'M': g1050_model_no = optarg[0] - 'A' + 1; break; case 'r': - test_sending = FALSE; + test_sending = false; break; case 'S': g1050_speed_pattern_no = atoi(optarg); break; case 's': - test_sending = TRUE; + test_sending = true; break; case 't': - t38_mode = TRUE; + t38_mode = true; break; default: //usage(); diff --git a/libs/spandsp/tests/t35_tests.c b/libs/spandsp/tests/t35_tests.c index 62599e7630..b65e30189d 100644 --- a/libs/spandsp/tests/t35_tests.c +++ b/libs/spandsp/tests/t35_tests.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) const char *country; const char *model; const char *real_country; - int first_hit; + bool first_hit; printf("Sweep through all the possible countries\n"); for (i = 0; i < 256; i++) @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) msg[0] = i; msg[1] = '\x00'; msg[2] = '\x00'; - first_hit = TRUE; + first_hit = true; for (j = 0; j < 65536; j++) { msg[1] = (j >> 8) & 0xFF; @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) printf("%s\n", real_country); else printf("???\n"); - first_hit = FALSE; + first_hit = false; } printf(" 0x%02x 0x%02x 0x%02x '%s'\n", msg[0], msg[1], msg[2], vendor); } diff --git a/libs/spandsp/tests/t38_core_tests.c b/libs/spandsp/tests/t38_core_tests.c index 094e688827..21c131bf3c 100644 --- a/libs/spandsp/tests/t38_core_tests.c +++ b/libs/spandsp/tests/t38_core_tests.c @@ -51,8 +51,8 @@ These tests exercise the T.38 core ASN.1 processing code. #define MAX_FIELDS 42 #define MAX_FIELD_LEN 8192 +static bool succeeded = true; static int t38_version; -static int succeeded = TRUE; static int ok_indicator_packets; static int bad_indicator_packets; static int ok_data_packets; @@ -130,7 +130,7 @@ static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t t = (t38_core_state_t *) user_data; span_log(t38_core_get_logging_state(s), SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count); if (t38_core_rx_ifp_packet(t, buf, len, seq_no) < 0) - succeeded = FALSE; + succeeded = false; seq_no++; return 0; } @@ -400,7 +400,7 @@ static int encode_then_decode_tests(t38_core_state_t *a, t38_core_state_t *b) for (i = 0, seq_no = 0; i < concat_len; i += len) { if ((len = t38_core_rx_ifp_stream(b, &concat[i], concat_len - i, seq_no)) < 0) - succeeded = FALSE; + succeeded = false; seq_no++; } @@ -597,8 +597,8 @@ int main(int argc, char *argv[]) t38_set_t38_version(t38_core_a, t38_version); t38_set_t38_version(t38_core_b, t38_version); - t38_set_pace_transmission(t38_core_a, FALSE); - t38_set_pace_transmission(t38_core_b, FALSE); + t38_set_pace_transmission(t38_core_a, false); + t38_set_pace_transmission(t38_core_b, false); t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP); t38_set_data_transport_protocol(t38_core_b, T38_TRANSPORT_TCP); @@ -629,7 +629,7 @@ int main(int argc, char *argv[]) t38_set_t38_version(t38_core_a, t38_version); - t38_set_pace_transmission(t38_core_a, FALSE); + t38_set_pace_transmission(t38_core_a, false); t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP); @@ -677,8 +677,8 @@ int main(int argc, char *argv[]) t38_set_t38_version(t38_core_a, t38_version); t38_set_t38_version(t38_core_b, t38_version); - t38_set_pace_transmission(t38_core_a, FALSE); - t38_set_pace_transmission(t38_core_b, FALSE); + t38_set_pace_transmission(t38_core_a, false); + t38_set_pace_transmission(t38_core_b, false); t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP_TPKT); t38_set_data_transport_protocol(t38_core_b, T38_TRANSPORT_TCP_TPKT); @@ -708,7 +708,7 @@ int main(int argc, char *argv[]) } t38_set_t38_version(t38_core_a, t38_version); - t38_set_pace_transmission(t38_core_a, FALSE); + t38_set_pace_transmission(t38_core_a, false); t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP_TPKT); diff --git a/libs/spandsp/tests/t38_decode.c b/libs/spandsp/tests/t38_decode.c index 47716ca7bf..34f072b781 100644 --- a/libs/spandsp/tests/t38_decode.c +++ b/libs/spandsp/tests/t38_decode.c @@ -65,9 +65,9 @@ static SNDFILE *wave_handle; static int log_audio; static int use_transmit_on_idle; -static int done = FALSE; +static int done = false; -static int started = FALSE; +static int started = false; static int64_t current = 0; static int phase_b_handler(t30_state_t *s, void *user_data, int result) @@ -263,7 +263,7 @@ static int ifp_handler(void *user_data, const uint8_t msg[], int len, int seq_no { int i; - started = TRUE; + started = true; printf("%5d >>> ", seq_no); for (i = 0; i < len; i++) @@ -333,17 +333,17 @@ int main(int argc, char *argv[]) uint32_t dest_addr; uint16_t dest_port; - caller = FALSE; - use_ecm = FALSE; + caller = false; + use_ecm = false; t38_version = 0; options = 0; input_file_name = INPUT_FILE_NAME; - fill_removal = FALSE; - use_tep = FALSE; - use_transmit_on_idle = TRUE; + fill_removal = false; + use_tep = false; + use_transmit_on_idle = true; supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17; - t38_terminal_operation = TRUE; - log_audio = FALSE; + t38_terminal_operation = true; + log_audio = false; src_addr = 0; src_port = 0; dest_addr = 0; @@ -353,7 +353,7 @@ int main(int argc, char *argv[]) switch (opt) { case 'c': - caller = TRUE; + caller = true; break; case 'D': dest_addr = parse_inet_addr(optarg); @@ -362,19 +362,19 @@ int main(int argc, char *argv[]) dest_port = atoi(optarg); break; case 'e': - use_ecm = TRUE; + use_ecm = true; break; case 'F': - fill_removal = TRUE; + fill_removal = true; break; case 'G': - t38_terminal_operation = FALSE; + t38_terminal_operation = false; break; case 'i': input_file_name = optarg; break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': supported_modems = atoi(optarg); @@ -389,7 +389,7 @@ int main(int argc, char *argv[]) src_port = atoi(optarg); break; case 't': - use_tep = TRUE; + use_tep = true; break; case 'v': t38_version = atoi(optarg); @@ -440,7 +440,7 @@ int main(int argc, char *argv[]) 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, use_ecm); - t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6 | T4_SUPPORT_COMPRESSION_T85); + t30_set_supported_compressions(t30, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6 | T4_COMPRESSION_T85); if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, t38_terminal_timing_update, process_packet, NULL)) exit(2); @@ -497,7 +497,7 @@ int main(int argc, char *argv[]) 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); - t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6); + t30_set_supported_compressions(t30, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6); logging = fax_get_logging_state(fax_state); span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME); diff --git a/libs/spandsp/tests/t38_non_ecm_buffer_tests.c b/libs/spandsp/tests/t38_non_ecm_buffer_tests.c index c9fa046cb4..9b4cb4039c 100644 --- a/libs/spandsp/tests/t38_non_ecm_buffer_tests.c +++ b/libs/spandsp/tests/t38_non_ecm_buffer_tests.c @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) span_log_set_protocol(&logging, "Buffer"); printf("1 - Impose no minimum for the bits per row\n"); - t38_non_ecm_buffer_init(&buffer, TRUE, 0); + t38_non_ecm_buffer_init(&buffer, true, 0); n = 0; bit_no = 0; /* We should get ones until the buffers recognises an EOL */ @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("2 - Impose no minimum for the bits per row, different alignment\n"); - t38_non_ecm_buffer_init(&buffer, TRUE, 0); + t38_non_ecm_buffer_init(&buffer, true, 0); n = 0; memset(buf, 0, sizeof(buf)); /* The first one in this should be seen as the first EOL */ @@ -235,7 +235,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("3 - Demand a fairly high minimum for the bits per row\n"); - t38_non_ecm_buffer_init(&buffer, TRUE, 400); + t38_non_ecm_buffer_init(&buffer, true, 400); n = 0; memset(buf, 0, sizeof(buf)); /* The first one in this should be seen as the first EOL */ @@ -300,7 +300,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("4 - Take some time to get to the first row of the image, output ahead\n"); - t38_non_ecm_buffer_init(&buffer, TRUE, 400); + t38_non_ecm_buffer_init(&buffer, true, 400); n = 0; /* Get some initial bits from an empty buffer. These should be ones */ for (i = 0; i < 1000; i++) @@ -448,7 +448,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("5 - Take some time to get to the first row of the image, output behind\n"); - t38_non_ecm_buffer_init(&buffer, TRUE, 400); + t38_non_ecm_buffer_init(&buffer, true, 400); n = 0; /* Inject some ones. */ memset(buf, 0xFF, 100); @@ -585,7 +585,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("6 - TCF without leading ones\n"); - t38_non_ecm_buffer_init(&buffer, FALSE, 400); + t38_non_ecm_buffer_init(&buffer, false, 400); n = 0; /* Get some initial bits from an empty buffer. These should be ones */ for (i = 0; i < 1000; i++) @@ -630,7 +630,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("7 - TCF with leading ones\n"); - t38_non_ecm_buffer_init(&buffer, FALSE, 400); + t38_non_ecm_buffer_init(&buffer, false, 400); n = 0; /* Get some initial bits from an empty buffer. These should be ones */ for (i = 0; i < 1000; i++) diff --git a/libs/spandsp/tests/t42_tests.c b/libs/spandsp/tests/t42_tests.c index 105ce60371..fe6b773e23 100644 --- a/libs/spandsp/tests/t42_tests.c +++ b/libs/spandsp/tests/t42_tests.c @@ -147,11 +147,15 @@ int main(int argc, char *argv[]) uint16_t *map_b; uint16_t *map_z; uint32_t jpeg_table_len; +#if 0 logging_state_t *logging; +#endif printf("Demo of ITU/Lab library.\n"); +#if 0 logging = span_log_init(NULL, SPAN_LOG_FLOW, "T.42"); +#endif #if defined(SPANDSP_SUPPORT_TIFF_FX) TIFF_FX_init(); @@ -159,7 +163,7 @@ int main(int argc, char *argv[]) /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); source_file = (argc > 1) ? argv[1] : IN_FILE_NAME; /* sRGB to ITU */ @@ -221,7 +225,7 @@ int main(int argc, char *argv[]) /* The default luminant is D50 */ set_lab_illuminant(&lab, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, false); lab_to_srgb(&lab, colour_map, colour_map, 256); for (i = 0; i < (1 << bits_per_pixel); i++) printf("Map %3d - %5d %5d %5d\n", i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]); @@ -230,7 +234,7 @@ int main(int argc, char *argv[]) { printf("There is no colour map\n"); } - process_raw = FALSE; + process_raw = false; printf("Compression is "); switch (compression) { @@ -242,18 +246,18 @@ int main(int argc, char *argv[]) return 0; case COMPRESSION_T85: printf("T.85\n"); - process_raw = TRUE; + process_raw = true; break; case COMPRESSION_T43: printf("T.43\n"); - process_raw = TRUE; + process_raw = true; break; case COMPRESSION_JPEG: printf("JPEG"); if (photometric == PHOTOMETRIC_ITULAB) { printf(" ITULAB"); - process_raw = TRUE; + process_raw = true; } printf("\n"); break; @@ -265,6 +269,7 @@ int main(int argc, char *argv[]) break; } + outsize = 0; if (process_raw) { uint8_t *jpeg_table; @@ -469,13 +474,13 @@ int main(int argc, char *argv[]) printf("CIELAB\n"); /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, TRUE); + set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, true); lab_to_srgb(&lab_param, data, data, w*h); break; case PHOTOMETRIC_ITULAB: /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); break; } //if (!t42_srgb_to_itulab_jpeg(logging, &lab_param, (tdata_t) &outptr, &outsize, data, off, w, h, 3)) @@ -538,7 +543,7 @@ int main(int argc, char *argv[]) totdata = h*bytes_per_row; /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); #if 0 start = rdtscll(); data2 = NULL; diff --git a/libs/spandsp/tests/t43_tests.c b/libs/spandsp/tests/t43_tests.c index e43699197b..7d51d7dfb4 100644 --- a/libs/spandsp/tests/t43_tests.c +++ b/libs/spandsp/tests/t43_tests.c @@ -67,18 +67,18 @@ typedef struct /* TIFF-FX related extensions to the tag set supported by libtiff */ static const TIFFFieldInfo tiff_fx_tiff_field_info[] = { - {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, FIELD_CUSTOM, FALSE, FALSE, (char *) "Indexed"}, - {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, FIELD_CUSTOM, FALSE, FALSE, (char *) "GlobalParametersIFD"}, - {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "ProfileType"}, - {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "FaxProfile"}, - {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "CodingMethods"}, - {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "VersionYear"}, - {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "ModeNumber"}, - {TIFFTAG_DECODE, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SRATIONAL, FIELD_CUSTOM, FALSE, TRUE, (char *) "Decode"}, - {TIFFTAG_IMAGEBASECOLOR, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SHORT, FIELD_CUSTOM, FALSE, TRUE, (char *) "ImageBaseColor"}, - {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "T82Options"}, - {TIFFTAG_STRIPROWCOUNTS, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_LONG, FIELD_CUSTOM, FALSE, TRUE, (char *) "StripRowCounts"}, - {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "ImageLayer"}, + {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, FIELD_CUSTOM, false, false, (char *) "Indexed"}, + {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, FIELD_CUSTOM, false, false, (char *) "GlobalParametersIFD"}, + {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "ProfileType"}, + {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, FIELD_CUSTOM, false, false, (char *) "FaxProfile"}, + {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "CodingMethods"}, + {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, FIELD_CUSTOM, false, false, (char *) "VersionYear"}, + {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, FIELD_CUSTOM, false, false, (char *) "ModeNumber"}, + {TIFFTAG_DECODE, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SRATIONAL, FIELD_CUSTOM, false, true, (char *) "Decode"}, + {TIFFTAG_IMAGEBASECOLOR, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SHORT, FIELD_CUSTOM, false, true, (char *) "ImageBaseColor"}, + {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "T82Options"}, + {TIFFTAG_STRIPROWCOUNTS, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_LONG, FIELD_CUSTOM, false, true, (char *) "StripRowCounts"}, + {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "ImageLayer"}, }; static TIFFFieldArray tifffxFieldArray; @@ -509,7 +509,7 @@ int read_file(meta_t *meta, int page) #endif /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, false); lab_to_srgb(&lab, meta->colour_map, meta->colour_map, 256); for (i = 0; i < entries; i++) printf("Map %3d - %5d %5d %5d\n", i, meta->colour_map[3*i], meta->colour_map[3*i + 1], meta->colour_map[3*i + 2]); @@ -552,7 +552,6 @@ int read_compressed_image(meta_t *meta, uint8_t **buf) int read_decompressed_image(meta_t *meta, uint8_t **buf) { int bytes_per_row; - tsize_t off; int x; int y; int xx; @@ -561,21 +560,23 @@ int read_decompressed_image(meta_t *meta, uint8_t **buf) int yyy; int i; int j; - uint32_t w; - uint32_t h; - uint16_t samples_per_pixel; int result; int total_raw; int total_data; uint8_t *raw_buf; uint8_t *image_buf; - uint8_t *jpeg_table; - uint32_t jpeg_table_len; t85_decode_state_t t85; t43_decode_state_t t43; packer_t pack; logging_state_t *logging; logging_state_t logging2; +#if 0 + uint8_t *jpeg_table; + uint32_t jpeg_table_len; + tsize_t off; + uint32_t w; + uint32_t h; +#endif image_buf = NULL; total_data = 0; @@ -652,8 +653,8 @@ total_data *= 8; if ((image_buf = malloc(total_data)) == NULL) printf("Failed to allocated image buffer\n"); - jpeg_table_len = 0; #if 0 + jpeg_table_len = 0; if (TIFFGetField(meta->tif, TIFFTAG_JPEGTABLES, &jpeg_table_len, &jpeg_table)) { total_image_len += (jpeg_table_len - 4); @@ -919,8 +920,9 @@ int main(int argc, char *argv[]) /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); + outptr = NULL; for (page_no = 0; ; page_no++) { if (read_file(&in_meta, page_no) < 0) @@ -963,7 +965,7 @@ int main(int argc, char *argv[]) printf("Bi-level\n"); /* We have finished acquiring the image. Now we need to push it out */ - meta.pre_compressed = FALSE; + meta.pre_compressed = false; meta.image_width = in_meta.image_width; meta.image_length = in_meta.image_length; meta.x_resolution = in_meta.x_resolution; @@ -1021,7 +1023,7 @@ int main(int argc, char *argv[]) off = in_meta.samples_per_pixel*in_meta.image_width*in_meta.image_length; /* We have finished acquiring the image. Now we need to push it out */ - meta.pre_compressed = FALSE; + meta.pre_compressed = false; meta.image_width = in_meta.image_width; meta.image_length = in_meta.image_length; meta.x_resolution = in_meta.x_resolution; @@ -1050,7 +1052,7 @@ int main(int argc, char *argv[]) free(data); data = (uint8_t *) outptr; - meta.pre_compressed = FALSE; + meta.pre_compressed = false; meta.image_width = in_meta.image_width; meta.image_length = in_meta.image_length; meta.x_resolution = in_meta.x_resolution; @@ -1072,7 +1074,7 @@ int main(int argc, char *argv[]) /* Convert this to sRGB first */ /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, TRUE); + set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, true); lab_to_srgb(&lab_param, data, data, in_meta.image_width*in_meta.image_length); break; case PHOTOMETRIC_RGB: @@ -1132,7 +1134,7 @@ int main(int argc, char *argv[]) #if 0 /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); if (!t42_srgb_to_itulab_jpeg(&logging2, &lab_param, (tdata_t) &outptr, &outsize, data, off, in_meta.image_width, in_meta.image_length, 3)) { printf("Failed to convert to ITULAB (B).\n"); @@ -1145,7 +1147,7 @@ int main(int argc, char *argv[]) off = outsize; #endif #endif - meta.pre_compressed = FALSE; + meta.pre_compressed = false; meta.image_width = in_meta.image_width; meta.image_length = in_meta.image_length; meta.x_resolution = in_meta.x_resolution; @@ -1188,7 +1190,7 @@ int main(int argc, char *argv[]) /* Convert this to sRGB first */ /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, TRUE); + set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, true); lab_to_srgb(&lab_param, data, data, in_meta.image_width*in_meta.image_length); break; case PHOTOMETRIC_SEPARATED: @@ -1217,7 +1219,7 @@ int main(int argc, char *argv[]) /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); //if (!t42_srgb_to_itulab_jpeg(&logging2, &lab_param, (tdata_t) &outptr, &outsize, data, off, in_meta.image_width, in_meta.image_length, 3)) { printf("Failed to convert to ITULAB (D).\n"); @@ -1228,7 +1230,7 @@ int main(int argc, char *argv[]) off = outsize; in_meta.bits_per_sample = 8; } - meta.pre_compressed = FALSE; + meta.pre_compressed = false; meta.image_width = in_meta.image_width; meta.image_length = in_meta.image_length; meta.x_resolution = in_meta.x_resolution; @@ -1250,7 +1252,7 @@ int main(int argc, char *argv[]) /* We now have the image in memory in ITULAB form */ - meta.pre_compressed = FALSE; + meta.pre_compressed = false; meta.compressed_image_len = off; meta.image_width = in_meta.image_width; meta.image_length = in_meta.image_length; @@ -1324,7 +1326,7 @@ int main(int argc, char *argv[]) totdata = meta.image_length*bytes_per_row; /* The default luminant is D50 */ set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); - set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, false); #if 0 start = rdtscll(); data2 = NULL; diff --git a/libs/spandsp/tests/t4_t6_tests.c b/libs/spandsp/tests/t4_t6_tests.c index c735557fb7..0e583ab059 100644 --- a/libs/spandsp/tests/t4_t6_tests.c +++ b/libs/spandsp/tests/t4_t6_tests.c @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) } } - end_of_page = FALSE; + end_of_page = false; #if 1 printf("Testing image_function->compress->decompress->image_function\n"); /* Send end gets image from a function */ @@ -372,7 +372,7 @@ int main(int argc, char *argv[]) switch (block_size) { case 0: - end_of_page = FALSE; + end_of_page = false; for (;;) { bit = t4_t6_encode_get_bit(send_state); diff --git a/libs/spandsp/tests/t4_tests.c b/libs/spandsp/tests/t4_tests.c index 75d953cfa5..0af75b1ab5 100644 --- a/libs/spandsp/tests/t4_tests.c +++ b/libs/spandsp/tests/t4_tests.c @@ -53,48 +53,6 @@ in ITU specifications T.4 and T.6. t4_tx_state_t *send_state; t4_rx_state_t *receive_state; -/* The following are some test cases from T.4 */ -#define FILL_70 " " -#define FILL_80 " " -#define FILL_100 " " -#define FILL_670 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_70 -#define FILL_980 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_80 - -static const char t4_t6_test_patterns[][1728 + 1] = -{ - "XXXXXX " FILL_980 " XXX XXX X " FILL_670 " XXXX", - "XXXXXX " FILL_980 " XXX X " FILL_670 " XXXX", - /* Line start should code to V(0). Line middle codes to VR(3) VL(2) V(0). Line end should code to V(0) V(0). */ - - " XXXX " FILL_980 " XXXXXXX " FILL_670 " XX ", - "XXXXX " FILL_980 "XX XX " FILL_670 " XXXX", - /* Line start should code to VL(1). Line middle codes to H(7,2). Line end should code to V(0) VR(2) */ - - "XXX " FILL_980 " XX XX XX XXX " FILL_670 " X ", - " " FILL_980 " X XXX XXXX " FILL_670 " X XX", - /* Line start should code to P. Line middle codes to P VL(1) V(0) H(3,4) P. Line end codes to V(0) VL(2) V(0). */ - - "XXXXX " FILL_980 " " FILL_670 " XXXX", - " XXX " FILL_980 " " FILL_670 " XX ", - /* Line start should code to VR(2). Line end codes to V(0) VL(2) V(0). */ - - " XX " FILL_980 " " FILL_670 " X XXX", - "XXX X " FILL_980 " " FILL_670 " X ", - /* Line start should code to H(0,3) VR(1). Line end codes to V(0) VR(3). */ - - " " FILL_980 " " FILL_670 " XX ", - " " FILL_980 " " FILL_670 " ", - /* Line end codes to P V(0) a'0. */ - - " " FILL_980 " " FILL_670 " XXXXXXXXXX", - " " FILL_980 " " FILL_670 " XXXXXX XXXXXX", - /* Line end codes to H(2,6). */ - - " " FILL_980 " " FILL_670 " XX XXXXX", - " " FILL_980 " " FILL_670 " XX ", - /* Line end codes to V(0) H(7,0). */ -}; - int rows_written = 0; int rows_read = 0; @@ -140,63 +98,7 @@ static void display_page_stats(t4_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -static int row_read_handler(void *user_data, uint8_t buf[], size_t len) -{ - int i; - int j; - const char *s; - - /* Send the test pattern. */ - if (rows_read >= 16) - return 0; - s = t4_t6_test_patterns[rows_read++]; - memset(buf, 0, len); - for (i = 0; i < len; i++) - { - for (j = 0; j < 8; j++) - { - if (*s++ != ' ') - buf[i] |= (0x80 >> j); - } - } - if (*s) - printf("Oops - '%c' at end of row %d\n", *s, rows_read); - return len; -} -/*- End of function --------------------------------------------------------*/ - -static int row_write_handler(void *user_data, const uint8_t buf[], size_t len) -{ - int i; - int j; - const char *s; - uint8_t ref[8192]; - - /* Verify that what is received matches the test pattern. */ - if (len == 0) - return 0; - s = t4_t6_test_patterns[rows_written++]; - memset(ref, 0, len); - for (i = 0; i < len; i++) - { - for (j = 0; j < 8; j++) - { - if (*s++ != ' ') - ref[i] |= (0x80 >> j); - } - } - if (*s) - printf("Oops - '%c' at end of row %d\n", *s, rows_written); - if (memcmp(buf, ref, len)) - { - printf("Test failed at row %d\n", rows_written); - exit(2); - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int detect_page_end(int bit, int page_ended) +static int detect_non_ecm_page_end(int bit, int page_ended) { static int consecutive_eols; static int max_consecutive_eols; @@ -207,10 +109,10 @@ static int detect_page_end(int bit, int page_ended) static int expected_eols; static int end_marks; - /* Check the EOLs are added properly to the end of an image. We can't rely on the - decoder giving the right answer, as a full set of EOLs is not needed for the - decoder to work. */ - if (bit == -1000000) + /* Check the EOLs are added properly to the end of a non-ECM image. We can't rely + on the decoder giving the right answer, as a full set of EOLs is not needed for + the decoder to work. */ + if (bit == -1) { /* Reset */ consecutive_eols = 0; @@ -287,6 +189,9 @@ int main(int argc, char *argv[]) T4_COMPRESSION_T6, T4_COMPRESSION_T85, T4_COMPRESSION_T85_L0, +#if defined(SPANDSP_SUPPORT_T88x) + T4_COMPRESSION_T88, +#endif #if defined(SPANDSP_SUPPORT_T42x) T4_COMPRESSION_T42_T81, T4_COMPRESSION_SYCC_T81, @@ -294,7 +199,9 @@ int main(int argc, char *argv[]) #if defined(SPANDSP_SUPPORT_T43x) T4_COMPRESSION_T43, #endif - //T4_COMPRESSION_T45, +#if defined(SPANDSP_SUPPORT_T45x) + T4_COMPRESSION_T45, +#endif -1 }; int sends; @@ -304,10 +211,7 @@ int main(int argc, char *argv[]) int res; int compression; int compression_step; - int add_page_headers; - int overlay_page_headers; int min_row_bits; - int restart_pages; int block_size; char buf[1024]; uint8_t block[1024]; @@ -319,8 +223,11 @@ int main(int argc, char *argv[]) int len; int i; int bit_error_rate; - int dump_as_xxx; int tests_failed; + bool restart_pages; + bool add_page_headers; + bool overlay_page_headers; + bool dump_as_xxx; unsigned int last_pkt_no; unsigned int pkt_no; int page_ended; @@ -329,9 +236,9 @@ int main(int argc, char *argv[]) tests_failed = 0; compression = -1; compression_step = 0; - add_page_headers = FALSE; - overlay_page_headers = FALSE; - restart_pages = FALSE; + 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; @@ -340,7 +247,7 @@ int main(int argc, char *argv[]) min_row_bits = 50; block_size = 1; bit_error_rate = 0; - dump_as_xxx = FALSE; + dump_as_xxx = false; while ((opt = getopt(argc, argv, "b:c:d:ehHri:m:t:x")) != -1) { switch (opt) @@ -348,7 +255,10 @@ int main(int argc, char *argv[]) case 'b': block_size = atoi(optarg); if (block_size > 1024) - block_size = 1024; + { + printf("Block size too large. Must be 1024 or less\n"); + exit(2); + } break; case 'c': if (strcmp(optarg, "T41D") == 0) @@ -371,6 +281,13 @@ int main(int argc, char *argv[]) compression = T4_COMPRESSION_T85; compression_step = -1; } +#if defined(SPANDSP_SUPPORT_T88) + else if (strcmp(optarg, "T88") == 0) + { + compression = T4_COMPRESSION_T88; + compression_step = -1; + } +#endif #if defined(SPANDSP_SUPPORT_T42) else if (strcmp(optarg, "T81") == 0) { @@ -385,6 +302,18 @@ int main(int argc, char *argv[]) compression_step = -1; } #endif +#if defined(SPANDSP_SUPPORT_T45) + else if (strcmp(optarg, "T45") == 0) + { + compression = T4_COMPRESSION_T45; + compression_step = -1; + } +#endif + else + { + printf("Unrecognised compression.\n"); + exit(2); + } break; case 'd': decode_file_name = optarg; @@ -393,15 +322,15 @@ int main(int argc, char *argv[]) bit_error_rate = 0x3FF; break; case 'h': - add_page_headers = TRUE; - overlay_page_headers = FALSE; + add_page_headers = true; + overlay_page_headers = false; break; case 'H': - add_page_headers = TRUE; - overlay_page_headers = TRUE; + add_page_headers = true; + overlay_page_headers = true; break; case 'r': - restart_pages = TRUE; + restart_pages = true; break; case 'i': in_file_name = optarg; @@ -413,7 +342,7 @@ int main(int argc, char *argv[]) page_header_tz = optarg; break; case 'x': - dump_as_xxx = TRUE; + dump_as_xxx = true; break; default: //usage(); @@ -533,130 +462,6 @@ int main(int argc, char *argv[]) } else { -#if 1 - printf("Testing image_function->compress->decompress->image_function\n"); - /* Send end gets image from a function */ - if ((send_state = t4_tx_init(NULL, NULL, -1, -1)) == NULL) - { - printf("Failed to init T.4 tx\n"); - exit(2); - } - span_log_set_level(t4_tx_get_logging_state(send_state), 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_image_width(send_state, 1728); - t4_tx_set_min_bits_per_row(send_state, min_row_bits); - t4_tx_set_max_2d_rows_per_1d_row(send_state, 2); - - /* Receive end puts TIFF to a function. */ - if ((receive_state = t4_rx_init(NULL, NULL, T4_COMPRESSION_T4_2D)) == NULL) - { - printf("Failed to init T.4 rx\n"); - exit(2); - } - span_log_set_level(t4_rx_get_logging_state(receive_state), 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)); - t4_rx_set_y_resolution(receive_state, t4_tx_get_y_resolution(send_state)); - - /* Now send and receive the test data with all compression modes. */ - /* If we are stepping around the compression schemes, reset to the start of the sequence. */ - if (compression_step > 0) - compression_step = 0; - for (;;) - { - end_marks = 0; - if (compression_step >= 0) - { - compression = compression_sequence[compression_step++]; - if (compression < 0 || (block_size == 0 && compression_step >= 3)) - 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; - if (t4_rx_start_page(receive_state)) - break; - detect_page_end(-1000000, compression); - page_ended = FALSE; - switch (block_size) - { - case 0: - while ((bit = t4_tx_get_bit(send_state)) >= 0) - { - /* Monitor whether the EOLs are there in the correct amount */ - if ((res = detect_page_end(bit, page_ended))) - { - printf("Incorrect EOLs - %d\n", res); - tests_failed += (res - 1); - break; - } - if (bit >= 0) - { - if (bit_error_rate) - { - if ((rand() % bit_error_rate) == 0) - bit ^= 1; - } - end_of_page = t4_rx_put_bit(receive_state, bit); - } - } - while (end_of_page != T4_DECODE_OK) - { - end_of_page = t4_rx_put_bit(receive_state, 0); - if (++end_marks > 50) - { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; - } - } - /* Now throw junk at the receive context, to ensure stuff occuring - after the end of page condition has no bad effect. */ - for (i = 0; i < 1000; i++) - t4_rx_put_bit(receive_state, (rand() >> 10) & 1); - break; - default: - /* Some decoders require a few extra bits before the recognise the end - of an image, so be prepared to offer it a few. */ - do - { - len = t4_tx_get(send_state, block, block_size); - if (len > 0) - end_of_page = t4_rx_put(receive_state, block, len); - } - while (len > 0); - while (end_of_page != T4_DECODE_OK) - { - block[0] = 0; - end_of_page = t4_rx_put(receive_state, block, 1); - if (++end_marks > 5) - { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; - } - } - break; - } - 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; - } - t4_tx_release(send_state); - t4_rx_release(receive_state); -#endif #if 1 printf("Testing TIFF->compress->decompress->TIFF cycle\n"); /* Send end gets TIFF from a file */ @@ -713,25 +518,55 @@ int main(int argc, char *argv[]) compression = compression_sequence[compression_step++]; } } - t4_tx_set_tx_encoding(send_state, compression); + if (t4_tx_set_tx_image_format(send_state, + compression, + T4_SUPPORT_WIDTH_215MM + | T4_SUPPORT_LENGTH_US_LETTER + | T4_SUPPORT_LENGTH_US_LEGAL + | T4_SUPPORT_LENGTH_UNLIMITED, + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200, + T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_1200_1200) < 0) + { + break; + } t4_rx_set_rx_encoding(receive_state, compression); if (t4_tx_start_page(send_state)) break; - 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_rx_set_x_resolution(receive_state, t4_tx_get_tx_x_resolution(send_state)); + t4_rx_set_y_resolution(receive_state, t4_tx_get_tx_y_resolution(send_state)); + t4_rx_set_image_width(receive_state, t4_tx_get_tx_image_width(send_state)); } t4_rx_start_page(receive_state); - detect_page_end(-1000000, compression); - page_ended = FALSE; + detect_non_ecm_page_end(-1, compression); + page_ended = false; switch (block_size) { case 0: + /* Bit by bit operation. This is only appropriate for T.4 1D and 2D, + which are used without ECM. */ while ((bit = t4_tx_get_bit(send_state)) >= 0) { /* Monitor whether the EOLs are there in the correct amount */ - if ((res = detect_page_end(bit, page_ended))) + if ((res = detect_non_ecm_page_end(bit, page_ended))) { printf("Incorrect EOLs - %d\n", res); tests_failed += (res - 1); @@ -767,7 +602,7 @@ int main(int argc, char *argv[]) end_of_page = t4_rx_put(receive_state, block, len); } while (len > 0); - /* Some decoders require a few extra bits before the recognise the end + /* Some decoders require a few extra bits before they recognise the end of an image, so be prepared to offer it a few. */ while (end_of_page != T4_DECODE_OK) { diff --git a/libs/spandsp/tests/t81_t82_arith_coding_tests.c b/libs/spandsp/tests/t81_t82_arith_coding_tests.c index 748a8259db..8de5749928 100644 --- a/libs/spandsp/tests/t81_t82_arith_coding_tests.c +++ b/libs/spandsp/tests/t81_t82_arith_coding_tests.c @@ -52,9 +52,6 @@ the present time. #define MSG_SIZE 10000 -#define FALSE 0 -#define TRUE (!FALSE) - uint8_t msg[MSG_SIZE]; int32_t msg_len; @@ -134,7 +131,7 @@ int main(int argc, char *argv[]) printf("Arithmetic decoder tests from ITU-T T.82/7.1\n"); printf("Decoding byte by byte...\n"); - test_failed = FALSE; + test_failed = false; if ((sd = t81_t82_arith_decode_init(NULL)) == NULL) { fprintf(stderr, "Failed to allocate arithmetic decoder!\n"); @@ -162,7 +159,7 @@ int main(int argc, char *argv[]) printf("Bad pixel %d, byte %" PRIdPTR ".\n\n", i*16 + j + 1, sd->pscd_ptr - sd->pscd_end); - test_failed = TRUE; + test_failed = true; break; } if (pix != ((pix_7_1[i] >> (15 - j)) & 1)) @@ -170,7 +167,7 @@ int main(int argc, char *argv[]) printf("Bad PIX (%d) at pixel %d.\n\n", pix, i*16 + j + 1); - test_failed = TRUE; + test_failed = true; break; } } @@ -179,7 +176,7 @@ int main(int argc, char *argv[]) { printf("%" PRIdPTR " bytes left after decoder finished.\n\n", sd->pscd_end - sd->pscd_ptr - 2); - test_failed = TRUE; + test_failed = true; } if (test_failed) { @@ -189,7 +186,7 @@ int main(int argc, char *argv[]) printf("Test passed\n"); printf("Decoding chunk by chunk...\n"); - test_failed = FALSE; + test_failed = false; t81_t82_arith_decode_init(sd); sd->pscd_ptr = sde_7_1; sd->pscd_end = sde_7_1 + SDE_7_1_FULL_LEN; @@ -203,7 +200,7 @@ int main(int argc, char *argv[]) printf("Bad pixel %d, byte %" PRIdPTR ".\n\n", i*16 + j + 1, sd->pscd_ptr - sd->pscd_end); - test_failed = TRUE; + test_failed = true; break; } if (pix != ((pix_7_1[i] >> (15 - j)) & 1)) @@ -211,7 +208,7 @@ int main(int argc, char *argv[]) printf("Bad PIX (%d) at pixel %d.\n\n", pix, i*16 + j + 1); - test_failed = TRUE; + test_failed = true; break; } } @@ -220,7 +217,7 @@ int main(int argc, char *argv[]) { printf("%" PRIdPTR " bytes left after decoder finished.\n\n", sd->pscd_end - sd->pscd_ptr - 2); - test_failed = TRUE; + test_failed = true; } if (test_failed) { diff --git a/libs/spandsp/tests/t85_tests.c b/libs/spandsp/tests/t85_tests.c index b7047d2ad6..8acca038c5 100644 --- a/libs/spandsp/tests/t85_tests.c +++ b/libs/spandsp/tests/t85_tests.c @@ -57,9 +57,6 @@ in ITU specifications T.85. #define TESTBUF_SIZE 400000 #define TEST_IMAGE_SIZE (1951*1960/8) -#define FALSE 0 -#define TRUE (!FALSE) - uint8_t testbuf[TESTBUF_SIZE]; uint8_t test_image[TEST_IMAGE_SIZE]; diff --git a/libs/spandsp/tests/time_scale_tests.c b/libs/spandsp/tests/time_scale_tests.c index 8e6ae19117..3400b5f9b2 100644 --- a/libs/spandsp/tests/time_scale_tests.c +++ b/libs/spandsp/tests/time_scale_tests.c @@ -69,11 +69,11 @@ int main(int argc, char *argv[]) float rate; float sample_rate; const char *in_file_name; - int sweep_rate; + bool sweep_rate; int opt; rate = 1.8f; - sweep_rate = FALSE; + sweep_rate = false; in_file_name = IN_FILE_NAME; while ((opt = getopt(argc, argv, "i:r:s")) != -1) { @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) rate = atof(optarg); break; case 's': - sweep_rate = TRUE; + sweep_rate = true; break; default: //usage(); diff --git a/libs/spandsp/tests/timezone_tests.c b/libs/spandsp/tests/timezone_tests.c index 9ec4af76d7..ab4efe6890 100644 --- a/libs/spandsp/tests/timezone_tests.c +++ b/libs/spandsp/tests/timezone_tests.c @@ -39,14 +39,6 @@ #include "spandsp.h" -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE (!FALSE) -#endif - int main(int argc, char *argv[]) { struct tm tms; diff --git a/libs/spandsp/tests/tone_generate_tests.c b/libs/spandsp/tests/tone_generate_tests.c index 54b7c4e828..6f1f8af4ea 100644 --- a/libs/spandsp/tests/tone_generate_tests.c +++ b/libs/spandsp/tests/tone_generate_tests.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) 200, 300, 400, - FALSE); + false); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) 300, 200, 100, - TRUE); + true); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) 200, 300, 400, - TRUE); + true); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) 200, 300, 400, - TRUE); + true); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) 0, 0, 0, - FALSE); + false); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) 0, 0, 0, - FALSE); + false); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) 200, 300, 400, - TRUE); + true); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) 200, 300, 400, - TRUE); + true); tone_gen_init(&tone_state, &tone_desc); for (i = 0; i < 1000; i++) diff --git a/libs/spandsp/tests/tsb85_tests.c b/libs/spandsp/tests/tsb85_tests.c index 74f397d819..c8012162ef 100644 --- a/libs/spandsp/tests/tsb85_tests.c +++ b/libs/spandsp/tests/tsb85_tests.c @@ -71,12 +71,12 @@ SNDFILE *out_handle; -int use_receiver_not_ready = FALSE; -int test_local_interrupt = FALSE; +bool use_receiver_not_ready = false; +bool test_local_interrupt = false; const char *output_tiff_file_name; -int log_audio = FALSE; +bool log_audio = false; fax_state_t *fax; faxtester_state_t state; @@ -230,7 +230,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) if (i == 'A') { printf("%c: Initiating interrupt request\n", i); - t30_local_interrupt_request(s, TRUE); + t30_local_interrupt_request(s, true); } else { @@ -241,7 +241,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) case T30_PRI_EOM: case T30_PRI_EOP: printf("%c: Accepting interrupt request\n", i); - t30_local_interrupt_request(s, TRUE); + t30_local_interrupt_request(s, true); break; case T30_PIN: break; @@ -268,7 +268,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) static void t30_real_time_frame_handler(t30_state_t *s, void *user_data, - int direction, + bool incoming, const uint8_t *msg, int len) { @@ -279,7 +279,7 @@ static void t30_real_time_frame_handler(t30_state_t *s, { fprintf(stderr, "T.30: Real time frame handler - %s, %s, length = %d\n", - (direction) ? "line->T.30" : "T.30->line", + (incoming) ? "line->T.30" : "T.30->line", t30_frametype(msg[2]), len); } @@ -296,9 +296,9 @@ static int document_handler(t30_state_t *s, void *user_data, int event) { t30_set_tx_file(s, next_tx_file, -1, -1); next_tx_file[0] = '\0'; - return TRUE; + return true; } - return FALSE; + return false; } /*- End of function --------------------------------------------------------*/ @@ -367,8 +367,8 @@ static void fax_prepare(void) logging_state_t *logging; t30 = fax_get_t30_state(fax); - fax_set_transmit_on_idle(fax, TRUE); - fax_set_tep_mode(fax, TRUE); + fax_set_transmit_on_idle(fax, true); + fax_set_tep_mode(fax, true); #if 0 t30_set_tx_ident(t30, "1234567890"); t30_set_tx_sub_address(t30, "Sub-address"); @@ -380,7 +380,7 @@ static void fax_prepare(void) t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp NSF\x00", 16); //t30_set_tx_nss(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp NSS\x00", 16); t30_set_tx_nsc(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp NSC\x00", 16); - t30_set_ecm_capability(t30, TRUE); + t30_set_ecm_capability(t30, true); t30_set_supported_t30_features(t30, T30_SUPPORT_IDENTIFICATION | T30_SUPPORT_SELECTIVE_POLLING @@ -393,23 +393,24 @@ static void fax_prepare(void) | T4_SUPPORT_LENGTH_US_LEGAL | T4_SUPPORT_LENGTH_UNLIMITED); t30_set_supported_bilevel_resolutions(t30, - T4_SUPPORT_RESOLUTION_R8_STANDARD - | T4_SUPPORT_RESOLUTION_R8_FINE - | T4_SUPPORT_RESOLUTION_R8_SUPERFINE - | T4_SUPPORT_RESOLUTION_R16_SUPERFINE - | T4_SUPPORT_RESOLUTION_200_100 - | T4_SUPPORT_RESOLUTION_200_200 - | T4_SUPPORT_RESOLUTION_200_400 - | T4_SUPPORT_RESOLUTION_300_300 - | T4_SUPPORT_RESOLUTION_300_600 - | T4_SUPPORT_RESOLUTION_400_400 - | T4_SUPPORT_RESOLUTION_400_800 - | T4_SUPPORT_RESOLUTION_600_600 - | T4_SUPPORT_RESOLUTION_600_1200 - | T4_SUPPORT_RESOLUTION_1200_1200); + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE + | T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200); t30_set_supported_colour_resolutions(t30, 0); t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); - t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6); + t30_set_supported_compressions(t30, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6); 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'); @@ -639,9 +640,9 @@ static int next_step(faxtester_state_t *s) /* Add a bit of waiting at the end, to ensure everything gets flushed through, any timers can expire, etc. */ faxtester_set_timeout(s, -1); - faxtester_set_rx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); - faxtester_set_tx_type(s, T30_MODEM_PAUSE, 0, 120000, FALSE); - s->final_delayed = TRUE; + faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false); + faxtester_set_tx_type(s, T30_MODEM_PAUSE, 0, 120000, false); + s->final_delayed = true; return 1; } /* Finished */ @@ -699,10 +700,10 @@ static int next_step(faxtester_state_t *s) { hdlc = (strcasecmp((const char *) type, "PREAMBLE") == 0); short_train = (strcasecmp((const char *) type, "TCF") != 0); - faxtester_set_tx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); + faxtester_set_tx_type(s, T30_MODEM_NONE, 0, false, false); if (strcasecmp((const char *) modem, "V.21") == 0) { - faxtester_set_rx_type(s, T30_MODEM_V21, 300, FALSE, TRUE); + faxtester_set_rx_type(s, T30_MODEM_V21, 300, false, true); } else if (strcasecmp((const char *) modem, "V.17/14400") == 0) { @@ -722,19 +723,19 @@ static int next_step(faxtester_state_t *s) } else if (strcasecmp((const char *) modem, "V.29/9600") == 0) { - faxtester_set_rx_type(s, T30_MODEM_V29, 9600, FALSE, hdlc); + faxtester_set_rx_type(s, T30_MODEM_V29, 9600, false, hdlc); } else if (strcasecmp((const char *) modem, "V.29/7200") == 0) { - faxtester_set_rx_type(s, T30_MODEM_V29, 7200, FALSE, hdlc); + faxtester_set_rx_type(s, T30_MODEM_V29, 7200, false, hdlc); } else if (strcasecmp((const char *) modem, "V.27ter/4800") == 0) { - faxtester_set_rx_type(s, T30_MODEM_V27TER, 4800, FALSE, hdlc); + faxtester_set_rx_type(s, T30_MODEM_V27TER, 4800, false, hdlc); } else if (strcasecmp((const char *) modem, "V.27ter/2400") == 0) { - faxtester_set_rx_type(s, T30_MODEM_V27TER, 2400, FALSE, hdlc); + faxtester_set_rx_type(s, T30_MODEM_V27TER, 2400, false, hdlc); } else { @@ -761,14 +762,14 @@ static int next_step(faxtester_state_t *s) else if (strcasecmp((const char *) type, "CNG") == 0) { /* Look for CNG */ - faxtester_set_rx_type(s, T30_MODEM_CNG, 0, FALSE, FALSE); - faxtester_set_tx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); + faxtester_set_rx_type(s, T30_MODEM_CNG, 0, false, false); + faxtester_set_tx_type(s, T30_MODEM_NONE, 0, false, false); } else if (strcasecmp((const char *) type, "CED") == 0) { /* Look for CED */ - faxtester_set_rx_type(s, T30_MODEM_CED, 0, FALSE, FALSE); - faxtester_set_tx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); + faxtester_set_rx_type(s, T30_MODEM_CED, 0, false, false); + faxtester_set_tx_type(s, T30_MODEM_NONE, 0, false, false); } else if (strcasecmp((const char *) type, "HDLC") == 0) { @@ -802,10 +803,10 @@ static int next_step(faxtester_state_t *s) { hdlc = (strcasecmp((const char *) type, "PREAMBLE") == 0); short_train = (strcasecmp((const char *) type, "TCF") != 0); - faxtester_set_rx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); + faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false); if (strcasecmp((const char *) modem, "V.21") == 0) { - faxtester_set_tx_type(s, T30_MODEM_V21, 300, FALSE, TRUE); + faxtester_set_tx_type(s, T30_MODEM_V21, 300, false, true); } else if (strcasecmp((const char *) modem, "V.17/14400") == 0) { @@ -825,19 +826,19 @@ static int next_step(faxtester_state_t *s) } else if (strcasecmp((const char *) modem, "V.29/9600") == 0) { - faxtester_set_tx_type(s, T30_MODEM_V29, 9600, FALSE, hdlc); + faxtester_set_tx_type(s, T30_MODEM_V29, 9600, false, hdlc); } else if (strcasecmp((const char *) modem, "V.29/7200") == 0) { - faxtester_set_tx_type(s, T30_MODEM_V29, 7200, FALSE, hdlc); + faxtester_set_tx_type(s, T30_MODEM_V29, 7200, false, hdlc); } else if (strcasecmp((const char *) modem, "V.27ter/4800") == 0) { - faxtester_set_tx_type(s, T30_MODEM_V27TER, 4800, FALSE, hdlc); + faxtester_set_tx_type(s, T30_MODEM_V27TER, 4800, false, hdlc); } else if (strcasecmp((const char *) modem, "V.27ter/2400") == 0) { - faxtester_set_tx_type(s, T30_MODEM_V27TER, 2400, FALSE, hdlc); + faxtester_set_tx_type(s, T30_MODEM_V27TER, 2400, false, hdlc); } else { @@ -876,7 +877,7 @@ static int next_step(faxtester_state_t *s) } else if (strcasecmp((const char *) type, "CALL") == 0) { - fax = fax_init(NULL, FALSE); + fax = fax_init(NULL, false); fax_prepare(); next_tx_file[0] = '\0'; t30 = fax_get_t30_state(fax); @@ -892,7 +893,7 @@ static int next_step(faxtester_state_t *s) } else if (strcasecmp((const char *) type, "ANSWER") == 0) { - fax = fax_init(NULL, TRUE); + fax = fax_init(NULL, true); fax_prepare(); next_tx_file[0] = '\0'; t30 = fax_get_t30_state(fax); @@ -907,19 +908,19 @@ static int next_step(faxtester_state_t *s) } else if (strcasecmp((const char *) type, "CNG") == 0) { - faxtester_set_rx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); - faxtester_set_tx_type(s, T30_MODEM_CNG, 0, FALSE, FALSE); + faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false); + faxtester_set_tx_type(s, T30_MODEM_CNG, 0, false, false); } else if (strcasecmp((const char *) type, "CED") == 0) { - faxtester_set_rx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); - faxtester_set_tx_type(s, T30_MODEM_CED, 0, FALSE, FALSE); + faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false); + faxtester_set_tx_type(s, T30_MODEM_CED, 0, false, false); } else if (strcasecmp((const char *) type, "WAIT") == 0) { delay = (value) ? atoi((const char *) value) : 1; - faxtester_set_rx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); - faxtester_set_tx_type(s, T30_MODEM_PAUSE, 0, delay, FALSE); + faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false); + faxtester_set_tx_type(s, T30_MODEM_PAUSE, 0, delay, false); } else if (strcasecmp((const char *) type, "PREAMBLE") == 0) { @@ -936,9 +937,9 @@ static int next_step(faxtester_state_t *s) i = string_to_msg(buf, mask, (const char *) value); bit_reverse(buf, buf, abs(i)); if (crc_error && strcasecmp((const char *) crc_error, "0") == 0) - faxtester_send_hdlc_msg(s, buf, abs(i), FALSE); + faxtester_send_hdlc_msg(s, buf, abs(i), false); else - faxtester_send_hdlc_msg(s, buf, abs(i), TRUE); + faxtester_send_hdlc_msg(s, buf, abs(i), true); } else if (strcasecmp((const char *) type, "TCF") == 0) { @@ -980,7 +981,37 @@ static int next_step(faxtester_state_t *s) else if (strcasecmp((const char *) compression, "T.6") == 0) compression_type = T4_COMPRESSION_T6; } - t4_tx_set_tx_encoding(&t4_tx_state, compression_type); + if (t4_tx_set_tx_image_format(&t4_tx_state, + compression_type, + T4_SUPPORT_WIDTH_215MM + | T4_SUPPORT_LENGTH_US_LETTER + | T4_SUPPORT_LENGTH_US_LEGAL + | T4_SUPPORT_LENGTH_UNLIMITED, + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200, + T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_1200_1200) < 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Failed to set T.4 compression\n"); + printf("Test failed\n"); + exit(2); + } t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits); if (t4_tx_start_page(&t4_tx_state)) { @@ -1020,7 +1051,37 @@ static int next_step(faxtester_state_t *s) else if (strcasecmp((const char *) compression, "T.6") == 0) compression_type = T4_COMPRESSION_T6; } - t4_tx_set_tx_encoding(&t4_tx_state, compression_type); + if (t4_tx_set_tx_image_format(&t4_tx_state, + compression_type, + T4_SUPPORT_WIDTH_215MM + | T4_SUPPORT_LENGTH_US_LETTER + | T4_SUPPORT_LENGTH_US_LEGAL + | T4_SUPPORT_LENGTH_UNLIMITED, + T4_RESOLUTION_R8_STANDARD + | T4_RESOLUTION_R8_FINE + | T4_RESOLUTION_R8_SUPERFINE + | T4_RESOLUTION_R16_SUPERFINE + | T4_RESOLUTION_200_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_200_400 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_300_600 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_400_800 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_600_1200 + | T4_RESOLUTION_1200_1200, + T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_400_400 + | T4_RESOLUTION_600_600 + | T4_RESOLUTION_1200_1200) < 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Failed to set T.4 compression\n"); + printf("Test failed\n"); + exit(2); + } t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits); if (t4_tx_start_page(&t4_tx_state)) { @@ -1077,12 +1138,12 @@ static void exchange(faxtester_state_t *s) total_audio_time = 0; - faxtester_set_transmit_on_idle(&state, TRUE); + faxtester_set_transmit_on_idle(&state, true); faxtester_set_real_time_frame_handler(&state, faxtester_real_time_frame_handler, NULL); faxtester_set_front_end_step_complete_handler(&state, faxtester_front_end_step_complete_handler, NULL); faxtester_set_front_end_step_timeout_handler(&state, faxtester_front_end_step_timeout_handler, NULL); - fax = fax_init(NULL, FALSE); + fax = fax_init(NULL, false); fax_prepare(); next_tx_file[0] = '\0'; @@ -1294,13 +1355,13 @@ int main(int argc, char *argv[]) xml_file_name = "../spandsp/tsb85.xml"; test_name = "MRGN01"; - log_audio = FALSE; + log_audio = false; while ((opt = getopt(argc, argv, "lx:")) != -1) { switch (opt) { case 'l': - log_audio = TRUE; + log_audio = true; break; case 'x': xml_file_name = optarg; @@ -1317,7 +1378,7 @@ int main(int argc, char *argv[]) test_name = argv[0]; strcpy(image_path, "."); - faxtester_init(&state, TRUE); + 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"); diff --git a/libs/spandsp/tests/udptl.c b/libs/spandsp/tests/udptl.c index c153a6c803..1ddb8e346d 100644 --- a/libs/spandsp/tests/udptl.c +++ b/libs/spandsp/tests/udptl.c @@ -34,16 +34,14 @@ #include #include #include +#if defined(HAVE_STDBOOL_H) +#include +#else +#include +#endif #include "udptl.h" -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue) { if (*len >= limit) @@ -296,7 +294,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len) s->rx[x].fec_span = span; memset(repaired, 0, sizeof(repaired)); - repaired[x] = TRUE; + repaired[x] = true; /* The number of entries is defined as a length, but will only ever be a small value. Treat it as such. */ @@ -355,7 +353,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len) } } s->rx[which].buf_len = s->rx[l].fec_len[m]; - repaired[which] = TRUE; + repaired[which] = true; } } } diff --git a/libs/spandsp/tests/v17_tests.c b/libs/spandsp/tests/v17_tests.c index ca6bd54ca5..8ceb12060e 100644 --- a/libs/spandsp/tests/v17_tests.c +++ b/libs/spandsp/tests/v17_tests.c @@ -79,7 +79,7 @@ display of modem status is maintained. #define OUT_FILE_NAME "v17.wav" char *decode_test_file = NULL; -int use_gui = FALSE; +bool use_gui = false; int symbol_no = 0; @@ -319,29 +319,29 @@ int main(int argc, char *argv[]) SNDFILE *outhandle; int outframes; int samples; - int tep; int block_no; int noise_level; int signal_level; int bits_per_test; int line_model_no; - int log_audio; int channel_codec; int rbs_pattern; int opt; + bool tep; + bool log_audio; logging_state_t *logging; channel_codec = MUNGE_CODEC_NONE; rbs_pattern = 0; test_bps = 14400; - tep = FALSE; + tep = false; line_model_no = 0; decode_test_file = NULL; - use_gui = FALSE; + use_gui = false; noise_level = -70; signal_level = -13; bits_per_test = 50000; - log_audio = FALSE; + log_audio = false; while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:r:s:t")) != -1) { switch (opt) @@ -374,14 +374,14 @@ int main(int argc, char *argv[]) break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); #endif break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': line_model_no = atoi(optarg); @@ -396,7 +396,7 @@ int main(int argc, char *argv[]) signal_level = atoi(optarg); break; case 't': - tep = TRUE; + tep = true; break; default: //usage(); @@ -529,9 +529,9 @@ int main(int argc, char *argv[]) /* Bump the receiver AGC gain by 1dB, to compensate for the above */ rx->agc_scaling_save *= 1.122f; #endif - v17_tx_restart(tx, test_bps, tep, TRUE); + v17_tx_restart(tx, test_bps, tep, true); v17_tx_power(tx, signal_level); - v17_rx_restart(rx, test_bps, TRUE); + v17_rx_restart(rx, test_bps, true); //rx.eq_put_step = rand()%(192*10/3); bert_init(&bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20); bert_set_report(&bert, 10000, reporter, NULL); diff --git a/libs/spandsp/tests/v18_tests.c b/libs/spandsp/tests/v18_tests.c index 23efd7ae3c..948ffef501 100644 --- a/libs/spandsp/tests/v18_tests.c +++ b/libs/spandsp/tests/v18_tests.c @@ -41,17 +41,14 @@ #include "spandsp.h" #include "spandsp-sim.h" -#define FALSE 0 -#define TRUE (!FALSE) - #define OUTPUT_FILE_NAME "v18.wav" #define SAMPLES_PER_CHUNK 160 -int log_audio = FALSE; +int log_audio = false; SNDFILE *outhandle = NULL; -char result[1024]; -int unexpected_echo = FALSE; +char result[2][1024]; +int unexpected_echo = false; char *decode_test_file = NULL; @@ -81,14 +78,13 @@ static void put_text_msg(void *user_data, const uint8_t *msg, int len) } else { - good_message_received = TRUE; + good_message_received = true; } } /*- End of function --------------------------------------------------------*/ static void basic_tests(int mode) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -100,14 +96,14 @@ static void basic_tests(int mode) int j; printf("Testing %s\n", v18_mode_to_str(mode)); - v18[0] = v18_init(NULL, TRUE, mode, put_text_msg, NULL); + v18[0] = v18_init(NULL, true, mode, V18_AUTOMODING_GLOBAL, put_text_msg, NULL); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, mode, put_text_msg, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, mode, V18_AUTOMODING_GLOBAL, put_text_msg, NULL); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -125,7 +121,7 @@ static void basic_tests(int mode) } /* Fake an OK condition for the first message test */ - good_message_received = TRUE; + good_message_received = true; push = 0; if (v18_put(v18[0], qbf_tx, -1) != strlen(qbf_tx)) { @@ -133,6 +129,8 @@ static void basic_tests(int mode) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { if (push == 0) @@ -151,7 +149,7 @@ static void basic_tests(int mode) printf("No message received\n"); exit(2); } - good_message_received = FALSE; + good_message_received = false; if (v18_put(v18[0], qbf_tx, -1) != strlen(qbf_tx)) { printf("V.18 put failed\n"); @@ -204,9 +202,13 @@ static void basic_tests(int mode) } /*- End of function --------------------------------------------------------*/ +static void misc_01_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_01(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -223,18 +225,18 @@ static int test_misc_01(void) Preamble: N/A Method: A call is made to the TUT from the tester which remains off hook for 10 minutes without sending any signal. - Pass criteria: The TUT should answer the call and enter the probing state after 3 seconds. The + Pass criteria: The TUT should answer the call and enter the probing state after 3s. The TUT should continue to probe until the test is terminated. Comments: This feature should also be verified by observation during the automoding tests. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_01_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_01_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -251,6 +253,8 @@ static int test_misc_01(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -299,9 +303,13 @@ static int test_misc_01(void) } /*- End of function --------------------------------------------------------*/ +static void misc_02_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_02(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -315,25 +323,25 @@ static int test_misc_02(void) /* III.5.4.1.2 Automatic resumption of automoding Purpose: To ensure that the DCE can be configured to automatically re-assume the automode - calling state after 10 s of no valid signal. + calling state after 10s of no valid signal. Preamble: The TUT should be configured to automatically re-assume the initial automoding state. Method: The tester should set up a call to the TUT in V.21 mode and then drop the carrier. - The tester will then transmit silence for 11 seconds followed by a 1300Hz tone for - 5 seconds (i.e. V.23). - Pass criteria: 1) Ten seconds after dropping the carrier the TUT should return to state Monitor 1. - 2) After 2.7+-0.3 seconds the TUT should select V.23 mode and send a 390Hz tone. + The tester will then transmit silence for 11s followed by a 1300Hz tone for + 5s (i.e. V.23). + Pass criteria: 1) 10s after dropping the carrier the TUT should return to state Monitor 1. + 2) After 2.7+-0.3s the TUT should select V.23 mode and send a 390Hz tone. Comments: The TUT should indicate that carrier has been lost at some time after the 1650Hz signal is lost. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_02_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_02_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -350,6 +358,8 @@ static int test_misc_02(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -398,9 +408,13 @@ static int test_misc_02(void) } /*- End of function --------------------------------------------------------*/ +static void misc_03_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_03(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -418,21 +432,21 @@ static int test_misc_03(void) Preamble: The TUT should be configured to remain in the selected transmission mode when the carrier is lost. Method: The tester should set up a call to the TUT in V.21 mode, for example. It will drop - the carrier for 9 seconds and then re-start transmission of the same carrier for - 1 second followed by a short message. + the carrier for 9s and then re-start transmission of the same carrier for + 1s followed by a short message. Pass criteria: The TUT should resume operation in V.21 mode and capture the entire test message. Comments: The TUT should indicate that carrier has been lost at some time after the carrier signal is removed and not disconnect. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_03_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_03_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -449,6 +463,8 @@ static int test_misc_03(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -497,9 +513,13 @@ static int test_misc_03(void) } /*- End of function --------------------------------------------------------*/ +static void misc_04_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_04(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -523,14 +543,14 @@ static int test_misc_04(void) automatically hang up when busy tone is detected. PABX busy tones may differ in frequency and cadence from national parameters. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_04_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_04_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -547,6 +567,8 @@ static int test_misc_04(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -595,9 +617,13 @@ static int test_misc_04(void) } /*- End of function --------------------------------------------------------*/ +static void misc_05_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_05(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -618,14 +644,14 @@ static int test_misc_05(void) Pass criteria: The RINGING condition should be visually indicated by the TUT. Comments: This test should be repeated across a range of valid timings and ring voltages. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_05_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_05_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -642,6 +668,8 @@ static int test_misc_05(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -690,9 +718,13 @@ static int test_misc_05(void) } /*- End of function --------------------------------------------------------*/ +static void misc_06_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_06(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -716,14 +748,14 @@ static int test_misc_06(void) mode. There may be other cases, e.g. where the V.18 DCE is used in a gateway, when automatic disconnection is required. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_06_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_06_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -740,6 +772,8 @@ static int test_misc_06(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -788,9 +822,13 @@ static int test_misc_06(void) } /*- End of function --------------------------------------------------------*/ +static void misc_07_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_07(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -812,14 +850,14 @@ static int test_misc_07(void) However, this may possibly not be indicated by the DTE. Comments: The possible modes are: V.21, V.23, Baudot 45, Baudot 50, EDT, Bell 103, DTMF. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_07_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_07_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -836,6 +874,8 @@ static int test_misc_07(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -884,9 +924,13 @@ static int test_misc_07(void) } /*- End of function --------------------------------------------------------*/ +static void misc_08_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_08(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -902,21 +946,21 @@ static int test_misc_08(void) Purpose: To ensure that the DCE implements circuit 135 or an equivalent way of indicating presence of a signal. Preamble: N/A - Method: A call from the TUT should be answered in voice mode after 20 seconds. The tester + Method: A call from the TUT should be answered in voice mode after 20s. The tester will transmit sampled voice messages. V.24 circuit 135 or its equivalent should be observed. Pass criteria: The ring tone and speech shall be indicated by circuit 135. Comment: The response times and signal level thresholds of Circuit 135 are not specified in ITU-T V.18 or V.24 and therefore the pattern indicated may vary. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_08_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_08_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -933,6 +977,8 @@ static int test_misc_08(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -981,9 +1027,13 @@ static int test_misc_08(void) } /*- End of function --------------------------------------------------------*/ +static void misc_09_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_misc_09(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1003,14 +1053,14 @@ static int test_misc_09(void) Pass criteria: TBD Comment: TBD */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_09_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_09_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1027,6 +1077,8 @@ static int test_misc_09(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1075,9 +1127,13 @@ static int test_misc_09(void) } /*- End of function --------------------------------------------------------*/ +static void org_01_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_01(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1098,22 +1154,22 @@ static int test_org_01(void) check for correct coding and timing of the signal. Pass criteria: 1) No signal should be transmitted for one second after connecting to the line. 2) Four CI patterns are transmitted for each repetition. - 3) No signal is transmitted for two seconds after the end of each CI. + 3) No signal is transmitted for 2s after the end of each CI. 4) Each CI must have the correct bit pattern. - 5) The CI patterns followed by two seconds of silence must be repeated twice. + 5) The CI patterns followed by 2s of silence must be repeated twice. 6) One second after every 3 blocks CI an XCI signal must be transmitted. 7) The XCI should have the structure defined in 3.11. 8) The whole sequence should be repeated until the call is cleared. 9) When V.18 to V.18, the XCI must not force V.23 or Minitel mode. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_01_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_01_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1130,6 +1186,8 @@ static int test_org_01(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1178,9 +1236,13 @@ static int test_org_01(void) } /*- End of function --------------------------------------------------------*/ +static void org_02_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_02(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1198,20 +1260,19 @@ static int test_org_02(void) Preamble: Make a V.18 call from the TUT. Method: The Test System waits for the TUT to stop transmitting a CI and responds with an ANS signal. The V.21 demodulator is used to decode the TXP sequence and a timer - measures the silence intervals between them. ANS should be transmitted for 2 - seconds. - Pass criteria: 1) No signal should be transmitted by TUT for 0.5 seconds from detection of ANS. + measures the silence intervals between them. ANS should be transmitted for 2s. + Pass criteria: 1) No signal should be transmitted by TUT for 0.5s from detection of ANS. 2) The TUT should reply with transmission of TXP as defined in 5.1.2. 3) Verify that TXP sequence has correct bit pattern. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_02_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_02_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1228,6 +1289,8 @@ static int test_org_02(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1276,9 +1339,13 @@ static int test_org_02(void) } /*- End of function --------------------------------------------------------*/ +static void org_03_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_03(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1294,19 +1361,19 @@ static int test_org_03(void) Purpose: The TUT should stop sending TXP at the end of the current sequence when the ANS tone ceases. Preamble: Test ORG-02 should be successfully completed immediately prior to this test. - Method: The tester sends ANS for 2 seconds followed by silence. The tester will then + Method: The tester sends ANS for 2s followed by silence. The tester will then monitor for cessation of TXP at the end of the answer tone. Pass criteria: The TUT should stop sending TXP at the end of the current sequence when ANS tone ceases. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_03_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_03_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1323,6 +1390,8 @@ static int test_org_03(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1371,9 +1440,13 @@ static int test_org_03(void) } /*- End of function --------------------------------------------------------*/ +static void org_04_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_04(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1388,24 +1461,24 @@ static int test_org_04(void) III.5.4.2.4 ANS tone followed by TXP Purpose: To check correct detection of V.18 modem. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. - Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits - 3 TXP sequences using V.21 (2) and starts a 1 s timer. It will then transmit 1650Hz - for 5 seconds. + Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits + 3 TXP sequences using V.21 (2) and starts a 1s timer. It will then transmit 1650Hz + for 5s. Pass criteria: 1) TUT should initially respond with TXP. - 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. - 3) TUT should respond with 980Hz carrier within 1 second of end of 3 TXP sequences. + 2) TUT should stop sending TXP within 0.2s of end of ANS. + 3) TUT should respond with 980Hz carrier within 1s of end of 3 TXP sequences. 4) Data should be transmitted and received according to ITU-T T.140 to comply with the V.18 operational requirements. Comments: The TUT should indicate that V.18 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_04_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_04_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1422,6 +1495,8 @@ static int test_org_04(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1470,9 +1545,13 @@ static int test_org_04(void) } /*- End of function --------------------------------------------------------*/ +static void org_05_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_05(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1488,24 +1567,24 @@ static int test_org_05(void) Purpose: To check correct detection of V.21 modem upper channel when preceded by answer tone and to confirm discrimination between V.21 and V.18 modes. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. - Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits 1650Hz and starts a 0.7 second timer. Pass criteria: 1) TUT should initially respond with TXP. - 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. - 3) TUT should respond with 980Hz at 0.5(+0.2-0.0) seconds of start of 1650Hz. + 2) TUT should stop sending TXP within 0.2s of end of ANS. + 3) TUT should respond with 980Hz at 0.5(+0.2-0.0)s of start of 1650Hz. 4) Data should be transmitted and received at 300 bit/s complying with Annex F. Comments: Selection of ITU-T V.21 as opposed to ITU-T V.18 should be confirmed by examination of TUT. If there is no visual indication, verify by use of ITU-T T.50 for ITU-T V.21 as opposed to UTF-8 coded ISO 10646 character set for ITU-T V.18. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_05_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_05_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1522,6 +1601,8 @@ static int test_org_05(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1570,9 +1651,13 @@ static int test_org_05(void) } /*- End of function --------------------------------------------------------*/ +static void org_06_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_06(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1588,23 +1673,23 @@ static int test_org_06(void) Purpose: To check correct detection of V.23 modem upper channel when preceded by answer tone. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. - Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits - 1300Hz and starts a 2.7 s timer. + Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits + 1300Hz and starts a 2.7s timer. Pass criteria: 1) TUT should initially respond with TXP. - 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. - 3) TUT should respond with 390Hz after 1.7(+0.2-0.0) seconds of start of 1300Hz. + 2) TUT should stop sending TXP within 0.2s of end of ANS. + 3) TUT should respond with 390Hz after 1.7(+0.2-0.0)s of start of 1300Hz. 4) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively by the TUT to comply with Annex E. Comments: The TUT should indicate that V.23 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_06_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_06_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1621,6 +1706,8 @@ static int test_org_06(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1669,9 +1756,13 @@ static int test_org_06(void) } /*- End of function --------------------------------------------------------*/ +static void org_07_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_07(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1686,24 +1777,24 @@ static int test_org_07(void) III.5.4.2.7 ANS tone followed by no tone Purpose: To confirm that TUT does not lock up under this condition. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. - Method: Tester transmits ANS for 2.5 seconds followed by no tone for 10 s. It then transmits - DTMF tones for 2 seconds. + Method: Tester transmits ANS for 2.5s followed by no tone for 10 s. It then transmits + DTMF tones for 2s. Pass criteria: 1) TUT should initially respond with TXP. - 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. + 2) TUT should stop sending TXP within 0.2s of end of ANS. 3) TUT should return to Monitor 1 state and then connect in DTMF mode within - 12 seconds of the end of ANS tone. + 12s of the end of ANS tone. Comments: This condition would cause the terminal to lock up if the V.18 standard is followed literally. It may however, occur when connected to certain Swedish textphones if the handset is lifted just after the start of an automatically answered incoming call. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_07_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_07_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1720,6 +1811,8 @@ static int test_org_07(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1768,9 +1861,13 @@ static int test_org_07(void) } /*- End of function --------------------------------------------------------*/ +static void org_08_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_08(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1786,19 +1883,19 @@ static int test_org_08(void) Purpose: To verify that the TUT correctly detects the Bell 103 upper channel signal during the 2-second interval between transmission of CI sequences. Preamble: N/A - Method: The tester waits for a CI and then sends a 2225Hz signal for 5 seconds. - Pass criteria: 1) The TUT should respond with a 1270Hz tone in 0.5+-0.1 seconds. + Method: The tester waits for a CI and then sends a 2225Hz signal for 5s. + Pass criteria: 1) The TUT should respond with a 1270Hz tone in 0.5+-0.1s. 2) Data should be transmitted and received at 300 bit/s to comply with Annex D. Comments: The TUT should indicate that Bell 103 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_08_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_08_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1815,6 +1912,8 @@ static int test_org_08(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1863,9 +1962,13 @@ static int test_org_08(void) } /*- End of function --------------------------------------------------------*/ +static void org_09_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_09(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1881,19 +1984,19 @@ static int test_org_09(void) Purpose: To verify that the TUT correctly detects the V.21 upper channel signal during the 2-second interval between transmission of CI sequences. Preamble: N/A - Method: The tester waits for a CI and then sends a 1650Hz signal for 5 seconds. - Pass criteria: 1) The TUT should respond with a 980Hz tone in 0.5+-0.1 seconds. + Method: The tester waits for a CI and then sends a 1650Hz signal for 5s. + Pass criteria: 1) The TUT should respond with a 980Hz tone in 0.5+-0.1s. 2) Data should be transmitted and received at 300 bit/s to comply with Annex F. Comments: The TUT should indicate that V.21 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_09_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_09_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -1910,6 +2013,8 @@ static int test_org_09(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -1958,9 +2063,13 @@ static int test_org_09(void) } /*- End of function --------------------------------------------------------*/ +static void org_10_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_10(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -1976,20 +2085,20 @@ static int test_org_10(void) Purpose: To verify that the TUT correctly detects the V.23 upper channel signal during the 2-second interval between transmission of CI sequences. Preamble: N/A - Method: The tester waits for a CI and then sends a 1300Hz signal for 5 seconds. - Pass criteria: 1) The TUT should respond with a 390Hz tone in 1.7+-0.1 seconds. + Method: The tester waits for a CI and then sends a 1300Hz signal for 5s. + Pass criteria: 1) The TUT should respond with a 390Hz tone in 1.7+-0.1s. 2) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively by the TUT to comply with Annex E. Comments: The TUT should indicate that V.23 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_10_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_10_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2006,6 +2115,8 @@ static int test_org_10(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2054,9 +2165,13 @@ static int test_org_10(void) } /*- End of function --------------------------------------------------------*/ +static void org_11_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_11(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2072,23 +2187,23 @@ static int test_org_11(void) Purpose: To confirm correct selection of V.23 reverse mode during sending of XCI. Preamble: N/A Method: The tester should wait for the start of the XCI signal and then send 390Hz to TUT - for 5 seconds. + for 5s. Pass criteria: 1) The TUT should complete the XCI as normal. 2) The TUT should then maintain the 1300Hz tone while the 390Hz test tone is present. 3) Data should be transmitted and received at 1200 bit/s and 75 bit/s respectively by the TUT to comply with Annex E when connection is indicated. - Comments: The TUT should indicate that V.23 mode has been selected at least 3 seconds after + Comments: The TUT should indicate that V.23 mode has been selected at least 3s after the start of the 390Hz tone. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_11_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_11_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2105,6 +2220,8 @@ static int test_org_11(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2153,9 +2270,13 @@ static int test_org_11(void) } /*- End of function --------------------------------------------------------*/ +static void org_12_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_12(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2185,14 +2306,14 @@ static int test_org_12(void) automode answer state. The TUT may then select either 45.45 or 50 bit/s for the transmission. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_12_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_12_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2209,6 +2330,8 @@ static int test_org_12(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2257,9 +2380,13 @@ static int test_org_12(void) } /*- End of function --------------------------------------------------------*/ +static void org_13_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_13(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2275,7 +2402,7 @@ static int test_org_13(void) Purpose: To verify whether the TUT correctly recognizes DTMF signals during the 2-second interval between transmission of CI. Preamble: N/A - Method: The tester will send a single DTMF tone of 40 ms duration to TUT. When TUT + Method: The tester will send a single DTMF tone of 40ms duration to TUT. When TUT indicates a connection, type at least 5 characters back to the tester so that correct selection of mode can be confirmed. Pass criteria: The tester will analyse the received characters to confirm DTMF mode selection. @@ -2283,14 +2410,14 @@ static int test_org_13(void) TUT should comply with ITU-T Q.24 for the Danish Administration while receiving for best possible performance. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_13_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_13_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2307,6 +2434,8 @@ static int test_org_13(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2355,9 +2484,13 @@ static int test_org_13(void) } /*- End of function --------------------------------------------------------*/ +static void org_14_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_14(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2383,14 +2516,14 @@ static int test_org_14(void) the number lost should be minimal. The data bits and parity are specified in Annex C. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_14_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_14_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2407,6 +2540,8 @@ static int test_org_14(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2455,9 +2590,13 @@ static int test_org_14(void) } /*- End of function --------------------------------------------------------*/ +static void org_15_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_15(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2473,19 +2612,19 @@ static int test_org_15(void) Purpose: To verify the presence of 980/1180Hz at a different signalling rate than 110 bit/s returns the TUT modem to the "monitor A" state. Preamble: N/A - Method: The tester transmits 980/1180Hz signals at 300 bit/s for 2 seconds. + Method: The tester transmits 980/1180Hz signals at 300 bit/s for 2s. Pass criteria: The TUT should not select EDT or any other mode and should continue to transmit the CI signal. Comments: Echoes of the CI sequences may be detected at 300 bit/s. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_15_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_15_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2502,6 +2641,8 @@ static int test_org_15(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2550,9 +2691,13 @@ static int test_org_15(void) } /*- End of function --------------------------------------------------------*/ +static void org_16_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_16(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2567,20 +2712,20 @@ static int test_org_16(void) III.5.4.2.16 980Hz detection Purpose: To confirm correct selection of V.21 reverse mode. Preamble: N/A - Method: The tester sends 980Hz to TUT for 5 seconds. - Pass criteria: 1) TUT should respond with 1650Hz tone after 1.5+-0.1 seconds after start of + Method: The tester sends 980Hz to TUT for 5s. + Pass criteria: 1) TUT should respond with 1650Hz tone after 1.5+-0.1s after start of 980Hz tone. 2) Data should be transmitted and received at 300 bit/s complying with Annex F. Comments: The TUT should indicate that V.21 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_16_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_16_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2597,6 +2742,8 @@ static int test_org_16(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2645,9 +2792,13 @@ static int test_org_16(void) } /*- End of function --------------------------------------------------------*/ +static void org_17_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_17(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2662,18 +2813,18 @@ static int test_org_17(void) III.5.4.2.17 Loss of signal after 980Hz Purpose: To confirm that TUT returns to the Monitor 1 state if 980Hz signal disappears. Preamble: N/A - Method: The tester sends 980Hz to TUT for 1.2 seconds followed by silence for 5 seconds. + Method: The tester sends 980Hz to TUT for 1.2s followed by silence for 5s. Pass criteria: TUT should not respond to the 980Hz tone and resume sending CI signals after a - maximum of 2.4 seconds from the end of the 980Hz tone. + maximum of 2.4s from the end of the 980Hz tone. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_17_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_17_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2690,6 +2841,8 @@ static int test_org_17(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2738,9 +2891,13 @@ static int test_org_17(void) } /*- End of function --------------------------------------------------------*/ +static void org_18_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_18(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2755,20 +2912,20 @@ static int test_org_18(void) III.5.4.2.18 Tr timer Purpose: To confirm that TUT returns to the Monitor 1 state if Timer Tr expires. Preamble: N/A - Method: The tester sends 980Hz to TUT for 1.2 seconds followed by 1650Hz for 5 seconds + Method: The tester sends 980Hz to TUT for 1.2s followed by 1650Hz for 5s with no pause. - Pass criteria: TUT should respond with 980Hz after 1.3+-0.1 seconds of 1650Hz. - Comments: This implies timer Tr has expired 2 seconds after the start of the 980Hz tone and - then 1650Hz has been detected for 0.5 seconds. + Pass criteria: TUT should respond with 980Hz after 1.3+-0.1s of 1650Hz. + Comments: This implies timer Tr has expired 2s after the start of the 980Hz tone and + then 1650Hz has been detected for 0.5s. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_18_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_18_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2785,6 +2942,8 @@ static int test_org_18(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2833,9 +2992,13 @@ static int test_org_18(void) } /*- End of function --------------------------------------------------------*/ +static void org_19_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_19(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2850,19 +3013,19 @@ static int test_org_19(void) III.5.4.2.19 Bell 103 (1270Hz signal) detection Purpose: To confirm correct selection of Bell 103 reverse mode. Preamble: N/A - Method: The tester sends 1270Hz to TUT for 5 seconds. + Method: The tester sends 1270Hz to TUT for 5s. Pass criteria: 1) TUT should respond with 2225Hz tone after 0.7+-0.1 s. 2) Data should be transmitted and received at 300 bit/s complying with Annex D. Comments: The TUT should indicate that Bell 103 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_19_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_19_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2879,6 +3042,8 @@ static int test_org_19(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -2927,9 +3092,13 @@ static int test_org_19(void) } /*- End of function --------------------------------------------------------*/ +static void org_20_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_20(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -2956,14 +3125,14 @@ static int test_org_20(void) presence and cadence of the tones for instance by a flashing light. The TUT may disconnect on reception of tones indicating a failed call attempt. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_20_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_20_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -2980,6 +3149,8 @@ static int test_org_20(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3028,9 +3199,13 @@ static int test_org_20(void) } /*- End of function --------------------------------------------------------*/ +static void org_21_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_21(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3053,14 +3228,14 @@ static int test_org_21(void) Comments: Some high speed modems may fall back to a compatibility mode, e.g. V.21 or V.23 that should be correctly detected by the TUT. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_21_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_21_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3077,6 +3252,8 @@ static int test_org_21(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3125,9 +3302,13 @@ static int test_org_21(void) } /*- End of function --------------------------------------------------------*/ +static void org_22_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_22(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3149,14 +3330,14 @@ static int test_org_22(void) Comments: Ideally the TUT should detect the presence of a fax machine and report it back to the user. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_22_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_22_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3173,6 +3354,8 @@ static int test_org_22(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3221,9 +3404,13 @@ static int test_org_22(void) } /*- End of function --------------------------------------------------------*/ +static void org_23_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_23(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3245,14 +3432,14 @@ static int test_org_23(void) Comments: Ideally the TUT should report the presence of speech back to the user, e.g. via circuit 135. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_23_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_23_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3269,6 +3456,8 @@ static int test_org_23(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3317,9 +3506,13 @@ static int test_org_23(void) } /*- End of function --------------------------------------------------------*/ +static void org_24_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_24(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3337,20 +3530,20 @@ static int test_org_24(void) Preamble: Make a V.18 call from the TUT. Method: The Test System waits for the TUT to stop transmitting a CI and responds with an ANSam signal. The V.21 demodulator is used to decode the CM sequence. ANSam - should be transmitted for 2 seconds. - Pass criteria: 1) No signal should be transmitted by TUT for 0.5 seconds from detection of + should be transmitted for 2s. + Pass criteria: 1) No signal should be transmitted by TUT for 0.5s from detection of ANSam. 2) The TUT should reply with transmission of CM as defined in 5.2.13. 3) Verify that CM sequence has correct bit pattern. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_24_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_24_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3367,6 +3560,8 @@ static int test_org_24(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3415,9 +3610,13 @@ static int test_org_24(void) } /*- End of function --------------------------------------------------------*/ +static void org_25_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_org_25(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3436,14 +3635,14 @@ static int test_org_25(void) Method: The Test System waits for the TUT to start transmitting V.21 carrier (1). Pass criteria: The TUT should connect by sending V.21 carrier (1). */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_25_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_25_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3460,6 +3659,8 @@ static int test_org_25(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3508,9 +3709,13 @@ static int test_org_25(void) } /*- End of function --------------------------------------------------------*/ +static void ans_01_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_01(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3523,21 +3728,21 @@ static int test_ans_01(void) /* III.5.4.3.1 Ta timer - Purpose: To ensure that on connecting the call, the DCE starts timer Ta (3 seconds) and on + Purpose: To ensure that on connecting the call, the DCE starts timer Ta (3s) and on expiry begins probing. Preamble: N/A Method: The tester makes a call to the TUT and attempts to determine when the TUT answers the call. It will then monitor for any signal. - Pass criteria: The TUT should start probing 3 seconds after answering the call. + Pass criteria: The TUT should start probing 3s after answering the call. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_01_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_01_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3554,6 +3759,8 @@ static int test_ans_01(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3602,9 +3809,13 @@ static int test_ans_01(void) } /*- End of function --------------------------------------------------------*/ +static void ans_02_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_02(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3619,21 +3830,21 @@ static int test_ans_02(void) III.5.4.3.2 CI signal detection Purpose: To confirm the correct detection and response to the V.18 CI signal. Preamble: N/A - Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. It will + Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2s. It will monitor for ANS and measure duration. Pass criteria: 1) The TUT should respond after either the first or second CI with ANSam tone. - 2) ANSam tone should remain for 3 seconds +-0.5 s followed by silence. + 2) ANSam tone should remain for 3s+-0.5s followed by silence. Comments: The ANSam tone is a modulated 2100Hz tone. It may have phase reversals. The XCI signal is tested in a separate test. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_02_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_02_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3650,6 +3861,8 @@ static int test_ans_02(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3698,9 +3911,13 @@ static int test_ans_02(void) } /*- End of function --------------------------------------------------------*/ +static void ans_03_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_03(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3716,24 +3933,24 @@ static int test_ans_03(void) Purpose: To confirm that the TUT will respond correctly to TXP signals, i.e. by stopping ANSam tone on reception of TXP signal. Preamble: N/A - Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. On - reception of the ANSam tone the tester will wait 0.5 seconds and then begin + Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2s. On + reception of the ANSam tone the tester will wait 0.5s and then begin transmitting the TXP signal in V.21 (1) mode. - Pass criteria: 1) On reception of the TXP signal, the TUT should remain silent for 75+-5 ms. + Pass criteria: 1) On reception of the TXP signal, the TUT should remain silent for 75+-5ms. 2) The TUT should then transmit 3 TXP sequences in V.21(2) mode. 3) The 3 TXPs should be followed by continuous 1650Hz. 4) Correct transmission and reception of T.140 data should be verified after the V.18 mode connection is completed. Comments: The TUT should indicate V.18 mode. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_03_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_03_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3750,6 +3967,8 @@ static int test_ans_03(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3798,9 +4017,13 @@ static int test_ans_03(void) } /*- End of function --------------------------------------------------------*/ +static void ans_04_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_04(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3817,17 +4040,17 @@ static int test_ans_04(void) timer Tt expires. Preamble: Successful completion of test ANS-03. Method: After completion of test ANS-03 the tester will continue to monitor for signals. - Pass criteria: The TUT should start probing 3 seconds after ANSam disappears. + Pass criteria: The TUT should start probing 3s after ANSam disappears. Comments: It is assumed that timer Ta is restarted on return to Monitor A. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_04_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_04_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3844,6 +4067,8 @@ static int test_ans_04(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3892,9 +4117,13 @@ static int test_ans_04(void) } /*- End of function --------------------------------------------------------*/ +static void ans_05_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_05(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -3910,19 +4139,19 @@ static int test_ans_05(void) Purpose: To check correct detection of V.21 modem lower channel when preceded by answer tone. Preamble: N/A - Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits - 980Hz and starts a 1 s timer. - Pass criteria: TUT should respond with 1650Hz within 400+-100 ms of start of 980Hz. + Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits + 980Hz and starts a 1s timer. + Pass criteria: TUT should respond with 1650Hz within 400+-100ms of start of 980Hz. Comments: The TUT should indicate that V.21 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_05_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_05_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -3939,6 +4168,8 @@ static int test_ans_05(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -3987,9 +4218,13 @@ static int test_ans_05(void) } /*- End of function --------------------------------------------------------*/ +static void ans_06_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_06(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4005,19 +4240,19 @@ static int test_ans_06(void) Purpose: To check correct detection of V.23 modem upper channel when preceded by answer tone. Preamble: N/A - Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits 1300Hz and starts a 2-s timer. - Pass criteria: TUT should respond with 390Hz after 1.7(+0.2-0.0) seconds of start of 1300Hz. + Pass criteria: TUT should respond with 390Hz after 1.7(+0.2-0.0)s of start of 1300Hz. Comments: The TUT should indicate that V.23 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_06_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_06_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4034,6 +4269,8 @@ static int test_ans_06(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4082,9 +4319,13 @@ static int test_ans_06(void) } /*- End of function --------------------------------------------------------*/ +static void ans_07_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_07(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4100,19 +4341,19 @@ static int test_ans_07(void) Purpose: To check correct detection of V.21 modem upper channel when preceded by answer tone and to confirm discrimination between V.21 and V.18 modes. Preamble: N/A - Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits 1650Hz and starts a 1-second timer. - Pass criteria: TUT should respond with 980Hz within 400+-100 ms of start of 1650Hz. + Pass criteria: TUT should respond with 980Hz within 400+-100ms of start of 1650Hz. Comments: The TUT should indicate that V.21 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_07_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_07_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4129,6 +4370,8 @@ static int test_ans_07(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4177,9 +4420,13 @@ static int test_ans_07(void) } /*- End of function --------------------------------------------------------*/ +static void ans_08_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_08(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4200,16 +4447,16 @@ static int test_ans_08(void) Pass criteria: The TUT should respond with the appropriate carrier depending on when it connects. Comments: The TUT should indicate a V.21 connection. The time for which each frequency is - transmitted is random and varies between 0.64 and 2.56 seconds. + transmitted is random and varies between 0.64 and 2.56s. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_08_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_08_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4226,6 +4473,8 @@ static int test_ans_08(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4274,9 +4523,13 @@ static int test_ans_08(void) } /*- End of function --------------------------------------------------------*/ +static void ans_09_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_09(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4291,21 +4544,21 @@ static int test_ans_09(void) III.5.4.3.9 980Hz calling tone detection Purpose: To confirm correct detection of 980Hz calling tones as defined in V.25. Preamble: N/A - Method: The tester will send bursts of 980Hz signals (a) 400 ms, (b) 500 ms, (c) 700 ms and - (d) 800 ms followed by 1 second of silence. - Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. - 2) The TUT should immediately begin probing after a burst of 980Hz for 500 or - 700 ms followed by 1 second of silence. + Method: The tester will send bursts of 980Hz signals (a) 400ms, (b) 500ms, (c) 700ms and + (d) 800ms followed by 1s of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms. + 2) The TUT should immediately begin probing after a burst of 980Hz for 500ms or + 700ms followed by 1s of silence. Comments: The probe sent by the TUT will depend on the country setting. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_09_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_09_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4322,6 +4575,8 @@ static int test_ans_09(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4370,9 +4625,13 @@ static int test_ans_09(void) } /*- End of function --------------------------------------------------------*/ +static void ans_10_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_10(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4388,18 +4647,18 @@ static int test_ans_10(void) Purpose: To confirm correct selection of V.21 calling modem when the received signal is not modulated, i.e. there is no 1180Hz. Preamble: N/A - Method: The tester sends 980Hz to TUT for 2 seconds. - Pass criteria: The TUT should respond with a 1650Hz tone in 1.5+-0.1 seconds. + Method: The tester sends 980Hz to TUT for 2s. + Pass criteria: The TUT should respond with a 1650Hz tone in 1.5+-0.1s. Comments: The TUT should indicate that V.21 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_10_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_10_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4416,6 +4675,8 @@ static int test_ans_10(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4464,9 +4725,13 @@ static int test_ans_10(void) } /*- End of function --------------------------------------------------------*/ +static void ans_11_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_11(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4490,14 +4755,14 @@ static int test_ans_11(void) be lost during the detection process. However, the number lost should be minimal. The data bits and parity are specified in Annex C. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_11_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_11_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4514,6 +4779,8 @@ static int test_ans_11(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4562,9 +4829,13 @@ static int test_ans_11(void) } /*- End of function --------------------------------------------------------*/ +static void ans_12_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_12(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4589,14 +4860,14 @@ static int test_ans_12(void) (1650Hz) probe. However, it is catered for in V.18. It is more likely that this is where CI or TXP characters would be detected (see test ANS-02). */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_12_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_12_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4613,6 +4884,8 @@ static int test_ans_12(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4661,9 +4934,13 @@ static int test_ans_12(void) } /*- End of function --------------------------------------------------------*/ +static void ans_13_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_13(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4677,24 +4954,24 @@ static int test_ans_13(void) /* III.5.4.3.13 Tr timer Purpose: To ensure that the TUT returns to the Monitor A state on expiry of timer Tr - (2 seconds). Timer Tr is started when a modulated V.21 (1) signal is detected. + (2s). Timer Tr is started when a modulated V.21 (1) signal is detected. Preamble: N/A - Method: The tester will transmit 980Hz for 200 ms followed by alternating 980Hz/1180Hz - at 110 bit/s for 100 ms followed by 980Hz for 1 second. - Pass criteria: The TUT should begin probing 4+-0.5 seconds after the 980Hz signal is removed. + Method: The tester will transmit 980Hz for 200ms followed by alternating 980Hz/1180Hz + at 110 bit/s for 100ms followed by 980Hz for 1s. + Pass criteria: The TUT should begin probing 4+-0.5s after the 980Hz signal is removed. Comments: It is not possible to be precise on timings for this test since the definition of a "modulated signal" as in 5.2.4.4 is not specified. Therefore it is not known exactly when timer Tr will start. It is assumed that timer Ta is restarted on re-entering the Monitor A state. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_13_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_13_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4711,6 +4988,8 @@ static int test_ans_13(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4759,9 +5038,13 @@ static int test_ans_13(void) } /*- End of function --------------------------------------------------------*/ +static void ans_14_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_14(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4775,21 +5058,21 @@ static int test_ans_14(void) /* III.5.4.3.14 Te timer Purpose: To ensure that the TUT returns to the Monitor A on expiry of timer Te - (2.7 seconds). Timer Te is started when a 980Hz signal is detected. + (2.7s). Timer Te is started when a 980Hz signal is detected. Preamble: N/A - Method: The tester will transmit 980Hz for 200 ms followed silence for 7 s. - Pass criteria: The TUT should begin probing 5.5+-0.5 seconds after the 980Hz signal is removed. - Comments: It is assumed that timer Ta (3 seconds) is restarted on re-entering the Monitor A + Method: The tester will transmit 980Hz for 200ms followed silence for 7 s. + Pass criteria: The TUT should begin probing 5.5+-0.5s after the 980Hz signal is removed. + Comments: It is assumed that timer Ta (3s) is restarted on re-entering the Monitor A state. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_14_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_14_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4806,6 +5089,8 @@ static int test_ans_14(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4854,9 +5139,13 @@ static int test_ans_14(void) } /*- End of function --------------------------------------------------------*/ +static void ans_15_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_15(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4887,14 +5176,14 @@ static int test_ans_15(void) automode answer state. The TUT may then select either 45.45 or 50 bit/s for the transmission. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_15_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_15_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -4911,6 +5200,8 @@ static int test_ans_15(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -4959,9 +5250,13 @@ static int test_ans_15(void) } /*- End of function --------------------------------------------------------*/ +static void ans_16_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_16(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -4976,21 +5271,21 @@ static int test_ans_16(void) III.5.4.3.16 DTMF signal detection Purpose: To verify whether the TUT correctly recognizes DTMF signals. Preamble: N/A - Method: The tester will send a single DTMF tone of 40 ms duration to TUT. When TUT + Method: The tester will send a single DTMF tone of 40ms duration to TUT. When TUT indicates a connection, type at least 5 characters back to the tester so that correct selection of mode can be confirmed. Pass criteria: Tester will analyse the received characters to confirm DTMF mode selection. Comments: The TUT should indicate that it has selected DTMF mode. The DTMF capabilities of the TUT should comply with ITU-T Q.24 for the Danish Administration. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_16_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_16_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5007,6 +5302,8 @@ static int test_ans_16(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5055,9 +5352,13 @@ static int test_ans_16(void) } /*- End of function --------------------------------------------------------*/ +static void ans_17_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_17(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5072,18 +5373,18 @@ static int test_ans_17(void) III.5.4.3.17 Bell 103 (1270Hz signal) detection Purpose: To ensure correct detection and selection of Bell 103 modems. Preamble: N/A - Method: The tester sends 1270Hz to TUT for 5 seconds. - Pass criteria: TUT should respond with 2225Hz tone after 0.7+-0.1 s. + Method: The tester sends 1270Hz to TUT for 5s. + Pass criteria: TUT should respond with 2225Hz tone after 0.7+-0.1s. Comments: The TUT should indicate that Bell 103 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_17_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_17_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5100,6 +5401,8 @@ static int test_ans_17(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5148,9 +5451,13 @@ static int test_ans_17(void) } /*- End of function --------------------------------------------------------*/ +static void ans_18_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_18(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5165,19 +5472,19 @@ static int test_ans_18(void) III.5.4.3.18 Bell 103 (2225Hz signal) detection Purpose: To ensure correct detection and selection of Bell 103 modems in reverse mode. Preamble: N/A - Method: The tester sends 2225Hz to TUT for 5 seconds. - Pass criteria: The TUT should respond with 1270Hz after 1+-0.2 seconds. + Method: The tester sends 2225Hz to TUT for 5s. + Pass criteria: The TUT should respond with 1270Hz after 1+-0.2s. Comments: The TUT should indicate that Bell 103 mode has been selected. Bell 103 modems use 2225Hz as both answer tone and higher frequency of the upper channel. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_18_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_18_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5194,6 +5501,8 @@ static int test_ans_18(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5242,9 +5551,13 @@ static int test_ans_18(void) } /*- End of function --------------------------------------------------------*/ +static void ans_19_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_19(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5259,18 +5572,18 @@ static int test_ans_19(void) III.5.4.3.19 V.21 Reverse mode (1650Hz) detection Purpose: To ensure correct detection and selection of V.21 reverse mode. Preamble: N/A - Method: The tester sends 1650Hz to TUT for 5 seconds. - Pass criteria: The TUT should respond with 980Hz after 0.4+-0.2 seconds. + Method: The tester sends 1650Hz to TUT for 5s. + Pass criteria: The TUT should respond with 980Hz after 0.4+-0.2s. Comments: The TUT should indicate that V.21 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_19_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_19_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5287,6 +5600,8 @@ static int test_ans_19(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5335,9 +5650,13 @@ static int test_ans_19(void) } /*- End of function --------------------------------------------------------*/ +static void ans_20_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_20(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5352,21 +5671,21 @@ static int test_ans_20(void) III.5.4.3.20 1300Hz calling tone discrimination Purpose: To confirm correct detection of 1300Hz calling tones as defined in ITU-T V.25. Preamble: N/A - Method: The tester will send 1300Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and - (d) 800 ms followed by 1 second of silence. - Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. - 2) The TUT should immediately begin probing after a burst of 1300Hz for 500 or - 700 ms followed by 1 second of silence. + Method: The tester will send 1300Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and + (d) 800ms followed by 1s of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms. + 2) The TUT should immediately begin probing after a burst of 1300Hz for 500ms or + 700ms followed by 1s of silence. Comments: The probe sent by the TUT will depend on the country setting. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_20_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_20_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5383,6 +5702,8 @@ static int test_ans_20(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5431,9 +5752,13 @@ static int test_ans_20(void) } /*- End of function --------------------------------------------------------*/ +static void ans_21_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_21(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5448,18 +5773,18 @@ static int test_ans_21(void) III.5.4.3.21 V.23 Reverse mode (1300Hz) detection Purpose: To ensure correct detection and selection of V.23 reverse mode. Preamble: N/A - Method: The tester sends 1300Hz only, with no XCI signals, to TUT for 5 seconds. - Pass criteria: The TUT should respond with 390Hz after 1.7+-0.1 seconds. + Method: The tester sends 1300Hz only, with no XCI signals, to TUT for 5s. + Pass criteria: The TUT should respond with 390Hz after 1.7+-0.1s. Comments: The TUT should indicate that V.23 mode has been selected. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_21_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_21_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5476,6 +5801,8 @@ static int test_ans_21(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5524,9 +5851,13 @@ static int test_ans_21(void) } /*- End of function --------------------------------------------------------*/ +static void ans_22_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_22(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5542,17 +5873,17 @@ static int test_ans_22(void) Purpose: To ensure correct detection of the XCI signal and selection of V.18 mode. Preamble: N/A Method: The tester sends XCI signal as defined in 3.11. On reception of ANS it will become - silent for 500 ms then transmit the TXP signal in V.21 (1) mode. + silent for 500ms then transmit the TXP signal in V.21 (1) mode. Pass criteria: The TUT should respond with TXP using V.21 (2) and select V.18 mode. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_22_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_22_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5569,6 +5900,8 @@ static int test_ans_22(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5617,9 +5950,13 @@ static int test_ans_22(void) } /*- End of function --------------------------------------------------------*/ +static void ans_23_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_23(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5641,14 +5978,14 @@ static int test_ans_23(void) Pass criteria: The TUT should use the orders described in Appendix I. Comments: The order of the probes is not mandatory. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_23_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_23_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5665,6 +6002,8 @@ static int test_ans_23(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5713,9 +6052,13 @@ static int test_ans_23(void) } /*- End of function --------------------------------------------------------*/ +static void ans_24_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_24(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5734,17 +6077,17 @@ static int test_ans_24(void) Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent by the TUT. Pass criteria: The TUT should send the user defined probe message for Annexes A, B, and C - modes followed by a pause of Tm (default 3) seconds. + modes followed by a pause of Tm (default 3)s. Comments: The carrierless modes are those described in Annexes A, B and C. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_24_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_24_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5761,6 +6104,8 @@ static int test_ans_24(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5809,9 +6154,13 @@ static int test_ans_24(void) } /*- End of function --------------------------------------------------------*/ +static void ans_25_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_25(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5825,22 +6174,22 @@ static int test_ans_25(void) /* III.5.4.3.25 Interrupted carrierless mode probe Purpose: To ensure that the TUT continues probing from the point of interruption a maximum - of 20 s after a failed connect attempt. + of 20s after a failed connect attempt. Preamble: The TUT should be configured for the UK country setting. Method: The tester will call the TUT, wait for Ta to expire and then during the pause after - the first Baudot probe it will send a 200 ms burst of 1270Hz followed by silence - for 30 s. + the first Baudot probe it will send a 200ms burst of 1270Hz followed by silence + for 30s. Pass criteria: The TUT should transmit silence on detecting the 1270Hz tone and then continue - probing starting with the V.23 probe 20 seconds after the end of the 1270Hz signal. + probing starting with the V.23 probe 20s after the end of the 1270Hz signal. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_25_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_25_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5857,6 +6206,8 @@ static int test_ans_25(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -5905,9 +6256,13 @@ static int test_ans_25(void) } /*- End of function --------------------------------------------------------*/ +static void ans_26_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_26(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -5920,23 +6275,23 @@ static int test_ans_26(void) /* III.5.4.3.26 Stimulate carrier mode probe time - Purpose: To ensure that the TUT sends each carrier mode for time Tc (default 6 seconds) + Purpose: To ensure that the TUT sends each carrier mode for time Tc (default 6s) preceded by the correct answer tone. Preamble: None. Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent by the TUT. - Pass criteria: The TUT should send the ANS tone (2100Hz) for 1 second followed by silence for - 75+-5 ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc. + Pass criteria: The TUT should send the ANS tone (2100Hz) for 1s followed by silence for + 75+-5ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc. Comments: The carrier modes are those described in Annexes D, E, and F. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_26_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_26_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -5953,6 +6308,8 @@ static int test_ans_26(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6001,9 +6358,13 @@ static int test_ans_26(void) } /*- End of function --------------------------------------------------------*/ +static void ans_27_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_27(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6019,24 +6380,24 @@ static int test_ans_27(void) Purpose: To confirm correct selection of V.23 mode. Preamble: N/A Method: The tester waits until the 1300Hz probe is detected from the TUT and then - transmits 390Hz for 11 seconds. - Pass criteria: 1) After 3 seconds of the 390Hz signal the TUT should indicate that V.23 has + transmits 390Hz for 11s. + Pass criteria: 1) After 3s of the 390Hz signal the TUT should indicate that V.23 has been selected. 2) The tester will confirm that the 1300Hz carrier is maintained for at least - 4 seconds beyond the normal probe duration, i.e. Tc (= 6 s default) + 4 s = - 10 seconds total. + 4s beyond the normal probe duration, i.e. Tc (= 6s default) + 4s = + 10s total. Comments: All known V.23 devices need to receive 1300Hz tone before they will respond with 390Hz. When the 1300Hz probe is not being transmitted, a 390Hz tone may be interpreted as a 400Hz network tone. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_27_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_27_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6053,6 +6414,8 @@ static int test_ans_27(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6101,9 +6464,13 @@ static int test_ans_27(void) } /*- End of function --------------------------------------------------------*/ +static void ans_28_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_28(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6117,24 +6484,24 @@ static int test_ans_28(void) /* III.5.4.3.28 Interrupted carrier mode probe Purpose: To ensure that the TUT continues probing from the point of interruption a maximum - of 4 s after a failed connect attempt. + of 4s after a failed connect attempt. Preamble: The TUT should be configured for the UK country setting. Method: The tester will call the TUT, wait for Ta to expire and then during the first V.21 - probe it will send a 200 ms burst of 1270Hz followed by silence for 30 s. + probe it will send a 200ms burst of 1270Hz followed by silence for 30s. Pass criteria: The TUT should transmit silence on detecting the 1270Hz tone and then continue - probing with the Baudot stored message 4 seconds after the end of the 1270Hz + probing with the Baudot stored message 4s after the end of the 1270Hz burst. - Comments: It is most likely that the TUT will return to probing time Ta (3 seconds) after the + Comments: It is most likely that the TUT will return to probing time Ta (3s) after the 1270Hz tone ceases. This condition needs further clarification. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_28_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_28_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6151,6 +6518,8 @@ static int test_ans_28(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6199,9 +6568,13 @@ static int test_ans_28(void) } /*- End of function --------------------------------------------------------*/ +static void ans_29_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_29(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6224,14 +6597,14 @@ static int test_ans_29(void) Comments: The TUT may not respond to any signals while a carrierless mode probe is being sent since these modes are half duplex. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_29_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_29_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6248,6 +6621,8 @@ static int test_ans_29(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6296,9 +6671,13 @@ static int test_ans_29(void) } /*- End of function --------------------------------------------------------*/ +static void ans_30_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_30(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6323,14 +6702,14 @@ static int test_ans_30(void) tones may be ignored. Some devices may only provide a visual indication of the presence and cadence of the tones for instance by a flashing light. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_30_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_30_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6347,6 +6726,8 @@ static int test_ans_30(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6395,9 +6776,13 @@ static int test_ans_30(void) } /*- End of function --------------------------------------------------------*/ +static void ans_31_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_31(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6413,20 +6798,20 @@ static int test_ans_31(void) Purpose: To determine whether the TUT can discriminate fax calling tones. Preamble: N/A Method: The tester will call the TUT and send the fax calling tone, CNG. This is an 1100Hz - tone with cadence of 0.5 seconds ON and 3 seconds OFF as defined in ITU-T T.30. + tone with cadence of 0.5s ON and 3s OFF as defined in ITU-T T.30. Pass criteria: The TUT should not respond to this signal and may report it as being a calling fax machine. Comments: This is an optional test as detection of the fax calling tone is not required by ITU-T V.18. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_31_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_31_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6443,6 +6828,8 @@ static int test_ans_31(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6491,9 +6878,13 @@ static int test_ans_31(void) } /*- End of function --------------------------------------------------------*/ +static void ans_32_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_32(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6515,14 +6906,14 @@ static int test_ans_32(void) Comments: Ideally the TUT should report the presence of speech back to the user. This is an optional test. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_32_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_32_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6539,6 +6930,8 @@ static int test_ans_32(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6587,9 +6980,13 @@ static int test_ans_32(void) } /*- End of function --------------------------------------------------------*/ +static void ans_33_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_ans_33(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6605,8 +7002,8 @@ static int test_ans_33(void) Purpose: To confirm that the TUT will respond correctly to CM signals and connect according to V.8 procedures. Preamble: N/A - Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. On - reception of the ANSam tone the tester will wait 0.5 seconds and then begin + Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2s. On + reception of the ANSam tone the tester will wait 0.5s and then begin transmitting the CM signal with textphone and V.21 specified. Pass criteria: 1) On reception of the CM signal, the TUT should transmit JM with textphone and V.21. @@ -6616,14 +7013,14 @@ static int test_ans_33(void) V.18 mode connection is completed. Comments: The TUT should indicate V.18 mode. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_33_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_33_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6640,6 +7037,8 @@ static int test_ans_33(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6688,6 +7087,11 @@ static int test_ans_33(void) } /*- End of function --------------------------------------------------------*/ +static void mon_01_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_mon_01(void) { printf("Test not yet implemented\n"); @@ -6695,9 +7099,13 @@ static int test_mon_01(void) } /*- End of function --------------------------------------------------------*/ +static void mon_21_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_mon_21(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6710,21 +7118,21 @@ static int test_mon_21(void) /* III.5.4.4.1 Automode monitor Ta timer test - Purpose: To ensure that on entering monitor mode, timer Ta (3 seconds) is not active and that + Purpose: To ensure that on entering monitor mode, timer Ta (3s) is not active and that the TUT does not enter the probing state. Preamble: N/A Method: The TUT should be put into monitor state. The tester will then monitor for signals for 1 minute. Pass criteria: The TUT should not start probing. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_21_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_21_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6741,6 +7149,8 @@ static int test_mon_21(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6789,9 +7199,13 @@ static int test_mon_21(void) } /*- End of function --------------------------------------------------------*/ +static void mon_22_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_mon_22(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6807,22 +7221,22 @@ static int test_mon_22(void) Purpose: To confirm correct detection and reporting of 1300Hz calling tones as defined in ITU-T V.25. Preamble: N/A - Method: The tester will send 1300Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and - (d) 800 ms followed by 1 second of silence. - Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. + Method: The tester will send 1300Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and + (d) 800ms followed by 1s of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms. 2) The TUT should report detection of calling tones to the DTE after a burst of - 1300Hz for 500 or 700 ms followed by 1 second of silence. + 1300Hz for 500ms or 700ms followed by 1s of silence. Comments: In automode answer, the 1300Hz calling causes the DCE to start probing. In monitor mode it should only report detection to the DTE. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_22_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_22_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6839,6 +7253,8 @@ static int test_mon_22(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6887,9 +7303,13 @@ static int test_mon_22(void) } /*- End of function --------------------------------------------------------*/ +static void mon_23_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_mon_23(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -6905,22 +7325,22 @@ static int test_mon_23(void) Purpose: To confirm correct detection and reporting of 980Hz calling tones as defined in ITU-T V.25. Preamble: N/A - Method: The tester will send 980Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and - (d) 800 ms followed by 1 second of silence. - Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. + Method: The tester will send 980Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and + (d) 800ms followed by 1s of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms. 2) The TUT should report detection of calling tones to the DTE after a burst of - 980Hz for 500 or 700 ms followed by 1 second of silence. + 980Hz for 500ms or 700ms followed by 1s of silence. Comments: In automode answer, the 980Hz calling causes the DCE to start probing. In monitor mode it should only report detection to the DTE. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_23_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_23_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -6937,6 +7357,8 @@ static int test_mon_23(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -6989,7 +7411,7 @@ static void x_01_put_text_msg(void *user_data, const uint8_t *msg, int len) { printf("1-1 %d '%s'\n", len, msg); if (user_data == NULL) - strcat(result, (const char *) msg); + strcat(result[1], (const char *) msg); else v18_put(v18[1], "abcdefghij", 10); } @@ -7010,26 +7432,26 @@ static int test_x_01(void) /* III.5.4.5.1 Baudot carrier timing and receiver disabling - Purpose: To verify that the TUT sends unmodulated carrier for 150 ms before a new character - and disables its receiver for 300 ms after a character is transmitted. + Purpose: To verify that the TUT sends unmodulated carrier for 150ms before a new character + and disables its receiver for 300ms after a character is transmitted. Preamble: Establish a call between the tester and TUT in Baudot mode. Method: The operator should send a single character from the TUT. The tester will immediately start sending a unique character sequence. Examination of the TUT display will show when its receiver is re-enabled. - Pass criteria: 1) The TUT should send unmodulated carrier for 150 ms before the beginning of + Pass criteria: 1) The TUT should send unmodulated carrier for 150ms before the beginning of the start bit. - 2) The receiver should be re-enabled after 300 ms. + 2) The receiver should be re-enabled after 300ms. 3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used. - Comments: The carrier should be maintained during the 300 ms after a character. + Comments: The carrier should be maintained during the 300ms after a character. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, x_01_put_text_msg, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, x_01_put_text_msg, (void *) (intptr_t) 1); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7046,7 +7468,9 @@ static int test_x_01(void) exit(2); } - v18_put(v18[0], "z", 1); + result[0][0] = + result[1][0] = '\0'; + v18_put(v18[0], "zabcdefghijklmnopq", -1); for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -7091,17 +7515,21 @@ static int test_x_01(void) v18_free(v18[0]); v18_free(v18[1]); ref = "cdefghij"; - printf("Result:\n%s\n", result); + printf("Result:\n%s\n", result[1]); printf("Reference result:\n%s\n", ref); - if (unexpected_echo || strcmp(result, ref) != 0) + if (unexpected_echo || strcmp(result[1], ref) != 0) return -1; return 1; } /*- End of function --------------------------------------------------------*/ +static void x_02_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_02(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7121,14 +7549,14 @@ static int test_x_02(void) transmit the string "abcdef" at each rate. Pass criteria: The tester will measure the bit timings and confirm the rates. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_02_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_02_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7145,6 +7573,8 @@ static int test_x_02(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -7193,9 +7623,13 @@ static int test_x_02(void) } /*- End of function --------------------------------------------------------*/ +static void x_03_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_03(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7218,14 +7652,14 @@ static int test_x_03(void) Comments: The probe message must be long enough for the tester to establish the bit rate. "GA" may not be sufficient. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_5BIT_4545, V18_AUTOMODING_USA, x_03_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_5BIT_4545, V18_AUTOMODING_USA, x_03_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7242,6 +7676,8 @@ static int test_x_03(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -7290,24 +7726,27 @@ static int test_x_03(void) } /*- End of function --------------------------------------------------------*/ -static void x_04_put_echo_text_msg(void *user_data, const uint8_t *msg, int len) -{ - printf("Unexpected ECHO received (%d) '%s'\n", len, msg); - unexpected_echo = TRUE; -} -/*- End of function --------------------------------------------------------*/ - static void x_04_put_text_msg(void *user_data, const uint8_t *msg, int len) { + if (user_data == NULL) + { + strcat(result[0], (const char *) msg); +printf("Unexpected ECHO received (%d) '%s'\n", len, msg); + unexpected_echo = true; + } + else + { printf("1-1 %d '%s'\n", len, msg); - strcat(result, (const char *) msg); + strcat(result[1], (const char *) msg); + /* Echo each received character */ + //v18_put(v18[1], msg, len); + } } /*- End of function --------------------------------------------------------*/ static int test_x_04(void) { char msg[1024]; - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7336,14 +7775,14 @@ static int test_x_04(void) assumed that the character conversion is the same for Baudot at 50 bit/s and any other supported speed. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, x_04_put_echo_text_msg, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION, V18_AUTOMODING_GLOBAL, x_04_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, x_04_put_text_msg, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION, V18_AUTOMODING_GLOBAL, x_04_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7360,14 +7799,15 @@ static int test_x_04(void) exit(2); } - result[0] = '\0'; - unexpected_echo = FALSE; + result[0][0] = + result[1][0] = '\0'; + unexpected_echo = false; for (i = 0; i < 127; i++) msg[i] = i + 1; msg[127] = '\0'; v18_put(v18[0], msg, 127); - for (i = 0; i < 1000; i++) + for (i = 0; i < 2000; i++) { for (j = 0; j < 2; j++) { @@ -7409,9 +7849,10 @@ static int test_x_04(void) v18_free(v18[0]); v18_free(v18[1]); - printf("Result:\n%s\n", result); + printf("Result:\n%s\n", result[0]); + printf("Result:\n%s\n", result[1]); printf("Reference result:\n%s\n", full_baudot_rx); - if (unexpected_echo || strcmp(result, full_baudot_rx) != 0) + if (unexpected_echo || strcmp(result[1], full_baudot_rx) != 0) return -1; return 0; } @@ -7420,9 +7861,18 @@ static int test_x_04(void) static void x_05_put_text_msg(void *user_data, const uint8_t *msg, int len) { if (user_data == NULL) - strcat(result, (const char *) msg); + { + /* Gather the received characters, which should be like the transmitted characters, + but with the first three characters missing. */ + strcat(result[0], (const char *) msg); + } else + { + /* Receiving a character from the far end should block out its receiver + for a while. If we send a stream of DTMF back, the first few characters + (actually 3 for this particular text string) should be lost. */ v18_put(v18[1], "behknqtwz", 9); + } } /*- End of function --------------------------------------------------------*/ @@ -7441,23 +7891,23 @@ static int test_x_05(void) /* III.5.4.5.5 DTMF receiver disabling - Purpose: To verify that the TUT disables its DTMF receiver for 300 ms when a character is + Purpose: To verify that the TUT disables its DTMF receiver for 300ms when a character is transmitted. Preamble: Establish a call between the tester and TUT in DTMF mode. Method: The operator should send a single "e" character from the TUT which will result in sending a single DTMF tone to the tester. The tester will immediately start sending a unique character sequence using single DTMF tones. Examination of the TUT display will show when its receiver is re-enabled. - Pass criteria: The receiver should be re-enabled after 300 ms. + Pass criteria: The receiver should be re-enabled after 300ms. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, x_05_put_text_msg, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_05_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, x_05_put_text_msg, (void *) (intptr_t) 1); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_05_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7474,8 +7924,10 @@ static int test_x_05(void) exit(2); } - result[0] = '\0'; - v18_put(v18[0], "e", 1); + result[0][0] = + result[1][0] = '\0'; + /* Sending a character should block out the receiver for a while */ + v18_put(v18[0], "z", 1); for (i = 0; i < 1000; i++) { @@ -7521,9 +7973,9 @@ static int test_x_05(void) v18_free(v18[0]); v18_free(v18[1]); ref = "knqtwz"; - printf("Result:\n%s\n", result); + printf("Result:\n%s\n", result[0]); printf("Reference result:\n%s\n", ref); - if (strcmp(result, ref) != 0) + if (strcmp(result[0], ref) != 0) return -1; return 0; } @@ -7531,16 +7983,17 @@ static int test_x_05(void) static void x_06_put_text_msg(void *user_data, const uint8_t *msg, int len) { - strcat(result, (const char *) msg); + if (user_data == NULL) + ; + else + strcat(result[1], (const char *) msg); } /*- End of function --------------------------------------------------------*/ static int test_x_06(void) { char msg[128]; - char dtmf[1024]; const char *ref; - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7560,19 +8013,19 @@ static int test_x_06(void) after each one. Each character should be responded to at the TUT by typing the same character. Pass criteria: The tester will verify that each character is correctly echoed back by the TUT. - Comments: The conversion table is specified in Annex B. The receiver at the tester may be re- - enabled 100 ms after transmission of each character to maximize likelihood of + Comments: The conversion table is specified in Annex B. The receiver at the tester may be + re-enabled 100ms after transmission of each character to maximize likelihood of receiving character from the TUT. It is assumed that the echo delay in the test system is negligible. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, x_06_put_text_msg, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7589,15 +8042,12 @@ static int test_x_06(void) exit(2); } - result[0] = '\0'; + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 127; i++) msg[i] = i + 1; msg[127] = '\0'; - printf("Original:\n%s\n", msg); - - v18_encode_dtmf(NULL, dtmf, msg); - printf("DTMF:\n%s\n", dtmf); - v18_decode_dtmf(NULL, result, dtmf); + v18_put(v18[0], msg, 127); for (i = 0; i < 10000; i++) { @@ -7640,23 +8090,27 @@ static int test_x_06(void) v18_rx(v18[1], model_amp[0], samples); } - ref = "\b \n\n\n?\n\n\n %+().+,-.0123456789:;(=)" - "?XABCDEFGHIJKLMNOPQRSTUVWXYZ\xC6\xD8\xC5" + ref = "\b \n\n\n?\n\n\n !%+().+,-.0123456789:;(=)?" + "XABCDEFGHIJKLMNOPQRSTUVWXYZ\xC6\xD8\xC5" " abcdefghijklmnopqrstuvwxyz\xE6\xF8\xE5 \b"; - printf("Result:\n%s\n", result); + printf("Result:\n%s\n", result[0]); printf("Reference result:\n%s\n", ref); v18_free(v18[0]); v18_free(v18[1]); - if (strcmp(result, ref) != 0) + if (strcmp(result[1], ref) != 0) return -1; return 0; } /*- End of function --------------------------------------------------------*/ +static void x_07_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_07(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7669,26 +8123,26 @@ static int test_x_07(void) /* III.5.4.5.7 EDT carrier timing and receiver disabling - Purpose: To verify that the TUT sends unmodulated carrier for 300 ms before a character and - disables its receiver for 300 ms after a character is transmitted. + Purpose: To verify that the TUT sends unmodulated carrier for 300ms before a character and + disables its receiver for 300ms after a character is transmitted. Preamble: Establish a call between the tester and TUT in EDT mode. Method: The operator should send a single character from the TUT. The tester will immediately start sending a unique character sequence. Examination of the TUT display will show when its receiver is re-enabled. - Pass criteria: 1) The TUT should send unmodulated carrier for 300 ms before the beginning of + Pass criteria: 1) The TUT should send unmodulated carrier for 300ms before the beginning of the start bit. - 2) The receiver should be re-enabled after 300 ms. + 2) The receiver should be re-enabled after 300ms. 3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used. - Comments: The carrier should be maintained during the 300 ms after a character. + Comments: The carrier should be maintained during the 300ms after a character. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_07_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_07_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7705,6 +8159,8 @@ static int test_x_07(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -7753,9 +8209,13 @@ static int test_x_07(void) } /*- End of function --------------------------------------------------------*/ +static void x_08_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_08(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7776,14 +8236,14 @@ static int test_x_08(void) 2) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop bits are used. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_08_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_08_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7800,6 +8260,8 @@ static int test_x_08(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -7848,9 +8310,13 @@ static int test_x_08(void) } /*- End of function --------------------------------------------------------*/ +static void x_09_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_09(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7874,14 +8340,14 @@ static int test_x_09(void) that there are no duplicate characters on the TUT display. 3) The received string should be correctly displayed despite the incorrect parity. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_09_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_09_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7898,6 +8364,8 @@ static int test_x_09(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -7946,9 +8414,13 @@ static int test_x_09(void) } /*- End of function --------------------------------------------------------*/ +static void x_10_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_10(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -7975,14 +8447,14 @@ static int test_x_10(void) Comments: This test is only applicable to Minitel Dialogue terminals. Prestel and Minitel Normal terminals cannot operate in this mode. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_10_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_10_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -7999,6 +8471,8 @@ static int test_x_10(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -8047,9 +8521,13 @@ static int test_x_10(void) } /*- End of function --------------------------------------------------------*/ +static void x_11_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_11(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -8074,14 +8552,14 @@ static int test_x_11(void) 4) The last five characters on the TUT display should be "12345" (no "6") correctly displayed despite the incorrect parity. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_11_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_11_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -8098,6 +8576,8 @@ static int test_x_11(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -8146,9 +8626,13 @@ static int test_x_11(void) } /*- End of function --------------------------------------------------------*/ +static void x_12_put_text_msg(void *user_data, const uint8_t *msg, int len) +{ +} +/*- End of function --------------------------------------------------------*/ + static int test_x_12(void) { - v18_state_t *v18[2]; logging_state_t *logging; int16_t amp[2][SAMPLES_PER_CHUNK]; int16_t model_amp[2][SAMPLES_PER_CHUNK]; @@ -8170,14 +8654,14 @@ static int test_x_12(void) Pass criteria: The tester should confirm UTF8 encoded UNICODE characters are used with the controls specified in ITU-T T.140. */ - v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, NULL, NULL); + v18[0] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_12_put_text_msg, (void *) (intptr_t) 0); logging = v18_get_logging_state(v18[0]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "A"); - v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, NULL, NULL); + span_log_set_tag(logging, "Tester"); + v18[1] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_12_put_text_msg, (void *) (intptr_t) 1); logging = v18_get_logging_state(v18[1]); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_tag(logging, "B"); + span_log_set_tag(logging, "TUT"); if ((model = both_ways_line_model_init(line_model_no, (float) noise_level, @@ -8194,6 +8678,8 @@ static int test_x_12(void) exit(2); } + result[0][0] = + result[1][0] = '\0'; for (i = 0; i < 10000; i++) { for (j = 0; j < 2; j++) @@ -8267,7 +8753,7 @@ static int decode_test_data_file(int mode, const char *filename) fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file); exit(2); } - v18_state = v18_init(NULL, FALSE, mode, put_v18_msg, NULL); + v18_state = v18_init(NULL, false, mode, V18_AUTOMODING_GLOBAL, put_v18_msg, NULL); logging = v18_get_logging_state(v18_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, ""); @@ -8393,7 +8879,7 @@ int main(int argc, char *argv[]) { int i; int res; - int hit; + bool hit; const char *match; int test_standard; int opt; @@ -8408,7 +8894,7 @@ int main(int argc, char *argv[]) decode_test_file = optarg; break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 's': test_standard = atoi(optarg); @@ -8439,7 +8925,7 @@ int main(int argc, char *argv[]) } } - hit = FALSE; + hit = false; for (i = 0; test_list[i].title[0]; i++) { if (test_list[i].func @@ -8450,7 +8936,7 @@ int main(int argc, char *argv[]) && test_list[i].title[strlen(match)] == ' '))) { - hit = TRUE; + hit = true; printf("%s\n", test_list[i].title); res = test_list[i].func(); if (res < 0) @@ -8474,8 +8960,8 @@ int main(int argc, char *argv[]) printf("Test not found\n"); exit(2); } - basic_tests(V18_MODE_5BIT_45); - basic_tests(V18_MODE_5BIT_45 | 0x100); + basic_tests(V18_MODE_5BIT_4545); + basic_tests(V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION); if (log_audio) { if (sf_close_telephony(outhandle)) diff --git a/libs/spandsp/tests/v22bis_tests.c b/libs/spandsp/tests/v22bis_tests.c index aade32c726..3729687c35 100644 --- a/libs/spandsp/tests/v22bis_tests.c +++ b/libs/spandsp/tests/v22bis_tests.c @@ -63,7 +63,7 @@ display of modem status is maintained. #define OUT_FILE_NAME "v22bis.wav" char *decode_test_file = NULL; -int use_gui = FALSE; +bool use_gui = false; int rx_bits = 0; @@ -266,11 +266,11 @@ int main(int argc, char *argv[]) int bits_per_test; int noise_level; int signal_level; - int log_audio; int channel_codec; int rbs_pattern; int guard_tone_option; int opt; + bool log_audio; channel_codec = MUNGE_CODEC_NONE; rbs_pattern = 0; @@ -281,7 +281,7 @@ int main(int argc, char *argv[]) signal_level = -13; bits_per_test = 50000; guard_tone_option = V22BIS_GUARD_TONE_1800HZ; - log_audio = FALSE; + log_audio = false; while ((opt = getopt(argc, argv, "b:B:c:d:gG:lm:n:r:s:")) != -1) { switch (opt) @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); @@ -315,7 +315,7 @@ int main(int argc, char *argv[]) guard_tone_option = atoi(optarg); break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': line_model_no = atoi(optarg); diff --git a/libs/spandsp/tests/v27ter_tests.c b/libs/spandsp/tests/v27ter_tests.c index cb1b74a88c..671fd935af 100644 --- a/libs/spandsp/tests/v27ter_tests.c +++ b/libs/spandsp/tests/v27ter_tests.c @@ -78,7 +78,7 @@ display of modem status is maintained. #define OUT_FILE_NAME "v27ter.wav" char *decode_test_file = NULL; -int use_gui = FALSE; +bool use_gui = false; int symbol_no = 0; @@ -341,30 +341,30 @@ int main(int argc, char *argv[]) SNDFILE *outhandle; int outframes; int samples; - int tep; int test_bps; int noise_level; int signal_level; int bits_per_test; int line_model_no; int block_no; - int log_audio; int channel_codec; int rbs_pattern; int opt; + bool tep; + bool log_audio; logging_state_t *logging; channel_codec = MUNGE_CODEC_NONE; rbs_pattern = 0; test_bps = 4800; - tep = FALSE; + tep = false; line_model_no = 0; decode_test_file = NULL; - use_gui = FALSE; + use_gui = false; noise_level = -70; signal_level = -13; bits_per_test = 50000; - log_audio = FALSE; + log_audio = false; while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:r:s:t")) != -1) { switch (opt) @@ -388,14 +388,14 @@ int main(int argc, char *argv[]) break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); #endif break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': line_model_no = atoi(optarg); @@ -410,7 +410,7 @@ int main(int argc, char *argv[]) signal_level = atoi(optarg); break; case 't': - tep = TRUE; + tep = true; break; default: //usage(); @@ -537,7 +537,7 @@ int main(int argc, char *argv[]) signal_level--; v27ter_tx_restart(tx, test_bps, tep); v27ter_tx_power(tx, signal_level); - v27ter_rx_restart(rx, test_bps, FALSE); + v27ter_rx_restart(rx, test_bps, false); bert_init(&bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20); bert_set_report(&bert, 10000, reporter, NULL); one_way_line_model_release(line_model); diff --git a/libs/spandsp/tests/v29_tests.c b/libs/spandsp/tests/v29_tests.c index 246c217fd1..ec678c148a 100644 --- a/libs/spandsp/tests/v29_tests.c +++ b/libs/spandsp/tests/v29_tests.c @@ -78,7 +78,7 @@ display of modem status is maintained. #define OUT_FILE_NAME "v29.wav" char *decode_test_file = NULL; -int use_gui = FALSE; +bool use_gui = false; int symbol_no = 0; int rx_bits = 0; @@ -315,30 +315,30 @@ int main(int argc, char *argv[]) SNDFILE *outhandle; int outframes; int samples; - int tep; int test_bps; int noise_level; int signal_level; int bits_per_test; int line_model_no; int block_no; - int log_audio; int channel_codec; int rbs_pattern; int opt; + bool tep; + bool log_audio; logging_state_t *logging; channel_codec = MUNGE_CODEC_NONE; rbs_pattern = 0; test_bps = 9600; - tep = FALSE; + tep = false; line_model_no = 0; decode_test_file = NULL; - use_gui = FALSE; + use_gui = false; noise_level = -70; signal_level = -13; bits_per_test = 50000; - log_audio = FALSE; + log_audio = false; while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:r:s:t")) != -1) { switch (opt) @@ -362,14 +362,14 @@ int main(int argc, char *argv[]) break; case 'g': #if defined(ENABLE_GUI) - use_gui = TRUE; + use_gui = true; #else fprintf(stderr, "Graphical monitoring not available\n"); exit(2); #endif break; case 'l': - log_audio = TRUE; + log_audio = true; break; case 'm': line_model_no = atoi(optarg); @@ -384,7 +384,7 @@ int main(int argc, char *argv[]) signal_level = atoi(optarg); break; case 't': - tep = TRUE; + tep = true; break; default: //usage(); @@ -514,7 +514,7 @@ int main(int argc, char *argv[]) signal_level--; v29_tx_restart(tx, test_bps, tep); v29_tx_power(tx, signal_level); - v29_rx_restart(rx, test_bps, FALSE); + v29_rx_restart(rx, test_bps, false); #if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES) rx->eq_put_step = rand()%(48*10/3); #endif diff --git a/libs/spandsp/tests/v42_tests.c b/libs/spandsp/tests/v42_tests.c index fc4a9b17cc..727b5a8b58 100644 --- a/libs/spandsp/tests/v42_tests.c +++ b/libs/spandsp/tests/v42_tests.c @@ -128,14 +128,14 @@ static void v42_put_frames(void *user_data, const uint8_t msg[], int len) { if (++count == 5) { - v42_set_local_busy_status(s, TRUE); + v42_set_local_busy_status(s, true); xxx = 1; } } else { if (xxx && ++count == 45) - v42_set_local_busy_status(caller, FALSE); + v42_set_local_busy_status(caller, false); } } /*- End of function --------------------------------------------------------*/ @@ -144,13 +144,13 @@ int main(int argc, char *argv[]) { int i; int bit; - int insert_caller_bit_errors; - int insert_answerer_bit_errors; + bool insert_caller_bit_errors; + bool insert_answerer_bit_errors; int opt; - insert_caller_bit_errors = FALSE; - insert_answerer_bit_errors = FALSE; - variable_length = FALSE; + insert_caller_bit_errors = false; + insert_answerer_bit_errors = false; + variable_length = false; while ((opt = getopt(argc, argv, "bv")) != -1) { switch (opt) @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) insert_answerer_bit_errors = 10000; break; case 'v': - variable_length = TRUE; + variable_length = true; break; default: //usage(); @@ -169,8 +169,8 @@ int main(int argc, char *argv[]) } } - caller = v42_init(&callerx, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) &callerx); - answerer = v42_init(&answererx, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) &answererx); + caller = v42_init(&callerx, true, true, v42_get_frames, v42_put_frames, (void *) &callerx); + answerer = v42_init(&answererx, false, true, v42_get_frames, v42_put_frames, (void *) &answererx); v42_set_status_callback(caller, v42_status, (void *) caller); v42_set_status_callback(answerer, v42_status, (void *) answerer); v42_restart(caller); diff --git a/libs/spandsp/tests/v42bis_tests.c b/libs/spandsp/tests/v42bis_tests.c index cc95967c54..2ce718feba 100644 --- a/libs/spandsp/tests/v42bis_tests.c +++ b/libs/spandsp/tests/v42bis_tests.c @@ -82,8 +82,8 @@ int main(int argc, char *argv[]) int v42bis_fd; int out_fd; int do_compression; - int do_decompression; - int stutter_compression; + bool do_decompression; + bool stutter_compression; int stutter_time; int seg; int opt; @@ -94,21 +94,21 @@ int main(int argc, char *argv[]) const char *decompressed_file; argv0 = argv[0]; - do_compression = FALSE; - do_decompression = FALSE; - stutter_compression = FALSE; + do_compression = false; + do_decompression = false; + stutter_compression = false; while ((opt = getopt(argc, argv, "cds")) != -1) { switch (opt) { case 'c': - do_compression = TRUE; + do_compression = true; break; case 'd': - do_decompression = TRUE; + do_decompression = true; break; case 's': - stutter_compression = TRUE; + stutter_compression = true; break; default: //usage(); diff --git a/libs/spandsp/tests/v8_tests.c b/libs/spandsp/tests/v8_tests.c index d9ef7b82b9..df9243691e 100644 --- a/libs/spandsp/tests/v8_tests.c +++ b/libs/spandsp/tests/v8_tests.c @@ -41,9 +41,6 @@ #include "spandsp.h" #include "spandsp-sim.h" -#define FALSE 0 -#define TRUE (!FALSE) - #define SAMPLES_PER_CHUNK 160 #define OUTPUT_FILE_NAME "v8.wav" @@ -202,7 +199,7 @@ static int v8_calls_v8_tests(SNDFILE *outhandle) negotiations_ok = 0; v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE; - v8_call_parms.send_ci = TRUE; + v8_call_parms.send_ci = true; v8_call_parms.v92 = -1; v8_call_parms.call_function = V8_CALL_V_SERIES; v8_call_parms.modulations = caller_available_modulations; @@ -212,12 +209,12 @@ static int v8_calls_v8_tests(SNDFILE *outhandle) v8_call_parms.nsf = -1; v8_call_parms.t66 = -1; v8_caller = v8_init(NULL, - TRUE, + true, &v8_call_parms, handler, (void *) "caller"); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; - v8_answer_parms.send_ci = TRUE; + v8_answer_parms.send_ci = true; v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; @@ -227,7 +224,7 @@ static int v8_calls_v8_tests(SNDFILE *outhandle) v8_answer_parms.nsf = -1; v8_answer_parms.t66 = -1; v8_answerer = v8_init(NULL, - FALSE, + false, &v8_answer_parms, handler, (void *) "answerer"); @@ -329,7 +326,7 @@ static int non_v8_calls_v8_tests(SNDFILE *outhandle) non_v8_caller_rx = modem_connect_tones_rx_init(NULL, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; - v8_answer_parms.send_ci = TRUE; + v8_answer_parms.send_ci = true; v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; @@ -339,7 +336,7 @@ static int non_v8_calls_v8_tests(SNDFILE *outhandle) v8_answer_parms.nsf = -1; v8_answer_parms.t66 = -1; v8_answerer = v8_init(NULL, - FALSE, + false, &v8_answer_parms, handler, (void *) "answerer"); @@ -441,7 +438,7 @@ static int v8_calls_non_v8_tests(SNDFILE *outhandle) negotiations_ok = 0; v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE; - v8_call_parms.send_ci = TRUE; + v8_call_parms.send_ci = true; v8_call_parms.v92 = -1; v8_call_parms.call_function = V8_CALL_V_SERIES; v8_call_parms.modulations = caller_available_modulations; @@ -451,7 +448,7 @@ static int v8_calls_non_v8_tests(SNDFILE *outhandle) v8_call_parms.nsf = -1; v8_call_parms.t66 = -1; v8_caller = v8_init(NULL, - TRUE, + true, &v8_call_parms, handler, (void *) "caller"); @@ -522,7 +519,7 @@ int main(int argc, char *argv[]) SNDFILE *inhandle; SNDFILE *outhandle; int opt; - int log_audio; + bool log_audio; char *decode_test_file; v8_state_t *v8_caller; v8_state_t *v8_answerer; @@ -531,7 +528,7 @@ int main(int argc, char *argv[]) logging_state_t *logging; decode_test_file = NULL; - log_audio = FALSE; + log_audio = false; while ((opt = getopt(argc, argv, "d:l")) != -1) { switch (opt) @@ -540,7 +537,7 @@ int main(int argc, char *argv[]) decode_test_file = optarg; break; case 'l': - log_audio = TRUE; + log_audio = true; break; default: //usage(); @@ -582,7 +579,7 @@ int main(int argc, char *argv[]) printf("Decode file '%s'\n", decode_test_file); v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE; - v8_call_parms.send_ci = TRUE; + v8_call_parms.send_ci = true; v8_call_parms.v92 = -1; v8_call_parms.call_function = V8_CALL_V_SERIES; v8_call_parms.modulations = caller_available_modulations; @@ -592,7 +589,7 @@ int main(int argc, char *argv[]) v8_call_parms.nsf = -1; v8_call_parms.t66 = -1; v8_caller = v8_init(NULL, - TRUE, + true, &v8_call_parms, handler, (void *) "caller"); @@ -601,7 +598,7 @@ int main(int argc, char *argv[]) span_log_set_tag(logging, "caller"); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; - v8_answer_parms.send_ci = TRUE; + v8_answer_parms.send_ci = true; v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; @@ -611,7 +608,7 @@ int main(int argc, char *argv[]) v8_answer_parms.nsf = -1; v8_answer_parms.t66 = -1; v8_answerer = v8_init(NULL, - FALSE, + false, &v8_answer_parms, handler, (void *) "answerer"); diff --git a/libs/spandsp/tests/vector_float_tests.c b/libs/spandsp/tests/vector_float_tests.c index 26df593864..d6d1b95112 100644 --- a/libs/spandsp/tests/vector_float_tests.c +++ b/libs/spandsp/tests/vector_float_tests.c @@ -54,8 +54,8 @@ static int test_vec_copyf(void) for (i = 0; i < 99; i++) { x[i] = i; - za[i] = -1.0f; - zb[i] = -1.0f; + za[i] = -0.5f; + zb[i] = -0.5f; } vec_copyf_dumb(za + 3, x + 1, 0); vec_copyf(zb + 3, x + 1, 0); @@ -114,8 +114,8 @@ static int test_vec_negatef(void) for (i = 0; i < 99; i++) { x[i] = i; - za[i] = -1.0f; - zb[i] = -1.0f; + za[i] = -0.5f; + zb[i] = -0.5f; } vec_negatef_dumb(za + 3, x + 1, 0); vec_negatef(zb + 3, x + 1, 0); @@ -143,6 +143,7 @@ static int test_vec_negatef(void) vec_negatef(zb + 3, x + 1, 29); for (i = 0; i < 99; i++) { +printf("C %d %f %f %f\n", i, x[i], za[i], zb[i]); if (za[i] != zb[i]) { printf("vec_negatef() - %d %f %f\n", i, za[i], zb[i]); diff --git a/libs/srtp/include/srtp_priv.h b/libs/srtp/include/srtp_priv.h index 180a51b9e8..8425b351ce 100644 --- a/libs/srtp/include/srtp_priv.h +++ b/libs/srtp/include/srtp_priv.h @@ -83,11 +83,11 @@ typedef struct { #else /* BIG_ENDIAN */ typedef struct { - unsigned char version:2; /* protocol version */ - unsigned char p:1; /* padding flag */ - unsigned char x:1; /* header extension flag */ - unsigned char cc:4; /* CSRC count */ - unsigned char m:1; /* marker bit */ + unsigned version:2; /* protocol version */ + unsigned p:1; /* padding flag */ + unsigned x:1; /* header extension flag */ + unsigned cc:4; /* CSRC count */ + unsigned m:1; /* marker bit */ unsigned pt:7; /* payload type */ unsigned seq:16; /* sequence number */ unsigned ts:32; /* timestamp */ @@ -131,10 +131,10 @@ typedef struct { #else /* BIG_ENDIAN */ typedef struct { - unsigned char version:2; /* protocol version */ - unsigned char p:1; /* padding flag */ - unsigned char rc:5; /* reception report count */ - unsigned char pt:8; /* payload type */ + unsigned version:2; /* protocol version */ + unsigned p:1; /* padding flag */ + unsigned rc:5; /* reception report count */ + unsigned pt:8; /* payload type */ uint16_t len; /* length */ uint32_t ssrc; /* synchronization source */ } srtcp_hdr_t; diff --git a/libs/win32/apr/libapr.2010.vcxproj b/libs/win32/apr/libapr.2010.vcxproj index 5c6b686ee0..1bce164a1d 100644 --- a/libs/win32/apr/libapr.2010.vcxproj +++ b/libs/win32/apr/libapr.2010.vcxproj @@ -112,7 +112,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / /EHsc %(AdditionalOptions) Disabled ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - _DEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + _DEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 true @@ -181,7 +181,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / MaxSpeed OnlyExplicitInline ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - NDEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + NDEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDLL true diff --git a/libs/win32/apr/libapr.2012.vcxproj b/libs/win32/apr/libapr.2012.vcxproj index c491751b00..39cc98d863 100644 --- a/libs/win32/apr/libapr.2012.vcxproj +++ b/libs/win32/apr/libapr.2012.vcxproj @@ -116,7 +116,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / /EHsc %(AdditionalOptions) Disabled ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - _DEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + _DEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 true @@ -185,7 +185,7 @@ xcopy "$(ProjectDir)..\..\apr\include\*.h" "$(ProjectDir)..\..\include\" /C /D / MaxSpeed OnlyExplicitInline ..\..\apr\include;..\..\apr\include/arch;..\..\apr\include/arch/win32;..\..\apr\include/arch/unix;%(AdditionalIncludeDirectories) - NDEBUG;APR_DECLARE_EXPORT;WIN32;_WINDOWS;%(PreprocessorDefinitions) + NDEBUG;APR_DECLARE_EXPORT;APR_VOID_P_IS_QUAD;WIN32;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDLL true diff --git a/scripts/lua/zrtp_sas_proxy.lua b/scripts/lua/zrtp_sas_proxy.lua new file mode 100644 index 0000000000..503b8d8c72 --- /dev/null +++ b/scripts/lua/zrtp_sas_proxy.lua @@ -0,0 +1,103 @@ +-- zrtp_sas_proxy.lua +-- +-- Copyright (c) 2011-2013 Travis Cross +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- +-- +-- When we're acting as a ZRTP man-in-the-middle, proxy the SAS (Short +-- Authentication String) from one leg of the call to the other. +-- +-- This script should be called asynchonously with luarun. e.g.: +-- +-- +-- +aleg=argv[1] +api=freeswitch.API() + +function log(level,msg) return freeswitch.consoleLog(level,"zrtp_sas: "..msg.."\n") end +function sleep(sec) return freeswitch.msleep(sec*1000) end +function ready() return api:execute("uuid_exists",aleg)=="true" end +function getvar(uuid,var) + local x=api:execute("uuid_getvar",uuid.." "..var) + if x=="_undef_" then return nil end + return x +end +function getvarp(uuid,var) return getvar(uuid,var)=="true" end +function display(uuid,msg) + local cidn=getvar(uuid,"caller_id_name") + return api:execute("uuid_display",uuid.." "..msg.." "..cidn) +end + +function mk_sas(sas1,sas2) + if sas1 and sas2 then return sas1.." "..sas2 + else return sas1 or sas2 or "" end +end + +function get_sas(uuid) + return mk_sas(getvar(uuid,"zrtp_sas1_string_audio"), + getvar(uuid,"zrtp_sas2_string")) +end + +function log_sas(leg,uuid) + return log("notice",leg..": "..uuid.." sas: "..get_sas(uuid)) +end + +function display_sas(to,from) + return display(to," ("..get_sas(from)..")") +end + +function get_bleg(aleg) + local retries=15 bleg=nil + while ready() do + if retries<1 then return nil end + local bleg=getvar(aleg,"signal_bond") + if bleg then return bleg end + log("debug","waiting for bleg uuid...") + sleep(1) + retries=retries-1 + end +end + +function handle_sas(aleg,bleg) + local retries=45 af=false bf=false + while ready() do + if retries<1 then return nil end + if not af and getvarp(aleg,"zrtp_secure_media_confirmed_audio") then + af=true + log_sas("aleg",aleg) + display_sas(bleg,aleg) + end + if not bf and getvarp(bleg,"zrtp_secure_media_confirmed_audio") then + bf=true + log_sas("bleg",bleg) + display_sas(aleg,bleg) + end + if (af and bf) then break + elseif af then log("debug","waiting on bleg zrtp...") + elseif bf then log("debug","waiting on aleg zrtp...") + else log("debug","waiting for zrtp...") end + sleep(1) + retries=retries-1 + end +end + +if not (getvarp(aleg,"zrtp_passthru") or getvarp(aleg,"proxy_media")) then + handle_sas(aleg,get_bleg(aleg)) +end diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 5cf7196382..dd83e7052d 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -240,6 +240,10 @@ struct switch_runtime { uint32_t sps_total; int32_t sps; int32_t sps_last; + int32_t sps_peak; + int32_t sps_peak_fivemin; + int32_t sessions_peak; + int32_t sessions_peak_fivemin; switch_log_level_t hard_log_level; char *mailer_app; char *mailer_app_args; diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index f21265e581..f0dc1c76fe 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -57,6 +57,9 @@ SWITCH_BEGIN_EXTERN_C +#define profile_dup(a,b,p) if (!zstr(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; } +#define profile_dup_clean(a,b,p) if (!zstr(a)) { b = switch_var_clean_string(switch_clean_string(switch_core_strdup(p, a)));} else { b = SWITCH_BLANK_STRING; } + typedef struct profile_node_s { char *var; char *val; diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 416ed185de..dfa1d39d7c 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1967,6 +1967,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_check_results(switch_asr_handle_ */ SWITCH_DECLARE(switch_status_t) switch_core_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags); +/*! + \brief Get result headers from an asr handle + \param ah the handle to get results from + \param headers a pointer to dynamically allocate an switch_event_t result to + \param flags flags to influence behaviour + \return SWITCH_STATUS_SUCCESS +*/ +SWITCH_DECLARE(switch_status_t) switch_core_asr_get_result_headers(switch_asr_handle_t *ah, switch_event_t **headers, switch_asr_flag_t *flags); + /*! \brief Load a grammar to an asr handle \param ah the handle to load to @@ -2557,6 +2566,11 @@ SWITCH_DECLARE(int) switch_core_cert_expand_fingerprint(dtls_fingerprint_t *fp, SWITCH_DECLARE(int) switch_core_cert_verify(dtls_fingerprint_t *fp); SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video(switch_core_session_t *session); +SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait); +SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream); +SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream); + + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 624d3bddd0..122f9f2b65 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -68,12 +68,12 @@ typedef enum { SCMF_RUNNING, SCMF_DISABLE_TRANSCODING, SCMF_AUTOFIX_TIMING, + SCMF_AUTOFIX_PT, SCMF_CODEC_GREEDY, SCMF_CODEC_SCROOGE, SCMF_DISABLE_HOLD, SCMF_RENEG_ON_HOLD, SCMF_RENEG_ON_REINVITE, - SCMF_T38_PASSTHRU, SCMF_LIBERAL_DTMF, SCMF_SUPPRESS_CNG, SCMF_DISABLE_RTP_AUTOADJ, @@ -243,7 +243,7 @@ SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_ses SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp); -SWITCH_DECLARE(void) switch_core_media_reset_autofix_timing(switch_core_session_t *session, switch_media_type_t type); +SWITCH_DECLARE(void) switch_core_media_reset_autofix(switch_core_session_t *session, switch_media_type_t type); SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session, switch_core_session_t *o_session); SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_session_t *session, switch_media_type_t media); SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *session); diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 43aa6c0bef..bccf71a3a1 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -90,6 +90,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, + const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index ba5ad7011b..c0ba440c99 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -184,6 +184,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_se switch_input_args_t *args); +/*! + \brief Initialize background Speech detection on a session, so that parameters can be set, and grammars loaded. + After calling this function, it is possible to call switch_ivr_set_param_detect_speech() to set recognition parameters. + Calling switch_ivr_detect_speech_load_grammar() starts the speech recognition. + \param session the session to attach + \param mod_name the module name of the ASR library + \param dest the destination address + \param ah an ASR handle to use (NULL to create one) + \return SWITCH_STATUS_SUCCESS if all is well +*/ +SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_init(switch_core_session_t *session, const char *mod_name, + const char *dest, switch_asr_handle_t *ah); /*! \brief Engage background Speech detection on a session \param session the session to attach @@ -775,6 +787,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops. *\param invalid_sound Optional pointer to a sound to play after invalid input. *\param exit_sound Optional pointer to a sound to play upon exiting the menu. + *\param transfer_sound Optional pointer to a sound to play upon transfer away from the menu. *\param confirm_macro phrase macro name to confirm input *\param confirm_key the dtmf key required for positive confirmation *\param tts_engine the tts engine to use for this menu @@ -795,6 +808,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, + const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, @@ -934,6 +948,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_ip(switch_core_session_t *session switch_input_args_t *args); SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data); +SWITCH_DECLARE(switch_status_t) switch_ivr_set_user_xml(switch_core_session_t *session, const char *prefix, + const char *user, const char *domain, switch_xml_t x_user); + SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session); SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname, const char *prefix); SWITCH_DECLARE(switch_bool_t) switch_ivr_uuid_exists(const char *uuid); diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index cdfb9eb2e9..b4ea5a4bc8 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -377,6 +377,8 @@ struct switch_asr_interface { switch_status_t (*asr_check_results) (switch_asr_handle_t *ah, switch_asr_flag_t *flags); /*! function to read results from the ASR */ switch_status_t (*asr_get_results) (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags); + /*! function to read result headers from the ASR */ + switch_status_t (*asr_get_result_headers) (switch_asr_handle_t *ah, switch_event_t **headers, switch_asr_flag_t *flags); /*! function to start ASR input timers */ switch_status_t (*asr_start_input_timers) (switch_asr_handle_t *ah); void (*asr_text_param) (switch_asr_handle_t *ah, char *param, const char *val); diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index ff7079b833..f704d943d1 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -139,6 +139,7 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void); SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port); SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc); +SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc); /*! \brief Set/Get RTP end port diff --git a/src/include/switch_scheduler.h b/src/include/switch_scheduler.h index 8d9bd9ca1a..59997a006d 100644 --- a/src/include/switch_scheduler.h +++ b/src/include/switch_scheduler.h @@ -43,6 +43,7 @@ SWITCH_BEGIN_EXTERN_C int64_t created; int64_t runtime; uint32_t cmd_id; + uint32_t repeat; char *group; void *cmd_arg; uint32_t task_id; diff --git a/src/include/switch_stun.h b/src/include/switch_stun.h index fdf1fbd74d..b6de510159 100644 --- a/src/include/switch_stun.h +++ b/src/include/switch_stun.h @@ -142,6 +142,27 @@ typedef struct { } switch_stun_ip_t; +#if SWITCH_BYTE_ORDER == __BIG_ENDIAN + +typedef struct { + unsigned padding:21; + unsigned code:3; + unsigned number:8; + char reason[764]; +} switch_stun_error_code_t; + +#else + +typedef struct { + unsigned number:8; + unsigned code:3; + unsigned padding:21; + char reason[764]; +} switch_stun_error_code_t; + +#endif + + /*! \brief Writes random characters into a buffer \param buf the buffer diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 2e469de3de..7f3aade715 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -762,10 +762,17 @@ typedef enum { If this setting is enabled it will NOT do this (old behaviour). */ - RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10) + RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10), /* FLUSH JITTERBUFFER When getting RFC2833 to reduce bleed through */ + RTP_BUG_ACCEPT_ANY_PAYLOAD = (1 << 11) + + /* + Make FS accept any payload type instead of dropping and returning CNG frame. Workaround while FS only supports a single payload per rtp session. + This can be used by endpoint modules to detect payload changes and act appropriately (ex: sofia could send a reINVITE with single codec). + This should probably be a flag, but flag enum is already full! + */ } switch_rtp_bug_flag_t; @@ -1326,6 +1333,7 @@ typedef enum { CF_DTLS_OK, CF_VIDEO_PASSIVE, CF_NOVIDEO, + CF_VIDEO_ECHO, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ /* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */ CF_FLAG_MAX @@ -1886,7 +1894,11 @@ typedef enum { SCSC_DEBUG_SQL, SCSC_SQL, SCSC_API_EXPANSION, - SCSC_RECOVER + SCSC_RECOVER, + SCSC_SPS_PEAK, + SCSC_SPS_PEAK_FIVEMIN, + SCSC_SESSIONS_PEAK, + SCSC_SESSIONS_PEAK_FIVEMIN } switch_session_ctl_t; typedef enum { diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 923919bc6a..40630d8c9f 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -613,7 +613,7 @@ static inline char *switch_sanitize_number(char *number) while ((q = strrchr(p, '@'))) *q = '\0'; - + for (i = 0; i < (int) strlen(warp); i++) { while (p && (q = strchr(p, warp[i]))) p = q + 1; diff --git a/src/mod/.gitignore b/src/mod/.gitignore index 1aa253520e..bfcc02ab70 100644 --- a/src/mod/.gitignore +++ b/src/mod/.gitignore @@ -24,16 +24,19 @@ /applications/mod_stress/Makefile /applications/mod_stress/Makefile.in /applications/mod_stress/mod_stress.log +/applications/mod_translate/Makefile /applications/mod_valet_parking/Makefile /applications/mod_voicemail/Makefile /asr_tts/mod_unimrcp/Makefile /asr_tts/mod_unimrcp/Makefile.in /asr_tts/mod_unimrcp/mod_unimrcp.log /asr_tts/mod_flite/*/*/mod_flite_manifest.rc +/codecs/mod_b64/Makefile /codecs/mod_skel_codec/Makefile /codecs/mod_vp8/Makefile /dialplans/mod_dialplan_asterisk/Makefile /dialplans/mod_dialplan_xml/Makefile +/endpoints/mod_html5/mod_html5.log /endpoints/mod_portaudio/Makefile /endpoints/mod_portaudio/Makefile.in /endpoints/mod_portaudio/mod_portaudio.log @@ -55,8 +58,9 @@ /formats/mod_portaudio_stream/Makefile.in /formats/mod_portaudio_stream/mod_portaudio_stream.log /formats/mod_tone_stream/Makefile -/languages/mod_java/freeswitch.jar /languages/mod_java/Makefile +/languages/mod_java/classes/ +/languages/mod_java/freeswitch.jar /languages/mod_lua/Makefile /languages/mod_lua/Makefile.in /languages/mod_lua/mod_lua.log diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index c758147078..4e9e852aa9 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -562,27 +562,28 @@ char *cc_execute_sql2str(cc_queue_t *queue, switch_mutex_t *mutex, char *sql, ch switch_cache_db_handle_t *dbh = NULL; - if (!(dbh = cc_get_db_handle())) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); - return NULL; - } - if (mutex) { switch_mutex_lock(mutex); } else { switch_mutex_lock(globals.mutex); } + if (!(dbh = cc_get_db_handle())) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n"); + goto end; + } + ret = switch_cache_db_execute_sql2str(dbh, sql, resbuf, len, NULL); +end: + switch_cache_db_release_db_handle(&dbh); + if (mutex) { switch_mutex_unlock(mutex); } else { switch_mutex_unlock(globals.mutex); } - switch_cache_db_release_db_handle(&dbh); - return ret; } @@ -1524,7 +1525,15 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa /* Switch the agent session */ if (real_uuid) { switch_core_session_rwunlock(agent_session); - agent_session = switch_core_session_locate(real_uuid); + if (!(agent_session = switch_core_session_locate(real_uuid))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Real session is already gone (agent '%s')\n", h->agent_name); + sql = switch_mprintf("UPDATE members SET state = '%q', serving_agent = '', serving_system = ''" + " WHERE serving_agent = '%q' AND serving_system = '%q' AND uuid = '%q' AND system = 'single_box'", + cc_member_state2str(CC_MEMBER_STATE_WAITING), h->agent_name, h->agent_system, h->member_uuid); + cc_execute_sql(NULL, sql, NULL); + switch_safe_free(sql); + goto done; + } agent_uuid = switch_core_session_get_uuid(agent_session); agent_channel = switch_core_session_get_channel(agent_session); diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index ef34a985f7..fc74c3dd65 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2012,7 +2012,8 @@ SWITCH_STANDARD_API(lan_addr_function) SWITCH_STANDARD_API(status_function) { switch_core_time_duration_t duration = { 0 }; - int sps = 0, last_sps = 0; + int sps = 0, last_sps = 0, max_sps = 0, max_sps_fivemin = 0; + int sessions_peak = 0, sessions_peak_fivemin = 0; /* Max Concurrent Sessions buffers */ switch_bool_t html = SWITCH_FALSE; /* shortcut to format.html */ char * nl = "\n"; /* shortcut to format.nl */ stream_format format = { 0 }; @@ -2056,9 +2057,14 @@ SWITCH_STANDARD_API(status_function) switch_core_ready() ? "ready" : "not ready", nl); stream->write_function(stream, "%" SWITCH_SIZE_T_FMT " session(s) since startup%s", switch_core_session_id() - 1, nl); + switch_core_session_ctl(SCSC_SESSIONS_PEAK, &sessions_peak); + switch_core_session_ctl(SCSC_SESSIONS_PEAK_FIVEMIN, &sessions_peak_fivemin); + stream->write_function(stream, "%d session(s) - peak %d, last 5min %d %s", switch_core_session_count(), sessions_peak, sessions_peak_fivemin, nl); switch_core_session_ctl(SCSC_LAST_SPS, &last_sps); switch_core_session_ctl(SCSC_SPS, &sps); - stream->write_function(stream, "%d session(s) - %d out of max %d per sec %s", switch_core_session_count(), last_sps, sps, nl); + switch_core_session_ctl(SCSC_SPS_PEAK, &max_sps); + switch_core_session_ctl(SCSC_SPS_PEAK_FIVEMIN, &max_sps_fivemin); + stream->write_function(stream, "%d session(s) per Sec out of max %d, peak %d, last 5min %d %s", last_sps, sps, max_sps, max_sps_fivemin, nl); stream->write_function(stream, "%d session(s) max%s", switch_core_session_limit(0), nl); stream->write_function(stream, "min idle cpu %0.2f/%0.2f%s", switch_core_min_idle_cpu(-1.0), switch_core_idle_cpu(), nl); @@ -2067,7 +2073,7 @@ SWITCH_STANDARD_API(status_function) return SWITCH_STATUS_SUCCESS; } -#define CTL_SYNTAX "[recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]]" +#define CTL_SYNTAX "[recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sps_peak_reset|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]]" SWITCH_STANDARD_API(ctl_function) { int argc; @@ -2289,6 +2295,10 @@ SWITCH_STANDARD_API(ctl_function) switch_core_session_ctl(SCSC_DEBUG_LEVEL, &arg); stream->write_function(stream, "+OK DEBUG level: %d\n", arg); + } else if (!strcasecmp(argv[0], "sps_peak_reset")) { + arg = -1; + switch_core_session_ctl(SCSC_SPS_PEAK, &arg); + stream->write_function(stream, "+OK max sessions per second counter reset\n"); } else if (!strcasecmp(argv[0], "last_sps")) { switch_core_session_ctl(SCSC_LAST_SPS, &arg); stream->write_function(stream, "+OK last sessions per second: %d\n", arg); @@ -3154,7 +3164,7 @@ SWITCH_STANDARD_API(uuid_broadcast_function) return SWITCH_STATUS_SUCCESS; } -#define SCHED_BROADCAST_SYNTAX "[+]