Asterisk - The Open Source Telephony Project GIT-master-b023714
|
Stasis application snoop control support. More...
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/stasis_app_impl.h"
#include "asterisk/stasis_app_snoop.h"
#include "asterisk/audiohook.h"
#include "asterisk/pbx.h"
#include "asterisk/timing.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/json.h"
#include "asterisk/format_cache.h"
Go to the source code of this file.
Data Structures | |
struct | stasis_app_snoop |
Structure which contains all of the snoop information. More... | |
Macros | |
#define | SNOOP_INTERVAL 20 |
The interval (in milliseconds) that the Snoop timer is triggered, also controls length of audio within frames. | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | load_module (void) |
static void | publish_chanspy_message (struct stasis_app_snoop *snoop, int start) |
static void | snoop_destroy (void *obj) |
Destructor for snoop structure. | |
static void | snoop_determine_format (struct ast_channel *chan, struct stasis_app_snoop *snoop) |
Helper function which gets the format for a Snoop channel based on the channel being snooped on. | |
static int | snoop_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
static int | snoop_hangup (struct ast_channel *chan) |
Callback function for hanging up a Snoop channel. | |
static struct ast_frame * | snoop_read (struct ast_channel *chan) |
Callback function for reading from a Snoop channel. | |
static int | snoop_setup_audiohook (struct ast_channel *chan, enum ast_audiohook_type type, enum stasis_app_snoop_direction requested_direction, enum ast_audiohook_direction *direction, struct ast_audiohook *audiohook) |
Internal helper function which sets up and attaches a snoop audiohook. | |
static void * | snoop_stasis_thread (void *obj) |
Thread used for running the Stasis application. | |
static int | snoop_write (struct ast_channel *chan, struct ast_frame *frame) |
Callback function for writing to a Snoop whisper audiohook. | |
struct ast_channel * | stasis_app_control_snoop (struct ast_channel *chan, enum stasis_app_snoop_direction spy, enum stasis_app_snoop_direction whisper, const char *app, const char *app_args, const char *snoop_id) |
Create a snoop on the provided channel. | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS , .description = "Stasis application snoop support" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_stasis", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static unsigned int | chan_idx |
Index used to keep Snoop channel names unique. | |
static struct ast_channel_tech | snoop_tech |
Channel interface declaration. | |
Stasis application snoop control support.
Definition in file res_stasis_snoop.c.
#define SNOOP_INTERVAL 20 |
The interval (in milliseconds) that the Snoop timer is triggered, also controls length of audio within frames.
Definition at line 44 of file res_stasis_snoop.c.
|
static |
Definition at line 445 of file res_stasis_snoop.c.
|
static |
Definition at line 445 of file res_stasis_snoop.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 445 of file res_stasis_snoop.c.
|
static |
|
static |
Definition at line 113 of file res_stasis_snoop.c.
References ao2_cleanup, ast_channel_chanspy_start_type(), ast_channel_chanspy_stop_type(), ast_channel_lock, ast_channel_snapshot_get_latest(), ast_channel_topic(), ast_channel_uniqueid(), ast_channel_unlock, ast_json_null(), ast_json_unref(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_create(), stasis_app_snoop::chan, NULL, RAII_VAR, stasis_app_snoop::spyee_chan, stasis_message_create(), stasis_publish(), and type.
Referenced by snoop_hangup(), and stasis_app_control_snoop().
|
static |
Destructor for snoop structure.
Definition at line 80 of file res_stasis_snoop.c.
References stasis_app_snoop::app, ast_audiohook_destroy(), ast_channel_cleanup, ast_free, ast_timer_close(), stasis_app_snoop::chan, ast_frame::data, NULL, ast_frame::ptr, stasis_app_snoop::silence, stasis_app_snoop::spy, stasis_app_snoop::spy_active, stasis_app_snoop::spyee_chan, stasis_app_snoop::timer, stasis_app_snoop::whisper, and stasis_app_snoop::whisper_active.
Referenced by stasis_app_control_snoop().
|
static |
Helper function which gets the format for a Snoop channel based on the channel being snooped on.
Definition at line 294 of file res_stasis_snoop.c.
References ast_channel_rawreadformat(), ast_channel_rawwriteformat(), ast_format_cache_get_slin_by_rate(), ast_format_get_sample_rate(), lock, MAX, SCOPED_CHANNELLOCK, and stasis_app_snoop::spy_format.
Referenced by stasis_app_control_snoop().
|
static |
Definition at line 229 of file res_stasis_snoop.c.
References ast_channel_ref, ast_channel_tech_pvt(), ast_channel_unref, and stasis_app_snoop::chan.
|
static |
Callback function for hanging up a Snoop channel.
Definition at line 204 of file res_stasis_snoop.c.
References ao2_cleanup, ast_audiohook_detach(), ast_audiohook_lock, ast_audiohook_unlock, ast_channel_tech_pvt(), ast_channel_tech_pvt_set(), stasis_app_snoop::chan, NULL, publish_chanspy_message(), stasis_app_snoop::spy, stasis_app_snoop::spy_active, stasis_app_snoop::whisper, and stasis_app_snoop::whisper_active.
|
static |
Callback function for reading from a Snoop channel.
Definition at line 177 of file res_stasis_snoop.c.
References ast_audiohook_lock, ast_audiohook_read_frame(), AST_AUDIOHOOK_STATUS_RUNNING, ast_audiohook_unlock, ast_channel_tech_pvt(), ast_null_frame, ast_timer_ack(), stasis_app_snoop::chan, NULL, stasis_app_snoop::silence, stasis_app_snoop::spy, stasis_app_snoop::spy_active, stasis_app_snoop::spy_direction, stasis_app_snoop::spy_format, stasis_app_snoop::spy_samples, ast_audiohook::status, stasis_app_snoop::timer, stasis_app_snoop::whisper, and stasis_app_snoop::whisper_active.
|
static |
Internal helper function which sets up and attaches a snoop audiohook.
Definition at line 267 of file res_stasis_snoop.c.
References ast_audiohook_attach(), AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_init(), ast_audiohook_set_frame_feed_direction(), STASIS_SNOOP_DIRECTION_BOTH, STASIS_SNOOP_DIRECTION_IN, STASIS_SNOOP_DIRECTION_OUT, and type.
Referenced by stasis_app_control_snoop().
|
static |
Thread used for running the Stasis application.
Definition at line 255 of file res_stasis_snoop.c.
References ao2_cleanup, ast_hangup(), ast_pbx_exec_application(), ast_str_buffer(), NULL, and RAII_VAR.
Referenced by stasis_app_control_snoop().
|
static |
Callback function for writing to a Snoop whisper audiohook.
Definition at line 156 of file res_stasis_snoop.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_lock, ast_audiohook_unlock, ast_audiohook_write_frame(), ast_channel_tech_pvt(), stasis_app_snoop::chan, stasis_app_snoop::whisper, stasis_app_snoop::whisper_active, and stasis_app_snoop::whisper_direction.
struct ast_channel * stasis_app_control_snoop | ( | struct ast_channel * | chan, |
enum stasis_app_snoop_direction | spy, | ||
enum stasis_app_snoop_direction | whisper, | ||
const char * | app, | ||
const char * | app_args, | ||
const char * | snoop_id | ||
) |
Create a snoop on the provided channel.
chan | Channel to snoop on. |
spy | Direction of media that should be spied on. |
whisper | Direction of media that should be whispered into. |
app | Stasis application to execute on the snoop channel. |
app_args | Stasis application arguments. |
snoop_id |
NULL | if snoop channel couldn't be created. |
Definition at line 303 of file res_stasis_snoop.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_ref, app, ast_atomic_fetchadd_int(), AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_calloc, ast_channel_alloc, ast_channel_nativeformats_set(), ast_channel_ref, ast_channel_set_fd(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_uniqueid(), ast_channel_unlock, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_get_sample_rate(), AST_FRAME_VOICE, ast_hangup(), ast_pthread_create_detached_background, AST_STATE_UP, ast_str_append(), ast_str_create, ast_str_set(), ast_strlen_zero(), ast_timer_fd(), ast_timer_open(), ast_timer_set_rate(), chan_idx, NULL, publish_chanspy_message(), RAII_VAR, snoop_destroy(), snoop_determine_format(), SNOOP_INTERVAL, snoop_setup_audiohook(), snoop_stasis_thread(), snoop_tech, STASIS_SNOOP_DIRECTION_NONE, thread, and ast_assigned_ids::uniqueid.
Referenced by ari_channels_handle_snoop_channel().
|
static |
Definition at line 435 of file res_stasis_snoop.c.
|
static |
Definition at line 445 of file res_stasis_snoop.c.
|
static |
Definition at line 445 of file res_stasis_snoop.c.
|
static |
Index used to keep Snoop channel names unique.
Definition at line 47 of file res_stasis_snoop.c.
Referenced by stasis_app_control_snoop().
|
static |
Channel interface declaration.
Definition at line 245 of file res_stasis_snoop.c.
Referenced by stasis_app_control_snoop().