25 #ifndef _ASTERISK_FRAME_H
26 #define _ASTERISK_FRAME_H
28 #if defined(__cplusplus) || defined(c_plusplus)
128 #define AST_FRAME_DTMF AST_FRAME_DTMF_END
183 #define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen) \
185 (fr)->data.ptr = (char *)_base + (_ofs); \
186 (fr)->offset = (_ofs); \
187 (fr)->datalen = (_datalen); \
204 #define AST_FRIENDLY_OFFSET 64
205 #define AST_MIN_OFFSET 32
208 #define AST_MALLOCD_HDR (1 << 0)
210 #define AST_MALLOCD_DATA (1 << 1)
212 #define AST_MALLOCD_SRC (1 << 2)
216 #define AST_MODEM_T38 1
218 #define AST_MODEM_V150 2
222 #define AST_HTML_URL 1
224 #define AST_HTML_DATA 2
226 #define AST_HTML_BEGIN 4
228 #define AST_HTML_END 8
230 #define AST_HTML_LDCOMPLETE 16
232 #define AST_HTML_NOSUPPORT 17
234 #define AST_HTML_LINKURL 18
236 #define AST_HTML_UNLINK 19
238 #define AST_HTML_LINKREJECT 20
242 #define AST_FORMAT_G723_1 (1ULL << 0)
244 #define AST_FORMAT_GSM (1ULL << 1)
246 #define AST_FORMAT_ULAW (1ULL << 2)
248 #define AST_FORMAT_ALAW (1ULL << 3)
250 #define AST_FORMAT_G726_AAL2 (1ULL << 4)
252 #define AST_FORMAT_ADPCM (1ULL << 5)
254 #define AST_FORMAT_SLINEAR (1ULL << 6)
256 #define AST_FORMAT_LPC10 (1ULL << 7)
258 #define AST_FORMAT_G729A (1ULL << 8)
260 #define AST_FORMAT_SPEEX (1ULL << 9)
262 #define AST_FORMAT_ILBC (1ULL << 10)
264 #define AST_FORMAT_G726 (1ULL << 11)
266 #define AST_FORMAT_G722 (1ULL << 12)
268 #define AST_FORMAT_SIREN7 (1ULL << 13)
270 #define AST_FORMAT_SIREN14 (1ULL << 14)
272 #define AST_FORMAT_SLINEAR16 (1ULL << 15)
274 #define AST_FORMAT_AUDIO_MASK 0xFFFF0000FFFFULL
276 #define AST_FORMAT_JPEG (1ULL << 16)
278 #define AST_FORMAT_PNG (1ULL << 17)
280 #define AST_FORMAT_H261 (1ULL << 18)
281 #define AST_FORMAT_FIRST_VIDEO_BIT AST_FORMAT_H261
283 #define AST_FORMAT_H263 (1ULL << 19)
285 #define AST_FORMAT_H263_PLUS (1ULL << 20)
287 #define AST_FORMAT_H264 (1ULL << 21)
289 #define AST_FORMAT_MP4_VIDEO (1ULL << 22)
290 #define AST_FORMAT_VIDEO_MASK ((((1ULL << 25)-1) & ~(AST_FORMAT_AUDIO_MASK)) | 0x7FFF000000000000ULL)
292 #define AST_FORMAT_T140RED (1ULL << 26)
294 #define AST_FORMAT_T140 (1ULL << 27)
296 #define AST_FORMAT_MAX_TEXT (1ULL << 28)
297 #define AST_FORMAT_TEXT_MASK (((1ULL << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
299 #define AST_FORMAT_G719 (1ULL << 32)
301 #define AST_FORMAT_SPEEX16 (1ULL << 33)
303 #define AST_FORMAT_TESTLAW (1ULL << 47)
305 #define AST_FORMAT_RESERVED (1ULL << 63)
381 unsigned char payload[0];
417 unsigned int fill_bit_removal:1;
418 unsigned int transcoding_mmr:1;
419 unsigned int transcoding_jbig:1;
427 #define AST_SMOOTHER_FLAG_G729 (1 << 0)
428 #define AST_SMOOTHER_FLAG_BE (1 << 1)
431 #define AST_OPTION_FLAG_REQUEST 0
432 #define AST_OPTION_FLAG_ACCEPT 1
433 #define AST_OPTION_FLAG_REJECT 2
434 #define AST_OPTION_FLAG_QUERY 4
435 #define AST_OPTION_FLAG_ANSWER 5
436 #define AST_OPTION_FLAG_WTF 6
441 #define AST_OPTION_TONE_VERIFY 1
445 #define AST_OPTION_TDD 2
449 #define AST_OPTION_RELAXDTMF 3
453 #define AST_OPTION_AUDIO_MODE 4
458 #define AST_OPTION_TXGAIN 5
463 #define AST_OPTION_RXGAIN 6
469 #define AST_OPTION_OPRMODE 7
476 #define AST_OPTION_ECHOCAN 8
484 #define AST_OPTION_CHANNEL_WRITE 9
490 #define AST_OPTION_T38_STATE 10
494 #define AST_OPTION_FORMAT_READ 11
498 #define AST_OPTION_FORMAT_WRITE 12
504 #define AST_OPTION_MAKE_COMPATIBLE 13
508 #define AST_OPTION_DIGIT_DETECT 14
512 #define AST_OPTION_FAX_DETECT 15
516 #define AST_OPTION_DEVICE_NAME 16
520 #define AST_OPTION_CC_AGENT_TYPE 17
524 #define AST_OPTION_SECURE_SIGNALING 18
525 #define AST_OPTION_SECURE_MEDIA 19
534 #if __BYTE_ORDER == __BIG_ENDIAN
538 #if __BYTE_ORDER == __LITTLE_ENDIAN
542 #error Byte order not defined
572 struct ast_frame *ast_fralloc(
char *source,
int len);
583 #define ast_frfree(fr) ast_frame_free(fr, 1)
611 #if __BYTE_ORDER == __LITTLE_ENDIAN
612 #define ast_frame_byteswap_le(fr) do { ; } while(0)
613 #define ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0)
615 #define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0)
616 #define ast_frame_byteswap_be(fr) do { ; } while(0)
686 #define ast_smoother_feed(s,f) __ast_smoother_feed(s, f, 0)
687 #if __BYTE_ORDER == __LITTLE_ENDIAN
688 #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 1)
689 #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 0)
691 #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 0)
692 #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1)
831 #if defined(__cplusplus) || defined(c_plusplus)
void ast_frame_free(struct ast_frame *fr, int cache)
Requests a frame to be allocated.
union ast_frame_subclass subclass
struct ast_smoother * ast_smoother_new(int bytes)
Main Channel structure associated with a channel.
void ast_smoother_free(struct ast_smoother *s)
struct ast_frame ast_null_frame
int ast_frame_clear(struct ast_frame *frame)
Clear all audio samples from an ast_frame. The frame must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR.
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size)
Dump audio codec preference list into a string.
struct ast_frame * ast_smoother_read(struct ast_smoother *s)
static int ast_codec_interp_len(format_t format)
Gets duration in ms of interpolation frame for a format.
char order[sizeof(format_t)*8]
int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems)
Set packet size for codec.
void ast_smoother_set_flags(struct ast_smoother *smoother, int flags)
format_t ast_codec_pref_index(struct ast_codec_pref *pref, int index)
Codec located at a particular place in the preference index.
int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap)
void ast_smoother_reset(struct ast_smoother *s, int bytes)
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
struct ast_frame * ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe)
Appends a frame to the end of a list of frames, truncating the maximum length of the list...
void ast_codec_pref_init(struct ast_codec_pref *pref)
Initialize an audio codec preference to "no preference".
struct ast_format_list * ast_get_format_list(size_t *size)
void ast_smoother_reconfigure(struct ast_smoother *s, int bytes)
Reconfigure an existing smoother to output a different number of bytes per frame. ...
int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format)
Append a audio codec to a preference list, removing it first if it was already there.
struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format)
Get packet size for codec.
void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format)
Remove audio a codec from a preference list.
Asterisk architecture endianess compatibility definitions.
static struct callattempt * find_best(struct callattempt *outgoing)
find the entry with the best metric, or NULL
A set of macros to manage forward-linked lists.
#define AST_FORMAT_SLINEAR16
format_t ast_getformatbyname(const char *name)
Gets a format from a name.
ast_control_frame_type
Internal control frame subtype field values.
char * ast_getformatname(format_t format)
Get the name of a format.
#define AST_FORMAT_SIREN7
format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best)
Select the best audio format according to preference list from supplied options. If "find_best" is no...
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_FORMAT_SIREN14
struct ast_format_list * ast_get_format_list_index(int index)
int ast_smoother_test_flag(struct ast_smoother *s, int flag)
struct ast_channel * peer
struct ao2_container * cache
ast_frame_type
Frame types.
ast_control_t38_rate_management
int ast_codec_get_samples(struct ast_frame *f)
Returns the number of samples contained in the frame.
int ast_smoother_get_flags(struct ast_smoother *smoother)
int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
Adjusts the volume of the audio samples contained in a frame.
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Data structure associated with a single frame of data.
void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int right)
Shift an audio codec preference list up or down 65 bytes so that it becomes an ASCII string...
enum ast_frame_type frametype
void ast_swapcopy_samples(void *dst, const void *src, int samples)
int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2)
Sums two frames of audio samples.
static snd_pcm_format_t format
Asterisk internal frame definitions.
union ast_frame::@172 data
int ast_codec_get_len(format_t format, int samples)
Returns the number of bytes for the number of samples of the given format.
struct ast_frame * ast_frdup(const struct ast_frame *fr)
Copies a frame.
int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing)
Parse an "allow" or "deny" line in a channel or device configuration and update the capabilities mask...
void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing)
Prepend an audio codec to a preference list, removing it first if it was already there.
static char prefix[MAX_PREFIX]
#define AST_FORMAT_SPEEX16
char * ast_codec2str(format_t codec)
Get a name from a format Gets a name from a format.