|
|
|
@ -97,14 +97,6 @@ static int audiohook_set_internal_rate(struct ast_audiohook *audiohook, int rate
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Initialize an audiohook structure
|
|
|
|
|
*
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \param type
|
|
|
|
|
* \param source, init_flags
|
|
|
|
|
*
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags init_flags)
|
|
|
|
|
{
|
|
|
|
|
/* Need to keep the type and source */
|
|
|
|
@ -126,10 +118,6 @@ int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Destroys an audiohook structure
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
|
|
|
|
|
{
|
|
|
|
|
/* Drop the factories used by this audiohook type */
|
|
|
|
@ -161,12 +149,6 @@ int ast_audiohook_destroy(struct ast_audiohook *audiohook)
|
|
|
|
|
(ast_test_flag(hook, AST_AUDIOHOOK_MUTE_WRITE) && (dir == AST_AUDIOHOOK_DIRECTION_WRITE)) || \
|
|
|
|
|
(ast_test_flag(hook, AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE) == (AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE)))
|
|
|
|
|
|
|
|
|
|
/*! \brief Writes a frame into the audiohook structure
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \param direction Direction the audio frame came from
|
|
|
|
|
* \param frame Frame to write in
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction, struct ast_frame *frame)
|
|
|
|
|
{
|
|
|
|
|
struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
|
|
|
|
@ -439,27 +421,11 @@ static struct ast_frame *audiohook_read_frame_helper(struct ast_audiohook *audio
|
|
|
|
|
return final_frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Reads a frame in from the audiohook structure
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \param samples Number of samples wanted in requested output format
|
|
|
|
|
* \param direction Direction the audio frame came from
|
|
|
|
|
* \param format Format of frame remote side wants back
|
|
|
|
|
* \return Returns frame on success, NULL on failure
|
|
|
|
|
*/
|
|
|
|
|
struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, struct ast_format *format)
|
|
|
|
|
{
|
|
|
|
|
return audiohook_read_frame_helper(audiohook, samples, direction, format, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Reads a frame in from the audiohook structure
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \param samples Number of samples wanted
|
|
|
|
|
* \param direction Direction the audio frame came from
|
|
|
|
|
* \param format Format of frame remote side wants back
|
|
|
|
|
* \param read_frame frame pointer for copying read frame data
|
|
|
|
|
* \param write_frame frame pointer for copying write frame data
|
|
|
|
|
* \return Returns frame on success, NULL on failure
|
|
|
|
|
*/
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
return audiohook_read_frame_helper(audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, format, read_frame, write_frame);
|
|
|
|
@ -493,11 +459,6 @@ static void audiohook_list_set_samplerate_compatibility(struct ast_audiohook_lis
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Attach audiohook to channel
|
|
|
|
|
* \param chan Channel
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
|
|
|
|
|
{
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
@ -554,14 +515,6 @@ int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audioho
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Update audiohook's status
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \param status Audiohook status enum
|
|
|
|
|
*
|
|
|
|
|
* \note once status is updated to DONE, this function can not be used to set the
|
|
|
|
|
* status back to any other setting. Setting DONE effectively locks the status as such.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audiohook_status status)
|
|
|
|
|
{
|
|
|
|
|
ast_audiohook_lock(audiohook);
|
|
|
|
@ -572,10 +525,6 @@ void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audio
|
|
|
|
|
ast_audiohook_unlock(audiohook);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Detach audiohook from channel
|
|
|
|
|
* \param audiohook Audiohook structure
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_detach(struct ast_audiohook *audiohook)
|
|
|
|
|
{
|
|
|
|
|
if (audiohook->status == AST_AUDIOHOOK_STATUS_NEW || audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
|
|
|
|
@ -635,7 +584,8 @@ void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
|
|
|
|
|
/*! \brief find an audiohook based on its source
|
|
|
|
|
* \param audiohook_list The list of audiohooks to search in
|
|
|
|
|
* \param source The source of the audiohook we wish to find
|
|
|
|
|
* \return Return the corresponding audiohook or NULL if it cannot be found.
|
|
|
|
|
* \return corresponding audiohook
|
|
|
|
|
* \retval NULL if it cannot be found
|
|
|
|
|
*/
|
|
|
|
|
static struct ast_audiohook *find_audiohook_by_source(struct ast_audiohook_list *audiohook_list, const char *source)
|
|
|
|
|
{
|
|
|
|
@ -723,11 +673,6 @@ void ast_audiohook_move_all(struct ast_channel *old_chan, struct ast_channel *ne
|
|
|
|
|
AST_LIST_TRAVERSE_SAFE_END;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Detach specified source audiohook from channel
|
|
|
|
|
* \param chan Channel to detach from
|
|
|
|
|
* \param source Name of source to detach
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_detach_source(struct ast_channel *chan, const char *source)
|
|
|
|
|
{
|
|
|
|
|
struct ast_audiohook *audiohook = NULL;
|
|
|
|
@ -751,16 +696,6 @@ int ast_audiohook_detach_source(struct ast_channel *chan, const char *source)
|
|
|
|
|
return (audiohook ? 0 : -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Remove an audiohook from a specified channel
|
|
|
|
|
*
|
|
|
|
|
* \param chan Channel to remove from
|
|
|
|
|
* \param audiohook Audiohook to remove
|
|
|
|
|
*
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*
|
|
|
|
|
* \note The channel does not need to be locked before calling this function
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
|
|
|
|
|
{
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
@ -795,7 +730,8 @@ int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audioho
|
|
|
|
|
* \param audiohook_list List of audiohooks
|
|
|
|
|
* \param direction Direction frame is coming in from
|
|
|
|
|
* \param frame The frame itself
|
|
|
|
|
* \return Return frame on success, NULL on failure
|
|
|
|
|
* \return frame on success
|
|
|
|
|
* \retval NULL on failure
|
|
|
|
|
*/
|
|
|
|
|
static struct ast_frame *dtmf_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame)
|
|
|
|
|
{
|
|
|
|
@ -950,7 +886,8 @@ static void audiohook_list_set_hook_rate(struct ast_audiohook_list *audiohook_li
|
|
|
|
|
* \param audiohook_list List of audiohooks
|
|
|
|
|
* \param direction Direction frame is coming in from
|
|
|
|
|
* \param frame The frame itself
|
|
|
|
|
* \return Return frame on success, NULL on failure
|
|
|
|
|
* \return frame on success
|
|
|
|
|
* \retval NULL on failure
|
|
|
|
|
*/
|
|
|
|
|
static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame)
|
|
|
|
|
{
|
|
|
|
@ -1117,13 +1054,6 @@ int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
|
|
|
|
|
&& AST_LIST_EMPTY(&audiohook_list->manipulate_list));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Pass a frame off to be handled by the audiohook core
|
|
|
|
|
* \param chan Channel that the list is coming off of
|
|
|
|
|
* \param audiohook_list List of audiohooks
|
|
|
|
|
* \param direction Direction frame is coming in from
|
|
|
|
|
* \param frame The frame itself
|
|
|
|
|
* \return Return frame on success, NULL on failure
|
|
|
|
|
*/
|
|
|
|
|
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 off frame to it's respective list write function */
|
|
|
|
@ -1236,7 +1166,6 @@ struct audiohook_volume {
|
|
|
|
|
|
|
|
|
|
/*! \brief Callback used to destroy the audiohook volume datastore
|
|
|
|
|
* \param data Volume information structure
|
|
|
|
|
* \return Returns nothing
|
|
|
|
|
*/
|
|
|
|
|
static void audiohook_volume_destroy(void *data)
|
|
|
|
|
{
|
|
|
|
@ -1262,7 +1191,8 @@ static const struct ast_datastore_info audiohook_volume_datastore = {
|
|
|
|
|
* \param chan Channel we are attached to
|
|
|
|
|
* \param frame Frame of audio we want to manipulate
|
|
|
|
|
* \param direction Direction the audio came in from
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
* \retval 0 on success
|
|
|
|
|
* \retval -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
static int audiohook_volume_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
|
|
|
|
|
{
|
|
|
|
@ -1300,7 +1230,8 @@ static int audiohook_volume_callback(struct ast_audiohook *audiohook, struct ast
|
|
|
|
|
/*! \brief Helper function which finds and optionally creates an audiohook_volume_datastore datastore on a channel
|
|
|
|
|
* \param chan Channel to look on
|
|
|
|
|
* \param create Whether to create the datastore if not found
|
|
|
|
|
* \return Returns audiohook_volume structure on success, NULL on failure
|
|
|
|
|
* \return audiohook_volume structure on success
|
|
|
|
|
* \retval NULL on failure
|
|
|
|
|
*/
|
|
|
|
|
static struct audiohook_volume *audiohook_volume_get(struct ast_channel *chan, int create)
|
|
|
|
|
{
|
|
|
|
@ -1337,12 +1268,6 @@ static struct audiohook_volume *audiohook_volume_get(struct ast_channel *chan, i
|
|
|
|
|
return audiohook_volume;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Adjust the volume on frames read from or written to a channel
|
|
|
|
|
* \param chan Channel to muck with
|
|
|
|
|
* \param direction Direction to set on
|
|
|
|
|
* \param volume Value to adjust the volume by
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_volume_set(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume)
|
|
|
|
|
{
|
|
|
|
|
struct audiohook_volume *audiohook_volume = NULL;
|
|
|
|
@ -1363,11 +1288,6 @@ int ast_audiohook_volume_set(struct ast_channel *chan, enum ast_audiohook_direct
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Retrieve the volume adjustment value on frames read from or written to a channel
|
|
|
|
|
* \param chan Channel to retrieve volume adjustment from
|
|
|
|
|
* \param direction Direction to retrieve
|
|
|
|
|
* \return Returns adjustment value
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_volume_get(struct ast_channel *chan, enum ast_audiohook_direction direction)
|
|
|
|
|
{
|
|
|
|
|
struct audiohook_volume *audiohook_volume = NULL;
|
|
|
|
@ -1388,12 +1308,6 @@ int ast_audiohook_volume_get(struct ast_channel *chan, enum ast_audiohook_direct
|
|
|
|
|
return adjustment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Adjust the volume on frames read from or written to a channel
|
|
|
|
|
* \param chan Channel to muck with
|
|
|
|
|
* \param direction Direction to increase
|
|
|
|
|
* \param volume Value to adjust the adjustment by
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_volume_adjust(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume)
|
|
|
|
|
{
|
|
|
|
|
struct audiohook_volume *audiohook_volume = NULL;
|
|
|
|
@ -1414,13 +1328,6 @@ int ast_audiohook_volume_adjust(struct ast_channel *chan, enum ast_audiohook_dir
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Mute frames read from or written to a channel
|
|
|
|
|
* \param chan Channel to muck with
|
|
|
|
|
* \param source Type of audiohook
|
|
|
|
|
* \param flag which flag to set / clear
|
|
|
|
|
* \param clear set or clear
|
|
|
|
|
* \return Returns 0 on success, -1 on failure
|
|
|
|
|
*/
|
|
|
|
|
int ast_audiohook_set_mute(struct ast_channel *chan, const char *source, enum ast_audiohook_flags flag, int clear)
|
|
|
|
|
{
|
|
|
|
|
struct ast_audiohook *audiohook = NULL;
|
|
|
|
|