190 short *data1, *data2;
194 static const int num_samples = 160;
195 short combine_buf[num_samples];
200 .datalen = num_samples * 2,
201 .samples = num_samples,
205 memset(&combine_buf, 0,
sizeof(combine_buf));
228 for (i = 0, data1 = combine_buf, data2 = f->
data.
ptr; i < num_samples; i++, data1++, data2++) {
262 ast_debug(2,
"Using a long queue to store audio frames in spy audiohook\n");
276 ast_verb(3,
"Attaching spy channel %s to %s\n",
281 ast_debug(9,
"Using a long queue to store audio frames in whisper audiohook\n");
310 ast_log(
LOG_WARNING,
"Barge failed: channel is bridged, but not to a 2-party bridge. Use the 'r' option.\n");
317 if (!internal_bridge_autochan) {
326 *spyee_bridge_autochan = internal_bridge_autochan;
334 ast_debug(2,
"Whisper audiohook no longer running\n");
343 ast_debug(2,
"Whisper (bridged) audiohook no longer running\n");
352 ast_debug(2,
"Spy audiohook no longer running\n");
443 ast_debug(1,
"Broadcasting: (TX->1) whisper=%d, (TX->2) barge=%d, (RX<-%d) spy=%d (%s)\n",
448 readonly ?
"single" :
"both");
561 ast_debug(1,
"Exiting due to all target channels having left the broadcast\n");
611 ast_log(
LOG_WARNING,
"At least one of the b, s, or w option must be specified (provided options have no effect)\n");
static int do_broadcast(struct ast_channel *chan, struct ast_flags *flags, const char *channels)
static void * spy_alloc(struct ast_channel *chan, void *data)
static int broadcast_exec(struct ast_channel *chan, const char *data)
static const struct ast_app_option spy_opts[128]
static int start_whispering(struct ast_autochan *autochan, const char *spychan_name, struct ast_audiohook *audiohook, struct ast_flags *flags)
static int start_spying(struct ast_autochan *autochan, const char *spychan_name, struct ast_audiohook *audiohook, struct ast_flags *flags)
static int load_module(void)
static int attach_barge(struct ast_autochan *spyee_autochan, struct ast_autochan **spyee_bridge_autochan, struct ast_audiohook *bridge_whisper_audiohook, const char *spyer_name, const char *name, struct ast_flags *flags)
static int unload_module(void)
static const char app_broadcast[]
static void spy_release(struct ast_channel *chan, void *data)
static void multi_autochan_free(struct multi_autochan *mac)
static int spy_generate(struct ast_channel *chan, void *data, int len, int samples)
static struct ast_generator spygen
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
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.
struct ast_frame * ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, struct ast_format *format)
Reads a frame in from the audiohook structure.
int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction, struct ast_frame *frame)
Writes a frame into the audiohook structure.
@ AST_AUDIOHOOK_DIRECTION_READ
@ AST_AUDIOHOOK_DIRECTION_WRITE
@ AST_AUDIOHOOK_DIRECTION_BOTH
#define ast_audiohook_lock(ah)
Lock an audiohook.
@ AST_AUDIOHOOK_MUTE_WRITE
@ AST_AUDIOHOOK_SMALL_QUEUE
@ AST_AUDIOHOOK_TRIGGER_SYNC
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
@ AST_AUDIOHOOK_TYPE_WHISPER
@ AST_AUDIOHOOK_STATUS_RUNNING
int ast_audiohook_set_frame_feed_direction(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction)
Sets direction on audiohook.
"smart" channels that update automatically if a channel is masqueraded
struct ast_autochan * ast_autochan_setup(struct ast_channel *chan)
set up a new ast_autochan structure
void ast_autochan_destroy(struct ast_autochan *autochan)
destroy an ast_autochan structure
#define ast_autochan_channel_lock(autochan)
Lock the autochan's channel lock.
#define ast_autochan_channel_unlock(autochan)
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
#define ast_channel_ref(c)
Increase channel reference count.
void ast_deactivate_generator(struct ast_channel *chan)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Standard Command Line Interface.
static struct channel_usage channels
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#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_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_RWLIST_HEAD(name, type)
Defines a structure to be used to hold a read/write list of specified type.
#define AST_RWLIST_INSERT_TAIL
Asterisk locking-related definitions:
Asterisk module definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define AST_MODULE_INFO_STANDARD_EXTENDED(keystr, desc)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Options provided by main asterisk program.
Core PBX routines and definitions.
static void cleanup(void)
Clean up any old apps that we don't need any more.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
enum ast_audiohook_status status
struct ast_channel * chan
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
enum ast_frame_type frametype
union ast_frame::@239 data
void *(* alloc)(struct ast_channel *chan, void *params)
struct multi_autochan * next
struct ast_audiohook bridge_whisper_audiohook
struct ast_audiohook whisper_audiohook
struct ast_autochan * autochan
struct multi_autochan::@10 entry
struct ast_audiohook spy_audiohook
unsigned int bridge_connected
struct ast_autochan * bridge_autochan
struct multi_autochan_list * chanlist
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_clear_flag(p, flag)
static force_inline void ast_slinear_saturated_add(short *input, short *value)
#define ast_set_flag(p, flag)