115 #define DEFAULT_SILENCE_THRESHOLD 2500 139 if (td_params->
dsp) {
147 .
type =
"talk_detect",
162 int update_talking = 0;
182 td_params = datastore->
data;
199 if (update_talking) {
213 td_params->
talking ?
"talking" :
"silent");
241 td_params = datastore->
data;
273 td_params =
ast_calloc(1,
sizeof(*td_params));
287 if (!td_params->
dsp) {
292 datastore->
data = td_params;
298 td_params = datastore->
data;
323 if (!strcasecmp(data,
"set")) {
338 if (sscanf(
args.silence_threshold,
"%30d", &dsp_silence_threshold) != 1) {
340 args.silence_threshold);
344 if (dsp_silence_threshold < 1) {
346 dsp_silence_threshold);
352 if (sscanf(
args.talking_threshold,
"%30d", &dsp_talking_threshold) != 1) {
354 args.talking_threshold);
358 if (dsp_talking_threshold < 1) {
360 dsp_silence_threshold);
366 res =
set_talk_detect(chan, dsp_silence_threshold, dsp_talking_threshold);
367 }
else if (!strcasecmp(data,
"remove")) {
379 .
name =
"TALK_DETECT",
struct stasis_message_type * ast_channel_talking_stop(void)
Message type for a channel stopping talking.
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int dsp_talking_threshold
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_dsp_free(struct ast_dsp *dsp)
Convenient Signal Processing routines.
#define ast_set_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
Remove an audiohook from a specified channel.
static int load_module(void)
Structure for a data store type.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
struct stasis_message_type * ast_channel_talking_start(void)
Message type for a channel starting talking.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
#define DEFAULT_SILENCE_THRESHOLD
#define ast_verb(level,...)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
#define ast_strlen_zero(foo)
ast_audiohook_manipulate_callback manipulate_callback
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags)
Initialize an audiohook structure.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
static int unload_module(void)
#define ao2_ref(o, delta)
#define ast_strdupa(s)
duplicate a string in memory from the stack
int dsp_silence_threshold
Core PBX routines and definitions.
Private data structure used with the function's datastore.
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
static int talk_detect_fn_write(struct ast_channel *chan, const char *function, char *data, const char *value)
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
struct ast_audiohook audiohook
static int talk_detect_audiohook_cb(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
static const struct ast_datastore_info talk_detect_datastore
The channel datastore the function uses to store state.
static void parse(struct mgcp_request *req)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
static struct ast_custom_function talk_detect_function
Definition of the TALK_DETECT function.
#define ast_calloc(num, len)
A wrapper for calloc()
static int set_talk_detect(struct ast_channel *chan, int dsp_silence_threshold, int dsp_talking_threshold)
Module has failed to load, may be in an inconsistent state.
struct stasis_message * ast_channel_blob_create_from_cache(const char *uniqueid, struct stasis_message_type *type, struct ast_json *blob)
Create a ast_channel_blob message, pulling channel state from the cache.
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
const char * ast_channel_name(const struct ast_channel *chan)
Data structure associated with a single frame of data.
Abstract JSON element (object, array, string, int, ...).
struct ast_dsp * ast_dsp_new_with_rate(unsigned int sample_rate)
Allocates a new dsp with a specific internal sample rate used during processing.
enum ast_audiohook_status status
#define ast_datastore_alloc(info, uid)
enum ast_frame_type frametype
static int remove_talk_detect(struct ast_channel *chan)
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Asterisk module definitions.
struct timeval talking_start
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_custom_function_register(acf)
Register a custom function.
#define AST_APP_ARG(name)
Define an application argument.
static void datastore_destroy_cb(void *data)