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