Another round of tweaks for spandsp. There should be no functional changes,

although quite a few things have changed in the test suite
This commit is contained in:
Steve Underwood
2011-07-02 21:16:52 +08:00
parent d30e82e226
commit 4a7bbf4ec6
77 changed files with 966 additions and 357 deletions
+3 -3
View File
@@ -713,7 +713,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(int standard)
{
adsi_rx(rx_adsi, amp, frames);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
exit(2);
@@ -819,7 +819,7 @@ int main(int argc, char *argv[])
break;
adsi_rx(rx_adsi, amp, len);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -857,7 +857,7 @@ int main(int argc, char *argv[])
}
if (log_audio)
{
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+1 -1
View File
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
}
error = 100.0*(1.0 - sqrt(total/total_samples)/noise_source.rms);
printf("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
log10(sqrt(total/total_samples)/32768.0)*20.0 + DBM0_MAX_POWER,
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) + DBM0_MAX_POWER,
j,
error,
clip_low,
+1 -1
View File
@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
}
while (len > 0);
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit (2);
+4 -4
View File
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
exit(2);
}
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
if (fabs(power_meter_current_dbm0(&meter) + 10.0f) > 0.05f)
if (fabs(power_meter_current_dbm0(&meter) + 10.0f) > 0.1f)
{
printf("Test failed.\n");
exit(2);
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
exit(2);
}
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
if (fabs(power_meter_current_dbov(&meter) + 10.0f) > 0.05f)
if (fabs(power_meter_current_dbov(&meter) + 10.0f) > 0.1f)
{
printf("Test failed.\n");
exit(2);
@@ -159,7 +159,7 @@ int main(int argc, char *argv[])
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_COMPLEX);
exit(2);
+1 -1
View File
@@ -659,7 +659,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
hits += len;
}
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
exit(2);
+1 -1
View File
@@ -215,7 +215,7 @@ int main(int argc, char *argv[])
}
while (len > 0);
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -228,9 +228,9 @@ int echo_can_monitor_line_spectrum_update(const int16_t amp[], int len)
{
s->spec_re_plot[2*i] = i*4000.0/512.0;
#if defined(HAVE_FFTW3_H)
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768)) + 3.14;
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
#else
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768)) + 3.14;
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
#endif
}
s->spec_re = new Ca_Line(512, s->spec_re_plot, 0, 0, FL_BLUE, CA_NO_POINT);
+9 -9
View File
@@ -212,7 +212,7 @@ static void signal_load(signal_source_t *sig, const char *name)
static void signal_free(signal_source_t *sig)
{
if (sf_close(sig->handle) != 0)
if (sf_close_telephony(sig->handle))
{
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
exit(2);
@@ -324,7 +324,7 @@ static float level_measurement_device(level_measurement_device_t *dev, int16_t a
}
if (signal <= 0.0f)
return -99.0f;
power = DBM0_MAX_POWER + 20.0f*log10f(signal/32767.0f);
power = DBM0_MAX_POWER + 20.0f*log10f(signal/32767.0f + 1.0e-10f);
if (power > dev->peak)
dev->peak = power;
return power;
@@ -368,7 +368,7 @@ static void print_results(void)
printf("%-4s %-1d %-5.1f%6.2fs%9.2f%9.2f%9.2f%9.2f%9.2f\n",
test_name,
chan_model.model_no,
20.0f*log10f(-chan_model.erl),
20.0f*log10f(-chan_model.erl + 1.0e-10f),
0.0f, //test_clock,
level_measurement_device_get_peak(rin_power_meter),
level_measurement_device_get_peak(rout_power_meter),
@@ -1559,14 +1559,14 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
if (two_channel_file)
{
sf_close(rxtxfile);
sf_close_telephony(rxtxfile);
}
else
{
sf_close(txfile);
sf_close(rxfile);
sf_close_telephony(txfile);
sf_close_telephony(rxfile);
}
sf_close(ecfile);
sf_close_telephony(ecfile);
}
/*- End of function --------------------------------------------------------*/
@@ -1703,7 +1703,7 @@ int main(int argc, char *argv[])
}
match_test_name(argv[i]);
}
if (sf_close(result_handle) != 0)
if (sf_close_telephony(result_handle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", "result_sound.wav");
exit(2);
@@ -1712,7 +1712,7 @@ int main(int argc, char *argv[])
}
signal_free(&local_css);
signal_free(&far_css);
if (sf_close(residue_handle) != 0)
if (sf_close_telephony(residue_handle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", RESIDUE_FILE_NAME);
exit(2);
+1 -1
View File
@@ -545,7 +545,7 @@ int main(int argc, char *argv[])
}
t4_rx_release(&t4_state);
if (sf_close(inhandle) != 0)
if (sf_close(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", filename);
exit(2);
+2 -2
View File
@@ -26,7 +26,7 @@
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <inttypes.h>
@@ -287,7 +287,7 @@ static void hdlc_rx_status(void *user_data, int status)
faxtester_state_t *s;
s = (faxtester_state_t *) user_data;
fprintf(stderr, "HDLC carrier status is %s (%d)\n", signal_status_to_str(status), status);
span_log(&s->logging, SPAN_LOG_FLOW, "HDLC carrier status is %s (%d)\n", signal_status_to_str(status), status);
switch (status)
{
case SIG_STATUS_TRAINING_FAILED:
+7 -7
View File
@@ -82,7 +82,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -95,9 +95,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
if (use_receiver_not_ready)
t30_set_receiver_not_ready(s, 3);
@@ -138,9 +138,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
t30_get_transfer_statistics(s, &t);
machines[i - 'A'].succeeded = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
machines[i - 'A'].done = TRUE;
+21 -3
View File
@@ -40,7 +40,7 @@
#include "spandsp-sim.h"
#include "fax_utils.h"
void log_tx_parameters(t30_state_t *s, const char *tag)
void fax_log_tx_parameters(t30_state_t *s, const char *tag)
{
const char *u;
@@ -59,7 +59,7 @@ void log_tx_parameters(t30_state_t *s, const char *tag)
}
/*- End of function --------------------------------------------------------*/
void log_rx_parameters(t30_state_t *s, const char *tag)
void fax_log_rx_parameters(t30_state_t *s, const char *tag)
{
const char *u;
@@ -84,7 +84,7 @@ void log_rx_parameters(t30_state_t *s, const char *tag)
}
/*- End of function --------------------------------------------------------*/
void log_transfer_statistics(t30_state_t *s, const char *tag)
void fax_log_transfer_statistics(t30_state_t *s, const char *tag)
{
t30_stats_t t;
@@ -105,4 +105,22 @@ void log_transfer_statistics(t30_state_t *s, const char *tag)
#endif
}
/*- End of function --------------------------------------------------------*/
int get_tiff_total_pages(const char *file)
{
TIFF *tiff_file;
int max;
if ((tiff_file = TIFFOpen(file, "r")) == NULL)
return -1;
/* Each page *should* contain the total number of pages, but can this be
trusted? Some files say 0. Actually searching for the last page is
more reliable. */
max = 0;
while (TIFFSetDirectory(tiff_file, (tdir_t) max))
max++;
TIFFClose(tiff_file);
return max;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+5 -3
View File
@@ -33,11 +33,13 @@ extern "C"
{
#endif
void log_tx_parameters(t30_state_t *s, const char *tag);
void fax_log_tx_parameters(t30_state_t *s, const char *tag);
void log_rx_parameters(t30_state_t *s, const char *tag);
void fax_log_rx_parameters(t30_state_t *s, const char *tag);
void log_transfer_statistics(t30_state_t *s, const char *tag);
void fax_log_transfer_statistics(t30_state_t *s, const char *tag);
int get_tiff_total_pages(const char *file);
#if defined(__cplusplus)
}
+2 -2
View File
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
fsk_rx(caller_rx, caller_model_amp, samples);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -519,7 +519,7 @@ int main(int argc, char *argv[])
}
if (log_audio)
{
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+1 -1
View File
@@ -73,7 +73,7 @@ static void signal_load(signal_source_t *sig, const char *name)
static void signal_free(signal_source_t *sig)
{
if (sf_close(sig->handle) != 0)
if (sf_close_telephony(sig->handle))
{
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
exit(2);
+3 -3
View File
@@ -324,7 +324,7 @@ static void compliance_tests(int log_audio)
if (log_audio)
{
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
@@ -486,7 +486,7 @@ int main(int argc, char *argv[])
}
if (encode)
{
if (sf_close(inhandle))
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
exit(2);
@@ -498,7 +498,7 @@ int main(int argc, char *argv[])
}
if (decode)
{
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+54 -1
View File
@@ -58,7 +58,7 @@ and the resulting audio stored in post_g722.wav.
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <stdlib.h>
@@ -347,6 +347,58 @@ static void itu_compliance_tests(void)
}
/*- End of function --------------------------------------------------------*/
static void signal_to_distortion_tests(void)
{
g722_encode_state_t enc_state;
g722_decode_state_t dec_state;
swept_tone_state_t *swept;
power_meter_t in_meter;
power_meter_t out_meter;
int16_t original[1024];
uint8_t compressed[1024];
int16_t decompressed[1024];
int len;
int len2;
int len3;
int i;
int32_t in_level;
int32_t out_level;
/* Test a back to back encoder/decoder pair to ensure we comply with Figure 11/G.722 to
Figure 16/G.722, Figure A.1/G.722, and Figure A.2/G.722 */
g722_encode_init(&enc_state, 64000, 0);
g722_decode_init(&dec_state, 64000, 0);
power_meter_init(&in_meter, 7);
power_meter_init(&out_meter, 7);
/* First some silence */
len = 1024;
memset(original, 0, len*sizeof(original[0]));
for (i = 0; i < len; i++)
in_level = power_meter_update(&in_meter, original[i]);
len2 = g722_encode(&enc_state, compressed, original, len);
len3 = g722_decode(&dec_state, decompressed, compressed, len2);
for (i = 0; i < len3; i++)
out_level = power_meter_update(&out_meter, decompressed[i]);
printf("Silence produces %d at the output\n", out_level);
/* Now a swept tone test */
swept = swept_tone_init(NULL, 25.0f, 3500.0f, -10.0f, 60*16000, FALSE);
do
{
len = swept_tone(swept, original, 1024);
for (i = 0; i < len; i++)
in_level = power_meter_update(&in_meter, original[i]);
len2 = g722_encode(&enc_state, compressed, original, len);
len3 = g722_decode(&dec_state, decompressed, compressed, len2);
for (i = 0; i < len3; i++)
out_level = power_meter_update(&out_meter, decompressed[i]);
printf("%10d, %10d, %f\n", in_level, out_level, (float) out_level/in_level);
}
while (len > 0);
}
/*- End of function --------------------------------------------------------*/
int main(int argc, char *argv[])
{
g722_encode_state_t enc_state;
@@ -445,6 +497,7 @@ int main(int argc, char *argv[])
if (itutests)
{
itu_compliance_tests();
signal_to_distortion_tests();
}
else
{
+3 -3
View File
@@ -62,7 +62,7 @@ decompressed, and the resulting audio stored in post_g726.wav.
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <stdlib.h>
@@ -1285,12 +1285,12 @@ int main(int argc, char *argv[])
frames = g726_decode(&dec_state, amp, adpcmdata, adpcm);
outframes = sf_writef_short(outhandle, amp, frames);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
printf(" Cannot close audio file '%s'\n", IN_FILE_NAME);
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
printf(" Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -608,12 +608,12 @@ int main(int argc, char *argv[])
outframes = sf_writef_short(outhandle, post_amp, frames);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -182,12 +182,12 @@ int main(int argc, char *argv[])
}
outframes = sf_writef_short(outhandle, post_amp, dec_frames);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -228,9 +228,9 @@ int line_model_monitor_line_spectrum_update(const int16_t amp[], int len)
{
s->spec_re_plot[2*i] = i*4000.0/512.0;
#if defined(HAVE_FFTW3_H)
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768)) + 3.14;
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
#else
s->spec_re_plot[2*i + 1] = 20.0*log10(sqrt(s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768)) + 3.14;
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
#endif
}
s->spec_re = new Ca_Line(512, s->spec_re_plot, 0, 0, FL_BLUE, CA_NO_POINT);
+9 -7
View File
@@ -96,7 +96,7 @@ static void complexify_tests(void)
fprintf(stderr, " Error writing audio file\n");
exit(2);
}
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_COMPLEXIFY);
exit(2);
@@ -174,13 +174,13 @@ static void test_one_way_model(int line_model_no, int speech_test)
}
if (speech_test)
{
if (sf_close(inhandle1))
if (sf_close_telephony(inhandle1))
{
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
exit(2);
}
}
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME1);
exit(2);
@@ -288,18 +288,18 @@ static void test_both_ways_model(int line_model_no, int speech_test)
}
if (speech_test)
{
if (sf_close(inhandle1))
if (sf_close_telephony(inhandle1))
{
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
exit(2);
}
if (sf_close(inhandle2))
if (sf_close_telephony(inhandle2))
{
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME2);
exit(2);
}
}
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME2);
exit(2);
@@ -313,6 +313,7 @@ static void test_line_filter(int line_model_no)
float out;
double sumin;
double sumout;
double gain;
int i;
int j;
int p;
@@ -353,7 +354,8 @@ static void test_line_filter(int line_model_no)
sumout += out*out;
}
/*endfor*/
printf("%7.1f %f\n", swept_tone_current_frequency(s), 10.0*log10(sumout/sumin));
gain = (sumin != 0.0) ? 10.0*log10(sumout/sumin + 1.0e-10) : 0.0;
printf("%7.1f %f\n", swept_tone_current_frequency(s), gain);
}
/*endfor*/
swept_tone_free(s);
+4 -4
View File
@@ -29,7 +29,7 @@
\section lpc10_tests_page_sec_1 What does it do?
\section lpc10_tests_page_sec_2 How is it used?
To perform a general audio quality test, lpc10 should be run. The file ../test-data/local/short_nb_voice.wav
To perform a general audio quality test, lpc10 should be run. The file ../test-data/local/dam9.wav
will be compressed to LPC10 data, decompressed, and the resulting audio stored in post_lpc10.wav.
*/
@@ -220,19 +220,19 @@ int main(int argc, char *argv[])
else
outframes = sf_writef_short(outhandle, post_amp, dec_len);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
exit(2);
}
if (sf_close(refhandle) != 0)
if (sf_close_telephony(refhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", REF_FILE_NAME);
exit(2);
}
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
outframes = sf_writef_short(filehandle, silence_sound, C1_SILENCE_SAMPLES);
printf("%d samples of silence\n", C1_SILENCE_SAMPLES);
if (sf_close(filehandle) != 0)
if (sf_close(filehandle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", "sound_c1.wav");
exit(2);
@@ -333,7 +333,7 @@ int main(int argc, char *argv[])
outframes = sf_writef_short(filehandle, silence_sound, C3_SILENCE_SAMPLES);
printf("%d samples of silence\n", C3_SILENCE_SAMPLES);
if (sf_close(filehandle) != 0)
if (sf_close(filehandle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", "sound_c3.wav");
exit(2);
@@ -396,7 +396,7 @@ int main(int argc, char *argv[])
}
/*endif*/
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
printf(" Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
@@ -1374,7 +1374,7 @@ int main(int argc, char *argv[])
/*endif*/
}
/*endwhile*/
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", bellcore_files[j]);
exit(2);
@@ -1417,7 +1417,7 @@ int main(int argc, char *argv[])
modem_connect_tones_rx(&ans_pr_rx, amp, frames);
}
/*endwhile*/
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
exit(2);
+2 -2
View File
@@ -166,7 +166,7 @@ static void signal_load(signal_source_t *sig, const char *name)
static void signal_free(signal_source_t *sig)
{
if (sf_close(sig->handle) != 0)
if (sf_close_telephony(sig->handle))
{
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
exit(2);
@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
modem_echo_can_free(ctx);
signal_free(&local_css);
if (sf_close(resulthandle) != 0)
if (sf_close_telephony(resulthandle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", "result_sound.wav");
exit(2);
+1 -4
View File
@@ -322,10 +322,7 @@ int qam_monitor_update_audio_level(qam_monitor_t *s, const int16_t amp[], int le
s->audio_meter->sample(amp[i]/32768.0);
s->power_reading += ((amp[i]*amp[i] - s->power_reading) >> 10);
}
if (s->power_reading <= 0)
val = -90.0;
else
val = log10((double) s->power_reading/(32767.0f*32767.0f))*10.0f + 3.14 + 3.02;
val = 10.0*log10((double) s->power_reading/(32767.0*32767.0) + 1.0e-10) + 3.14 + 3.02;
snprintf(buf, sizeof(buf), "%5.1fdBm0", val);
s->audio_level->value(buf);
+5 -5
View File
@@ -104,12 +104,12 @@ int main (int argc, char *argv[])
total += ((double) value)*((double) value);
}
printf ("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
log10(sqrt(total/total_samples)/32768.0)*20.0,
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10),
level,
100.0*(1.0 - sqrt(total/total_samples)/(pow(10.0, level/20.0)*32768.0)),
clip_low,
clip_high);
if (level < -5 && fabs(log10(sqrt(total/total_samples)/32768.0)*20.0 - level) > 0.2)
if (level < -5 && fabs(10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) - level) > 0.2)
{
printf("Test failed\n");
exit(2);
@@ -195,12 +195,12 @@ int main (int argc, char *argv[])
total += ((double) value)*((double) value);
}
printf ("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
log10(sqrt(total/total_samples)/32768.0)*20.0,
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10),
level,
100.0*(1.0 - sqrt(total/total_samples)/(pow(10.0, level/20.0)*32768.0)),
clip_low,
clip_high);
if (level < -5 && fabs(log10(sqrt(total/total_samples)/32768.0)*20.0 - level) > 0.2)
if (level < -5 && fabs(10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) - level) > 0.2)
{
printf("Test failed\n");
exit(2);
@@ -223,7 +223,7 @@ int main (int argc, char *argv[])
}
}
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
oki_adpcm_release(oki_enc_state);
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
exit(2);
@@ -290,7 +290,7 @@ int main(int argc, char *argv[])
}
oki_adpcm_release(oki_dec_state);
oki_adpcm_release(oki_dec_state2);
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
-1
View File
@@ -36,7 +36,6 @@ extern "C"
typedef int (pcap_timing_update_handler_t)(void *user_data, struct timeval *ts);
typedef int (pcap_packet_handler_t)(void *user_data, const uint8_t *pkt, int len);
int pcap_scan_pkts(const char *file,
uint32_t src_addr,
uint16_t src_port,
+2 -2
View File
@@ -205,12 +205,12 @@ printf("len = %d\n", len);
}
}
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", INPUT_FILE_NAME);
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -165,13 +165,13 @@ int main(int argc, char *argv[])
printf("Dropped %d of %d blocks\n", lost_blocks, block_no);
if (tone < 0)
{
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", INPUT_FILE_NAME);
exit(2);
}
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+17 -5
View File
@@ -33,7 +33,7 @@ Both tones and noise are used to check the meter's behaviour.
*/
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <stdlib.h>
@@ -145,7 +145,11 @@ static int power_surge_detector_tests(void)
exit(2);
}
}
sf_close(outhandle);
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
}
printf("Min on %d, max on %d, min off %d, max off %d\n", extremes[0], extremes[1], extremes[2], extremes[3]);
return 0;
}
@@ -168,7 +172,7 @@ static int power_surge_detector_file_test(const char *file)
if ((inhandle = sf_open_telephony_read(file, 1)) == NULL)
{
printf(" Cannot open speech file '%s'\n", file);
printf(" Cannot open audio file '%s'\n", file);
exit(2);
}
@@ -202,8 +206,16 @@ static int power_surge_detector_file_test(const char *file)
sf_writef_short(outhandle, amp_out, inframes);
sample += inframes;
}
sf_close(inhandle);
sf_close(outhandle);
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", file);
exit(2);
}
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
}
return 0;
}
/*- End of function --------------------------------------------------------*/
+1 -1
View File
@@ -30,7 +30,7 @@
*/
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <stdlib.h>
+1 -1
View File
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
outframes = sf_writef_short(outhandle, amp, len);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit (2);
+3 -6
View File
@@ -295,10 +295,7 @@ static void map_frequency_response(sig_tone_rx_state_t *s, template_t template[]
sumout += (double) buf[i]*(double) buf[i];
/*endfor*/
freq = swept_tone_current_frequency(swept);
if (sumin)
gain = 10.0*log10(sumout/sumin);
else
gain = 0.0;
gain = (sumin != 0.0) ? 10.0*log10(sumout/sumin + 1.0e-10) : 0.0;
printf("%7.1f Hz %.3f dBm0 < %.3f dBm0 < %.3f dBm0\n",
freq,
template[template_entry].min_level,
@@ -367,7 +364,7 @@ static void speech_immunity_tests(sig_tone_rx_state_t *s)
sig_tone_rx(s, amp, frames);
}
/*endwhile*/
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
exit(2);
@@ -509,7 +506,7 @@ static void sequence_tests(sig_tone_tx_state_t *tx_state, sig_tone_rx_state_t *r
/*endif*/
}
/*endfor*/
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -405,7 +405,7 @@ int main(int argc, char *argv[])
sample += x;
}
}
if (sf_close(inhandle))
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
exit(2);
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
sample += x;
}
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
exit(2);
+2 -2
View File
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
}
printf("Test with swept tone.\n");
s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, 1);
s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, TRUE);
for (j = 0; j < 60*SAMPLE_RATE; j += BLOCK_LEN)
{
len = swept_tone(s, buf, BLOCK_LEN);
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
#endif
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+9 -9
View File
@@ -282,7 +282,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -295,9 +295,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -310,9 +310,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("Phase E handler on channel %c\n", i);
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
//exit(0);
}
/*- End of function --------------------------------------------------------*/
@@ -942,7 +942,7 @@ static int t30_tests(int log_audio, int test_sending)
}
if (decode_test_file)
{
if (sf_close(in_handle) != 0)
if (sf_close_telephony(in_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -950,7 +950,7 @@ static int t30_tests(int log_audio, int test_sending)
}
if (log_audio)
{
if (sf_close(wave_handle) != 0)
if (sf_close_telephony(wave_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
exit(2);
+1 -1
View File
@@ -31,7 +31,7 @@ These tests exercise the T.38 core ASN.1 processing code.
*/
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <stdlib.h>
+309 -65
View File
@@ -5,7 +5,7 @@
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2009 Steve Underwood
* Copyright (C) 2010 Steve Underwood
*
* All rights reserved.
*
@@ -21,12 +21,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Some code from SIPP (http://sf.net/projects/sipp) was used as a model
* for how to work with PCAP files. That code was authored by Guillaume
* TEISSIER from FTR&D 02/02/2006, and released under the GPL2 licence.
*/
/*! \file */
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@@ -43,17 +44,38 @@
#include <unistd.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "udptl.h"
#include "spandsp.h"
#include "spandsp-sim.h"
#include "fax_utils.h"
#include "pcap_parse.h"
#define INPUT_FILE_NAME "t38.pcap"
#define OUTPUT_FILE_NAME "t38pcap.tif"
#define INPUT_TIFF_FILE_NAME "../test-data/itu/fax/itutests.tif"
#define OUTPUT_TIFF_FILE_NAME "t38pcap.tif"
t38_terminal_state_t *t38_state;
struct timeval now;
#define OUTPUT_WAVE_FILE_NAME "t38_decode2.wav"
#define SAMPLES_PER_CHUNK 160
static t38_core_state_t *t38_core;
static t38_terminal_state_t *t38_terminal_state;
static t38_gateway_state_t *t38_gateway_state;
static fax_state_t *fax_state;
static struct timeval now;
static SNDFILE *wave_handle;
static int log_audio;
static int use_transmit_on_idle;
static int done = FALSE;
static int started = FALSE;
static int64_t current = 0;
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
@@ -63,7 +85,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -76,9 +98,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -92,9 +114,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
t30_get_transfer_statistics(s, &t);
}
/*- End of function --------------------------------------------------------*/
@@ -105,14 +127,12 @@ static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t
}
/*- End of function --------------------------------------------------------*/
static int timing_update(void *user_data, struct timeval *ts)
static int t38_terminal_timing_update(void *user_data, struct timeval *ts)
{
t30_state_t *t30;
t38_core_state_t *t38_core;
logging_state_t *logging;
int samples;
int partial;
static int64_t current = 0;
int64_t when;
int64_t diff;
@@ -120,24 +140,125 @@ static int timing_update(void *user_data, struct timeval *ts)
when = ts->tv_sec*1000000LL + ts->tv_usec;
if (current == 0)
current = when;
{
if (started)
current = when;
return 0;
}
diff = when - current;
samples = diff/125LL;
while (samples > 0)
{
partial = (samples > 160) ? 160 : samples;
partial = (samples > SAMPLES_PER_CHUNK) ? SAMPLES_PER_CHUNK : samples;
//fprintf(stderr, "Update time by %d samples\n", partial);
logging = t38_terminal_get_logging_state(t38_state);
logging = t38_terminal_get_logging_state(t38_terminal_state);
span_log_bump_samples(logging, partial);
t38_core = t38_terminal_get_t38_core_state(t38_state);
logging = t38_core_get_logging_state(t38_core);
span_log_bump_samples(logging, partial);
t30 = t38_terminal_get_t30_state(t38_state);
t30 = t38_terminal_get_t30_state(t38_terminal_state);
logging = t30_get_logging_state(t30);
span_log_bump_samples(logging, partial);
t38_terminal_send_timeout(t38_terminal_state, partial);
current = when;
samples -= partial;
}
return 0;
}
/*- End of function --------------------------------------------------------*/
static int t38_gateway_timing_update(void *user_data, struct timeval *ts)
{
t30_state_t *t30;
logging_state_t *logging;
int samples;
int partial;
int64_t when;
int64_t diff;
int16_t t38_amp[SAMPLES_PER_CHUNK];
int16_t t30_amp[SAMPLES_PER_CHUNK];
int16_t out_amp[2*SAMPLES_PER_CHUNK];
int t38_len;
int t30_len;
int outframes;
int i;
memcpy(&now, ts, sizeof(now));
when = ts->tv_sec*1000000LL + ts->tv_usec;
if (current == 0)
{
if (started)
current = when;
return 0;
}
diff = when - current;
samples = diff/125LL;
while (samples > 0)
{
partial = (samples > SAMPLES_PER_CHUNK) ? SAMPLES_PER_CHUNK : samples;
//fprintf(stderr, "Update time by %d samples\n", partial);
logging = t38_gateway_get_logging_state(t38_gateway_state);
span_log_bump_samples(logging, partial);
logging = t38_core_get_logging_state(t38_core);
span_log_bump_samples(logging, partial);
logging = fax_get_logging_state(fax_state);
span_log_bump_samples(logging, partial);
t30 = fax_get_t30_state(fax_state);
logging = t30_get_logging_state(t30);
span_log_bump_samples(logging, partial);
memset(out_amp, 0, sizeof(out_amp));
t30_len = fax_tx(fax_state, t30_amp, partial);
if (!use_transmit_on_idle)
{
/* The receive side always expects a full block of samples, but the
transmit side may not be sending any when it doesn't need to. We
may need to pad with some silence. */
if (t30_len < partial)
{
memset(t30_amp + t30_len, 0, sizeof(int16_t)*(partial - t30_len));
t30_len = partial;
}
}
if (log_audio)
{
for (i = 0; i < t30_len; i++)
out_amp[2*i + 1] = t30_amp[i];
}
if (t38_gateway_rx(t38_gateway_state, t30_amp, t30_len))
break;
t38_terminal_send_timeout(t38_state, partial);
t38_len = t38_gateway_tx(t38_gateway_state, t38_amp, partial);
if (!use_transmit_on_idle)
{
if (t38_len < partial)
{
memset(t38_amp + t38_len, 0, sizeof(int16_t)*(partial - t38_len));
t38_len = partial;
}
}
if (log_audio)
{
for (i = 0; i < t38_len; i++)
out_amp[2*i] = t38_amp[i];
}
if (fax_rx(fax_state, t38_amp, partial))
break;
if (log_audio)
{
outframes = sf_writef_short(wave_handle, out_amp, partial);
if (outframes != partial)
break;
}
if (done)
break;
current = when;
samples -= partial;
}
@@ -147,15 +268,15 @@ static int timing_update(void *user_data, struct timeval *ts)
static int ifp_handler(void *user_data, const uint8_t msg[], int len, int seq_no)
{
t38_core_state_t *t38_core;
int i;
started = TRUE;
printf("%5d >>> ", seq_no);
for (i = 0; i < len; i++)
printf("%02X ", msg[i]);
printf("\n");
t38_core = t38_terminal_get_t38_core_state(t38_state);
t38_core_rx_ifp_packet(t38_core, msg, len, seq_no);
return 0;
@@ -174,42 +295,75 @@ static int process_packet(void *user_data, const uint8_t *pkt, int len)
}
/*- End of function --------------------------------------------------------*/
static uint32_t parse_inet_addr(const char *s)
{
int i;
uint32_t a;
uint32_t b;
uint32_t c;
uint32_t d;
a = 0;
b = 0;
c = 0;
d = 0;
i = sscanf(s, "%" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32, &a, &b, &c, &d);
switch (i)
{
case 4:
c = (c << 8) | d;
case 3:
b = (b << 16) | c;
case 2:
a = (a << 24) | b;
}
return a;
}
/*- End of function --------------------------------------------------------*/
int main(int argc, char *argv[])
{
t30_state_t *t30;
t38_core_state_t *t38_core;
logging_state_t *logging;
const char *input_file_name;
int t38_version;
int caller;
int use_ecm;
int use_tep;
int options;
int supported_modems;
int fill_removal;
int opt;
int t38_terminal_operation;
uint32_t src_addr;
uint16_t src_port;
uint32_t dest_addr;
uint16_t dest_port;
caller = FALSE;
use_ecm = FALSE;
t38_version = 1;
t38_version = 0;
options = 0;
input_file_name = INPUT_FILE_NAME;
fill_removal = FALSE;
use_tep = FALSE;
use_transmit_on_idle = TRUE;
supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17;
t38_terminal_operation = TRUE;
log_audio = FALSE;
src_addr = 0;
src_port = 0;
dest_addr = 0;
dest_port = 0;
while ((opt = getopt(argc, argv, "D:d:eFi:m:oS:s:tv:")) != -1)
while ((opt = getopt(argc, argv, "cD:d:eFGi:lm:oS:s:tv:")) != -1)
{
switch (opt)
{
case 'c':
caller = TRUE;
break;
case 'D':
dest_addr = atoi(optarg);
dest_addr = parse_inet_addr(optarg);
break;
case 'd':
dest_port = atoi(optarg);
@@ -220,9 +374,15 @@ int main(int argc, char *argv[])
case 'F':
fill_removal = TRUE;
break;
case 'G':
t38_terminal_operation = FALSE;
break;
case 'i':
input_file_name = optarg;
break;
case 'l':
log_audio = TRUE;
break;
case 'm':
supported_modems = atoi(optarg);
break;
@@ -230,7 +390,7 @@ int main(int argc, char *argv[])
options = atoi(optarg);
break;
case 'S':
src_addr = atoi(optarg);
src_addr = parse_inet_addr(optarg);
break;
case 's':
src_port = atoi(optarg);
@@ -248,44 +408,128 @@ int main(int argc, char *argv[])
}
}
if ((t38_state = t38_terminal_init(NULL, FALSE, tx_packet_handler, NULL)) == NULL)
printf("Using T.38 version %d\n", t38_version);
if (t38_terminal_operation)
{
fprintf(stderr, "Cannot start the T.38 channel\n");
exit(2);
}
t30 = t38_terminal_get_t30_state(t38_state);
t38_core = t38_terminal_get_t38_core_state(t38_state);
t38_set_t38_version(t38_core, t38_version);
t38_terminal_set_config(t38_state, options);
t38_terminal_set_tep_mode(t38_state, use_tep);
if ((t38_terminal_state = t38_terminal_init(NULL, caller, tx_packet_handler, NULL)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 channel\n");
exit(2);
}
t30 = t38_terminal_get_t30_state(t38_terminal_state);
t38_core = t38_terminal_get_t38_core_state(t38_terminal_state);
t38_set_t38_version(t38_core, t38_version);
t38_terminal_set_config(t38_terminal_state, options);
t38_terminal_set_tep_mode(t38_terminal_state, use_tep);
logging = t38_terminal_get_logging_state(t38_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t38_terminal_get_logging_state(t38_terminal_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t38_core_get_logging_state(t38_core);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t38_core_get_logging_state(t38_core);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t30_get_logging_state(t30);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t30_get_logging_state(t30);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
t30_set_supported_modems(t30, supported_modems);
t30_set_tx_ident(t30, "11111111");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
t30_set_rx_file(t30, OUTPUT_FILE_NAME, -1);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
t30_set_ecm_capability(t30, TRUE);
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
t30_set_supported_modems(t30, supported_modems);
t30_set_tx_ident(t30, "11111111");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
if (caller)
t30_set_tx_file(t30, INPUT_TIFF_FILE_NAME, -1, -1);
else
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
t30_set_ecm_capability(t30, TRUE);
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION);
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, timing_update, process_packet, NULL))
exit(2);
/* Push the time along, to flush out any remaining activity from the application. */
now.tv_sec += 60;
timing_update(NULL, &now);
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, t38_terminal_timing_update, process_packet, NULL))
exit(2);
/* Push the time along, to flush out any remaining activity from the application. */
now.tv_sec += 60;
t38_terminal_timing_update(NULL, &now);
}
else
{
wave_handle = NULL;
if (log_audio)
{
if ((wave_handle = sf_open_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == NULL)
{
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
exit(2);
}
}
if ((t38_gateway_state = t38_gateway_init(NULL, tx_packet_handler, NULL)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 channel\n");
exit(2);
}
t38_core = t38_gateway_get_t38_core_state(t38_gateway_state);
t38_gateway_set_transmit_on_idle(t38_gateway_state, use_transmit_on_idle);
t38_set_t38_version(t38_core, t38_version);
t38_gateway_set_ecm_capability(t38_gateway_state, TRUE);
logging = t38_gateway_get_logging_state(t38_gateway_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t38_core_get_logging_state(t38_core);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
if ((fax_state = fax_init(NULL, caller)) == NULL)
{
fprintf(stderr, "Cannot start FAX\n");
exit(2);
}
t30 = fax_get_t30_state(fax_state);
fax_set_transmit_on_idle(fax_state, use_transmit_on_idle);
fax_set_tep_mode(fax_state, use_tep);
t30_set_supported_modems(t30, supported_modems);
t30_set_tx_ident(t30, "22222222");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
if (caller)
t30_set_tx_file(t30, INPUT_TIFF_FILE_NAME, -1, -1);
else
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'B');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'B');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'B');
t30_set_ecm_capability(t30, TRUE);
t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
logging = fax_get_logging_state(fax_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "FAX ");
logging = t30_get_logging_state(t30);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "FAX ");
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, t38_gateway_timing_update, process_packet, NULL))
exit(2);
/* Push the time along, to flush out any remaining activity from the application. */
now.tv_sec += 60;
t38_gateway_timing_update(NULL, &now);
fax_release(fax_state);
t38_gateway_release(t38_gateway_state);
if (log_audio)
{
if (sf_close_telephony(wave_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
exit(2);
}
}
}
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+9 -9
View File
@@ -36,7 +36,7 @@ These tests exercise the path
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
@@ -95,7 +95,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -108,9 +108,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -124,9 +124,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
t30_get_transfer_statistics(s, &t);
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
done[i - 'A'] = TRUE;
@@ -647,7 +647,7 @@ int main(int argc, char *argv[])
fax_release(fax_state_b);
if (log_audio)
{
if (sf_close(wave_handle) != 0)
if (sf_close_telephony(wave_handle) != 0)
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
exit(2);
@@ -36,7 +36,7 @@ These tests exercise the path
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
@@ -103,7 +103,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -116,9 +116,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -132,9 +132,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
t30_get_transfer_statistics(s, &t);
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
done[i - 'A'] = TRUE;
@@ -363,7 +363,7 @@ static int decode_test(const char *decode_test_file)
}
t38_gateway_release(t38_state_a);
t38_terminal_release(t38_state_b);
if (sf_close(wave_handle) != 0)
if (sf_close_telephony(wave_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -690,7 +690,7 @@ int main(int argc, char *argv[])
t38_terminal_release(t38_state_b);
if (log_audio)
{
if (sf_close(wave_handle) != 0)
if (sf_close_telephony(wave_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
exit(2);
@@ -32,7 +32,7 @@ module, used for T.38 gateways.
*/
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <stdlib.h>
+8 -8
View File
@@ -35,7 +35,7 @@ These tests exercise the path
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
@@ -90,7 +90,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -103,9 +103,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -119,9 +119,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
t30_get_transfer_statistics(s, &t);
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
//done[i - 'A'] = TRUE;
@@ -36,7 +36,7 @@ These tests exercise the path
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
@@ -94,7 +94,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_rx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -107,9 +107,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
@@ -123,9 +123,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
t30_get_transfer_statistics(s, &t);
succeeded[i - 'A'] = (result == T30_ERR_OK) && (t.pages_tx == 12 || t.pages_rx == 12);
done[i - 'A'] = TRUE;
@@ -496,7 +496,7 @@ int main(int argc, char *argv[])
fax_release(fax_state_b);
if (log_audio)
{
if (sf_close(wave_handle) != 0)
if (sf_close_telephony(wave_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
exit(2);
+2 -2
View File
@@ -151,12 +151,12 @@ int main(int argc, char *argv[])
count = 0;
}
}
if (sf_close(inhandle) != 0)
if (sf_close(inhandle))
{
printf(" Cannot close audio file '%s'\n", in_file_name);
exit(2);
}
if (sf_close(outhandle) != 0)
if (sf_close(outhandle))
{
printf(" Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+1 -1
View File
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
outframes = sf_writef_short(outhandle, amp, len);
}
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit (2);
+2 -1
View File
@@ -28,6 +28,7 @@ run_tsb85_test()
fi
}
for TEST in PPS-MPS-lost-PPS ; do
for TEST in PPS-MPS-lost-PPS
do
run_tsb85_test
done
+14 -14
View File
@@ -26,7 +26,7 @@
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#include "config.h"
#endif
#include <inttypes.h>
@@ -69,7 +69,7 @@
#define OUTPUT_TIFF_FILE_NAME "tsb85.tif"
#define OUTPUT_FILE_NAME_WAVE "tsb85.wav"
#define OUTPUT_WAVE_FILE_NAME "tsb85.wav"
#define SAMPLES_PER_CHUNK 160
@@ -220,9 +220,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
if (use_receiver_not_ready)
t30_set_receiver_not_ready(s, 3);
@@ -262,9 +262,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
log_transfer_statistics(s, tag);
log_tx_parameters(s, tag);
log_rx_parameters(s, tag);
fax_log_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
}
/*- End of function --------------------------------------------------------*/
@@ -869,7 +869,7 @@ static int next_step(faxtester_state_t *s)
else if (strcasecmp((const char *) tag, "TXFILE") == 0)
{
sprintf(next_tx_file, "%s/%s", image_path, (const char *) value);
printf("Push '%s'\n", next_tx_file);
printf("Push '%s'\n", next_tx_file);
}
return 0;
}
@@ -1066,9 +1066,9 @@ static void exchange(faxtester_state_t *s)
if (log_audio)
{
if ((out_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == NULL)
if ((out_handle = sf_open_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == NULL)
{
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
printf("Test failed\n");
exit(2);
}
@@ -1116,7 +1116,7 @@ static void exchange(faxtester_state_t *s)
span_log_bump_samples(&s->logging, len);
len = faxtester_tx(s, amp, 160);
len = faxtester_tx(s, amp, SAMPLES_PER_CHUNK);
if (fax_rx(fax, amp, len))
break;
/*endif*/
@@ -1134,9 +1134,9 @@ static void exchange(faxtester_state_t *s)
/*endfor*/
if (log_audio)
{
if (sf_close(out_handle))
if (sf_close_telephony(out_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
printf("Test failed\n");
exit(2);
}
+42 -23
View File
@@ -28,7 +28,8 @@ run_tsb85_test()
fi
}
for TEST in MRGN01 MRGN02 MRGN03 MRGN04 MRGN05 MRGN06a MRGN06b MRGN07 MRGN08 ; do
for TEST in MRGN01 MRGN02 MRGN03 MRGN04 MRGN05 MRGN06a MRGN06b MRGN07 MRGN08
do
run_tsb85_test
done
@@ -37,16 +38,19 @@ done
#MRGN16 fails because we don't adequately distinguish between receiving a
#bad image signal and receiving none at all.
#for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN14 MRGN15 MRGN16 MRGN17 ; do
for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 MRGN17 ; do
#for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN14 MRGN15 MRGN16 MRGN17
for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 MRGN17
do
run_tsb85_test
done
for TEST in ORGC01 ORGC02 ORGC03 ; do
for TEST in ORGC01 ORGC02 ORGC03
do
run_tsb85_test
done
for TEST in OREN01 OREN02 OREN03 OREN04 OREN05 OREN06 OREN07 OREN08 OREN09 OREN10 ; do
for TEST in OREN01 OREN02 OREN03 OREN04 OREN05 OREN06 OREN07 OREN08 OREN09 OREN10
do
run_tsb85_test
done
@@ -54,69 +58,84 @@ done
# MRGX05 is failing because we don't distinguish MPS immediately after MCF from MPS after
# a corrupt image signal.
#for TEST in MRGX01 MRGX02 MRGX03 MRGX04 MRGX05 MRGX06 MRGX07 MRGX08 ; do
for TEST in MRGX01 MRGX02 MRGX04 MRGX06 MRGX07 MRGX08 ; do
#for TEST in MRGX01 MRGX02 MRGX03 MRGX04 MRGX05 MRGX06 MRGX07 MRGX08
for TEST in MRGX01 MRGX02 MRGX04 MRGX06 MRGX07 MRGX08
do
run_tsb85_test
done
for TEST in MRGX09 MRGX10 MRGX11 MRGX12 MRGX13 MRGX14 MRGX15 ; do
for TEST in MRGX09 MRGX10 MRGX11 MRGX12 MRGX13 MRGX14 MRGX15
do
run_tsb85_test
done
for TEST in MTGP01 MTGP02 OTGP03 ; do
for TEST in MTGP01 MTGP02 OTGP03
do
run_tsb85_test
done
for TEST in MTGN01 MTGN02 MTGN03 MTGN04 MTGN05 MTGN06 MTGN07 MTGN08 MTGN09 MTGN10 ; do
for TEST in MTGN01 MTGN02 MTGN03 MTGN04 MTGN05 MTGN06 MTGN07 MTGN08 MTGN09 MTGN10
do
run_tsb85_test
done
for TEST in MTGN11 MTGN12 MTGN13 MTGN14 MTGN15 MTGN16 MTGN17 MTGN18 MTGN19 MTGN20 ; do
for TEST in MTGN11 MTGN12 MTGN13 MTGN14 MTGN15 MTGN16 MTGN17 MTGN18 MTGN19 MTGN20
do
run_tsb85_test
done
for TEST in MTGN21 MTGN22 MTGN23 MTGN24 MTGN25 MTGN26 MTGN27 MTGN28 ; do
for TEST in MTGN21 MTGN22 MTGN23 MTGN24 MTGN25 MTGN26 MTGN27 MTGN28
do
run_tsb85_test
done
for TEST in OTGC01 OTGC02 OTGC03 OTGC04 OTGC05 OTGC06 OTGC07 OTGC08 ; do
for TEST in OTGC01 OTGC02 OTGC03 OTGC04 OTGC05 OTGC06 OTGC07 OTGC08
do
run_tsb85_test
done
for TEST in OTGC09-01 OTGC09-02 OTGC09-03 OTGC09-04 OTGC09-05 OTGC09-06 OTGC09-07 OTGC09-08 OTGC09-09 OTGC09-10 OTGC09-11 OTGC09-12 ; do
for TEST in OTGC09-01 OTGC09-02 OTGC09-03 OTGC09-04 OTGC09-05 OTGC09-06 OTGC09-07 OTGC09-08 OTGC09-09 OTGC09-10 OTGC09-11 OTGC09-12
do
run_tsb85_test
done
for TEST in OTGC10 OTGC11 ; do
for TEST in OTGC10 OTGC11
do
run_tsb85_test
done
#OTEN02 fails because ?????
#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 ; do
for TEST in OTEN01 OTEN03 OTEN04 OTEN05 OTEN06 ; do
#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06
for TEST in OTEN01 OTEN03 OTEN04 OTEN05 OTEN06
do
run_tsb85_test
done
#MTGX02 fails because ?????
#for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 ; do
for TEST in MTGX01 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 ; do
#for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08
for TEST in MTGX01 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08
do
run_tsb85_test
done
for TEST in MTGX09 MTGX10 MTGX11 MTGX12 MTGX13 MTGX14 MTGX15 MTGX16 ; do
for TEST in MTGX09 MTGX10 MTGX11 MTGX12 MTGX13 MTGX14 MTGX15 MTGX16
do
run_tsb85_test
done
for TEST in MTGX17 MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23 ; do
for TEST in MTGX17 MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23
do
run_tsb85_test
done
for TEST in MRGP01 MRGP02 MRGP03 MRGP04 MRGP05 MRGP06 MRGP07 MRGP08 ; do
for TEST in MRGP01 MRGP02 MRGP03 MRGP04 MRGP05 MRGP06 MRGP07 MRGP08
do
run_tsb85_test
done
for TEST in ORGP09 ORGP10 ; do
for TEST in ORGP09 ORGP10
do
run_tsb85_test
done
+2 -2
View File
@@ -293,7 +293,7 @@ static int decode_test_data_file(int mode, const char *filename)
break;
v18_rx(v18_state, amp, len);
}
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -493,7 +493,7 @@ int main(int argc, char *argv[])
basic_tests(V18_MODE_5BIT_45);
if (log_audio)
{
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
#endif
if (decode_test_file)
{
if (sf_close(inhandle))
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -420,7 +420,7 @@ int main(int argc, char *argv[])
}
if (log_audio)
{
if (sf_close(outhandle) != 0)
if (sf_close_telephony(outhandle) != 0)
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -532,7 +532,7 @@ int main(int argc, char *argv[])
#endif
if (decode_test_file)
{
if (sf_close(inhandle))
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -540,7 +540,7 @@ int main(int argc, char *argv[])
}
if (log_audio)
{
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+2 -2
View File
@@ -561,7 +561,7 @@ int main(int argc, char *argv[])
#endif
if (decode_test_file)
{
if (sf_close(inhandle))
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
@@ -569,7 +569,7 @@ int main(int argc, char *argv[])
}
if (log_audio)
{
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
exit(2);
+32 -12
View File
@@ -56,13 +56,13 @@ int tx_next[3] = {0};
static void v42_status(void *user_data, int status)
{
int x;
v42_state_t *s;
x = (intptr_t) user_data;
s = (v42_state_t *) user_data;
if (status < 0)
printf("%d: Status is '%s' (%d)\n", x, signal_status_to_str(status), status);
printf("%p: Status is '%s' (%d)\n", s, signal_status_to_str(status), status);
else
printf("%d: Status is '%s' (%d)\n", x, lapm_status_to_str(status), status);
printf("%p: Status is '%s' (%d)\n", s, lapm_status_to_str(status), status);
}
/*- End of function --------------------------------------------------------*/
@@ -72,13 +72,15 @@ static int v42_get_frames(void *user_data, uint8_t *msg, int len)
int j;
int k;
int x;
v42_state_t *s;
if (len < 0)
{
v42_status(user_data, len);
return 0;
}
x = (intptr_t) user_data;
s = (v42_state_t *) user_data;
x = (s == &caller) ? 1 : 2;
if (variable_length)
{
j = make_mask32(len);
@@ -99,24 +101,42 @@ static int v42_get_frames(void *user_data, uint8_t *msg, int len)
static void v42_put_frames(void *user_data, const uint8_t *msg, int len)
{
int i;
v42_state_t *s;
int x;
static int count = 0;
static int xxx = 0;
if (len < 0)
{
v42_status(user_data, len);
return;
}
x = (intptr_t) user_data;
s = (v42_state_t *) user_data;
x = (s == &caller) ? 1 : 2;
for (i = 0; i < len; i++)
{
if (msg[i] != (rx_next[x] & 0xFF))
{
printf("%d: Mismatch 0x%02X 0x%02X\n", x, msg[i], rx_next[x] & 0xFF);
printf("%p: Mismatch 0x%02X 0x%02X\n", user_data, msg[i], rx_next[x] & 0xFF);
exit(2);
}
rx_next[x]++;
}
printf("%d: Got frame len %d\n", x, len);
printf("%p: Got frame len %d\n", user_data, len);
printf("%p: %d Far end busy status %d\n", user_data, count, v42_get_far_busy_status(s));
if (s == &caller)
{
if (++count == 5)
{
v42_set_local_busy_status(s, TRUE);
xxx = 1;
}
}
else
{
if (xxx && ++count == 45)
v42_set_local_busy_status(&caller, FALSE);
}
}
/*- End of function --------------------------------------------------------*/
@@ -149,10 +169,10 @@ int main(int argc, char *argv[])
}
}
v42_init(&caller, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) 1);
v42_init(&answerer, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) 2);
v42_set_status_callback(&caller, v42_status, (void *) 1);
v42_set_status_callback(&answerer, v42_status, (void *) 2);
v42_init(&caller, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) &caller);
v42_init(&answerer, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) &answerer);
v42_set_status_callback(&caller, v42_status, (void *) &caller);
v42_set_status_callback(&answerer, v42_status, (void *) &answerer);
v42_restart(&caller);
v42_restart(&answerer);
+2 -2
View File
@@ -631,7 +631,7 @@ int main(int argc, char *argv[])
v8_free(v8_caller);
v8_free(v8_answerer);
if (sf_close(inhandle) != 0)
if (sf_close_telephony(inhandle))
{
fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
exit(2);
@@ -663,7 +663,7 @@ int main(int argc, char *argv[])
if (outhandle)
{
if (sf_close(outhandle))
if (sf_close_telephony(outhandle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
exit(2);