41 #define SMOOTHER_SIZE 8000
48 unsigned int opt_needs_swap:1;
50 struct timeval delivery;
51 char data[SMOOTHER_SIZE];
59 if (s->flags & AST_SMOOTHER_FLAG_G729) {
61 ast_log(LOG_NOTICE,
"Dropping extra frame of G.729 since we already have a VAD frame at the end\n");
66 ast_swapcopy_samples(s->data + s->len, f->
data.ptr, f->
samples);
79 void ast_smoother_reset(
struct ast_smoother *s,
int bytes)
81 ao2_cleanup(s->format);
82 memset(s, 0,
sizeof(*s));
89 if (s->size == bytes) {
104 smoother_frame_feed(s, s->opt, s->opt_needs_swap);
114 ast_smoother_reset(s, size);
123 void ast_smoother_set_flags(
struct ast_smoother *s,
int flags)
128 int ast_smoother_test_flag(
struct ast_smoother *s,
int flag)
130 return (s->flags & flag);
136 ast_log(LOG_WARNING,
"Huh? Can't smooth a non-voice frame!\n");
143 ast_log(LOG_WARNING,
"Smoother was working on %s format frames, now trying to feed %s?\n",
147 if (s->len + f->
datalen > SMOOTHER_SIZE) {
148 ast_log(LOG_WARNING,
"Out of smoother space\n");
151 if (((f->
datalen == s->size) ||
152 ((f->
datalen < 10) && (s->flags & AST_SMOOTHER_FLAG_G729))) &&
155 (f->
offset >= AST_MIN_OFFSET)) {
162 s->opt_needs_swap = swap ? 1 : 0;
166 return smoother_frame_feed(s, f, swap);
177 ast_log(LOG_WARNING,
"Returning a frame of inappropriate offset (%d).\n",
185 if (s->len < s->size) {
187 if (!((s->flags & AST_SMOOTHER_FLAG_G729) && (s->len % 10)))
200 s->f.
samples = len * s->samplesperbyte;
203 memcpy(s->f.
data.ptr, s->data, len);
209 memmove(s->data, s->data + len, s->len);
222 ao2_cleanup(s->format);
Asterisk main include file. File version handling, generic pbx functions.
Time-related functions and macros.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Asterisk internal frame definitions.
struct ast_frame_subclass subclass
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
Asterisk internal frame definitions.
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
void ast_smoother_reconfigure(struct ast_smoother *s, int bytes)
Reconfigure an existing smoother to output a different number of bytes per frame. ...
union ast_frame::@224 data
#define ast_calloc(num, len)
A wrapper for calloc()
Prototypes for public functions only of internal interest,.
Data structure associated with a single frame of data.
enum ast_frame_type frametype
struct ast_format * format