We have a setup where we create a snoop channel on a PJSIP channel using ARI (POST /channels/{channelId}/snoop with spy=in, whisper=out) to spy on a channel and inject audio into it. Both directions work in general. However, when we inject (whisper) audio into the snoop channel via ARI (POST /channels/{snoopChannelId}/play), we receive no incoming (spying) audio for the duration of the Playback.
We are quite surprised by this behavior. We would have thought that playing on a snoop channel would not affect the spying and we are not sure if this should be considered a bug (after all, we thought that this is exactly what snoop channels are here for).
We have been trying to understand the code e.g. in res_stasis_playback.c:play_on_channel()and app.c:control_streamfile()which would explain this behavior, but we haven’t fully grasped it yet.
If this should be considered a bug, let us know and we can file a bug report on GitHub.
If this is a known limitation that could be improved, we can file an improvement issue on GitHub.
If this is a known limitation that can not be easily improved (for architectural or backwards-compatibility reasons or anything else), let us know and we can look into solving our “duplex snoop” issue differently.
E.g. if this is possible, we could maybe create a second snoop channel on the PJSIP channel - one for whispering, one for spying. Maybe you would have a suggestion for what a good approach could be here.
Yes, sorry, I thought it wouldn’t be relevant for the problem description. The snoop channel is bridged with an external media channel (UnicastRTP) which sends the audio to our application. Further, the PJSIP channel itself may also be bridged with another PJSIP channel (then the whisper audio is correctly mixed by Asterisk).
Fundamentally if you call Playback then control of the channel goes to it, which just discards incoming audio from the channel.
Ok, I thought so. And that’s intentional I guess? Even for snoop channels which have the spying option set? And there’s probably no simple change in the code that would change this? If that’s even a possibility from your side.
If you need to do two things at once like this - then two Snoop channels is the mechanism.
It’s a fundamental way that Asterisk works. Multiple things can’t have control over a channel at once. When playback is invoked it gets control until it is done. Changing this would be a fundamental rearchitecture of how Asterisk works and would require touching everything that handles channels - applications, core APIs, etc.