#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/slinfactory.h"


Go to the source code of this file.
Data Structures | |
| struct | ast_audiohook |
| struct | ast_audiohook_options |
Defines | |
| #define | ast_audiohook_lock(ah) ast_mutex_lock(&(ah)->lock) |
| Lock an audiohook. | |
| #define | ast_audiohook_unlock(ah) ast_mutex_unlock(&(ah)->lock) |
| Unlock an audiohook. | |
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. | |
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) } |
| 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. | |
| int | ast_audiohook_destroy (struct ast_audiohook *audiohook) |
| Destroys an audiohook structure. | |
| int | ast_audiohook_detach (struct ast_audiohook *audiohook) |
| Detach audiohook from channel. | |
| int | ast_audiohook_detach_list (struct ast_audiohook_list *audiohook_list) |
| Detach audiohooks from list and destroy said list. | |
| int | ast_audiohook_detach_source (struct ast_channel *chan, const char *source) |
| Detach specified source audiohook from channel. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| int | ast_audiohook_remove (struct ast_channel *chan, struct ast_audiohook *audiohook) |
| Remove an audiohook from a specified channel. | |
| 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. | |
| void | ast_audiohook_trigger_wait (struct ast_audiohook *audiohook) |
| Wait for audiohook trigger to be triggered. | |
| void | ast_audiohook_update_status (struct ast_audiohook *audiohook, enum ast_audiohook_status status) |
| Update audiohook's status. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| int | ast_audiohook_write_list_empty (struct ast_audiohook_list *audiohook_list) |
| determines if a audiohook_list is empty or not. | |
| 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. | |
| 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. | |
Definition in file audiohook.h.
| #define ast_audiohook_lock | ( | ah | ) | ast_mutex_lock(&(ah)->lock) |
Lock an audiohook.
| ah | Audiohook structure |
Definition at line 278 of file audiohook.h.
Referenced by ast_audiohook_move_by_source(), ast_audiohook_update_status(), audio_audiohook_write_list(), channel_spy(), destroy_monitor_audiohook(), dtmf_audiohook_write_list(), mixmonitor_thread(), spy_generate(), and stop_mixmonitor_exec().
| #define ast_audiohook_unlock | ( | ah | ) | ast_mutex_unlock(&(ah)->lock) |
Unlock an audiohook.
| ah | Audiohook structure |
Definition at line 283 of file audiohook.h.
Referenced by ast_audiohook_move_by_source(), ast_audiohook_update_status(), audio_audiohook_write_list(), channel_spy(), destroy_monitor_audiohook(), dtmf_audiohook_write_list(), mixmonitor_thread(), spy_generate(), and stop_mixmonitor_exec().
| 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 | Audiohook structure | |
| chan | Channel | |
| frame | Frame of audio to manipulate | |
| direction | Direction frame came from |
The input frame should never be freed or corrupted during a manipulate callback. If the callback has the potential to corrupt the frame's data during manipulation, local data should be used for the manipulation and only copied to the frame on success.
A failure return value indicates that the frame was not manipulated and that is being returned in its original state.
Definition at line 93 of file audiohook.h.
| 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.
00048 { 00049 AST_AUDIOHOOK_DIRECTION_READ = 0, /*!< Reading audio in */ 00050 AST_AUDIOHOOK_DIRECTION_WRITE, /*!< Writing audio out */ 00051 AST_AUDIOHOOK_DIRECTION_BOTH, /*!< Both reading audio in and writing audio out */ 00052 };
| enum ast_audiohook_flags |
Definition at line 54 of file audiohook.h.
00054 { 00055 AST_AUDIOHOOK_TRIGGER_MODE = (3 << 0), /*!< When audiohook should be triggered to do something */ 00056 AST_AUDIOHOOK_TRIGGER_READ = (1 << 0), /*!< Audiohook wants to be triggered when reading audio in */ 00057 AST_AUDIOHOOK_TRIGGER_WRITE = (2 << 0), /*!< Audiohook wants to be triggered when writing audio out */ 00058 AST_AUDIOHOOK_WANTS_DTMF = (1 << 2), /*!< Audiohook also wants to receive DTMF frames */ 00059 AST_AUDIOHOOK_TRIGGER_SYNC = (1 << 3), /*!< Audiohook wants to be triggered when both sides have combined audio available */ 00060 /*! Audiohooks with this flag set will not allow for a large amount of samples to build up on its 00061 * slinfactories. We will flush the factories if they contain too many samples. 00062 */ 00063 AST_AUDIOHOOK_SMALL_QUEUE = (1 << 4), 00064 AST_AUDIOHOOK_MUTE_READ = (1 << 5), /*!< audiohook should be mute frames read */ 00065 AST_AUDIOHOOK_MUTE_WRITE = (1 << 6), /*!< audiohook should be mute frames written */ 00066 };
Definition at line 68 of file audiohook.h.
00068 { 00069 /*! Audiohook manipulate callback is capable of handling slinear at any sample rate. 00070 * Without enabling this flag on initialization the manipulation callback is guaranteed 00071 * 8khz audio only. */ 00072 AST_AUDIOHOOK_MANIPULATE_ALL_RATES = (1 << 0), 00073 };
| enum ast_audiohook_status |
Definition at line 41 of file audiohook.h.
00041 { 00042 AST_AUDIOHOOK_STATUS_NEW = 0, /*!< Audiohook was just created, not in use yet */ 00043 AST_AUDIOHOOK_STATUS_RUNNING, /*!< Audiohook is running on a channel */ 00044 AST_AUDIOHOOK_STATUS_SHUTDOWN, /*!< Audiohook is being shutdown */ 00045 AST_AUDIOHOOK_STATUS_DONE, /*!< Audiohook has shutdown and is not running on a channel any longer */ 00046 };
| enum ast_audiohook_type |
Definition at line 35 of file audiohook.h.
00035 { 00036 AST_AUDIOHOOK_TYPE_SPY = 0, /*!< Audiohook wants to receive audio */ 00037 AST_AUDIOHOOK_TYPE_WHISPER, /*!< Audiohook wants to provide audio to be mixed with existing audio */ 00038 AST_AUDIOHOOK_TYPE_MANIPULATE, /*!< Audiohook wants to manipulate the audio */ 00039 };
| int ast_audiohook_attach | ( | struct ast_channel * | chan, | |
| struct ast_audiohook * | audiohook | |||
| ) |
Attach audiohook to channel.
| chan | Channel | |
| audiohook | Audiohook structure |
Definition at line 433 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_lock, ast_channel_unlock, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_TAIL, audiohook_list_set_samplerate_compatibility(), audiohook_set_internal_rate(), ast_channel::audiohooks, ast_audiohook::list, ast_audiohook_list::list_internal_samp_rate, ast_audiohook_list::manipulate_list, ast_audiohook_list::spy_list, ast_audiohook::type, and ast_audiohook_list::whisper_list.
Referenced by ast_audiohook_move_by_source(), audiohook_volume_get(), enable_jack_hook(), mute_add_audiohook(), pitchshift_helper(), speex_write(), start_spying(), startmon(), and volume_write().
00434 { 00435 ast_channel_lock(chan); 00436 00437 if (!chan->audiohooks) { 00438 /* Whoops... allocate a new structure */ 00439 if (!(chan->audiohooks = ast_calloc(1, sizeof(*chan->audiohooks)))) { 00440 ast_channel_unlock(chan); 00441 return -1; 00442 } 00443 AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->spy_list); 00444 AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->whisper_list); 00445 AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->manipulate_list); 00446 /* This sample rate will adjust as necessary when writing to the list. */ 00447 chan->audiohooks->list_internal_samp_rate = 8000; 00448 } 00449 00450 /* Drop into respective list */ 00451 if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY) 00452 AST_LIST_INSERT_TAIL(&chan->audiohooks->spy_list, audiohook, list); 00453 else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER) 00454 AST_LIST_INSERT_TAIL(&chan->audiohooks->whisper_list, audiohook, list); 00455 else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE) 00456 AST_LIST_INSERT_TAIL(&chan->audiohooks->manipulate_list, audiohook, list); 00457 00458 00459 audiohook_set_internal_rate(audiohook, chan->audiohooks->list_internal_samp_rate, 1); 00460 audiohook_list_set_samplerate_compatibility(chan->audiohooks); 00461 00462 /* Change status over to running since it is now attached */ 00463 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_RUNNING); 00464 00465 ast_channel_unlock(chan); 00466 00467 return 0; 00468 }
| int ast_audiohook_destroy | ( | struct ast_audiohook * | audiohook | ) |
Destroys an audiohook structure.
| audiohook | Audiohook structure |
Definition at line 126 of file audiohook.c.
References AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_cond_destroy, ast_mutex_destroy, ast_slinfactory_destroy(), ast_translator_free_path(), 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(), channel_spy(), destroy_callback(), destroy_jack_data(), destroy_monitor_audiohook(), and launch_monitor_thread().
00127 { 00128 /* Drop the factories used by this audiohook type */ 00129 switch (audiohook->type) { 00130 case AST_AUDIOHOOK_TYPE_SPY: 00131 ast_slinfactory_destroy(&audiohook->read_factory); 00132 case AST_AUDIOHOOK_TYPE_WHISPER: 00133 ast_slinfactory_destroy(&audiohook->write_factory); 00134 break; 00135 default: 00136 break; 00137 } 00138 00139 /* Destroy translation path if present */ 00140 if (audiohook->trans_pvt) 00141 ast_translator_free_path(audiohook->trans_pvt); 00142 00143 /* Lock and trigger be gone! */ 00144 ast_cond_destroy(&audiohook->trigger); 00145 ast_mutex_destroy(&audiohook->lock); 00146 00147 return 0; 00148 }
| int ast_audiohook_detach | ( | struct ast_audiohook * | audiohook | ) |
Detach audiohook from channel.
| audiohook | Audiohook structure |
Definition at line 492 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 channel_spy(), destroy_monitor_audiohook(), disable_jack_hook(), and speex_write().
00493 { 00494 if (audiohook->status == AST_AUDIOHOOK_STATUS_NEW || audiohook->status == AST_AUDIOHOOK_STATUS_DONE) 00495 return 0; 00496 00497 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_SHUTDOWN); 00498 00499 while (audiohook->status != AST_AUDIOHOOK_STATUS_DONE) 00500 ast_audiohook_trigger_wait(audiohook); 00501 00502 return 0; 00503 }
| int ast_audiohook_detach_list | ( | struct ast_audiohook_list * | audiohook_list | ) |
Detach audiohooks from list and destroy said list.
| audiohook_list | List of audiohooks |
Definition at line 509 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_DONE, ast_audiohook_update_status(), ast_free, AST_LIST_REMOVE_HEAD, ast_translator_free_path(), ast_audiohook_list::in_translate, ast_audiohook::list, ast_audiohook::manipulate_callback, ast_audiohook_list::manipulate_list, ast_audiohook_list::out_translate, ast_audiohook_list::spy_list, ast_audiohook_translate::trans_pvt, and ast_audiohook_list::whisper_list.
Referenced by __ast_read(), ast_write(), and destroy_hooks().
00510 { 00511 int i = 0; 00512 struct ast_audiohook *audiohook = NULL; 00513 00514 /* Drop any spies */ 00515 while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->spy_list, list))) { 00516 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); 00517 } 00518 00519 /* Drop any whispering sources */ 00520 while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->whisper_list, list))) { 00521 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); 00522 } 00523 00524 /* Drop any manipulaters */ 00525 while ((audiohook = AST_LIST_REMOVE_HEAD(&audiohook_list->manipulate_list, list))) { 00526 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); 00527 audiohook->manipulate_callback(audiohook, NULL, NULL, 0); 00528 } 00529 00530 /* Drop translation paths if present */ 00531 for (i = 0; i < 2; i++) { 00532 if (audiohook_list->in_translate[i].trans_pvt) 00533 ast_translator_free_path(audiohook_list->in_translate[i].trans_pvt); 00534 if (audiohook_list->out_translate[i].trans_pvt) 00535 ast_translator_free_path(audiohook_list->out_translate[i].trans_pvt); 00536 } 00537 00538 /* Free ourselves */ 00539 ast_free(audiohook_list); 00540 00541 return 0; 00542 }
| 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 |
| chan | Channel to detach from | |
| source | Name of source to detach |
Definition at line 600 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_DONE, AST_AUDIOHOOK_STATUS_SHUTDOWN, ast_audiohook_update_status(), ast_channel_lock, ast_channel_unlock, ast_channel::audiohooks, find_audiohook_by_source(), and ast_audiohook::status.
00601 { 00602 struct ast_audiohook *audiohook = NULL; 00603 00604 ast_channel_lock(chan); 00605 00606 /* Ensure the channel has audiohooks on it */ 00607 if (!chan->audiohooks) { 00608 ast_channel_unlock(chan); 00609 return -1; 00610 } 00611 00612 audiohook = find_audiohook_by_source(chan->audiohooks, source); 00613 00614 ast_channel_unlock(chan); 00615 00616 if (audiohook && audiohook->status != AST_AUDIOHOOK_STATUS_DONE) 00617 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_SHUTDOWN); 00618 00619 return (audiohook ? 0 : -1); 00620 }
| int ast_audiohook_init | ( | struct ast_audiohook * | audiohook, | |
| enum ast_audiohook_type | type, | |||
| const char * | source, | |||
| enum ast_audiohook_init_flags | init_flags | |||
| ) |
Initialize an audiohook structure.
| audiohook | Audiohook structure | |
| type | Type of audiohook to initialize this as | |
| source | Who is initializing this audiohook | |
| init | flags |
| audiohook | Audiohook structure | |
| type | ||
| source |
Definition at line 101 of file audiohook.c.
References AST_AUDIOHOOK_STATUS_NEW, ast_audiohook_update_status(), ast_cond_init, ast_mutex_init, audiohook_set_internal_rate(), ast_audiohook::init_flags, ast_audiohook::lock, ast_audiohook::source, ast_audiohook::trigger, and ast_audiohook::type.
Referenced by audiohook_volume_get(), channel_spy(), enable_jack_hook(), initialize_mutehook(), launch_monitor_thread(), pitchshift_helper(), speex_write(), and volume_write().
00102 { 00103 /* Need to keep the type and source */ 00104 audiohook->type = type; 00105 audiohook->source = source; 00106 00107 /* Initialize lock that protects our audiohook */ 00108 ast_mutex_init(&audiohook->lock); 00109 ast_cond_init(&audiohook->trigger, NULL); 00110 00111 audiohook->init_flags = init_flags; 00112 00113 /* initialize internal rate at 8khz, this will adjust if necessary */ 00114 audiohook_set_internal_rate(audiohook, 8000, 0); 00115 00116 /* Since we are just starting out... this audiohook is new */ 00117 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_NEW); 00118 00119 return 0; 00120 }
| 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 571 of file audiohook.c.
References ast_audiohook_attach(), ast_audiohook_lock, ast_audiohook_remove(), ast_audiohook_unlock, ast_channel::audiohooks, find_audiohook_by_source(), and ast_audiohook::status.
Referenced by audiohook_inheritance_fixup().
00572 { 00573 struct ast_audiohook *audiohook; 00574 enum ast_audiohook_status oldstatus; 00575 00576 if (!old_chan->audiohooks || !(audiohook = find_audiohook_by_source(old_chan->audiohooks, source))) { 00577 return; 00578 } 00579 00580 /* By locking both channels and the audiohook, we can assure that 00581 * another thread will not have a chance to read the audiohook's status 00582 * as done, even though ast_audiohook_remove signals the trigger 00583 * condition. 00584 */ 00585 ast_audiohook_lock(audiohook); 00586 oldstatus = audiohook->status; 00587 00588 ast_audiohook_remove(old_chan, audiohook); 00589 ast_audiohook_attach(new_chan, audiohook); 00590 00591 audiohook->status = oldstatus; 00592 ast_audiohook_unlock(audiohook); 00593 }
| struct ast_frame* ast_audiohook_read_frame | ( | struct ast_audiohook * | audiohook, | |
| size_t | samples, | |||
| enum ast_audiohook_direction | direction, | |||
| struct ast_format * | format | |||
| ) | [read] |
Reads a frame in from the audiohook structure.
| audiohook | Audiohook structure | |
| samples | Number of samples wanted | |
| direction | Direction the audio frame came from | |
| format | Format of frame remote side wants back |
| audiohook | Audiohook structure | |
| samples | Number of samples wanted in requested output format | |
| direction | Direction the audio frame came from | |
| format | Format of frame remote side wants back |
Definition at line 397 of file audiohook.c.
References audiohook_read_frame_helper().
Referenced by spy_generate().
00398 { 00399 return audiohook_read_frame_helper(audiohook, samples, direction, format, NULL, NULL); 00400 }
| 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 | |||
| ) | [read] |
Reads a frame in from the audiohook structure in mixed audio mode and copies read and write frame data to provided arguments.
| audiohook | Audiohook structure | |
| samples | Number of samples wanted | |
| direction | Direction the audio frame came from | |
| format | Format of frame remote side wants back | |
| ast_frame | read_frame - if available, we'll copy the read buffer to this. | |
| ast_frame | write_frame - if available, we'll copy the write buffer to this. |
| audiohook | Audiohook structure | |
| samples | Number of samples wanted | |
| direction | Direction the audio frame came from | |
| format | Format of frame remote side wants back | |
| read_frame | frame pointer for copying read frame data | |
| write_frame | frame pointer for copying write frame data |
Definition at line 411 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_BOTH, and audiohook_read_frame_helper().
Referenced by mixmonitor_thread().
00412 { 00413 return audiohook_read_frame_helper(audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, format, read_frame, write_frame); 00414 }
| 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 |
Definition at line 632 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_lock, ast_channel_unlock, AST_LIST_REMOVE, audiohook_list_set_samplerate_compatibility(), ast_channel::audiohooks, ast_audiohook::list, ast_audiohook_list::manipulate_list, ast_audiohook_list::spy_list, ast_audiohook::type, and ast_audiohook_list::whisper_list.
Referenced by ast_audiohook_move_by_source(), and speex_write().
00633 { 00634 ast_channel_lock(chan); 00635 00636 if (!chan->audiohooks) { 00637 ast_channel_unlock(chan); 00638 return -1; 00639 } 00640 00641 if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY) 00642 AST_LIST_REMOVE(&chan->audiohooks->spy_list, audiohook, list); 00643 else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER) 00644 AST_LIST_REMOVE(&chan->audiohooks->whisper_list, audiohook, list); 00645 else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE) 00646 AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list); 00647 00648 audiohook_list_set_samplerate_compatibility(chan->audiohooks); 00649 ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); 00650 00651 ast_channel_unlock(chan); 00652 00653 return 0; 00654 }
| 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 |
| chan | Channel to muck with | |
| source | Type of audiohook | |
| flag | which flag to set / clear | |
| clear | set or clear |
Definition at line 1207 of file audiohook.c.
References ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_set_flag, ast_channel::audiohooks, and find_audiohook_by_source().
Referenced by manager_mute_mixmonitor().
01208 { 01209 struct ast_audiohook *audiohook = NULL; 01210 01211 ast_channel_lock(chan); 01212 01213 /* Ensure the channel has audiohooks on it */ 01214 if (!chan->audiohooks) { 01215 ast_channel_unlock(chan); 01216 return -1; 01217 } 01218 01219 audiohook = find_audiohook_by_source(chan->audiohooks, source); 01220 01221 if (audiohook) { 01222 if (clear) { 01223 ast_clear_flag(audiohook, flag); 01224 } else { 01225 ast_set_flag(audiohook, flag); 01226 } 01227 } 01228 01229 ast_channel_unlock(chan); 01230 01231 return (audiohook ? 0 : -1); 01232 }
| void ast_audiohook_trigger_wait | ( | struct ast_audiohook * | audiohook | ) |
Wait for audiohook trigger to be triggered.
| audiohook | Audiohook to wait on |
Definition at line 926 of file audiohook.c.
References ast_cond_timedwait, ast_samp2tv(), ast_tvadd(), ast_tvnow(), ast_audiohook::lock, and ast_audiohook::trigger.
Referenced by ast_audiohook_detach(), and mixmonitor_thread().
00927 { 00928 struct timeval wait; 00929 struct timespec ts; 00930 00931 wait = ast_tvadd(ast_tvnow(), ast_samp2tv(50000, 1000)); 00932 ts.tv_sec = wait.tv_sec; 00933 ts.tv_nsec = wait.tv_usec * 1000; 00934 00935 ast_cond_timedwait(&audiohook->trigger, &audiohook->lock, &ts); 00936 00937 return; 00938 }
| void ast_audiohook_update_status | ( | struct ast_audiohook * | audiohook, | |
| enum ast_audiohook_status | status | |||
| ) |
Update audiohook's status.
| audiohook | Audiohook structure | |
| audiohook | status enum |
| audiohook | Audiohook structure | |
| status | Audiohook status enum |
Definition at line 478 of file audiohook.c.
References ast_audiohook_lock, AST_AUDIOHOOK_STATUS_DONE, ast_audiohook_unlock, ast_cond_signal, 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(), dtmf_audiohook_write_list(), and stop_mixmonitor_exec().
00479 { 00480 ast_audiohook_lock(audiohook); 00481 if (audiohook->status != AST_AUDIOHOOK_STATUS_DONE) { 00482 audiohook->status = status; 00483 ast_cond_signal(&audiohook->trigger); 00484 } 00485 ast_audiohook_unlock(audiohook); 00486 }
| 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 |
| chan | Channel to muck with | |
| direction | Direction to increase | |
| volume | Value to adjust the adjustment by |
Definition at line 1180 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 execute_menu_entry().
01181 { 01182 struct audiohook_volume *audiohook_volume = NULL; 01183 01184 /* Attempt to find the audiohook volume information, and create an audiohook if none exists */ 01185 if (!(audiohook_volume = audiohook_volume_get(chan, 1))) { 01186 return -1; 01187 } 01188 01189 /* Based on the direction change the specific adjustment value */ 01190 if (direction == AST_AUDIOHOOK_DIRECTION_READ || direction == AST_AUDIOHOOK_DIRECTION_BOTH) { 01191 audiohook_volume->read_adjustment += volume; 01192 } 01193 if (direction == AST_AUDIOHOOK_DIRECTION_WRITE || direction == AST_AUDIOHOOK_DIRECTION_BOTH) { 01194 audiohook_volume->write_adjustment += volume; 01195 } 01196 01197 return 0; 01198 }
| 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 |
| chan | Channel to retrieve volume adjustment from | |
| direction | Direction to retrieve |
Definition at line 1154 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().
01155 { 01156 struct audiohook_volume *audiohook_volume = NULL; 01157 int adjustment = 0; 01158 01159 /* Attempt to find the audiohook volume information, but do not create it as we only want to look at the values */ 01160 if (!(audiohook_volume = audiohook_volume_get(chan, 0))) { 01161 return 0; 01162 } 01163 01164 /* Grab the adjustment value based on direction given */ 01165 if (direction == AST_AUDIOHOOK_DIRECTION_READ) { 01166 adjustment = audiohook_volume->read_adjustment; 01167 } else if (direction == AST_AUDIOHOOK_DIRECTION_WRITE) { 01168 adjustment = audiohook_volume->write_adjustment; 01169 } 01170 01171 return adjustment; 01172 }
| 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 |
| chan | Channel to muck with | |
| direction | Direction to set on | |
| volume | Value to adjust the volume by |
Definition at line 1129 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(), and execute_menu_entry().
01130 { 01131 struct audiohook_volume *audiohook_volume = NULL; 01132 01133 /* Attempt to find the audiohook volume information, but only create it if we are not setting the adjustment value to zero */ 01134 if (!(audiohook_volume = audiohook_volume_get(chan, (volume ? 1 : 0)))) { 01135 return -1; 01136 } 01137 01138 /* Now based on the direction set the proper value */ 01139 if (direction == AST_AUDIOHOOK_DIRECTION_READ || direction == AST_AUDIOHOOK_DIRECTION_BOTH) { 01140 audiohook_volume->read_adjustment = volume; 01141 } 01142 if (direction == AST_AUDIOHOOK_DIRECTION_WRITE || direction == AST_AUDIOHOOK_DIRECTION_BOTH) { 01143 audiohook_volume->write_adjustment = volume; 01144 } 01145 01146 return 0; 01147 }
| 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 | Audiohook structure | |
| direction | Direction the audio frame came from | |
| frame | Frame to write in |
Definition at line 156 of file audiohook.c.
References AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_DIRECTION_WRITE, AST_AUDIOHOOK_MUTE_READ, AST_AUDIOHOOK_MUTE_WRITE, 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_cond_signal, ast_debug, ast_frame_clear(), ast_slinfactory_available(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), ast_frame::datalen, 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 channel_spy().
00157 { 00158 struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory); 00159 struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory); 00160 struct timeval *rwtime = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *rwtime; 00161 int our_factory_samples; 00162 int our_factory_ms; 00163 int other_factory_samples; 00164 int other_factory_ms; 00165 int muteme = 0; 00166 00167 /* Update last feeding time to be current */ 00168 *rwtime = ast_tvnow(); 00169 00170 our_factory_samples = ast_slinfactory_available(factory); 00171 our_factory_ms = ast_tvdiff_ms(*rwtime, previous_time) + (our_factory_samples / (audiohook->hook_internal_samp_rate / 1000)); 00172 other_factory_samples = ast_slinfactory_available(other_factory); 00173 other_factory_ms = other_factory_samples / (audiohook->hook_internal_samp_rate / 1000); 00174 00175 if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && other_factory_samples && (our_factory_ms - other_factory_ms > AST_AUDIOHOOK_SYNC_TOLERANCE)) { 00176 ast_debug(1, "Flushing audiohook %p so it remains in sync\n", audiohook); 00177 ast_slinfactory_flush(factory); 00178 ast_slinfactory_flush(other_factory); 00179 } 00180 00181 if (ast_test_flag(audiohook, AST_AUDIOHOOK_SMALL_QUEUE) && ((our_factory_ms > AST_AUDIOHOOK_SMALL_QUEUE_TOLERANCE) || (other_factory_ms > AST_AUDIOHOOK_SMALL_QUEUE_TOLERANCE))) { 00182 ast_debug(1, "Audiohook %p has stale audio in its factories. Flushing them both\n", audiohook); 00183 ast_slinfactory_flush(factory); 00184 ast_slinfactory_flush(other_factory); 00185 } 00186 00187 /* swap frame data for zeros if mute is required */ 00188 if ((ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ) && (direction == AST_AUDIOHOOK_DIRECTION_READ)) || 00189 (ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_WRITE) && (direction == AST_AUDIOHOOK_DIRECTION_WRITE)) || 00190 (ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE) == (AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE))) { 00191 muteme = 1; 00192 } 00193 00194 if (muteme && frame->datalen > 0) { 00195 ast_frame_clear(frame); 00196 } 00197 00198 /* Write frame out to respective factory */ 00199 ast_slinfactory_feed(factory, frame); 00200 00201 /* If we need to notify the respective handler of this audiohook, do so */ 00202 if ((ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_MODE) == AST_AUDIOHOOK_TRIGGER_READ) && (direction == AST_AUDIOHOOK_DIRECTION_READ)) { 00203 ast_cond_signal(&audiohook->trigger); 00204 } else if ((ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_MODE) == AST_AUDIOHOOK_TRIGGER_WRITE) && (direction == AST_AUDIOHOOK_DIRECTION_WRITE)) { 00205 ast_cond_signal(&audiohook->trigger); 00206 } else if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC)) { 00207 ast_cond_signal(&audiohook->trigger); 00208 } 00209 00210 return 0; 00211 }
| 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 | |||
| ) | [read] |
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 |
Definition at line 912 of file audiohook.c.
References AST_FRAME_DTMF, AST_FRAME_VOICE, audio_audiohook_write_list(), dtmf_audiohook_write_list(), and ast_frame::frametype.
Referenced by __ast_read(), and ast_write().
00913 { 00914 /* Pass off frame to it's respective list write function */ 00915 if (frame->frametype == AST_FRAME_VOICE) 00916 return audio_audiohook_write_list(chan, audiohook_list, direction, frame); 00917 else if (frame->frametype == AST_FRAME_DTMF) 00918 return dtmf_audiohook_write_list(chan, audiohook_list, direction, frame); 00919 else 00920 return frame; 00921 }
| int ast_audiohook_write_list_empty | ( | struct ast_audiohook_list * | audiohook_list | ) |
determines if a audiohook_list is empty or not.
retval 0 false, 1 true
Definition at line 894 of file audiohook.c.
References AST_LIST_EMPTY, ast_audiohook_list::manipulate_list, ast_audiohook_list::spy_list, and ast_audiohook_list::whisper_list.
Referenced by __ast_read(), ast_write(), and audio_audiohook_write_list().
00895 { 00896 if (AST_LIST_EMPTY(&audiohook_list->spy_list) && 00897 AST_LIST_EMPTY(&audiohook_list->whisper_list) && 00898 AST_LIST_EMPTY(&audiohook_list->manipulate_list)) { 00899 00900 return 1; 00901 } 00902 return 0; 00903 }
| 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 |
Definition at line 941 of file audiohook.c.
References AST_AUDIOHOOK_TYPE_MANIPULATE, AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_debug, AST_LIST_TRAVERSE, ast_channel::audiohooks, ast_audiohook::list, ast_audiohook_list::manipulate_list, ast_audiohook::source, ast_audiohook_list::spy_list, and ast_audiohook_list::whisper_list.
Referenced by builtin_automixmonitor().
00942 { 00943 int count = 0; 00944 struct ast_audiohook *ah = NULL; 00945 00946 if (!chan->audiohooks) 00947 return -1; 00948 00949 switch (type) { 00950 case AST_AUDIOHOOK_TYPE_SPY: 00951 AST_LIST_TRAVERSE(&chan->audiohooks->spy_list, ah, list) { 00952 if (!strcmp(ah->source, source)) { 00953 count++; 00954 } 00955 } 00956 break; 00957 case AST_AUDIOHOOK_TYPE_WHISPER: 00958 AST_LIST_TRAVERSE(&chan->audiohooks->whisper_list, ah, list) { 00959 if (!strcmp(ah->source, source)) { 00960 count++; 00961 } 00962 } 00963 break; 00964 case AST_AUDIOHOOK_TYPE_MANIPULATE: 00965 AST_LIST_TRAVERSE(&chan->audiohooks->manipulate_list, ah, list) { 00966 if (!strcmp(ah->source, source)) { 00967 count++; 00968 } 00969 } 00970 break; 00971 default: 00972 ast_debug(1, "Invalid audiohook type supplied, (%d)\n", type); 00973 return -1; 00974 } 00975 00976 return count; 00977 }
| 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 |
Definition at line 980 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_channel::audiohooks, ast_audiohook::list, ast_audiohook_list::manipulate_list, ast_audiohook::source, ast_audiohook_list::spy_list, ast_audiohook::status, and ast_audiohook_list::whisper_list.
Referenced by builtin_automixmonitor().
00981 { 00982 int count = 0; 00983 struct ast_audiohook *ah = NULL; 00984 if (!chan->audiohooks) 00985 return -1; 00986 00987 switch (type) { 00988 case AST_AUDIOHOOK_TYPE_SPY: 00989 AST_LIST_TRAVERSE(&chan->audiohooks->spy_list, ah, list) { 00990 if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING)) 00991 count++; 00992 } 00993 break; 00994 case AST_AUDIOHOOK_TYPE_WHISPER: 00995 AST_LIST_TRAVERSE(&chan->audiohooks->whisper_list, ah, list) { 00996 if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING)) 00997 count++; 00998 } 00999 break; 01000 case AST_AUDIOHOOK_TYPE_MANIPULATE: 01001 AST_LIST_TRAVERSE(&chan->audiohooks->manipulate_list, ah, list) { 01002 if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING)) 01003 count++; 01004 } 01005 break; 01006 default: 01007 ast_debug(1, "Invalid audiohook type supplied, (%d)\n", type); 01008 return -1; 01009 } 01010 return count; 01011 }
1.5.6