Can't able hear Playback() sound

I am trying to record sound and then playback them but I can not hear anything.
Yeah in cli its showing playing audio file but there is no sound.

root@test-VirtualBox:/etc/asterisk# asterisk -rvvvvvvvv
Asterisk 16.15.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 16.15.1 currently running on test-VirtualBox (pid = 9420)
test-VirtualBox*CLI> module load app_record.so
Loaded app_record.so
  == Registered application 'Record'
 Loaded app_record.so => (Trivial Record Application)
  == Setting global variable 'SIPDOMAIN' to '192.168.1.5'
    -- Executing [1102@Long-Distance:1] Answer("PJSIP/1101-00000000", "") in new stack
       > 0x7f8cb0035fe0 -- Strict RTP learning after remote address set to: 103.241.225.181:8356
       > 0x7f8cb0035fe0 -- Strict RTP qualifying stream type: audio
       > 0x7f8cb0035fe0 -- Strict RTP switching source address to 192.168.1.3:7078
    -- Executing [1102@Long-Distance:2] Playback("PJSIP/1101-00000000", "hello-world") in new stack
    -- <PJSIP/1101-00000000> Playing 'hello-world.slin' (language 'en')
    -- Executing [1102@Long-Distance:3] Playback("PJSIP/1101-00000000", "beep") in new stack
    -- <PJSIP/1101-00000000> Playing 'beep.slin' (language 'en')
    -- Executing [1102@Long-Distance:4] NoOp("PJSIP/1101-00000000", "Answered,Playback,beep done") in new stack
    -- Executing [1102@Long-Distance:5] Record("PJSIP/1101-00000000", "/home/test/Documents/data/record.wav,,10") in new stack
    -- <PJSIP/1101-00000000> Playing 'beep.slin' (language 'en')
       > 0x7f8cb0035fe0 -- Strict RTP learning complete - Locking on source address 192.168.1.3:7078
    -- Executing [1102@Long-Distance:6] Playback("PJSIP/1101-00000000", "/home/test/Documents/data-record") in new stack
    -- <PJSIP/1101-00000000> Playing '/home/test/Documents/data-record.slin' (language 'en')
    -- Executing [1102@Long-Distance:7] NoOp("PJSIP/1101-00000000", "Record & Playback done") in new stack
    -- Executing [1102@Long-Distance:8] Hangup("PJSIP/1101-00000000", "") in new stack
  == Spawn extension (Long-Distance, 1102, 8) exited non-zero on 'PJSIP/1101-00000000'
    -- Added contact 'sip:1102@192.168.1.2:63252;transport=UDP;rinstance=2ad9163d97593d9d' to AOR '1102' with expiration of 60 seconds
  == Contact 1102/sip:1102@192.168.1.2:63252;transport=UDP;rinstance=2ad9163d97593d9d has been deleted
  == Endpoint 1102 is now Unreachable
  == Endpoint 1102 is now Reachable
  == Contact 1102/sip:1102@192.168.1.2:63252;transport=UDP;rinstance=2ad9163d97593d9d has been deleted
  == Endpoint 1102 is now Unreachable
    -- Added contact 'sip:1102@192.168.1.2:63252;transport=UDP;rinstance=2ad9163d97593d9d' to AOR '1102' with expiration of 60 seconds
  == Endpoint 1102 is now Reachable
test-VirtualBox*CLI> 

My pjsip.conf context:

;================================ TRANSPORTS ==
; Our primary transport definition for UDP communication behind NAT.
[transport-udp-nat]
type = transport
protocol = udp
bind = 0.0.0.0

[endpoint-internal-d70](!)
type = endpoint
context = Long-Distance
allow = all
direct_media = no
trust_id_outbound = yes
device_state_busy_at = 1
dtmf_mode = rfc4733
use_avpf = yes

[auth-userpass](!)
type = auth
auth_type = userpass

[aor-single-reg](!)
type = aor
max_contacts = 1

[1101](endpoint-internal-d70)
auth = 1101
aors = 1101
callerid = Maria Berny <1101>

[1101](auth-userpass)
password = SW2fur7facrarac
username = 3605657CFB45

[1101](aor-single-reg)
mailboxes = 1101@example

[1102](endpoint-internal-d70)
auth = 1102
aors = 1102
callerid = Yash Mistry <1102>

[1102](auth-userpass)
password = yash1234
username = 1234

[1102](aor-single-reg)
mailboxes = 1102@example

[1103](endpoint-internal-d70)
auth = 1103
aors = 1103
callerid = Penelope Bronte <1103>

[1103](auth-userpass)
password = zutAnacHe8ewuWr
username = D5F646797302

[1103](aor-single-reg)
mailboxes = 103@example

What am I missing to add?

Maybe there is a codec which I am missing, slin codec but where I can’t figure out.

If possible tell me which codec is best if I have to use that recorded file in speech recognition or in simple term which one gives me better quality audio.

First thing is you don’t want to use “allow=all”, you should be selective in what is configured. A commonly supported codec is ulaw, so doing “allow=!all,ulaw” would limit negotiation to ulaw.

