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