38 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
40 #include <spandsp/version.h>
51 #define SPANDSP_FAX_SAMPLES 160
52 #define SPANDSP_FAX_TIMER_RATE 8000 / SPANDSP_FAX_SAMPLES
69 .description =
"Spandsp FAX Driver",
70 #if SPANDSP_RELEASE_DATE >= 20090220
72 .version = SPANDSP_RELEASE_DATETIME_STRING,
77 .version =
"pre-20090220",
132 static
void spandsp_log(
int level, const
char *msg);
145 t30_terminate(p->t30_state);
150 fax_release(&p->fax_state);
151 t38_terminal_release(&p->t38_state);
167 .src =
"res_fax_spandsp_t38",
190 switch (completion_code) {
196 case T30_ERR_CEDTONE:
197 case T30_ERR_T0_EXPIRED:
198 case T30_ERR_T1_EXPIRED:
199 case T30_ERR_T3_EXPIRED:
200 case T30_ERR_HDLC_CARRIER:
201 case T30_ERR_CANNOT_TRAIN:
205 case T30_ERR_OPER_INT_FAIL:
206 case T30_ERR_INCOMPATIBLE:
207 case T30_ERR_RX_INCAPABLE:
208 case T30_ERR_TX_INCAPABLE:
209 case T30_ERR_NORESSUPPORT:
210 case T30_ERR_NOSIZESUPPORT:
214 case T30_ERR_UNEXPECTED:
219 case T30_ERR_TX_BADDCS:
220 case T30_ERR_TX_BADPG:
221 case T30_ERR_TX_ECMPHD:
222 case T30_ERR_TX_GOTDCN:
223 case T30_ERR_TX_INVALRSP:
224 case T30_ERR_TX_NODIS:
225 case T30_ERR_TX_PHBDEAD:
226 case T30_ERR_TX_PHDDEAD:
227 case T30_ERR_TX_T5EXP:
232 case T30_ERR_RX_ECMPHD:
233 case T30_ERR_RX_GOTDCS:
234 case T30_ERR_RX_INVALCMD:
235 case T30_ERR_RX_NOCARRIER:
236 case T30_ERR_RX_NOEOL:
239 case T30_ERR_RX_NOFAX:
242 case T30_ERR_RX_T2EXPDCN:
243 case T30_ERR_RX_T2EXPD:
244 case T30_ERR_RX_T2EXPFAX:
245 case T30_ERR_RX_T2EXPMPS:
246 case T30_ERR_RX_T2EXPRR:
247 case T30_ERR_RX_T2EXP:
248 case T30_ERR_RX_DCNWHY:
249 case T30_ERR_RX_DCNDATA:
250 case T30_ERR_RX_DCNFAX:
251 case T30_ERR_RX_DCNPHD:
252 case T30_ERR_RX_DCNRRD:
253 case T30_ERR_RX_DCNNORTN:
258 case T30_ERR_FILEERROR:
260 case T30_ERR_BADTIFF:
261 case T30_ERR_BADPAGE:
263 case T30_ERR_BADTIFFHDR:
271 case T30_ERR_RETRYDCN:
274 case T30_ERR_CALLDROPPED:
280 case T30_ERR_IDENT_UNACCEPTABLE:
281 case T30_ERR_SUB_UNACCEPTABLE:
282 case T30_ERR_SEP_UNACCEPTABLE:
283 case T30_ERR_PSA_UNACCEPTABLE:
284 case T30_ERR_SID_UNACCEPTABLE:
285 case T30_ERR_PWD_UNACCEPTABLE:
286 case T30_ERR_TSA_UNACCEPTABLE:
287 case T30_ERR_IRA_UNACCEPTABLE:
288 case T30_ERR_CIA_UNACCEPTABLE:
289 case T30_ERR_ISP_UNACCEPTABLE:
290 case T30_ERR_CSA_UNACCEPTABLE:
295 ast_log(
LOG_WARNING,
"unknown FAX session result '%d' (%s)\n", completion_code, t30_completion_code_to_str(completion_code));
313 char headerinfo[T30_MAX_PAGE_HEADER_INFO + 1];
317 ast_debug(5,
"FAX session '%u' entering phase E\n", s->
id);
323 t30_get_transfer_statistics(t30_state, &stats);
325 if (completion_code == T30_ERR_OK) {
336 if ((c = t30_get_tx_ident(t30_state))) {
340 if ((c = t30_get_rx_ident(t30_state))) {
344 #if SPANDSP_RELEASE_DATE >= 20090220
354 t30_get_tx_page_header_info(t30_state, headerinfo);
366 if (level == SPAN_LOG_ERROR) {
368 }
else if (level == SPAN_LOG_WARNING) {
377 int level = SPAN_LOG_WARNING;
380 level = SPAN_LOG_DEBUG_3;
384 span_log_set_level(state, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | level);
394 t30_set_tx_page_header_info(t30_state, details->
headerinfo);
412 t30_set_ecm_capability(t30_state, details->
option.
ecm);
413 t30_set_supported_compressions(t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
420 modems |= T30_SUPPORT_V17;
423 modems |= T30_SUPPORT_V27TER;
426 modems |= T30_SUPPORT_V29;
429 #if defined(T30_SUPPORT_V34)
430 modems |= T30_SUPPORT_V34;
431 #elif defined(T30_SUPPORT_V34HDX)
432 modems |= T30_SUPPORT_V34HDX;
448 ast_log(
LOG_ERROR,
"Cannot initialize the spandsp private FAX technology structure.\n");
459 ast_log(
LOG_ERROR,
"Are we sending or receiving? The FAX requirements (capabilities: 0x%X) were not properly set.\n", s->
details->
caps);
521 .src =
"res_fax_spandsp_g711",
534 ast_debug(5,
"FAX session '%u' is complete.\n", s->
id);
589 #if SPANDSP_RELEASE_DATE >= 20080725
599 #if SPANDSP_RELEASE_DATE >= 20080725
639 fax_set_transmit_on_idle(&p->
fax_state, 1);
669 t30_set_phase_e_handler(p->
t30_state, NULL, NULL);
686 ast_cli(fd,
"SEND RECEIVE T.38 G.711\n\n");
697 ast_cli(fd,
"%-22s : %u\n",
"session", s->
id);
701 t30_get_transfer_statistics(p->
t30_state, &stats);
702 ast_cli(fd,
"%-22s : %s\n",
"Last Status", t30_completion_code_to_str(stats.current_status));
703 ast_cli(fd,
"%-22s : %s\n",
"ECM Mode", stats.error_correcting_mode ?
"Yes" :
"No");
704 ast_cli(fd,
"%-22s : %d\n",
"Data Rate", stats.bit_rate);
705 ast_cli(fd,
"%-22s : %dx%d\n",
"Image Resolution", stats.x_resolution, stats.y_resolution);
706 #if SPANDSP_RELEASE_DATE >= 20090220
709 ast_cli(fd,
"%-22s : %d\n",
"Page Number", stats.pages_transferred + 1);
713 ast_cli(fd,
"\nData Statistics:\n");
714 #if SPANDSP_RELEASE_DATE >= 20090220
715 ast_cli(fd,
"%-22s : %d\n",
"Tx Pages", stats.pages_tx);
716 ast_cli(fd,
"%-22s : %d\n",
"Rx Pages", stats.pages_rx);
721 ast_cli(fd,
"%-22s : %d\n",
"Longest Bad Line Run", stats.longest_bad_row_run);
722 ast_cli(fd,
"%-22s : %d\n",
"Total Bad Lines", stats.bad_rows);
733 ast_cli(fd,
"\n%-20.20s\n",
"Spandsp G.711");
748 ast_cli(fd,
"\n%-20.20s\n",
"Spandsp T.38");
792 span_set_message_handler(NULL);
const ast_string_field result
static void session_destroy(struct spandsp_pvt *p)
static struct @333 spandsp_global_stats
struct spandsp_fax_stats g711
Asterisk main include file. File version handling, generic pbx functions.
static int spandsp_modems(struct ast_fax_session_details *details)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
t38_terminal_state_t t38_state
void ast_fax_tech_unregister(struct ast_fax_tech *tech)
unregister a fax technology
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
struct ast_frame ast_null_frame
String manipulation functions.
static char * spandsp_fax_cli_show_settings(int fd)
Show res_fax_spandsp settings.
static char * spandsp_fax_cli_show_capabilities(int fd)
const ast_string_field headerinfo
static int spandsp_fax_start(struct ast_fax_session *s)
static void set_ecm(t30_state_t *t30_state, struct ast_fax_session_details *details)
static int spandsp_fax_switch_to_t38(struct ast_fax_session *s)
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
struct ast_timer * ast_timer_open(void)
Open a timer.
static struct ast_frame * spandsp_fax_read(struct ast_fax_session *s)
Read a frame from the spandsp fax stack.
static struct ast_fax_tech spandsp_fax_tech
#define ast_mutex_lock(a)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
static int t38_tx_packet_handler(t38_core_state_t *t38_core_state, void *data, const uint8_t *buf, int len, int count)
static int spandsp_fax_cancel(struct ast_fax_session *s)
struct spandsp_fax_stats t38
void ast_cli(int fd, const char *fmt,...)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
struct spandsp_pvt::frame_queue read_frames
t38_core_state_t * t38_core_state
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct ast_fax_session_details * details
static char * spandsp_fax_cli_show_session(struct ast_fax_session *s, int fd)
The data communicated between the high level applications and the generic fax function.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
struct ast_module * module
static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code)
Phase E handler callback.
static void set_logging(logging_state_t *state, struct ast_fax_session_details *details)
unsigned int transcoding_mmr
unsigned int transcoding_jbig
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
struct spandsp_fax_stats * stats
union ast_fax_session_details::@203 option
unsigned int pages_transferred
static void spandsp_fax_destroy(struct ast_fax_session *s)
Destroy a spandsp fax session.
static int load_module(void)
load res_fax_spandsp
struct ast_fax_documents documents
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
used to register a FAX technology module with res_fax
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static int update_stats(struct spandsp_pvt *p, int completion_code)
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
static void set_file(t30_state_t *t30_state, struct ast_fax_session_details *details)
enum ast_fax_modems modems
void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg)
Log message at FAX or recommended level.
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
static int unload_module(void)
unload res_fax_spandsp
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
static int spandsp_fax_write(struct ast_fax_session *s, const struct ast_frame *f)
Write a frame to the spandsp fax stack.
static void set_local_info(t30_state_t *t30_state, struct ast_fax_session_details *details)
Support for logging to various files, console and syslog Configuration in file logger.conf.
static char * spandsp_fax_cli_show_stats(int fd)
static void spandsp_log(int level, const char *msg)
Send spandsp log messages to asterisk.
#define AST_FORMAT_SLINEAR
Standard Command Line Interface.
#define SPANDSP_FAX_TIMER_RATE
#define SPANDSP_FAX_SAMPLES
The data required to handle a fax session.
const char * ast_fax_state_to_str(enum ast_fax_state state)
convert an ast_fax_state to a string
Data structure associated with a single frame of data.
enum ast_fax_capabilities caps
const ast_string_field resultstr
enum ast_frame_type frametype
const ast_string_field localstationid
#define ast_mutex_init(pmutex)
#define ast_mutex_destroy(a)
static void * spandsp_fax_new(struct ast_fax_session *s, struct ast_fax_tech_token *token)
create an instance of the spandsp tech_pvt for a fax session
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
unsigned int fill_bit_removal
struct ast_fax_t38_parameters their_t38_parameters
union ast_frame::@172 data
Timing source management.
Structure for mutex and tracking information.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
int ast_fax_tech_register(struct ast_fax_tech *tech)
register a fax technology
#define ast_mutex_unlock(a)
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.