AudioSocket sending not working

Hello,

I have a Setup with Kamailio, RTPEngine, Asterisk, AudioSocket and ARI implemented by a Python Program. It is used as the base for a voice bot. I can receive Data from Audio Socket and playback .wav via POST /channels/{channelId}/play.
Unfortunately, it is not possible to stream the audio data in real time, it seems like Asterisk is discarding the audio packets and I don`t know why:

By doing a simple echo I observe:

– Executing [+1234…@from-kamailio:3] Stasis(“PJSIP/kamailio-01-00000006”, "audioari, sip:user@my.domain.com;tag=48e83e0c, , ") in new stack
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058052, ts 1022308286, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058056, ts 1022308926, len 000160)
– Channel Snoop/1739896844.48-0000000c joined ‘simple_bridge’ stasis-bridge
– Called localhost:8080/19746b10-ee17-11ef-8d3c-fa163edfb44b
– AudioSocket/localhost:8080-19746b10-ee17-11ef-8d3c-fa163edfb44b answered

Launching Stasis(audioari) on AudioSocket/localhost:8080-19746b10-ee17-11ef-8d3c-fa163edfb44b
– Channel AudioSocket/localhost:8080-19746b10-ee17-11ef-8d3c-fa163edfb44b joined ‘simple_bridge’ stasis-bridge
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058057, ts 1022309086, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058058, ts 1022309246, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058059, ts 1022309406, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058060, ts 1022309566, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058061, ts 1022309726, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058062, ts 1022309886, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058063, ts 1022310046, len 000160)
Got RTP packet from 192.168.2.140:38354 (type 08, seq 058064, ts 1022310206, len 000160)

I’m sure it is not a problem with:

  • NAT, as the playback over URL is working
  • Transcoding, as I restricted it to alaw

Unfortunately, there is no documentation and no example that could help to solve this issue.

What mechanism stops Asterisk sending the RTP packets?
Is there a config that must be adjusted, if so, which?

Any help would be appreciated.

That’s awesome!

Are they malformed ?

:drum: please take a look at this great presentation from last month at AstriCon that you might find edifying, regarding AI and Asterisk Audiosocket, by Diego Gosmar & Giuseppe Careri:

@penguinpbx thanks for the link.

Found it.
Due to all the setup changes and use of different snoop channels, the original pjsip channel was no longer connected to the bridge. With pjsip channel and AudioSocket in the bridge, rtp is now flowing in both directions.

Remarkable: I have to send the audio bytes in 8k 16bit mono and not alaw encoded. It seems like Asterisk is always doing some transcoding even if the packets are already encoded correctly.

I’m guessing that you are originating a call, and using a local channel. When you originate, Asterisk doesn’t know the codec that will eventually be used so has to set up any local channel with a higher quality codec.

The other thing that might cause this is a mixing type bridge, as all mixing has to be done on linear samples, e.g. call conferences have to be converted to linear.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.