@ -543,6 +543,9 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
memset ( & csth , 0 , sizeof ( csth ) ) ;
ast_copy_flags ( & csth . flags , flags , AST_FLAGS_ALL ) ;
/* This is the audiohook which gives us the audio off the channel we are
spying on .
*/
ast_audiohook_init ( & csth . spy_audiohook , AST_AUDIOHOOK_TYPE_SPY , " ChanSpy " ) ;
if ( start_spying ( spyee_autochan , spyer_name , & csth . spy_audiohook ) ) {
@ -550,17 +553,30 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
return 0 ;
}
ast_audiohook_init ( & csth . whisper_audiohook , AST_AUDIOHOOK_TYPE_WHISPER , " ChanSpy " ) ;
ast_audiohook_init ( & csth . bridge_whisper_audiohook , AST_AUDIOHOOK_TYPE_WHISPER , " Chanspy " ) ;
if ( start_spying ( spyee_autochan , spyer_name , & csth . whisper_audiohook ) ) {
ast_log ( LOG_WARNING , " Unable to attach whisper audiohook to spyee %s. Whisper mode disabled! \n " , name ) ;
if ( ast_test_flag ( flags , OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES ) ) {
/* This audiohook will let us inject audio from our channel into the
channel we are currently spying on .
*/
ast_audiohook_init ( & csth . whisper_audiohook , AST_AUDIOHOOK_TYPE_WHISPER , " ChanSpy " ) ;
if ( start_spying ( spyee_autochan , spyer_name , & csth . whisper_audiohook ) ) {
ast_log ( LOG_WARNING , " Unable to attach whisper audiohook to spyee %s. Whisper mode disabled! \n " , name ) ;
}
}
if ( ( spyee_bridge_autochan = ast_autochan_setup ( ast_bridged_channel ( spyee_autochan - > chan ) ) ) ) {
ast_channel_lock ( spyee_bridge_autochan - > chan ) ;
if ( start_spying ( spyee_bridge_autochan , spyer_name , & csth . bridge_whisper_audiohook ) ) {
ast_log ( LOG_WARNING , " Unable to attach barge audiohook on spyee %s. Barge mode disabled! \n " , name ) ;
if ( ast_test_flag ( flags , OPTION_BARGE | OPTION_DTMF_SWITCH_MODES ) ) {
/* And this hook lets us inject audio into the channel that the spied on
channel is currently bridged with .
*/
ast_audiohook_init ( & csth . bridge_whisper_audiohook , AST_AUDIOHOOK_TYPE_WHISPER , " Chanspy " ) ;
if ( ( spyee_bridge_autochan = ast_autochan_setup ( ast_bridged_channel ( spyee_autochan - > chan ) ) ) ) {
ast_channel_lock ( spyee_bridge_autochan - > chan ) ;
if ( start_spying ( spyee_bridge_autochan , spyer_name , & csth . bridge_whisper_audiohook ) ) {
ast_log ( LOG_WARNING , " Unable to attach barge audiohook on spyee %s. Barge mode disabled! \n " , name ) ;
}
ast_channel_unlock ( spyee_bridge_autochan - > chan ) ;
}
ast_channel_unlock ( spyee_bridge_autochan - > chan ) ;
}
ast_channel_lock ( chan ) ;
@ -683,15 +699,19 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
ast_clear_flag ( chan , AST_FLAG_END_DTMF_ONLY ) ;
ast_channel_unlock ( chan ) ;
ast_audiohook_lock ( & csth . whisper_audiohook ) ;
ast_audiohook_detach ( & csth . whisper_audiohook ) ;
ast_audiohook_unlock ( & csth . whisper_audiohook ) ;
ast_audiohook_destroy ( & csth . whisper_audiohook ) ;
ast_audiohook_lock ( & csth . bridge_whisper_audiohook ) ;
ast_audiohook_detach ( & csth . bridge_whisper_audiohook ) ;
ast_audiohook_unlock ( & csth . bridge_whisper_audiohook ) ;
ast_audiohook_destroy ( & csth . bridge_whisper_audiohook ) ;
if ( ast_test_flag ( flags , OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES ) ) {
ast_audiohook_lock ( & csth . whisper_audiohook ) ;
ast_audiohook_detach ( & csth . whisper_audiohook ) ;
ast_audiohook_unlock ( & csth . whisper_audiohook ) ;
ast_audiohook_destroy ( & csth . whisper_audiohook ) ;
}
if ( ast_test_flag ( flags , OPTION_BARGE | OPTION_DTMF_SWITCH_MODES ) ) {
ast_audiohook_lock ( & csth . bridge_whisper_audiohook ) ;
ast_audiohook_detach ( & csth . bridge_whisper_audiohook ) ;
ast_audiohook_unlock ( & csth . bridge_whisper_audiohook ) ;
ast_audiohook_destroy ( & csth . bridge_whisper_audiohook ) ;
}
ast_audiohook_lock ( & csth . spy_audiohook ) ;
ast_audiohook_detach ( & csth . spy_audiohook ) ;