I’am very new to astrisk so please excuse for any basic mistakes/questions.
I’am using ari-py connected to Stasis app.
-
On StasisStart a new mixing bridge is created. Calling channel is added to the bridge
-
An external media channel is created with format alaw and also added to the bridge.
-
I’am able to receive audio via rtp and record it to wave file for testing. Audio is ok.
-
When injecting audio to UNICASTRTP_LOCAL_ADDRESS:UNICASTRTP_LOCAL_PORT I see the following in rtp set debug on:
Got RTP packet from 192.168.1.27:42373 (type 08, seq 001437, ts 1277898169, len 000160)
Sent RTP packet to 192.168.1.20:12222 (type 08, seq 015266, ts 1277898168, len 000160)
Got RTP packet from 192.168.1.20:44701 (type 08, seq 000254, ts 040640, len 000160)
Sent RTP packet to [fe80::580a:82ff:fe78:9e11]:42373 (type 08, seq 017379, ts 040640, len -000013)
Got RTP packet from 192.168.1.27:42373 (type 08, seq 001438, ts 1277898329, len 000160)
Sent RTP packet to 192.168.1.20:12222 (type 08, seq 015267, ts 1277898328, len 000160)
Got RTP packet from 192.168.1.27:42373 (type 08, seq 001439, ts 1277898489, len 000160)
Sent RTP packet to 192.168.1.20:12222 (type 08, seq 015268, ts 1277898488, len 000160)
Got RTP packet from 192.168.1.20:44701 (type 08, seq 000255, ts 040800, len 000160)
Sent RTP packet to [fe80::580a:82ff:fe78:9e11]:42373 (type 08, seq 017380, ts 040800, len -000013)
Got RTP packet from 192.168.1.27:42373 (type 08, seq 001440, ts 1277898649, len 000160)
Sent RTP packet to 192.168.1.20:12222 (type 08, seq 015269, ts 1277898648, len 000160)
Got RTP packet from 192.168.1.20:44701 (type 08, seq 000256, ts 040960, len 000160)
Sent RTP packet to [fe80::580a:82ff:fe78:9e11]:42373 (type 08, seq 017381, ts 040960, len -000013)
192.168.1.20:44701 → Python script sending RTP packets (injected audio)
[fe80::580a:82ff:fe78:9e11]:42373 → Endpoint Linphone app on Andriod
192.168.1.27:42373 → Linphone
192.168.1.20:12222 → RTP server
I can see the packets are received and send to Linphone but cant hear anything. I also observed
len -000013 in sent packets, IMO should this not be 000160 ? Also not sure why is it using ipv6 when sending RTP packet
Configs:
pjsip.conf:
[transport-udp]
type=transport
protocol=udp
bind=192.168.1.20:5060 ; Use your server’s IP address
[6001] (This linphone end point)
type=endpoint
transport=transport-udp
context=internal
disallow=all
allow=alaw
auth=6001
aors=6001
[6001]
type=auth
auth_type=userpass
password=60016001
username=6001
[6001]
type=aor
max_contacts=5
contact=sip:6001@192.168.1.20:5060
extensions.conf:
exten => 6030,1,NoOp()
same => n,Stasis(channel-state)
same => n,Hangup()
Script to create RTP packet:
def create_rtp_packet(sequence_number, timestamp, payload):
# RTP header fields
version = 2 # Version (2 bits, should be 2)
padding = 0 # Padding bit (1 bit)
extension = 0 # Extension bit (1 bit)
cc = 0 # CSRC count (4 bits, usually 0)
marker = 0 # Marker bit (1 bit)
payload_type = 8 # Payload type for PCMA (G.711 A-law)
ssrc = random.randint(0, 0xFFFFFFFF)
first_byte = (version << 6) | (padding << 5) | (extension << 4) | cc
second_byte = (marker << 7) | payload_type
rtp_header = struct.pack('!BBHLL', first_byte, second_byte, sequence_number, timestamp, ssrc)
return rtp_header + payload
To create payload a chunk size of 320 bytes of PCM audio is taken and converted to alaw, this results in 160 bytes. RTP packet is created with the above script and sent every 20 ms
Please help to identify why I cant hear the injected audio.