48 #if (defined(LOW_MEMORY) || defined(MALLOC_DEBUG)) && !defined(NO_FRAME_CACHE)
49 #define NO_FRAME_CACHE
52 #if !defined(NO_FRAME_CACHE)
53 static void frame_cache_cleanup(
void *data);
67 #define FRAME_CACHE_MAX_SIZE 10
81 static struct ast_frame *ast_frame_header_new(
const char *file,
int line,
const char *func)
85 #if !defined(NO_FRAME_CACHE)
92 memset(f, 0,
sizeof(*f));
100 if (!(f = __ast_calloc(1,
sizeof(*f), file, line, func))) {
109 #if !defined(NO_FRAME_CACHE)
110 static void frame_cache_cleanup(
void *data)
127 #if !defined(NO_FRAME_CACHE)
130 && ast_opt_cache_media_frames) {
158 ast_free((
void *) fr->
src);
182 __frame_free(frame, cache);
206 return __ast_frdup(fr, file, line, func);
217 if (!(out = ast_frame_header_new(file, line, func))) {
233 ast_copy_flags(out, fr, AST_FLAGS_ALL);
262 }
else if (out != fr) {
292 out->
data.ptr = newdata;
294 }
else if (out != fr) {
297 memset(&fr->
data, 0,
sizeof(fr->
data));
305 struct ast_frame *__ast_frdup(
const struct ast_frame *f,
const char *file,
int line,
const char *func)
311 #if !defined(NO_FRAME_CACHE)
323 srclen = strlen(f->
src);
327 #if !defined(NO_FRAME_CACHE)
334 memset(out, 0,
sizeof(*out));
346 if (!(buf = __ast_calloc(1, len, file, line, func)))
384 src = (
char *) out->
src;
388 ast_copy_flags(out, f, AST_FLAGS_ALL);
396 void ast_swapcopy_samples(
void *dst,
const void *src,
int samples)
399 unsigned short *dst_s = dst;
400 const unsigned short *src_s = src;
402 for (i = 0; i < samples; i++)
403 dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
485 message =
"Negotiation Requested";
487 message =
"Negotiation Request Terminated";
489 message =
"Negotiated";
491 message =
"Terminated";
495 snprintf(subclass, slen,
"T38_Parameters/%s", message);
597 snprintf(subclass, slen,
"Synchronous Bridge Frametype %d", f->
subclass.
integer);
644 snprintf(subclass, slen,
"Unknown HTML frame '%d'\n", f->
subclass.
integer);
657 snprintf(subclass, slen,
"Unknown MODEM frame '%d'\n", f->
subclass.
integer);
673 switch (frame_type) {
723 snprintf(ftype, len,
"Unknown Frametype '%u'", frame_type);
733 const char noname[] =
"unknown";
734 char ftype[40] =
"Unknown Frametype";
736 char subclass[40] =
"Unknown Subclass";
738 char moreinfo[40] =
"";
748 ast_verb(-1,
"%s [ %s (NULL) ] [%s]\n",
749 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK,
sizeof(cp)),
750 term_color(cft,
"HANGUP", COLOR_BRRED, COLOR_BLACK,
sizeof(cft)),
751 term_color(cn, name, COLOR_YELLOW, COLOR_BLACK,
sizeof(cn)));
768 if (!ast_strlen_zero(moreinfo))
769 ast_verb(-1,
"%s [ TYPE: %s (%u) SUBCLASS: %s (%d) '%s' ] [%s]\n",
770 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK,
sizeof(cp)),
771 term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK,
sizeof(cft)),
773 term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK,
sizeof(csub)),
775 term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK,
sizeof(cmn)),
776 term_color(cn, name, COLOR_YELLOW, COLOR_BLACK,
sizeof(cn)));
778 ast_verb(-1,
"%s [ TYPE: %s (%u) SUBCLASS: %s (%d) ] [%s]\n",
779 term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK,
sizeof(cp)),
780 term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK,
sizeof(cft)),
782 term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK,
sizeof(csub)),
784 term_color(cn, name, COLOR_YELLOW, COLOR_BLACK,
sizeof(cn)));
790 short *fdata = f->
data.ptr;
791 short adjust_value = abs(adjustment);
801 for (count = 0; count < f->
samples; count++) {
802 if (adjustment > 0) {
803 ast_slinear_saturated_multiply(&fdata[count], &adjust_value);
804 }
else if (adjustment < 0) {
805 ast_slinear_saturated_divide(&fdata[count], &adjust_value);
815 short *fdata = f->
data.ptr;
816 float adjust_value = fabs(adjustment);
826 for (count = 0; count < f->
samples; count++) {
827 if (adjustment > 0) {
828 ast_slinear_saturated_multiply_float(&fdata[count], &adjust_value);
829 }
else if (adjustment < 0) {
830 ast_slinear_saturated_divide_float(&fdata[count], &adjust_value);
840 short *data1, *data2;
851 for (count = 0, data1 = f1->
data.ptr, data2 = f2->
data.ptr;
853 count++, data1++, data2++)
854 ast_slinear_saturated_add(data1, data2);
This is just so ast_frames, a list head struct for holding a list of ast_frame structures, is defined.
struct ast_frame * __ast_frisolate(struct ast_frame *fr, const char *file, int line, const char *func)
'isolates' a frame by duplicating non-malloc'ed components (header, src, data). On return all compone...
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
void ast_frame_free(struct ast_frame *frame, int cache)
Frees a frame or list of frames.
#define AST_HTML_NOSUPPORT
char * ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
Copy the discription of a frame type into the provided string.
Support for translation of data formats. translate.c.
#define AST_HTML_LDCOMPLETE
Convenient Signal Processing routines.
#define AST_HTML_LINKREJECT
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
enum ast_control_t38 request_response
char * ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
Copy the discription of a frame's subclass into the provided string.
void ast_frame_dtor(struct ast_frame *f)
NULL-safe wrapper for ast_frfree, good for RAII_VAR.
#define ast_strdup(str)
A wrapper for strdup()
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
Definitions to aid in the use of thread local storage.
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
struct ast_frame_subclass subclass
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
#define FRAME_CACHE_MAX_SIZE
Maximum ast_frame cache size.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Asterisk internal frame definitions.
A set of macros to manage forward-linked lists.
#define ast_malloc(len)
A wrapper for malloc()
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2)
Sums two frames of audio samples.
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
ast_frame_type
Frame types.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
union ast_frame::@224 data
Prototypes for public functions only of internal interest,.
struct ast_frame ast_null_frame
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
int ast_frame_adjust_volume_float(struct ast_frame *f, float adjustment)
Adjusts the volume of the audio samples contained in a frame.
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Data structure associated with a single frame of data.
Handy terminal functions for vt* terms.
int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
Adjusts the volume of the audio samples contained in a frame.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
static struct sorcery_test_caching cache
Global scope caching structure for testing.
struct ast_format * format
struct ast_stream_topology * topology
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.