Record Media stream before answered when dial with "r" opetion

Good morning all,

I created a call file on asterisk which allows me to generate calls automatically without using a sip phone.
Now I would like to be able to send long DTMF access to the connected call but everything I try does not work.

Because the DTMF is not transmitted in the current call.

Can you help me with this problem

THis is my dialplan

[AutoCaller]
exten => _X.,1,NoOp(IN CALL : ${CALLERID(num)} => ${EXTEN})
	;same => n,Dial(SIP/VosWilfried/0033756751100)
	same => n,SendDTMF(**${EXTEN},1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**${EXTEN},1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**${EXTEN},1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**${EXTEN},1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**${EXTEN},1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,Echo()  
	same => n,Hangup()

and this is the code of my callfile

Channel: SIP/VosWilfried/0033756751100
CallerID: 999
Context: AutoCaller
Extension: 0033756751100

Thank you in advance

This won’t work. You cannot send things this way. It’s actually the other way around. You answer a call and then you send audio. There are a couple of applications like Playback of Send DTMF for that.

With your setup, you basically have no active channels.

You can use the M() option to send the DTMF to the called channel

exten=>_*.,1,Noop()
same=>n,Dial(SIP/${trunk}/${EXTEN:1},,M(dtmf))

[macro-dtmf]
exten => s,1,Wait(1)
exten => s,2,SendDTMF(1)
exten => s,3,SendDTMF(2)

Please can you share me a little example wich explain how to do it ?

Tks for you answer i will test it rigth now and update you there

The channel is always answered before the extension is run!

If what you are trying to do is to send DTMF as early media, on a single leg call, and there is some reason that encoding it in the dial string can’t be used (this would require using a local channel, to be able to call Dial on the single leg), you could try using a local channel, which answers, before dialing, to trick Originate into thinking that the call is up when it isn’t, and then send DTMF from the extension.

Note I haven’t checked whether SendDTMF supports early media.

Hello all i tried many time and many solution but not work

There is my dialplan

[AutoCaller]
exten => _X.,1,NoOp(IN CALL : ${CALLERID(num)} => ${EXTEN})
	;same => n,SIPDtmfMode(inband|info|rfc2833)
	same => n,SIPDtmfMode(inband)
	;same => n,Dial(SIP/VosWilfried/0033756751652,60,D(wwwwwwwwwwwwww*w*w0w0w3w3w7w5w6w7w5w1w6w5w3wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww))
	same => n,Dial(SIP/VosWilfried/0033756751651,30,M(dtmf))
	same => n,Echo()  
	same => n,Hangup()
	
[macro-dtmf]
exten => s,1,Wait(1)
	;same => n,SIPDtmfMode(inband|info|rfc2833)
	same => n,SIPDtmfMode(inband)
	same => n,Wait(10)
	same => n,SendDTMF(**0033756751653,1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**0033756751653,1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**0033756751653,1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**0033756751653,1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)
	same => n,SendDTMF(**0033756751653,1500)
	same => n,Wait(10)
	same => n,SendDTMF(*1,1500)
	same => n,Wait(10)

There is my Agi FIle

#!/usr/bin/php -q

<?php 
	ini_set('display_errors', 1); 
	set_time_limit(30); 
	require('phpagi/phpagi.php'); 
	error_reporting(E_ALL); 
	$agi = new AGI(); 
	$agi->answer(); 
	$agi->verbose("Envoie DTMF 3",3); 
	$agi-> exec("sendDTMF","ww**0033756751655"); 
	$agi->verbose("Fin Envoie DTMF 3",3); 
	$agi->exec("echo","Yesoo"); // $agi->hangup(); 
?>

There is my first call file

Channel: SIP/VosWilfried/0033756751650
CallerID: 999
Context: AutoCaller
Extension: 0033756751650

there is my second call file with use the Agi

Channel: SIP/VosWilfried/0033756751651
CallerID: 999
Context: AutoCaller
WaitTime: 20 
Application: AGI 
Data: test.agi
Extension: 0033756751651

There is a log when i test on first call file


Connected to Asterisk 13.28.1 currently running on vm23195 (pid = 1682)
    -- Attempting call on SIP/VosWilfried/0033756751650 for 0033756751650@AutoCaller:1 (Retry 1)
[May 17 08:14:31] WARNING[19422]: acl.c:616 ast_append_ha: Invalid IP address: all
[May 17 08:14:31] ERROR[19422]: chan_sip.c:31559 build_peer: Bad ACL entry in configuration line 0 : all
  == Using SIP RTP CoS mark 5
    -- Called VosWilfried/0033756751650
       > 0x7fde2c008d10 -- Strict RTP learning after remote address set to: 134.119.187.163:39936
    -- SIP/VosWilfried-00000000 is making progress
       > 0x7fde2c008d10 -- Strict RTP switching to RTP target address 134.119.187.163:39936 as source
    -- SIP/VosWilfried-00000000 answered
    -- Executing [0033756751650@AutoCaller:1] NoOp("SIP/VosWilfried-00000000", "IN CALL : 999 => 0033756751650") in new stack
    -- Executing [0033756751650@AutoCaller:2] SIPDtmfMode("SIP/VosWilfried-00000000", "inband") in new stack
    -- Executing [0033756751650@AutoCaller:3] Dial("SIP/VosWilfried-00000000", "SIP/VosWilfried/0033756751651,,M(dtmf)") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/VosWilfried/0033756751651
       > 0x7fde2c01c260 -- Strict RTP learning after remote address set to: 134.119.187.163:10142
    -- SIP/VosWilfried-00000001 is making progress passing it to SIP/VosWilfried-00000000
       > 0x7fde2c01c260 -- Strict RTP switching to RTP target address 134.119.187.163:10142 as source
       > 0x7fde2c008d10 -- Strict RTP learning complete - Locking on source address 134.119.187.163:39936
    -- SIP/VosWilfried-00000001 answered SIP/VosWilfried-00000000
    -- Executing [s@macro-dtmf:1] Wait("SIP/VosWilfried-00000001", "1") in new stack
    -- Executing [s@macro-dtmf:2] SIPDtmfMode("SIP/VosWilfried-00000001", "inband") in new stack
    -- Executing [s@macro-dtmf:3] Wait("SIP/VosWilfried-00000001", "10") in new stack
       > 0x7fde2c01c260 -- Strict RTP learning complete - Locking on source address 134.119.187.163:10142
    -- Executing [s@macro-dtmf:4] SendDTMF("SIP/VosWilfried-00000001", "**0033756751653,1500") in new stack
    -- Executing [s@macro-dtmf:5] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:6] SendDTMF("SIP/VosWilfried-00000001", "*1,1500") in new stack
    -- Executing [s@macro-dtmf:7] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:8] SendDTMF("SIP/VosWilfried-00000001", "**0033756751653,1500") in new stack
    -- Executing [s@macro-dtmf:9] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:10] SendDTMF("SIP/VosWilfried-00000001", "*1,1500") in new stack
    -- Executing [s@macro-dtmf:11] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:12] SendDTMF("SIP/VosWilfried-00000001", "**0033756751653,1500") in new stack
    -- Executing [s@macro-dtmf:13] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:14] SendDTMF("SIP/VosWilfried-00000001", "*1,1500") in new stack
    -- Executing [s@macro-dtmf:15] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:16] SendDTMF("SIP/VosWilfried-00000001", "**0033756751653,1500") in new stack
    -- Executing [s@macro-dtmf:17] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:18] SendDTMF("SIP/VosWilfried-00000001", "*1,1500") in new stack
    -- Executing [s@macro-dtmf:19] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:20] SendDTMF("SIP/VosWilfried-00000001", "**0033756751653,1500") in new stack
    -- Executing [s@macro-dtmf:21] Wait("SIP/VosWilfried-00000001", "10") in new stack
    -- Executing [s@macro-dtmf:22] SendDTMF("SIP/VosWilfried-00000001", "*1,1500") in new stack
    -- Executing [s@macro-dtmf:23] Wait("SIP/VosWilfried-00000001", "10") in new stack
vm23195*CLI> core restart now
vm23195*CLI>
Disconnected from Asterisk server

there is log when i use the second calllfile


vm23195*CLI>
vm23195*CLI>
    -- Attempting call on SIP/VosWilfried/0033756751651 for application AGI(test.agi) (Retry 1)
  == Using SIP RTP CoS mark 5
    -- Called VosWilfried/0033756751651
       > 0x7f8ba0009d70 -- Strict RTP learning after remote address set to: 134.119.187.163:13118
    -- SIP/VosWilfried-00000001 is making progress
       > 0x7f8ba0009d70 -- Strict RTP switching to RTP target address 134.119.187.163:13118 as source
    -- SIP/VosWilfried-00000001 answered
       > Launching AGI(test.agi) on SIP/VosWilfried-00000001
    -- Launched AGI Script /var/lib/asterisk/agi-bin/test.agi
    -- <SIP/VosWilfried-00000001>AGI Script test.agi completed, returning 0
[May 17 08:28:40] NOTICE[19962]: pbx_spool.c:460 attempt_thread: Call completed to SIP/VosWilfried/0033756751651
vm23195*CLI>

Still waiting you help please

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