Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _ASTERISK_RES_FAX_H
00021 #define _ASTERISK_RES_FAX_H
00022
00023 #include <asterisk.h>
00024 #include <asterisk/lock.h>
00025 #include <asterisk/linkedlists.h>
00026 #include <asterisk/module.h>
00027 #include <asterisk/utils.h>
00028 #include <asterisk/options.h>
00029 #include <asterisk/frame.h>
00030 #include <asterisk/cli.h>
00031 #include <asterisk/stringfields.h>
00032
00033
00034 enum ast_fax_capabilities {
00035
00036 AST_FAX_TECH_SEND = (1 << 0),
00037
00038 AST_FAX_TECH_RECEIVE = (1 << 1),
00039
00040 AST_FAX_TECH_AUDIO = (1 << 2),
00041
00042 AST_FAX_TECH_T38 = (1 << 3),
00043
00044 AST_FAX_TECH_MULTI_DOC = (1 << 4),
00045
00046 AST_FAX_TECH_GATEWAY = (1 << 5),
00047
00048 AST_FAX_TECH_V21_DETECT = (1 << 6),
00049 };
00050
00051
00052 enum ast_fax_modems {
00053
00054 AST_FAX_MODEM_V17 = (1 << 0),
00055
00056 AST_FAX_MODEM_V27 = (1 << 1),
00057
00058 AST_FAX_MODEM_V29 = (1 << 2),
00059
00060 AST_FAX_MODEM_V34 = (1 << 3),
00061 };
00062
00063
00064 enum ast_fax_state {
00065
00066 AST_FAX_STATE_UNINITIALIZED = 0,
00067
00068 AST_FAX_STATE_INITIALIZED,
00069
00070 AST_FAX_STATE_OPEN,
00071
00072 AST_FAX_STATE_ACTIVE,
00073
00074 AST_FAX_STATE_COMPLETE,
00075
00076 AST_FAX_STATE_RESERVED,
00077
00078 AST_FAX_STATE_INACTIVE,
00079 };
00080
00081
00082 enum ast_fax_optflag {
00083
00084 AST_FAX_OPTFLAG_FALSE = 0,
00085
00086 AST_FAX_OPTFLAG_TRUE,
00087
00088 AST_FAX_OPTFLAG_DEFAULT,
00089 };
00090
00091 struct ast_fax_t38_parameters {
00092 unsigned int version;
00093 unsigned int max_ifp;
00094 enum ast_control_t38_rate rate;
00095 enum ast_control_t38_rate_management rate_management;
00096 unsigned int fill_bit_removal:1;
00097 unsigned int transcoding_mmr:1;
00098 unsigned int transcoding_jbig:1;
00099 };
00100
00101 struct ast_fax_document {
00102 AST_LIST_ENTRY(ast_fax_document) next;
00103 char filename[0];
00104 };
00105
00106 AST_LIST_HEAD_NOLOCK(ast_fax_documents, ast_fax_document);
00107
00108
00109 struct ast_fax_session_details {
00110
00111
00112 enum ast_fax_capabilities caps;
00113
00114 enum ast_fax_modems modems;
00115
00116 unsigned int id;
00117
00118 struct ast_fax_documents documents;
00119 AST_DECLARE_STRING_FIELDS(
00120
00121
00122 AST_STRING_FIELD(resolution);
00123
00124
00125 AST_STRING_FIELD(transfer_rate);
00126
00127
00128 AST_STRING_FIELD(localstationid);
00129
00130
00131 AST_STRING_FIELD(remotestationid);
00132
00133
00134 AST_STRING_FIELD(headerinfo);
00135
00136 AST_STRING_FIELD(result);
00137
00138 AST_STRING_FIELD(resultstr);
00139
00140 AST_STRING_FIELD(error);
00141 );
00142
00143 unsigned int pages_transferred;
00144
00145 union {
00146
00147 uint32_t dontuse;
00148 struct {
00149
00150 uint32_t debug:2;
00151
00152 uint32_t ecm:1;
00153
00154 uint32_t statusevents:2;
00155
00156 uint32_t allow_audio:2;
00157
00158 uint32_t switch_to_t38:1;
00159
00160 uint32_t send_ced:1;
00161
00162 uint32_t send_cng:1;
00163
00164 uint32_t request_t38:1;
00165
00166 uint32_t v21_detected:1;
00167 };
00168 } option;
00169
00170 unsigned int minrate;
00171
00172 unsigned int maxrate;
00173
00174 struct ast_fax_t38_parameters our_t38_parameters;
00175
00176 struct ast_fax_t38_parameters their_t38_parameters;
00177
00178 int gateway_id;
00179
00180 int gateway_timeout;
00181
00182 int faxdetect_id;
00183 };
00184
00185 struct ast_fax_tech;
00186 struct ast_fax_debug_info;
00187 struct ast_fax_tech_token;
00188
00189
00190 struct ast_fax_session {
00191
00192 unsigned int id;
00193
00194 int fd;
00195
00196 struct ast_fax_session_details *details;
00197
00198 unsigned long frames_received;
00199
00200 unsigned long frames_sent;
00201
00202 const struct ast_fax_tech *tech;
00203
00204 void *tech_pvt;
00205
00206 enum ast_fax_state state;
00207
00208 char *channame;
00209
00210 char *chan_uniqueid;
00211
00212 struct ast_channel *chan;
00213
00214 struct ast_fax_debug_info *debug_info;
00215
00216 struct ast_smoother *smoother;
00217 };
00218
00219
00220 #define AST_FAX_FRFLAG_GATEWAY (1 << 13)
00221
00222
00223 struct ast_fax_tech {
00224
00225 const char * const type;
00226
00227 const char * const description;
00228
00229 const char * const version;
00230
00231 const enum ast_fax_capabilities caps;
00232
00233 struct ast_module *module;
00234
00235 struct ast_fax_tech_token *(* const reserve_session)(struct ast_fax_session *);
00236
00237 void (* const release_token)(struct ast_fax_tech_token *);
00238
00239 void *(* const new_session)(struct ast_fax_session *, struct ast_fax_tech_token *);
00240
00241 void (* const destroy_session)(struct ast_fax_session *);
00242
00243 struct ast_frame *(* const read)(struct ast_fax_session *);
00244
00245 int (* const write)(struct ast_fax_session *, const struct ast_frame *);
00246
00247 int (* const start_session)(struct ast_fax_session *);
00248
00249 int (* const cancel_session)(struct ast_fax_session *);
00250
00251 int (* const generate_silence)(struct ast_fax_session *);
00252
00253 int (* const switch_to_t38)(struct ast_fax_session *);
00254
00255 char * (* const cli_show_capabilities)(int);
00256
00257 char * (* const cli_show_session)(struct ast_fax_session *, int);
00258
00259 char * (* const cli_show_stats)(int);
00260
00261 char * (* const cli_show_settings)(int);
00262 };
00263
00264
00265 int ast_fax_tech_register(struct ast_fax_tech *tech);
00266
00267
00268 void ast_fax_tech_unregister(struct ast_fax_tech *tech);
00269
00270
00271 unsigned int ast_fax_minrate(void);
00272
00273
00274 unsigned int ast_fax_maxrate(void);
00275
00276
00277 const char *ast_fax_state_to_str(enum ast_fax_state state);
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg);
00289
00290 #endif