Asterisk - The Open Source Telephony Project
18.5.0
|
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static struct ast_frame * | snoop_read (struct ast_channel *chan) |
Callback function for reading from a Snoop channel. More... | |
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. More... | |
static void * | snoop_stasis_thread (void *obj) |
Thread used for running the Stasis application. More... | |
static int | snoop_write (struct ast_channel *chan, struct ast_frame *frame) |
Callback function for writing to a Snoop whisper audiohook. More... | |
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. More... | |
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 = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .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. More... | |
static struct ast_channel_tech | snoop_tech |
Channel interface declaration. More... | |
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.
Referenced by stasis_app_control_snoop().
|
static |
Definition at line 451 of file res_stasis_snoop.c.
|
static |
Definition at line 451 of file res_stasis_snoop.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 451 of file res_stasis_snoop.c.
|
static |
Definition at line 436 of file res_stasis_snoop.c.
References AST_MODULE_LOAD_SUCCESS.
Referenced by unload_module().
|
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_snapshot_get_latest(), ast_channel_topic(), ast_channel_uniqueid(), 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 300 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 237 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 212 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(), 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 173 of file res_stasis_snoop.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_lock, ast_audiohook_read_frame(), AST_AUDIOHOOK_STATUS_RUNNING, ast_audiohook_unlock, ast_channel_tech_pvt(), ast_frame_dtor(), ast_null_frame, ast_timer_ack(), 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 281 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(), STASIS_SNOOP_DIRECTION_BOTH, STASIS_SNOOP_DIRECTION_IN, and STASIS_SNOOP_DIRECTION_OUT.
Referenced by stasis_app_control_snoop().
|
static |
Thread used for running the Stasis application.
Definition at line 263 of file res_stasis_snoop.c.
References ao2_cleanup, ast_hangup(), ast_str_buffer(), NULL, pbx_exec(), pbx_findapp(), RAII_VAR, and stasis.
Referenced by stasis_app_control_snoop().
|
static |
Callback function for writing to a Snoop whisper audiohook.
Definition at line 152 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::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. |
NULL
if snoop channel couldn't be created. Definition at line 309 of file res_stasis_snoop.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_ref, 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(), STASIS_SNOOP_DIRECTION_NONE, thread, and ast_assigned_ids::uniqueid.
Referenced by ari_channels_handle_snoop_channel().
|
static |
Definition at line 441 of file res_stasis_snoop.c.
References AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, and load_module().
|
static |
Definition at line 451 of file res_stasis_snoop.c.
|
static |
Definition at line 451 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 253 of file res_stasis_snoop.c.