Wed Jan 8 2020 09:50:18

Asterisk developer's documentation


res_fax.h File Reference
#include <asterisk.h>
#include <asterisk/lock.h>
#include <asterisk/linkedlists.h>
#include <asterisk/module.h>
#include <asterisk/utils.h>
#include <asterisk/options.h>
#include <asterisk/frame.h>
#include <asterisk/cli.h>
#include <asterisk/stringfields.h>

Go to the source code of this file.

Data Structures

struct  ast_fax_document
 
struct  ast_fax_documents
 
struct  ast_fax_session
 The data required to handle a fax session. More...
 
struct  ast_fax_session_details
 The data communicated between the high level applications and the generic fax function. More...
 
struct  ast_fax_t38_parameters
 
struct  ast_fax_tech
 used to register a FAX technology module with res_fax More...
 

Enumerations

enum  ast_fax_capabilities {
  AST_FAX_TECH_SEND = (1 << 0), AST_FAX_TECH_RECEIVE = (1 << 1), AST_FAX_TECH_AUDIO = (1 << 2), AST_FAX_TECH_T38 = (1 << 3),
  AST_FAX_TECH_MULTI_DOC = (1 << 4)
}
 capabilities for res_fax to locate a fax technology module More...
 
enum  ast_fax_modems { AST_FAX_MODEM_V17 = (1 << 0), AST_FAX_MODEM_V27 = (1 << 1), AST_FAX_MODEM_V29 = (1 << 2), AST_FAX_MODEM_V34 = (1 << 3) }
 fax modem capabilities More...
 
enum  ast_fax_optflag { AST_FAX_OPTFLAG_FALSE = 0, AST_FAX_OPTFLAG_TRUE, AST_FAX_OPTFLAG_DEFAULT }
 fax session options More...
 
enum  ast_fax_state {
  AST_FAX_STATE_UNINITIALIZED = 0, AST_FAX_STATE_INITIALIZED, AST_FAX_STATE_OPEN, AST_FAX_STATE_ACTIVE,
  AST_FAX_STATE_COMPLETE, AST_FAX_STATE_RESERVED, AST_FAX_STATE_INACTIVE
}
 current state of a fax session More...
 

Functions

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. More...
 
unsigned int ast_fax_maxrate (void)
 get the maxiumum supported fax rate More...
 
unsigned int ast_fax_minrate (void)
 get the minimum supported fax rate More...
 
const char * ast_fax_state_to_str (enum ast_fax_state state)
 convert an ast_fax_state to a string More...
 
int ast_fax_tech_register (struct ast_fax_tech *tech)
 register a fax technology More...
 
void ast_fax_tech_unregister (struct ast_fax_tech *tech)
 unregister a fax technology More...
 

Enumeration Type Documentation

capabilities for res_fax to locate a fax technology module

Enumerator
AST_FAX_TECH_SEND 

SendFax is supported

AST_FAX_TECH_RECEIVE 

ReceiveFax is supported

AST_FAX_TECH_AUDIO 

Audio FAX session supported

AST_FAX_TECH_T38 

T.38 FAX session supported

AST_FAX_TECH_MULTI_DOC 

sending mulitple documents supported

Definition at line 34 of file res_fax.h.

34  {
35  /*! SendFax is supported */
36  AST_FAX_TECH_SEND = (1 << 0),
37  /*! ReceiveFax is supported */
38  AST_FAX_TECH_RECEIVE = (1 << 1),
39  /*! Audio FAX session supported */
40  AST_FAX_TECH_AUDIO = (1 << 2),
41  /*! T.38 FAX session supported */
42  AST_FAX_TECH_T38 = (1 << 3),
43  /*! sending mulitple documents supported */
44  AST_FAX_TECH_MULTI_DOC = (1 << 4),
45 };

fax modem capabilities

Enumerator
AST_FAX_MODEM_V17 

V.17

AST_FAX_MODEM_V27 

V.27

AST_FAX_MODEM_V29 

V.29

AST_FAX_MODEM_V34 

V.34

Definition at line 48 of file res_fax.h.

48  {
49  /*! V.17 */
50  AST_FAX_MODEM_V17 = (1 << 0),
51  /*! V.27 */
52  AST_FAX_MODEM_V27 = (1 << 1),
53  /*! V.29 */
54  AST_FAX_MODEM_V29 = (1 << 2),
55  /*! V.34 */
56  AST_FAX_MODEM_V34 = (1 << 3),
57 };

fax session options

Enumerator
AST_FAX_OPTFLAG_FALSE 

false/disable configuration override

AST_FAX_OPTFLAG_TRUE 

true/enable configuration override

AST_FAX_OPTFLAG_DEFAULT 

use the configured default

Definition at line 78 of file res_fax.h.

78  {
79  /*! false/disable configuration override */
81  /*! true/enable configuration override */
83  /*! use the configured default */
85 };

current state of a fax session

Enumerator
AST_FAX_STATE_UNINITIALIZED 

uninitialized state

AST_FAX_STATE_INITIALIZED 

initialized state

AST_FAX_STATE_OPEN 

fax resources open state

AST_FAX_STATE_ACTIVE 

fax session in progress

AST_FAX_STATE_COMPLETE 

fax session complete

