audiohook: add directional awareness

Add enum to allow setting optional direction. If set to only one
direction, only feed matching-direction frames to the associated
slin factory.

This prevents mangling the transcoder on non-mixed frames when the
READ and WRITE frames would have otherwise required it.  Also
removes the need to mute or discard the un-wanted frames as they
are no longer added in the first place.

res_stasis_snoop is changed to use this addition to set direction
on audiohook based on spy direction.

If no direction is set, the ast_audiohook_init will init this enum
to BOTH which maintains existing functionality.

ASTERISK-30252

Change-Id: If8716bad334562a5d812be4eeb2a92e4f3be28eb
This commit is contained in:
Mike Bradeen
2022-09-29 14:55:20 -06:00
committed by Friendly Automation
parent b331caca30
commit 907d7e7d7d
3 changed files with 40 additions and 13 deletions

View File

@@ -118,6 +118,7 @@ struct ast_audiohook {
ast_audiohook_manipulate_callback manipulate_callback; /*!< Manipulation callback */
struct ast_audiohook_options options; /*!< Applicable options */
unsigned int hook_internal_samp_rate; /*!< internal read/write sample rate on the audiohook.*/
enum ast_audiohook_direction direction; /*!< Intended audiohook direction, BOTH by default on init */
AST_LIST_ENTRY(ast_audiohook) list; /*!< Linked list information */
};
@@ -140,6 +141,14 @@ int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type
*/
int ast_audiohook_destroy(struct ast_audiohook *audiohook);
/*! \brief Sets direction on audiohook
* \param audiohook
* \param 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
* \retval 0 on success
* \retval -1 on failure due to audiohook already in use or in shutdown. Can only set direction on NEW audiohooks
*/
int ast_audiohook_set_frame_feed_direction(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction);
/*! \brief Writes a frame into the audiohook structure
* \param audiohook
* \param direction Direction the audio frame came from