Asterisk - The Open Source Telephony Project
21.4.1
|
Audiohooks Architecture. More...
Go to the source code of this file.
Data Structures | |
struct | ast_audiohook |
struct | ast_audiohook_options |
Macros | |
#define | ast_audiohook_lock(ah) ast_mutex_lock(&(ah)->lock) |
Lock an audiohook. More... | |
#define | ast_audiohook_unlock(ah) ast_mutex_unlock(&(ah)->lock) |
Unlock an audiohook. More... | |
Typedefs | |
typedef int(* | ast_audiohook_manipulate_callback) (struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction) |
Callback function for manipulate audiohook type. More... | |
Enumerations | |
enum | ast_audiohook_direction { AST_AUDIOHOOK_DIRECTION_READ = 0, AST_AUDIOHOOK_DIRECTION_WRITE, AST_AUDIOHOOK_DIRECTION_BOTH } |
enum | ast_audiohook_flags { AST_AUDIOHOOK_TRIGGER_MODE = (3 << 0), AST_AUDIOHOOK_TRIGGER_READ = (1 << 0), AST_AUDIOHOOK_TRIGGER_WRITE = (2 << 0), AST_AUDIOHOOK_WANTS_DTMF = (1 << 2), AST_AUDIOHOOK_TRIGGER_SYNC = (1 << 3), AST_AUDIOHOOK_SMALL_QUEUE = (1 << 4), AST_AUDIOHOOK_MUTE_READ = (1 << 5), AST_AUDIOHOOK_MUTE_WRITE = (1 << 6), AST_AUDIOHOOK_COMPATIBLE = (1 << 7), AST_AUDIOHOOK_SUBSTITUTE_SILENCE = (1 << 8) } |
enum | ast_audiohook_init_flags { AST_AUDIOHOOK_MANIPULATE_ALL_RATES = (1 << 0) } |
enum | ast_audiohook_status { AST_AUDIOHOOK_STATUS_NEW = 0, AST_AUDIOHOOK_STATUS_RUNNING, AST_AUDIOHOOK_STATUS_SHUTDOWN, AST_AUDIOHOOK_STATUS_DONE } |
enum | ast_audiohook_type { AST_AUDIOHOOK_TYPE_SPY = 0, AST_AUDIOHOOK_TYPE_WHISPER, AST_AUDIOHOOK_TYPE_MANIPULATE } |
Functions | |
int | ast_audiohook_attach (struct ast_channel *chan, struct ast_audiohook *audiohook) |
Attach audiohook to channel. More... | |
int | ast_audiohook_destroy (struct ast_audiohook *audiohook) |
Destroys an audiohook structure. More... | |
int | ast_audiohook_detach (struct ast_audiohook *audiohook) |
Detach audiohook from channel. More... | |
void | ast_audiohook_detach_list (struct ast_audiohook_list *audiohook_list) |
Detach audiohooks from list and destroy said list. More... | |
int | ast_audiohook_detach_source (struct ast_channel *chan, const char *source) |
Detach specified source audiohook from channel. More... | |
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. More... | |
void | ast_audiohook_move_all (struct ast_channel *old_chan, struct ast_channel *new_chan) |
Move all audiohooks from one channel to another. More... | |
void | ast_audiohook_move_by_source (struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source) |
Move an audiohook from one channel to a new one. More... | |
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. More... | |
struct ast_frame * | ast_audiohook_read_frame_all (struct ast_audiohook *audiohook, size_t samples, struct ast_format *format, struct ast_frame **read_frame, struct ast_frame **write_frame) |
Reads a frame in from the audiohook structure in mixed audio mode and copies read and write frame data to provided arguments. More... | |
int | ast_audiohook_remove (struct ast_channel *chan, struct ast_audiohook *audiohook) |
Remove an audiohook from a specified channel. More... | |
int | ast_audiohook_set_frame_feed_direction (struct ast_audiohook *audiohook, enum ast_audiohook_direction direction) |
Sets direction on audiohook. More... | |
int | ast_audiohook_set_mute (struct ast_channel *chan, const char *source, enum ast_audiohook_flags flag, int clear) |
Mute frames read from or written to a channel. More... | |
int | ast_audiohook_set_mute_all (struct ast_channel *chan, const char *source, enum ast_audiohook_flags flag, int clear) |
Mute frames read from or written for all audiohooks on a channel. More... | |
void | ast_audiohook_trigger_wait (struct ast_audiohook *audiohook) |
Wait for audiohook trigger to be triggered. More... | |
void | ast_audiohook_update_status (struct ast_audiohook *audiohook, enum ast_audiohook_status status) |
Update audiohook's status. More... | |
int | ast_audiohook_volume_adjust (struct ast_channel *chan, enum ast_audiohook_direction direction, int volume) |
Adjust the volume on frames read from or written to a channel. More... | |
int | ast_audiohook_volume_get (struct ast_channel *chan, enum ast_audiohook_direction direction) |
Retrieve the volume adjustment value on frames read from or written to a channel. More... | |
int | ast_audiohook_volume_set (struct ast_channel *chan, enum ast_audiohook_direction direction, int volume) |
Adjust the volume on frames read from or written to a channel. More... | |
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. More... | |
struct ast_frame * | ast_audiohook_write_list (struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame) |
Pass a frame off to be handled by the audiohook core. More... | |
int | ast_audiohook_write_list_empty (struct ast_audiohook_list *audiohook_list) |
Determine if a audiohook_list is empty or not. More... | |
int | ast_channel_audiohook_count_by_source (struct ast_channel *chan, const char *source, enum ast_audiohook_type type) |
Find out how many audiohooks from a certain source exist on a given channel, regardless of status. More... | |
int | ast_channel_audiohook_count_by_source_running (struct ast_channel *chan, const char *source, enum ast_audiohook_type type) |
Find out how many spies of a certain type exist on a given channel, and are in state running. More... | |
Audiohooks Architecture.
Definition in file audiohook.h.
#define ast_audiohook_lock | ( | ah | ) | ast_mutex_lock(&(ah)->lock) |
Lock an audiohook.
ah | Audiohook structure |
Definition at line 313 of file audiohook.h.
Referenced by ast_audiohook_update_status(), audio_audiohook_write_list(), dtmf_audiohook_write_list(), snoop_hangup(), snoop_read(), and snoop_write().
#define ast_audiohook_unlock | ( | ah | ) | ast_mutex_unlock(&(ah)->lock) |
Unlock an audiohook.
ah | Audiohook structure |
Definition at line 318 of file audiohook.h.
Referenced by ast_audiohook_update_status(), audio_audiohook_write_list(), dtmf_audiohook_write_list(), snoop_hangup(), snoop_read(), and snoop_write().
typedef int(* ast_audiohook_manipulate_callback) (struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction) |
Callback function for manipulate audiohook type.
audiohook | |
chan | |
frame | Frame of audio to manipulate |
direction | Direction frame came from |
0 | on success |
-1 | on failure |
Definition at line 97 of file audiohook.h.
Enumerator | |
---|---|
AST_AUDIOHOOK_DIRECTION_READ |
Reading audio in |
AST_AUDIOHOOK_DIRECTION_WRITE |
Writing audio out |
AST_AUDIOHOOK_DIRECTION_BOTH |
Both reading audio in and writing audio out |
Definition at line 48 of file audiohook.h.
enum ast_audiohook_flags |
Definition at line 54 of file audiohook.h.
Definition at line 71 of file audiohook.h.
enum ast_audiohook_status |
Definition at line 41 of file audiohook.h.
enum ast_audiohook_type |
Definition at line 35 of file audiohook.h.
int ast_audiohook_attach | ( | struct ast_channel * | chan, |
struct ast_audiohook * | audiohook | ||
) |
Attach audiohook to channel.
chan | |
audiohook |
-1 | on failure |
Definition at line 484 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_RUNNING, AST_AUDIOHOOK_TYPE_MANIPULATE, AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_audiohook_update_status(), ast_calloc, ast_channel_is_bridged(), ast_channel_set_unbridged_nolock(), AST_FLAG_ZOMBIE, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_TAIL, ast_audiohook_list::list_internal_samp_rate, and ast_audiohook::type.
Referenced by audiohook_volume_get(), and snoop_setup_audiohook().
int ast_audiohook_destroy | ( | struct ast_audiohook * | audiohook | ) |
Destroys an audiohook structure.
audiohook |
0 | on success |
-1 | on failure |
Definition at line 124 of file audiohook.c.
References AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_slinfactory_destroy(), ast_translator_free_path(), ast_audiohook::format, ast_audiohook::lock, ast_audiohook::read_factory, ast_audiohook::trans_pvt, ast_audiohook::trigger, ast_audiohook::type, and ast_audiohook::write_factory.
Referenced by audiohook_volume_destroy(), and snoop_destroy().
int ast_audiohook_detach | ( | struct ast_audiohook * | audiohook | ) |
Detach audiohook from channel.
audiohook |
Definition at line 550 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_DONE, AST_AUDIOHOOK_STATUS_NEW, AST_AUDIOHOOK_STATUS_SHUTDOWN, ast_audiohook_trigger_wait(), ast_audiohook_update_status(), and ast_audiohook::status.
Referenced by snoop_hangup().
void ast_audiohook_detach_list | ( | struct ast_audiohook_list * | audiohook_list | ) |
Detach audiohooks from list and destroy said list.
audiohook_list | List of audiohooks (NULL tolerant) |
Definition at line 565 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_DONE, ast_audiohook_update_status(), AST_LIST_REMOVE_HEAD, ast_translator_free_path(), ast_audiohook::list, and ast_audiohook::manipulate_callback.
Referenced by __ast_read(), and ast_write_stream().
int ast_audiohook_detach_source | ( | struct ast_channel * | chan, |
const char * | source | ||
) |
Detach specified source audiohook from channel.
chan | Channel to detach from |
source | Name of source to detach |
0 | on success |
-1 | on failure |
Definition at line 698 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_DONE, AST_AUDIOHOOK_STATUS_SHUTDOWN, ast_audiohook_update_status(), find_audiohook_by_source(), and ast_audiohook::status.
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.
audiohook | |
type | Type of audiohook to initialize this as |
source | Who is initializing this audiohook |
flags |
0 | on success |
-1 | on failure |
Definition at line 100 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_STATUS_NEW, ast_audiohook_update_status(), ast_audiohook::direction, ast_audiohook::init_flags, ast_audiohook::lock, ast_audiohook::source, ast_audiohook::trigger, and ast_audiohook::type.
Referenced by audiohook_volume_get(), and snoop_setup_audiohook().
void ast_audiohook_move_all | ( | struct ast_channel * | old_chan, |
struct ast_channel * | new_chan | ||
) |
Move all audiohooks from one channel to another.
old_chan | The source of the audiohooks being moved |
new_chan | The destination channel for the audiohooks to be moved to |
Definition at line 672 of file audiohook.c.
References AST_LIST_TRAVERSE_SAFE_BEGIN, and AST_LIST_TRAVERSE_SAFE_END.
Referenced by channel_do_masquerade().
void ast_audiohook_move_by_source | ( | struct ast_channel * | old_chan, |
struct ast_channel * | new_chan, | ||
const char * | source | ||
) |
Move an audiohook from one channel to a new one.
old_chan | The source of the audiohook to move |
new_chan | The destination to which we want the audiohook to move |
source | The source of the audiohook we want to move |
Definition at line 656 of file audiohook.c.
References find_audiohook_by_source().
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.
audiohook | |
samples | Number of samples wanted |
direction | Direction the audio frame came from |
format | Format of frame remote side wants back |
NULL | on failure |
Definition at line 446 of file audiohook.c.
Referenced by snoop_read().
struct ast_frame* ast_audiohook_read_frame_all | ( | struct ast_audiohook * | audiohook, |
size_t | samples, | ||
struct ast_format * | format, | ||
struct ast_frame ** | read_frame, | ||
struct ast_frame ** | write_frame | ||
) |
Reads a frame in from the audiohook structure in mixed audio mode and copies read and write frame data to provided arguments.
audiohook | |
samples | Number of samples wanted |
format | Format of frame remote side wants back |
read_frame | if available, we'll copy the read buffer to this. |
write_frame | if available, we'll copy the write buffer to this. |
NULL | on failure |
Definition at line 451 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_BOTH.
int ast_audiohook_remove | ( | struct ast_channel * | chan, |
struct ast_audiohook * | audiohook | ||
) |
Remove an audiohook from a specified channel.
chan | Channel to remove from |
audiohook | Audiohook to remove |
0 | on success |
-1 | on failure |
Definition at line 721 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_DONE, AST_AUDIOHOOK_TYPE_MANIPULATE, AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_audiohook_update_status(), ast_channel_is_bridged(), ast_channel_set_unbridged_nolock(), AST_LIST_REMOVE, ast_audiohook::list, and ast_audiohook::type.
int ast_audiohook_set_frame_feed_direction | ( | struct ast_audiohook * | audiohook, |
enum ast_audiohook_direction | direction | ||
) |
Sets direction on audiohook.
audiohook | |
direction | In which direction should the audiohook feed frames, ie if we are snooping 'in', set direction to READ so that only the 'in' frames are fed to the slin factory |
0 | on success |
-1 | on failure due to audiohook already in use or in shutdown. Can only set direction on NEW audiohooks |
Definition at line 150 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_NEW, ast_debug, ast_audiohook::direction, and ast_audiohook::status.
Referenced by snoop_setup_audiohook().
int ast_audiohook_set_mute | ( | struct ast_channel * | chan, |
const char * | source, | ||
enum ast_audiohook_flags | flag, | ||
int | clear | ||
) |
Mute frames read from or written to a channel.
chan | Channel to muck with |
source | Type of audiohook |
flag | which direction to set / clear |
clear | set or clear muted frames on direction based on flag parameter |
0 | success |
-1 | failure |
Definition at line 1353 of file audiohook.c.
References find_audiohook_by_source().
int ast_audiohook_set_mute_all | ( | struct ast_channel * | chan, |
const char * | source, | ||
enum ast_audiohook_flags | flag, | ||
int | clear | ||
) |
Mute frames read from or written for all audiohooks on a channel.
chan | Channel to muck with |
source | Type of audiohooks |
flag | which direction to set / clear |
clear | set or clear muted frames on direction based on flag parameter |
>=0 | number of muted audiohooks |
-1 | failure |
Definition at line 1380 of file audiohook.c.
References AST_LIST_TRAVERSE, ast_test_suite_event_notify, ast_audiohook::list, and ast_audiohook::source.
Referenced by manager_mute_mixmonitor().
void ast_audiohook_trigger_wait | ( | struct ast_audiohook * | audiohook | ) |
Wait for audiohook trigger to be triggered.
audiohook | Audiohook to wait on |
Definition at line 1094 of file audiohook.c.
References ast_samp2tv(), ast_tvadd(), ast_tvnow(), ast_audiohook::lock, and ast_audiohook::trigger.
Referenced by ast_audiohook_detach().
void ast_audiohook_update_status | ( | struct ast_audiohook * | audiohook, |
enum ast_audiohook_status | status | ||
) |
Update audiohook's status.
audiohook | |
status |
Definition at line 540 of file audiohook.c.
References ast_audiohook_lock, AST_AUDIOHOOK_STATUS_DONE, ast_audiohook_unlock, ast_audiohook::status, and ast_audiohook::trigger.
Referenced by ast_audiohook_attach(), ast_audiohook_detach(), ast_audiohook_detach_list(), ast_audiohook_detach_source(), ast_audiohook_init(), ast_audiohook_remove(), audio_audiohook_write_list(), and dtmf_audiohook_write_list().
int ast_audiohook_volume_adjust | ( | struct ast_channel * | chan, |
enum ast_audiohook_direction | direction, | ||
int | volume | ||
) |
Adjust the volume on frames read from or written to a channel.
chan | Channel to muck with |
direction | Direction to increase |
volume | Value to adjust the adjustment by |
0 | on success |
-1 | on failure |
Definition at line 1333 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, audiohook_volume_get(), audiohook_volume::read_adjustment, and audiohook_volume::write_adjustment.
int ast_audiohook_volume_get | ( | struct ast_channel * | chan, |
enum ast_audiohook_direction | direction | ||
) |
Retrieve the volume adjustment value on frames read from or written to a channel.
chan | Channel to retrieve volume adjustment from |
direction | Direction to retrieve |
Definition at line 1313 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, audiohook_volume_get(), audiohook_volume::read_adjustment, and audiohook_volume::write_adjustment.
Referenced by confbridge_exec().
int ast_audiohook_volume_set | ( | struct ast_channel * | chan, |
enum ast_audiohook_direction | direction, | ||
int | volume | ||
) |
Adjust the volume on frames read from or written to a channel.
chan | Channel to muck with |
direction | Direction to set on |
volume | Value to adjust the volume by |
0 | on success |
-1 | on failure |
Definition at line 1293 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, audiohook_volume_get(), audiohook_volume::read_adjustment, and audiohook_volume::write_adjustment.
Referenced by confbridge_exec().
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.
audiohook | |
direction | Direction the audio frame came from |
frame | Frame to write in |
0 | on success |
-1 | on failure |
Definition at line 167 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, AST_AUDIOHOOK_LONG_QUEUE_TOLERANCE, AST_AUDIOHOOK_SMALL_QUEUE, AST_AUDIOHOOK_SMALL_QUEUE_TOLERANCE, AST_AUDIOHOOK_SYNC_TOLERANCE, AST_AUDIOHOOK_TRIGGER_MODE, AST_AUDIOHOOK_TRIGGER_READ, AST_AUDIOHOOK_TRIGGER_SYNC, AST_AUDIOHOOK_TRIGGER_WRITE, ast_debug, ast_slinfactory_available(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_tvdiff_ms(), ast_tvnow(), ast_audiohook::direction, ast_audiohook::hook_internal_samp_rate, ast_audiohook::read_factory, ast_audiohook::read_time, ast_audiohook::trigger, ast_audiohook::write_factory, and ast_audiohook::write_time.
Referenced by audio_audiohook_write_list(), and snoop_write().
struct ast_frame* ast_audiohook_write_list | ( | struct ast_channel * | chan, |
struct ast_audiohook_list * | audiohook_list, | ||
enum ast_audiohook_direction | direction, | ||
struct ast_frame * | frame | ||
) |
Pass a frame off to be handled by the audiohook core.
chan | Channel that the list is coming off of |
audiohook_list | List of audiohooks |
direction | Direction frame is coming in from |
frame | The frame itself |
NULL | on failure |
Definition at line 1079 of file audiohook.c.
References AST_FRAME_VOICE, audio_audiohook_write_list(), dtmf_audiohook_write_list(), and ast_frame::frametype.
Referenced by __ast_read(), and ast_write_stream().
int ast_audiohook_write_list_empty | ( | struct ast_audiohook_list * | audiohook_list | ) |
Determine if a audiohook_list is empty or not.
audiohook_list | Audiohook to check. (NULL also means empty) |
0 | false |
1 | true |
Definition at line 1071 of file audiohook.c.
References AST_LIST_EMPTY.
Referenced by __ast_read(), ast_channel_has_audio_frame_or_monitor(), ast_channel_has_hook_requiring_audio(), and ast_write_stream().
int ast_channel_audiohook_count_by_source | ( | struct ast_channel * | chan, |
const char * | source, | ||
enum ast_audiohook_type | type | ||
) |
Find out how many audiohooks from a certain source exist on a given channel, regardless of status.
chan | The channel on which to find the spies |
source | The audiohook's source |
type | The type of audiohook |
Note: Function performs nlocking.
Definition at line 1109 of file audiohook.c.
References AST_AUDIOHOOK_TYPE_MANIPULATE, AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_debug, AST_LIST_TRAVERSE, ast_audiohook::list, and ast_audiohook::source.
int ast_channel_audiohook_count_by_source_running | ( | struct ast_channel * | chan, |
const char * | source, | ||
enum ast_audiohook_type | type | ||
) |
Find out how many spies of a certain type exist on a given channel, and are in state running.
chan | The channel on which to find the spies |
source | The source of the audiohook |
type | The type of spy to look for |
Note: Function performs no locking.
Definition at line 1149 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_RUNNING, AST_AUDIOHOOK_TYPE_MANIPULATE, AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_debug, AST_LIST_TRAVERSE, ast_audiohook::list, ast_audiohook::source, and ast_audiohook::status.