Hi. I’m struggling to figure out how to build the following functionality for a server application I am putting together. I have built a couple of C++ Asterisk applications with ARI+stasis and made some changes to channel drivers, so I can dive into the code when needed.
The server has 1 ALSA channel for playback and capture of an audio stream. I want to bridge this ALSA channel to multiple SIP channels, one for each connected client. However, unlike a mixing bridge or a holding bridge or an announcement bridge, etc, I want the bridge to enable exclusive speaking privileges to one channel at a time. Connected clients’ mics are nominally muted, and a client can claim use of the available bridge by unmuting their microphone and starting to speak. Specifically, I want this sort of bridge to have the following characteristics:
- All channels can receive frames from the bridge for playback.
- Only one channel can contribute frames to the bridge at a time. All other frames are ignored.
- The bridge becomes available if an audio frame has not been received from any connected channel after a certain timeout, say 100 msec. The bridge becomes unavailable if it is available and receives an audio frame from any connected channel.
- I’d like to give some feedback to connected SIP clients when the bridge is in use so I can turn on a light on the client device indicating such, directing those users to wait their turn (I am developing this client device software as well).
I am using Asterisk 16.8.0. Does such a feature already exist via apps and configuration? If I add it myself, I’d prefer to do this using ARI+stasis+configuration if at all possible. Is that possible? Or alternatively implement the bridge app in C and control/manage it via ARI using CreateBridge, Add, and friends.
I think I could implement this entirely in ARI if ARI had an event type for beginning and end of receiving a stream of frames. I could use a normal mixing bridge with all channels muted. When a frame is received on a channel to start a stream, unmute just that channel in the bridge and keep all others muted. When the stream end event is received after a 100 msec timeout, remute the channel and wait for a new stream start event. But I don’t think such an event type exists in ARI. TALK_DETECT does exist, but, as I understand it, actually inspects frame audio data for non-silence, which I don’t care about. I just care about any frame. I might be able to configure TALK_DETECT to open up the thresholds so it activates during any received frame and deactivates only for mute. That might work out.
Thanks for any help and guidance, much appreciated!