AST_FAX_STATE_RESERVED 

reserved state

AST_FAX_STATE_INACTIVE 

inactive state

Definition at line 60 of file res_fax.h.

60  {
61  /*! uninitialized state */
63  /*! initialized state */
65  /*! fax resources open state */
67  /*! fax session in progress */
69  /*! fax session complete */
71  /*! reserved state */
73  /*! inactive state */
75 };

Function Documentation

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.

The first four parameters can be represented with Asterisk's LOG_* levels. In other words, this function may be called like

ast_fax_log(LOG_DEBUG, msg);

Definition at line 680 of file res_fax.c.

References ast_log(), and ast_log_dynamic_level.

Referenced by spandsp_log().

681 {
682  if (fax_logger_level != -1) {
684  } else {
685  ast_log(level, file, line, function, "%s", msg);
686  }
687 }
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
Definition: logger.h:229
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...
Definition: logger.c:1207
static int fax_logger_level
Definition: res_fax.c:213
unsigned int ast_fax_maxrate ( void  )

get the maxiumum supported fax rate

Definition at line 444 of file res_fax.c.

References get_general_options(), and fax_options::maxrate.

Referenced by acf_faxopt_write().

445 {
446  struct fax_options options;
447  get_general_options(&options);
448 
449  return options.maxrate;
450 }
static void get_general_options(struct fax_options *options)
Definition: res_fax.c:2660
unsigned int ast_fax_minrate ( void  )

get the minimum supported fax rate

Definition at line 452 of file res_fax.c.

References get_general_options(), and fax_options::minrate.

Referenced by acf_faxopt_write().

453 {
454  struct fax_options options;
455  get_general_options(&options);
456 
457  return options.minrate;
458 }
static void get_general_options(struct fax_options *options)
Definition: res_fax.c:2660
const char* ast_fax_state_to_str ( enum ast_fax_state  state)

convert an ast_fax_state to a string

convert an ast_fax_state to a string

Definition at line 657 of file res_fax.c.

References AST_FAX_STATE_ACTIVE, AST_FAX_STATE_COMPLETE, AST_FAX_STATE_INACTIVE, AST_FAX_STATE_INITIALIZED, AST_FAX_STATE_OPEN, AST_FAX_STATE_RESERVED, AST_FAX_STATE_UNINITIALIZED, ast_log(), and LOG_WARNING.

Referenced by cli_fax_show_sessions(), spandsp_fax_cli_show_session(), and spandsp_fax_write().

658 {
659  switch (state) {
661  return "Uninitialized";
663  return "Initialized";
664  case AST_FAX_STATE_OPEN:
665  return "Open";
667  return "Active";
669  return "Complete";
671  return "Reserved";
673  return "Inactive";
674  default:
675  ast_log(LOG_WARNING, "unhandled FAX state: %u\n", state);
676  return "Unknown";
677  }
678 }
#define LOG_WARNING
Definition: logger.h:144
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...
Definition: logger.c:1207
int ast_fax_tech_register ( struct ast_fax_tech tech)

register a fax technology

register a fax technology

Definition at line 616 of file res_fax.c.

References ast_calloc, ast_module_ref(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_fax_tech::description, ast_module_info::self, fax_module::tech, and ast_fax_tech::type.

Referenced by load_module().

617 {
618  struct fax_module *fax;
619 
620  if (!(fax = ast_calloc(1, sizeof(*fax)))) {
621  return -1;
622  }
623  fax->tech = tech;
625  AST_RWLIST_INSERT_TAIL(&faxmodules, fax, list);
628 
629  ast_verb(3, "Registered handler for '%s' (%s)\n", fax->tech->type, fax->tech->description);
630 
631  return 0;
632 }
struct ast_fax_tech * tech
Definition: res_fax.c:242
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
const char *const type
Definition: res_fax.h:210
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
const char *const description
Definition: res_fax.h:212
#define ast_verb(level,...)
Definition: logger.h:243
struct ast_module * self
Definition: module.h:227
registered FAX technology modules are put into this list
Definition: res_fax.c:241
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:726
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_module * ast_module_ref(struct ast_module *)
Definition: loader.c:1300
void ast_fax_tech_unregister ( struct ast_fax_tech tech)

unregister a fax technology

unregister a fax technology

Definition at line 635 of file res_fax.c.

References ast_free, ast_module_unref(), AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_module_info::self, fax_module::tech, and ast_fax_tech::type.

Referenced by unload_module().

636 {
637  struct fax_module *fax;
638 
639  ast_verb(3, "Unregistering FAX module type '%s'\n", tech->type);
640 
643  if (fax->tech != tech) {
644  continue;
645  }
648  ast_free(fax);
649  ast_verb(4, "Unregistered FAX module type '%s'\n", tech->type);
650  break;
651  }
654 }
struct ast_fax_tech * tech
Definition: res_fax.c:242
void ast_module_unref(struct ast_module *)
Definition: loader.c:1312
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
const char *const type
Definition: res_fax.h:210
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_verb(level,...)
Definition: logger.h:243
struct ast_module * self
Definition: module.h:227
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:565
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:542
#define ast_free(a)
Definition: astmm.h:97
registered FAX technology modules are put into this list
Definition: res_fax.c:241
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:602