Secondly you’re assuming that the problem is in Asterisk so verify what is going on. Use “rtp set debug on” to confirm Asterisk is sending audio out. If it is, then the problem is not with Asterisk itself.

Thanks jcolp,

First time I tried

allow = !all,ulaw,g722

But still, nothing happened that’s why I try different options.

As you said to enable rtp debug, I did and there is lots of lines in that and I couldn’t get anything.

For your reference, I provide a minimal version of debug output below and whole debug log in text file at the end of the post.

RTP Packet Debugging Enabled
    -- Added contact 'sip:1102@192.168.1.2:57381;transport=UDP;rinstance=50413b7ae92adda7' to AOR '1102' with expiration of 60 seconds
  == Contact 1102/sip:1102@192.168.1.2:57381;transport=UDP;rinstance=50413b7ae92adda7 has been deleted
  == Endpoint 1102 is now Unreachable
  == Endpoint 1102 is now Reachable
  == Setting global variable 'SIPDOMAIN' to '192.168.1.5'
    -- Executing [1102@Long-Distance:1] Answer("PJSIP/1101-00000001", "") in new stack
       > 0x7fa6d003b0e0 -- Strict RTP learning after remote address set to: 103.241.225.181:7748
       > 0x7fa6d003b0e0 -- Strict RTP qualifying stream type: audio
       > 0x7fa6d003b0e0 -- Strict RTP switching source address to 192.168.1.3:7078
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000004, ts 400585646, len 000160)
    -- Executing [1102@Long-Distance:2] Playback("PJSIP/1101-00000001", "hello-world") in new stack
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003677, ts 000160, len 000160)
    -- <PJSIP/1101-00000001> Playing 'hello-world.slin' (language 'en')
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000005, ts 400585806, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003678, ts 000320, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000006, ts 400585966, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003679, ts 000480, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000007, ts 400586126, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003680, ts 000640, len 000160)
......
............
................
    -- Executing [1102@Long-Distance:3] Playback("PJSIP/1101-00000001", "beep") in new stack
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003748, ts 011372, len 000160)
    -- <PJSIP/1101-00000001> Playing 'beep.slin' (language 'en')
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000075, ts 400597006, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003749, ts 011532, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000076, ts 400597166, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003750, ts 011692, len 000160)
...........
.........
.............
    -- Executing [1102@Long-Distance:4] NoOp("PJSIP/1101-00000001", "Answered,Playback,beep done") in new stack
    -- Executing [1102@Long-Distance:5] Record("PJSIP/1101-00000001", "/home/test/Documents/data/record.wav,,7") in new stack
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003770, ts 014754, len 000160)
    -- <PJSIP/1101-00000001> Playing 'beep.slin' (language 'en')
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000096, ts 400600366, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003771, ts 014914, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000097, ts 400600526, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003772, ts 015074, len 000160)
...................
.......................
........................
      > 0x7fa6d003b0e0 -- Strict RTP learning complete - Locking on source address 192.168.1.3:7078
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000243, ts 400623886, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000244, ts 400624046, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000245, ts 400624206, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000246, ts 400624366, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000247, ts 400624526, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000248, ts 400624686, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000249, ts 400624846, len 000160)
.........................
...........................
.........................
    -- Executing [1102@Long-Distance:6] Playback("PJSIP/1101-00000001", "/home/test/Documents/data/record") in new stack
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003792, ts 074016, len 000160)
    -- <PJSIP/1101-00000001> Playing '/home/test/Documents/data/record.slin' (language 'en')
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000468, ts 400659886, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003793, ts 074176, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000469, ts 400660046, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 003794, ts 074336, len 000160)
...............................
..............................
............................
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000815, ts 400715406, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 004140, ts 129696, len 000160)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000816, ts 400715566, len 000160)
Sent RTP packet to      103.241.225.181:7748 (type 00, seq 004141, ts 129834, len 000138)
Got  RTP packet from    192.168.1.3:7078 (type 00, seq 000817, ts 400715726, len 000160)
    -- Executing [1102@Long-Distance:7] NoOp("PJSIP/1101-00000001", "Record & Playback done") in new stack
    -- Executing [1102@Long-Distance:8] Hangup("PJSIP/1101-00000001", "") in new stack
  == Spawn extension (Long-Distance, 1102, 8) exited non-zero on 'PJSIP/1101-00000001'
test-VirtualBox*CLI> 

Is there any codec problem?
‘rtp set debug on’ log.txt (114.9 KB)

There is no codec problem. Codec negotiation happens when the call is set up, if there was a problem in that aspect the call wouldn’t be set up. As well if there was a problem playing sound files then there would be messages as such. Your problem is likely this:

Sent RTP packet to      103.241.225.181:7748 (type 00, seq 004141, ts 129834, len 000138)

Your endpoint has told Asterisk to send its audio to that public IP address and port. Whether that would work or not I do not know.

You can tell Asterisk to ignore this and use where we are getting audio from by setting “rtp_symmetric” to “yes” on the endpoint in pjsip.conf

Solved by this,

Thanks jcolp

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