res_fax.h
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
00047
00048 enum ast_fax_modems {
00049
00050 AST_FAX_MODEM_V17 = (1 << 0),
00051
00052 AST_FAX_MODEM_V27 = (1 << 1),
00053
00054 AST_FAX_MODEM_V29 = (1 << 2),
00055
00056 AST_FAX_MODEM_V34 = (1 << 3),
00057 };
00058
00059
00060 enum ast_fax_state {
00061
00062 AST_FAX_STATE_UNINITIALIZED = 0,
00063
00064 AST_FAX_STATE_INITIALIZED,
00065
00066 AST_FAX_STATE_OPEN,
00067
00068 AST_FAX_STATE_ACTIVE,
00069
00070 AST_FAX_STATE_COMPLETE,
00071 };
00072
00073
00074 enum ast_fax_optflag {
00075
00076 AST_FAX_OPTFLAG_FALSE = 0,
00077
00078 AST_FAX_OPTFLAG_TRUE,
00079
00080 AST_FAX_OPTFLAG_DEFAULT,
00081 };
00082
00083 struct ast_fax_t38_parameters {
00084 unsigned int version;
00085 unsigned int max_ifp;
00086 enum ast_control_t38_rate rate;
00087 enum ast_control_t38_rate_management rate_management;
00088 unsigned int fill_bit_removal:1;
00089 unsigned int transcoding_mmr:1;
00090 unsigned int transcoding_jbig:1;
00091 };
00092
00093 struct ast_fax_document {
00094 AST_LIST_ENTRY(ast_fax_document) next;
00095 char filename[0];
00096 };
00097
00098 AST_LIST_HEAD_NOLOCK(ast_fax_documents, ast_fax_document);
00099
00100
00101 struct ast_fax_session_details {
00102
00103
00104 enum ast_fax_capabilities caps;
00105
00106 enum ast_fax_modems modems;
00107
00108 unsigned int id;
00109
00110 struct ast_fax_documents documents;
00111 AST_DECLARE_STRING_FIELDS(
00112
00113
00114 AST_STRING_FIELD(resolution);
00115
00116
00117 AST_STRING_FIELD(transfer_rate);
00118
00119
00120 AST_STRING_FIELD(localstationid);
00121
00122
00123 AST_STRING_FIELD(remotestationid);
00124
00125
00126 AST_STRING_FIELD(headerinfo);
00127
00128 AST_STRING_FIELD(result);
00129
00130 AST_STRING_FIELD(resultstr);
00131
00132 AST_STRING_FIELD(error);
00133 );
00134
00135 unsigned int pages_transferred;
00136
00137 union {
00138
00139 uint32_t dontuse;
00140 struct {
00141
00142 uint32_t debug:2;
00143
00144 uint32_t ecm:1;
00145
00146 uint32_t statusevents:2;
00147
00148 uint32_t allow_audio:2;
00149
00150 uint32_t switch_to_t38:1;
00151
00152 uint32_t send_ced:1;
00153
00154 uint32_t send_cng:1;
00155
00156 uint32_t request_t38:1;
00157 };
00158 } option;
00159
00160 unsigned int minrate;
00161
00162 unsigned int maxrate;
00163
00164 struct ast_fax_t38_parameters our_t38_parameters;
00165
00166 struct ast_fax_t38_parameters their_t38_parameters;
00167 };
00168
00169 struct ast_fax_tech;
00170 struct ast_fax_debug_info;
00171
00172
00173 struct ast_fax_session {
00174
00175 unsigned int id;
00176
00177 int fd;
00178
00179 struct ast_fax_session_details *details;
00180
00181 unsigned long frames_received;
00182
00183 unsigned long frames_sent;
00184
00185 const struct ast_fax_tech *tech;
00186
00187 void *tech_pvt;
00188
00189 enum ast_fax_state state;
00190
00191 char *channame;
00192
00193 char *chan_uniqueid;
00194
00195 struct ast_channel *chan;
00196
00197 struct ast_fax_debug_info *debug_info;
00198
00199 struct ast_smoother *smoother;
00200 };
00201
00202 struct ast_fax_tech_token;
00203
00204
00205 struct ast_fax_tech {
00206
00207 const char * const type;
00208
00209 const char * const description;
00210
00211 const char * const version;
00212
00213 const enum ast_fax_capabilities caps;
00214
00215 struct ast_module *module;
00216
00217 struct ast_fax_tech_token *(* const reserve_session)(struct ast_fax_session *);
00218
00219 void (* const release_token)(struct ast_fax_tech_token *);
00220
00221 void *(* const new_session)(struct ast_fax_session *, struct ast_fax_tech_token *);
00222
00223 void (* const destroy_session)(struct ast_fax_session *);
00224
00225 struct ast_frame *(* const read)(struct ast_fax_session *);
00226
00227 int (* const write)(struct ast_fax_session *, const struct ast_frame *);
00228
00229 int (* const start_session)(struct ast_fax_session *);
00230
00231 int (* const cancel_session)(struct ast_fax_session *);
00232
00233 int (* const generate_silence)(struct ast_fax_session *);
00234
00235 int (* const switch_to_t38)(struct ast_fax_session *);
00236
00237 char * (* const cli_show_capabilities)(int);
00238
00239 char * (* const cli_show_session)(struct ast_fax_session *, int);
00240
00241 char * (* const cli_show_stats)(int);
00242
00243 char * (* const cli_show_settings)(int);
00244 };
00245
00246
00247 int ast_fax_tech_register(struct ast_fax_tech *tech);
00248
00249
00250 void ast_fax_tech_unregister(struct ast_fax_tech *tech);
00251
00252
00253 unsigned int ast_fax_minrate(void);
00254
00255
00256 unsigned int ast_fax_maxrate(void);
00257
00258
00259 const char *ast_fax_state_to_str(enum ast_fax_state state);
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg);
00271
00272 #endif