84{
85 int res = 0;
86 char *tmp;
88 int notsilent = 0;
89 struct timeval start = { 0, 0 };
90 struct timeval detection_start = { 0, 0 };
91 int sil = 1000;
94 int analysistime = -1;
95 int continue_analysis = 1;
96 int x;
105 );
106
109 return -1;
110 }
111
114
116 sil = x;
117 }
120 }
123 }
125 analysistime = x;
126 }
127
128 ast_debug(1,
"Preparing detect of '%s', sil=%d, min=%d, max=%d, analysistime=%d\n",
args.filename, sil,
min,
max, analysistime);
129 do {
132 break;
133 }
134 }
135
139 res = -1;
140 break;
141 }
142
145 res = -1;
146 break;
147 }
151 break;
152 }
157 res = 0;
158 break;
159 }
160 if (res < 0) {
161 res = 1000;
162 }
164 if (res < 0) {
166 break;
167 } else if (res > 0) {
169 if (continue_analysis && analysistime >= 0) {
170
171
173 continue_analysis = 0;
175 }
176 }
177
178 if (!fr) {
179 res = -1;
180 break;
182 char t[2];
184 t[1] = '\0';
187
190 break;
191 }
195 int ms;
198
199 if (notsilent) {
200
202 ms -= sil;
203 if (ms < 0)
204 ms = 0;
205 if ((ms >
min) && ((
max < 0) || (ms <
max))) {
206 char ms_str[12];
207 ast_debug(1,
"Found qualified token of %d ms\n", ms);
208
209
210 snprintf(ms_str, sizeof(ms_str), "%d", ms);
212
214 res = 0;
216 break;
217 } else {
218 ast_debug(1,
"Found unqualified token of %d ms\n", ms);
219 }
220 notsilent = 0;
221 }
222 } else {
223 if (!notsilent) {
224
227 notsilent = 1;
228 }
229 }
230 }
232 }
234 }
236 } while (0);
237
238 if (res > -1) {
242 }
243 }
244 if (dsp) {
246 }
247 return res;
248}
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
const char * ast_channel_context(const struct ast_channel *chan)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.