v8_tests.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /*
  2. * SpanDSP - a series of DSP components for telephony
  3. *
  4. * v8_tests.c
  5. *
  6. * Written by Steve Underwood <steveu@coppice.org>
  7. *
  8. * Copyright (C) 2004 Steve Underwood
  9. *
  10. * All rights reserved.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2, as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. /*! \page v8_tests_page V.8 tests
  26. \section v8_tests_page_sec_1 What does it do?
  27. */
  28. #if defined(HAVE_CONFIG_H)
  29. #include "config.h"
  30. #endif
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <fcntl.h>
  34. #include <unistd.h>
  35. #include <string.h>
  36. #include <sndfile.h>
  37. #include "spandsp.h"
  38. #include "spandsp-sim.h"
  39. #define SAMPLES_PER_CHUNK 160
  40. #define OUTPUT_FILE_NAME "v8.wav"
  41. int negotiations_ok = 0;
  42. #if 0
  43. static int select_modulation(int mask)
  44. {
  45. /* Select the fastest data modem available */
  46. if (mask & V8_MOD_V90)
  47. return V8_MOD_V90;
  48. /*endif*/
  49. if (mask & V8_MOD_V34)
  50. return V8_MOD_V34;
  51. /*endif*/
  52. if (mask & V8_MOD_V32)
  53. return V8_MOD_V32;
  54. /*endif*/
  55. if (mask & V8_MOD_V23)
  56. return V8_MOD_V23;
  57. /*endif*/
  58. if (mask & V8_MOD_V21)
  59. return V8_MOD_V21;
  60. /*endif*/
  61. return -1;
  62. }
  63. /*- End of function --------------------------------------------------------*/
  64. #endif
  65. static void handler(void *user_data, v8_parms_t *result)
  66. {
  67. const char *s;
  68. s = (const char *) user_data;
  69. printf("%s ", s);
  70. switch (result->status)
  71. {
  72. case V8_STATUS_IN_PROGRESS:
  73. printf("V.8 negotiation in progress\n");
  74. return;
  75. case V8_STATUS_V8_OFFERED:
  76. printf("V.8 offered by the other party\n");
  77. break;
  78. case V8_STATUS_V8_CALL:
  79. printf("V.8 call negotiation successful\n");
  80. break;
  81. case V8_STATUS_NON_V8_CALL:
  82. printf("Non-V.8 call negotiation successful\n");
  83. break;
  84. case V8_STATUS_FAILED:
  85. printf("V.8 call negotiation failed\n");
  86. return;
  87. default:
  88. printf("Unexpected V.8 status %d\n", result->status);
  89. break;
  90. }
  91. /*endswitch*/
  92. printf(" Modem connect tone '%s' (%d)\n", modem_connect_tone_to_str(result->modem_connect_tone), result->modem_connect_tone);
  93. printf(" Call function '%s' (%d)\n", v8_call_function_to_str(result->call_function), result->call_function);
  94. printf(" Far end modulations 0x%X\n", result->modulations);
  95. printf(" Protocol '%s' (%d)\n", v8_protocol_to_str(result->protocol), result->protocol);
  96. printf(" PSTN access '%s' (%d)\n", v8_pstn_access_to_str(result->pstn_access), result->pstn_access);
  97. printf(" PCM modem availability '%s' (%d)\n", v8_pcm_modem_availability_to_str(result->pcm_modem_availability), result->pcm_modem_availability);
  98. if (result->t66 >= 0)
  99. printf(" T.66 '%s' (%d)\n", v8_t66_to_str(result->t66), result->t66);
  100. /*endif*/
  101. if (result->nsf >= 0)
  102. printf(" NSF %d\n", result->nsf);
  103. /*endif*/
  104. switch (result->status)
  105. {
  106. case V8_STATUS_V8_OFFERED:
  107. /* Edit the result information appropriately */
  108. //result->call_function = V8_CALL_T30_TX;
  109. result->modulations &= (V8_MOD_V17
  110. | V8_MOD_V21
  111. //| V8_MOD_V22
  112. //| V8_MOD_V23HDX
  113. //| V8_MOD_V23
  114. //| V8_MOD_V26BIS
  115. //| V8_MOD_V26TER
  116. | V8_MOD_V27TER
  117. | V8_MOD_V29
  118. //| V8_MOD_V32
  119. | V8_MOD_V34HDX
  120. //| V8_MOD_V34
  121. //| V8_MOD_V90
  122. | V8_MOD_V92);
  123. break;
  124. case V8_STATUS_V8_CALL:
  125. if (result->call_function == V8_CALL_V_SERIES
  126. &&
  127. result->protocol == V8_PROTOCOL_LAPM_V42)
  128. {
  129. negotiations_ok++;
  130. }
  131. /*endif*/
  132. break;
  133. case V8_STATUS_NON_V8_CALL:
  134. negotiations_ok = 42;
  135. break;
  136. }
  137. /*endswitch*/
  138. }
  139. /*- End of function --------------------------------------------------------*/
  140. static int v8_calls_v8_tests(SNDFILE *outhandle)
  141. {
  142. v8_state_t *v8_caller;
  143. v8_state_t *v8_answerer;
  144. logging_state_t *caller_logging;
  145. logging_state_t *answerer_logging;
  146. int caller_available_modulations;
  147. int answerer_available_modulations;
  148. int i;
  149. int samples;
  150. int remnant;
  151. int outframes;
  152. int16_t amp[SAMPLES_PER_CHUNK];
  153. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  154. v8_parms_t v8_call_parms;
  155. v8_parms_t v8_answer_parms;
  156. caller_available_modulations = V8_MOD_V17
  157. | V8_MOD_V21
  158. | V8_MOD_V22
  159. | V8_MOD_V23HDX
  160. | V8_MOD_V23
  161. | V8_MOD_V26BIS
  162. | V8_MOD_V26TER
  163. | V8_MOD_V27TER
  164. | V8_MOD_V29
  165. | V8_MOD_V32
  166. | V8_MOD_V34HDX
  167. | V8_MOD_V34
  168. | V8_MOD_V90
  169. | V8_MOD_V92;
  170. answerer_available_modulations = V8_MOD_V17
  171. | V8_MOD_V21
  172. | V8_MOD_V22
  173. | V8_MOD_V23HDX
  174. | V8_MOD_V23
  175. | V8_MOD_V26BIS
  176. | V8_MOD_V26TER
  177. | V8_MOD_V27TER
  178. | V8_MOD_V29
  179. | V8_MOD_V32
  180. | V8_MOD_V34HDX
  181. | V8_MOD_V34
  182. | V8_MOD_V90
  183. | V8_MOD_V92;
  184. negotiations_ok = 0;
  185. v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
  186. v8_call_parms.send_ci = true;
  187. v8_call_parms.v92 = -1;
  188. v8_call_parms.call_function = V8_CALL_V_SERIES;
  189. v8_call_parms.modulations = caller_available_modulations;
  190. v8_call_parms.protocol = V8_PROTOCOL_LAPM_V42;
  191. v8_call_parms.pcm_modem_availability = 0;
  192. v8_call_parms.pstn_access = 0;
  193. v8_call_parms.nsf = -1;
  194. v8_call_parms.t66 = -1;
  195. v8_caller = v8_init(NULL, true, &v8_call_parms, handler, (void *) "caller");
  196. v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR;
  197. v8_answer_parms.send_ci = true;
  198. v8_answer_parms.v92 = -1;
  199. v8_answer_parms.call_function = V8_CALL_V_SERIES;
  200. v8_answer_parms.modulations = answerer_available_modulations;
  201. v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42;
  202. v8_answer_parms.pcm_modem_availability = 0;
  203. v8_answer_parms.pstn_access = 0;
  204. v8_answer_parms.nsf = -1;
  205. v8_answer_parms.t66 = -1;
  206. v8_answerer = v8_init(NULL, false, &v8_answer_parms, handler, (void *) "answerer");
  207. caller_logging = v8_get_logging_state(v8_caller);
  208. span_log_set_level(caller_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
  209. span_log_set_tag(caller_logging, "caller");
  210. answerer_logging = v8_get_logging_state(v8_answerer);
  211. span_log_set_level(answerer_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
  212. span_log_set_tag(answerer_logging, "answerer");
  213. for (i = 0; i < 1000; i++)
  214. {
  215. samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
  216. if (samples < SAMPLES_PER_CHUNK)
  217. {
  218. printf("Caller silence %d\n", SAMPLES_PER_CHUNK - samples);
  219. vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
  220. samples = SAMPLES_PER_CHUNK;
  221. }
  222. /*endif*/
  223. span_log_bump_samples(caller_logging, samples);
  224. remnant = v8_rx(v8_answerer, amp, samples);
  225. for (i = 0; i < samples; i++)
  226. out_amp[2*i] = amp[i];
  227. /*endfor*/
  228. samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
  229. if (samples < SAMPLES_PER_CHUNK)
  230. {
  231. printf("Answerer silence %d\n", SAMPLES_PER_CHUNK - samples);
  232. vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
  233. samples = SAMPLES_PER_CHUNK;
  234. }
  235. /*endif*/
  236. span_log_bump_samples(answerer_logging, samples);
  237. if (v8_rx(v8_caller, amp, samples) && remnant)
  238. break;
  239. /*endif*/
  240. for (i = 0; i < samples; i++)
  241. out_amp[2*i + 1] = amp[i];
  242. /*endfor*/
  243. if (outhandle)
  244. {
  245. outframes = sf_writef_short(outhandle, out_amp, samples);
  246. if (outframes != samples)
  247. {
  248. fprintf(stderr, " Error writing audio file\n");
  249. exit(2);
  250. }
  251. /*endif*/
  252. }
  253. /*endif*/
  254. }
  255. /*endfor*/
  256. v8_free(v8_caller);
  257. v8_free(v8_answerer);
  258. if (negotiations_ok != 2)
  259. {
  260. printf("Tests failed.\n");
  261. exit(2);
  262. }
  263. /*endif*/
  264. return 0;
  265. }
  266. /*- End of function --------------------------------------------------------*/
  267. static int non_v8_calls_v8_tests(SNDFILE *outhandle)
  268. {
  269. silence_gen_state_t *non_v8_caller_tx;
  270. modem_connect_tones_rx_state_t *non_v8_caller_rx;
  271. v8_state_t *v8_answerer;
  272. logging_state_t *answerer_logging;
  273. int answerer_available_modulations;
  274. int i;
  275. int samples;
  276. int remnant;
  277. int outframes;
  278. int tone;
  279. int16_t amp[SAMPLES_PER_CHUNK];
  280. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  281. v8_parms_t v8_answer_parms;
  282. answerer_available_modulations = V8_MOD_V17
  283. | V8_MOD_V21
  284. | V8_MOD_V22
  285. | V8_MOD_V23HDX
  286. | V8_MOD_V23
  287. | V8_MOD_V26BIS
  288. | V8_MOD_V26TER
  289. | V8_MOD_V27TER
  290. | V8_MOD_V29
  291. | V8_MOD_V32
  292. | V8_MOD_V34HDX
  293. | V8_MOD_V34
  294. | V8_MOD_V90
  295. | V8_MOD_V92;
  296. negotiations_ok = 0;
  297. non_v8_caller_tx = silence_gen_init(NULL, 10*SAMPLE_RATE);
  298. non_v8_caller_rx = modem_connect_tones_rx_init(NULL, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
  299. v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR;
  300. v8_answer_parms.send_ci = true;
  301. v8_answer_parms.v92 = -1;
  302. v8_answer_parms.call_function = V8_CALL_V_SERIES;
  303. v8_answer_parms.modulations = answerer_available_modulations;
  304. v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42;
  305. v8_answer_parms.pcm_modem_availability = 0;
  306. v8_answer_parms.pstn_access = 0;
  307. v8_answer_parms.nsf = -1;
  308. v8_answer_parms.t66 = -1;
  309. v8_answerer = v8_init(NULL,
  310. false,
  311. &v8_answer_parms,
  312. handler,
  313. (void *) "answerer");
  314. answerer_logging = v8_get_logging_state(v8_answerer);
  315. span_log_set_level(answerer_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
  316. span_log_set_tag(answerer_logging, "answerer");
  317. for (i = 0; i < 1000; i++)
  318. {
  319. samples = silence_gen(non_v8_caller_tx, amp, SAMPLES_PER_CHUNK);
  320. if (samples < SAMPLES_PER_CHUNK)
  321. {
  322. vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
  323. samples = SAMPLES_PER_CHUNK;
  324. }
  325. /*endif*/
  326. remnant = v8_rx(v8_answerer, amp, samples);
  327. if (remnant)
  328. break;
  329. /*endif*/
  330. for (i = 0; i < samples; i++)
  331. out_amp[2*i] = amp[i];
  332. /*endfor*/
  333. samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
  334. if (samples < SAMPLES_PER_CHUNK)
  335. {
  336. vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
  337. samples = SAMPLES_PER_CHUNK;
  338. }
  339. /*endif*/
  340. span_log_bump_samples(answerer_logging, samples);
  341. modem_connect_tones_rx(non_v8_caller_rx, amp, samples);
  342. if ((tone = modem_connect_tones_rx_get(non_v8_caller_rx)) != MODEM_CONNECT_TONES_NONE)
  343. {
  344. printf("Detected %s (%d)\n", modem_connect_tone_to_str(tone), tone);
  345. if (tone == MODEM_CONNECT_TONES_ANSAM_PR)
  346. negotiations_ok++;
  347. /*endif*/
  348. }
  349. /*endif*/
  350. for (i = 0; i < samples; i++)
  351. out_amp[2*i + 1] = amp[i];
  352. /*endfor*/
  353. if (outhandle)
  354. {
  355. outframes = sf_writef_short(outhandle, out_amp, samples);
  356. if (outframes != samples)
  357. {
  358. fprintf(stderr, " Error writing audio file\n");
  359. exit(2);
  360. }
  361. /*endif*/
  362. }
  363. /*endif*/
  364. }
  365. /*endfor*/
  366. silence_gen_free(non_v8_caller_tx);
  367. modem_connect_tones_rx_free(non_v8_caller_rx);
  368. v8_free(v8_answerer);
  369. if (negotiations_ok != 1)
  370. {
  371. printf("Tests failed.\n");
  372. exit(2);
  373. }
  374. /*endif*/
  375. return 0;
  376. }
  377. /*- End of function --------------------------------------------------------*/
  378. static int v8_calls_non_v8_tests(SNDFILE *outhandle)
  379. {
  380. v8_state_t *v8_caller;
  381. modem_connect_tones_tx_state_t *non_v8_answerer_tx;
  382. logging_state_t *caller_logging;
  383. int caller_available_modulations;
  384. int i;
  385. int samples;
  386. int outframes;
  387. int16_t amp[SAMPLES_PER_CHUNK];
  388. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  389. v8_parms_t v8_call_parms;
  390. caller_available_modulations = V8_MOD_V17
  391. | V8_MOD_V21
  392. | V8_MOD_V22
  393. | V8_MOD_V23HDX
  394. | V8_MOD_V23
  395. | V8_MOD_V26BIS
  396. | V8_MOD_V26TER
  397. | V8_MOD_V27TER
  398. | V8_MOD_V29
  399. | V8_MOD_V32
  400. | V8_MOD_V34HDX
  401. | V8_MOD_V34
  402. | V8_MOD_V90
  403. | V8_MOD_V92;
  404. negotiations_ok = 0;
  405. v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
  406. v8_call_parms.send_ci = true;
  407. v8_call_parms.v92 = -1;
  408. v8_call_parms.call_function = V8_CALL_V_SERIES;
  409. v8_call_parms.modulations = caller_available_modulations;
  410. v8_call_parms.protocol = V8_PROTOCOL_LAPM_V42;
  411. v8_call_parms.pcm_modem_availability = 0;
  412. v8_call_parms.pstn_access = 0;
  413. v8_call_parms.nsf = -1;
  414. v8_call_parms.t66 = -1;
  415. v8_caller = v8_init(NULL,
  416. true,
  417. &v8_call_parms,
  418. handler,
  419. (void *) "caller");
  420. non_v8_answerer_tx = modem_connect_tones_tx_init(NULL, MODEM_CONNECT_TONES_ANS_PR);
  421. caller_logging = v8_get_logging_state(v8_caller);
  422. span_log_set_level(caller_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
  423. span_log_set_tag(caller_logging, "caller");
  424. for (i = 0; i < 1000; i++)
  425. {
  426. samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
  427. if (samples < SAMPLES_PER_CHUNK)
  428. {
  429. vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
  430. samples = SAMPLES_PER_CHUNK;
  431. }
  432. /*endif*/
  433. span_log_bump_samples(caller_logging, samples);
  434. for (i = 0; i < samples; i++)
  435. out_amp[2*i] = amp[i];
  436. /*endfor*/
  437. samples = modem_connect_tones_tx(non_v8_answerer_tx, amp, SAMPLES_PER_CHUNK);
  438. if (samples < SAMPLES_PER_CHUNK)
  439. {
  440. vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples);
  441. samples = SAMPLES_PER_CHUNK;
  442. }
  443. /*endif*/
  444. if (v8_rx(v8_caller, amp, samples))
  445. break;
  446. /*endif*/
  447. for (i = 0; i < samples; i++)
  448. out_amp[2*i + 1] = amp[i];
  449. /*endfor*/
  450. if (outhandle)
  451. {
  452. outframes = sf_writef_short(outhandle, out_amp, samples);
  453. if (outframes != samples)
  454. {
  455. fprintf(stderr, " Error writing audio file\n");
  456. exit(2);
  457. }
  458. /*endif*/
  459. }
  460. /*endif*/
  461. }
  462. /*endfor*/
  463. v8_free(v8_caller);
  464. modem_connect_tones_tx_free(non_v8_answerer_tx);
  465. if (negotiations_ok != 42)
  466. {
  467. printf("Tests failed.\n");
  468. exit(2);
  469. }
  470. /*endif*/
  471. return 0;
  472. }
  473. /*- End of function --------------------------------------------------------*/
  474. int main(int argc, char *argv[])
  475. {
  476. int16_t amp[SAMPLES_PER_CHUNK];
  477. int samples;
  478. int caller_available_modulations;
  479. int answerer_available_modulations;
  480. SNDFILE *inhandle;
  481. SNDFILE *outhandle;
  482. int opt;
  483. bool log_audio;
  484. char *decode_test_file;
  485. v8_state_t *v8_caller;
  486. v8_state_t *v8_answerer;
  487. v8_parms_t v8_call_parms;
  488. v8_parms_t v8_answer_parms;
  489. logging_state_t *logging;
  490. decode_test_file = NULL;
  491. log_audio = false;
  492. while ((opt = getopt(argc, argv, "d:l")) != -1)
  493. {
  494. switch (opt)
  495. {
  496. case 'd':
  497. decode_test_file = optarg;
  498. break;
  499. case 'l':
  500. log_audio = true;
  501. break;
  502. default:
  503. //usage();
  504. exit(2);
  505. break;
  506. }
  507. }
  508. if (decode_test_file)
  509. {
  510. caller_available_modulations = V8_MOD_V17
  511. | V8_MOD_V21
  512. | V8_MOD_V22
  513. | V8_MOD_V23HDX
  514. | V8_MOD_V23
  515. | V8_MOD_V26BIS
  516. | V8_MOD_V26TER
  517. | V8_MOD_V27TER
  518. | V8_MOD_V29
  519. | V8_MOD_V32
  520. | V8_MOD_V34HDX
  521. | V8_MOD_V34
  522. | V8_MOD_V90
  523. | V8_MOD_V92;
  524. answerer_available_modulations = V8_MOD_V17
  525. | V8_MOD_V21
  526. | V8_MOD_V22
  527. | V8_MOD_V23HDX
  528. | V8_MOD_V23
  529. | V8_MOD_V26BIS
  530. | V8_MOD_V26TER
  531. | V8_MOD_V27TER
  532. | V8_MOD_V29
  533. | V8_MOD_V32
  534. | V8_MOD_V34HDX
  535. | V8_MOD_V34
  536. | V8_MOD_V90
  537. | V8_MOD_V92;
  538. printf("Decode file '%s'\n", decode_test_file);
  539. v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE;
  540. v8_call_parms.send_ci = true;
  541. v8_call_parms.v92 = -1;
  542. v8_call_parms.call_function = V8_CALL_V_SERIES;
  543. v8_call_parms.modulations = caller_available_modulations;
  544. v8_call_parms.protocol = V8_PROTOCOL_LAPM_V42;
  545. v8_call_parms.pcm_modem_availability = 0;
  546. v8_call_parms.pstn_access = 0;
  547. v8_call_parms.nsf = -1;
  548. v8_call_parms.t66 = -1;
  549. v8_caller = v8_init(NULL,
  550. true,
  551. &v8_call_parms,
  552. handler,
  553. (void *) "caller");
  554. logging = v8_get_logging_state(v8_caller);
  555. span_log_set_level(logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG);
  556. span_log_set_tag(logging, "caller");
  557. v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR;
  558. v8_answer_parms.send_ci = true;
  559. v8_answer_parms.v92 = -1;
  560. v8_answer_parms.call_function = V8_CALL_V_SERIES;
  561. v8_answer_parms.modulations = answerer_available_modulations;
  562. v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42;
  563. v8_answer_parms.pcm_modem_availability = 0;
  564. v8_answer_parms.pstn_access = 0;
  565. v8_answer_parms.nsf = -1;
  566. v8_answer_parms.t66 = -1;
  567. v8_answerer = v8_init(NULL,
  568. false,
  569. &v8_answer_parms,
  570. handler,
  571. (void *) "answerer");
  572. logging = v8_get_logging_state(v8_answerer);
  573. span_log_set_level(logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG);
  574. span_log_set_tag(logging, "answerer");
  575. if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
  576. {
  577. fprintf(stderr, " Cannot open speech file '%s'\n", decode_test_file);
  578. exit (2);
  579. }
  580. /*endif*/
  581. while ((samples = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)))
  582. {
  583. v8_rx(v8_caller, amp, samples);
  584. v8_rx(v8_answerer, amp, samples);
  585. v8_tx(v8_caller, amp, samples);
  586. v8_tx(v8_answerer, amp, samples);
  587. }
  588. /*endwhile*/
  589. v8_free(v8_caller);
  590. v8_free(v8_answerer);
  591. if (sf_close_telephony(inhandle))
  592. {
  593. fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
  594. exit(2);
  595. }
  596. /*endif*/
  597. }
  598. else
  599. {
  600. outhandle = NULL;
  601. if (log_audio)
  602. {
  603. if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
  604. {
  605. fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
  606. exit(2);
  607. }
  608. /*endif*/
  609. }
  610. /*endif*/
  611. printf("Test 1: V.8 terminal calls V.8 terminal\n");
  612. v8_calls_v8_tests(outhandle);
  613. printf("Test 2: non-V.8 terminal calls V.8 terminal\n");
  614. non_v8_calls_v8_tests(outhandle);
  615. printf("Test 3: V.8 terminal calls non-V.8 terminal\n");
  616. v8_calls_non_v8_tests(outhandle);
  617. if (outhandle)
  618. {
  619. if (sf_close_telephony(outhandle))
  620. {
  621. fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
  622. exit(2);
  623. }
  624. /*endif*/
  625. }
  626. /*endif*/
  627. printf("Tests passed.\n");
  628. }
  629. return 0;
  630. }
  631. /*- End of function --------------------------------------------------------*/
  632. /*- End of file ------------------------------------------------------------*/