00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _ASTERISK_FRAME_H
00017 #define _ASTERISK_FRAME_H
00018
00019 #if defined(__cplusplus) || defined(c_plusplus)
00020 extern "C" {
00021 #endif
00022
00023 #include <sys/types.h>
00024 #include <sys/time.h>
00025
00026
00027
00028
00029 #ifndef __BYTE_ORDER
00030 #ifdef __linux__
00031 #include <endian.h>
00032 #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
00033 #if defined(__OpenBSD__)
00034 #include <machine/types.h>
00035 #endif
00036 #include <machine/endian.h>
00037 #define __BYTE_ORDER BYTE_ORDER
00038 #define __LITTLE_ENDIAN LITTLE_ENDIAN
00039 #define __BIG_ENDIAN BIG_ENDIAN
00040 #else
00041 #ifdef __LITTLE_ENDIAN__
00042 #define __BYTE_ORDER __LITTLE_ENDIAN
00043 #endif
00044
00045 #if defined(i386) || defined(__i386__)
00046 #define __BYTE_ORDER __LITTLE_ENDIAN
00047 #endif
00048
00049 #if defined(sun) && defined(unix) && defined(sparc)
00050 #define __BYTE_ORDER __BIG_ENDIAN
00051 #endif
00052
00053 #endif
00054
00055 #endif
00056
00057 #ifndef __BYTE_ORDER
00058 #error Need to know endianess
00059 #endif
00060
00061
00062
00063
00064 struct ast_frame {
00065
00066 int frametype;
00067
00068 int subclass;
00069
00070 int datalen;
00071
00072 int samples;
00073
00074 int mallocd;
00075
00076 int offset;
00077
00078 char *src;
00079
00080 void *data;
00081
00082 struct timeval delivery;
00083
00084 struct ast_frame *prev;
00085
00086 struct ast_frame *next;
00087
00088
00089
00090 };
00091
00092 struct ast_frame_chain {
00093
00094 struct ast_frame *fr;
00095 struct ast_frame_chain *next;
00096 };
00097
00098 #define AST_FRIENDLY_OFFSET 64
00099
00100
00101 #define AST_MIN_OFFSET 32
00102
00103
00104 #define AST_MALLOCD_HDR (1 << 0)
00105
00106 #define AST_MALLOCD_DATA (1 << 1)
00107
00108 #define AST_MALLOCD_SRC (1 << 2)
00109
00110
00111
00112 #define AST_FRAME_DTMF 1
00113
00114 #define AST_FRAME_VOICE 2
00115
00116 #define AST_FRAME_VIDEO 3
00117
00118 #define AST_FRAME_CONTROL 4
00119
00120 #define AST_FRAME_NULL 5
00121
00122 #define AST_FRAME_IAX 6
00123
00124 #define AST_FRAME_TEXT 7
00125
00126 #define AST_FRAME_IMAGE 8
00127
00128 #define AST_FRAME_HTML 9
00129
00130
00131 #define AST_FRAME_CNG 10
00132
00133
00134
00135 #define AST_HTML_URL 1
00136
00137 #define AST_HTML_DATA 2
00138
00139 #define AST_HTML_BEGIN 4
00140
00141 #define AST_HTML_END 8
00142
00143 #define AST_HTML_LDCOMPLETE 16
00144
00145 #define AST_HTML_NOSUPPORT 17
00146
00147 #define AST_HTML_LINKURL 18
00148
00149 #define AST_HTML_UNLINK 19
00150
00151 #define AST_HTML_LINKREJECT 20
00152
00153
00154
00155 #define AST_FORMAT_G723_1 (1 << 0)
00156
00157 #define AST_FORMAT_GSM (1 << 1)
00158
00159 #define AST_FORMAT_ULAW (1 << 2)
00160
00161 #define AST_FORMAT_ALAW (1 << 3)
00162
00163 #define AST_FORMAT_G726 (1 << 4)
00164
00165 #define AST_FORMAT_ADPCM (1 << 5)
00166
00167 #define AST_FORMAT_SLINEAR (1 << 6)
00168
00169 #define AST_FORMAT_LPC10 (1 << 7)
00170
00171 #define AST_FORMAT_G729A (1 << 8)
00172
00173 #define AST_FORMAT_SPEEX (1 << 9)
00174
00175 #define AST_FORMAT_ILBC (1 << 10)
00176
00177 #define AST_FORMAT_MAX_AUDIO (1 << 15)
00178
00179 #define AST_FORMAT_JPEG (1 << 16)
00180
00181 #define AST_FORMAT_PNG (1 << 17)
00182
00183 #define AST_FORMAT_H261 (1 << 18)
00184
00185 #define AST_FORMAT_H263 (1 << 19)
00186
00187 #define AST_FORMAT_MAX_VIDEO (1 << 24)
00188
00189
00190
00191 #define AST_CONTROL_HANGUP 1
00192
00193 #define AST_CONTROL_RING 2
00194
00195 #define AST_CONTROL_RINGING 3
00196
00197 #define AST_CONTROL_ANSWER 4
00198
00199 #define AST_CONTROL_BUSY 5
00200
00201 #define AST_CONTROL_TAKEOFFHOOK 6
00202
00203 #define AST_CONTROL_OFFHOOK 7
00204
00205 #define AST_CONTROL_CONGESTION 8
00206
00207 #define AST_CONTROL_FLASH 9
00208
00209 #define AST_CONTROL_WINK 10
00210
00211 #define AST_CONTROL_OPTION 11
00212
00213 #define AST_CONTROL_RADIO_KEY 12
00214
00215 #define AST_CONTROL_RADIO_UNKEY 13
00216
00217 #define AST_CONTROL_PROGRESS 14
00218
00219 #define AST_CONTROL_PROCEEDING 15
00220
00221 #define AST_SMOOTHER_FLAG_G729 (1 << 0)
00222
00223
00224 #define AST_OPTION_FLAG_REQUEST 0
00225 #define AST_OPTION_FLAG_ACCEPT 1
00226 #define AST_OPTION_FLAG_REJECT 2
00227 #define AST_OPTION_FLAG_QUERY 4
00228 #define AST_OPTION_FLAG_ANSWER 5
00229 #define AST_OPTION_FLAG_WTF 6
00230
00231
00232
00233 #define AST_OPTION_TONE_VERIFY 1
00234
00235
00236 #define AST_OPTION_TDD 2
00237
00238
00239 #define AST_OPTION_RELAXDTMF 3
00240
00241
00242 #define AST_OPTION_AUDIO_MODE 4
00243
00244 struct ast_option_header {
00245
00246 #if __BYTE_ORDER == __BIG_ENDIAN
00247 u_int16_t flag:3;
00248 u_int16_t option:13;
00249 #else
00250 #if __BYTE_ORDER == __LITTLE_ENDIAN
00251 u_int16_t option:13;
00252 u_int16_t flag:3;
00253 #else
00254 #error Byte order not defined
00255 #endif
00256 #endif
00257 u_int8_t data[0];
00258 };
00259
00260
00261
00262
00263
00264
00265
00266 #if 0
00267 struct ast_frame *ast_fralloc(char *source, int len);
00268 #endif
00269
00270
00271
00272
00273
00274
00275
00276 void ast_frfree(struct ast_frame *fr);
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 struct ast_frame *ast_frisolate(struct ast_frame *fr);
00288
00289
00290
00291
00292
00293
00294
00295 struct ast_frame *ast_frdup(struct ast_frame *fr);
00296
00297
00298 #if 0
00299 void ast_frchain(struct ast_frame_chain *fc);
00300 #endif
00301
00302
00303
00304
00305
00306
00307
00308 struct ast_frame *ast_fr_fdread(int fd);
00309
00310
00311
00312
00313
00314
00315
00316
00317 int ast_fr_fdwrite(int fd, struct ast_frame *frame);
00318
00319
00320
00321
00322
00323
00324
00325 int ast_fr_fdhangup(int fd);
00326
00327
00328
00329
00330
00331
00332 extern char* ast_getformatname(int format);
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 extern char* ast_getformatname_multiple(char *buf, unsigned n, int format);
00344
00345
00346
00347
00348
00349
00350
00351 extern int ast_getformatbyname(char *name);
00352
00353
00354
00355
00356
00357
00358
00359 extern char *ast_codec2str(int codec);
00360
00361
00362
00363 extern int ast_best_codec(int fmts);
00364
00365 struct ast_smoother;
00366
00367 extern struct ast_smoother *ast_smoother_new(int bytes);
00368 extern void ast_smoother_set_flags(struct ast_smoother *smoother, int flags);
00369 extern int ast_smoother_get_flags(struct ast_smoother *smoother);
00370 extern void ast_smoother_free(struct ast_smoother *s);
00371 extern void ast_smoother_reset(struct ast_smoother *s, int bytes);
00372 extern int ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f);
00373 extern struct ast_frame *ast_smoother_read(struct ast_smoother *s);
00374
00375 extern void ast_frame_dump(char *name, struct ast_frame *f, char *prefix);
00376
00377 #if defined(__cplusplus) || defined(c_plusplus)
00378 }
00379 #endif
00380
00381
00382 #endif