2
0

fax_tester.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * SpanDSP - a series of DSP components for telephony
  3. *
  4. * fax_tester.h
  5. *
  6. * Written by Steve Underwood <steveu@coppice.org>
  7. *
  8. * Copyright (C) 2008 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. /*! \file */
  26. #if !defined(_SPANDSP_FAX_TESTER_H_)
  27. #define _SPANDSP_FAX_TESTER_H_
  28. /*! \page fax_tester_page FAX over analogue modem handling
  29. \section fax_tester_page_sec_1 What does it do?
  30. \section fax_tester_page_sec_2 How does it work?
  31. */
  32. typedef struct faxtester_state_s faxtester_state_t;
  33. typedef void (*faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which);
  34. /*!
  35. FAX tester descriptor.
  36. */
  37. struct faxtester_state_s
  38. {
  39. /*! \brief The far end FAX context */
  40. fax_state_t *far_fax;
  41. t38_terminal_state_t *far_t38;
  42. int far_tag;
  43. /*! \brief The far end T.38 terminal context */
  44. t38_terminal_state_t *far_t38_fax;
  45. t30_state_t *far_t30;
  46. t30_exchanged_info_t expected_rx_info;
  47. bool use_receiver_not_ready;
  48. bool test_local_interrupt;
  49. /*! \brief Path for the FAX image test files. */
  50. char image_path[1024];
  51. /*! \brief Pointer to the XML document. */
  52. xmlDocPtr doc;
  53. /*! \brief Pointer to our current step in the test. */
  54. xmlNodePtr cur;
  55. int repeat_min;
  56. int repeat_max;
  57. int repeat_count;
  58. xmlNodePtr repeat_start;
  59. xmlNodePtr repeat_parent;
  60. faxtester_flush_handler_t flush_handler;
  61. void *flush_user_data;
  62. const uint8_t *image_buffer;
  63. int image_len;
  64. int image_ptr;
  65. int image_bit_ptr;
  66. uint8_t image[1000000];
  67. int ecm_frame_size;
  68. int corrupt_crc;
  69. int final_delayed;
  70. fax_modems_state_t modems;
  71. /*! \brief CED or CNG detector */
  72. modem_connect_tones_rx_state_t connect_rx;
  73. /*! If true, transmission is in progress */
  74. bool transmit;
  75. /*! \brief true if the short training sequence should be used. */
  76. bool short_train;
  77. /*! \brief The currently select receiver type */
  78. int current_rx_type;
  79. /*! \brief The currently select transmitter type */
  80. int current_tx_type;
  81. int wait_for_silence;
  82. int tone_state;
  83. int64_t tone_on_time;
  84. int64_t timer;
  85. int64_t timeout;
  86. bool test_for_call_clear;
  87. int call_clear_timer;
  88. bool far_end_cleared_call;
  89. int timein_x;
  90. int timeout_x;
  91. uint8_t awaited[1000];
  92. int awaited_len;
  93. char next_tx_file[1000];
  94. /*! \brief Error and flow logging control */
  95. logging_state_t logging;
  96. };
  97. #if defined(__cplusplus)
  98. extern "C"
  99. {
  100. #endif
  101. /*! Apply T.30 receive processing to a block of audio samples.
  102. \brief Apply T.30 receive processing to a block of audio samples.
  103. \param s The FAX tester context.
  104. \param amp The audio sample buffer.
  105. \param len The number of samples in the buffer.
  106. \return The number of samples unprocessed. This should only be non-zero if
  107. the software has reached the end of the FAX call.
  108. */
  109. int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len);
  110. /*! Apply T.30 transmit processing to generate a block of audio samples.
  111. \brief Apply T.30 transmit processing to generate a block of audio samples.
  112. \param s The FAX tester context.
  113. \param amp The audio sample buffer.
  114. \param max_len The number of samples to be generated.
  115. \return The number of samples actually generated. This will be zero when
  116. there is nothing to send.
  117. */
  118. int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len);
  119. void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
  120. void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
  121. void faxtest_set_rx_silence(faxtester_state_t *s);
  122. void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags);
  123. void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok);
  124. void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t handler, void *user_data);
  125. /*! Select whether silent audio will be sent when FAX transmit is idle.
  126. \brief Select whether silent audio will be sent when FAX transmit is idle.
  127. \param s The FAX tester context.
  128. \param transmit_on_idle true if silent audio should be output when the FAX transmitter is
  129. idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default
  130. behaviour is FALSE.
  131. */
  132. void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle);
  133. /*! Select whether talker echo protection tone will be sent for the image modems.
  134. \brief Select whether TEP will be sent for the image modems.
  135. \param s The FAX tester context.
  136. \param use_tep true if TEP should be sent.
  137. */
  138. void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep);
  139. void faxtester_set_timeout(faxtester_state_t *s, int timeout);
  140. SPAN_DECLARE(int) faxtester_next_step(faxtester_state_t *s);
  141. /*! Get the logging context associated with a FAX tester context.
  142. \brief Get the logging context associated with a FAX tester context.
  143. \param s The FAX tester context.
  144. \return A pointer to the logging context */
  145. SPAN_DECLARE(logging_state_t *) faxtester_get_logging_state(faxtester_state_t *s);
  146. /*! Initialise a FAX tester context.
  147. \brief Initialise a FAX tester context.
  148. \param s The FAX tester context.
  149. \param test_file The name of the file of XML test scripts.
  150. \param test The name of the XML script test.
  151. \return A pointer to the FAX context, or NULL if there was a problem.
  152. */
  153. faxtester_state_t *faxtester_init(faxtester_state_t *s, const char *test_file, const char *test);
  154. /*! Release a FAX context.
  155. \brief Release a FAX context.
  156. \param s The FAX tester context.
  157. \return 0 for OK, else -1. */
  158. int faxtester_release(faxtester_state_t *s);
  159. /*! Free a FAX context.
  160. \brief Free a FAX context.
  161. \param s The FAX tester context.
  162. \return 0 for OK, else -1. */
  163. int faxtester_free(faxtester_state_t *s);
  164. #if defined(__cplusplus)
  165. }
  166. #endif
  167. #endif
  168. /*- End of file ------------------------------------------------------------*/