So what I can do, is that the commercial agent will do a waiting for the caller by pressing the button pause on the Grandstream after he pick up the second call who is come when is already online with an another caller.
As I use the line bellow in my dialplan :
...
same => n,Set(CHANNEL(musicclass)=waiting-audio)
...
I do not want to use queue because he send the call to the ip phone who is free when the commercial agent is online. And also I made a system via the cdr to redirect the caller who talk with a commercial agent to this last commercial agent when he calls again. Only if he is a new caller at this moment three ip phone of commercials agents ring together.
I think it’s worth a try on this application: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_StartMusicOnHold
It will play a background class music and will not stop the dialplan execution, so you’ll have to call this application right on the start of the context, Dial normally, and when the call is answered it will automatically stop the music on hold.
But it will not play the ringing sound, only the music.
== Setting global variable 'SIPDOMAIN' to 'IP_Address'
-- Executing [042770677@from-external:1] NoOp("PJSIP/belgium-voip-0000000d", "## Incoming Call from "Arnold" <028992018> ##") in new stack
-- Executing [042770677@from-external:2] Verbose("PJSIP/belgium-voip-0000000d", "Call start time: 2018-10-17 16:35:41") in new stack
Call start time: 2018-10-17 16:35:41
-- Executing [042770677@from-external:3] Set("PJSIP/belgium-voip-0000000d", "CDR(calldate)=2018-10-17 16:35:41") in new stack
-- Executing [042770677@from-external:4] Set("PJSIP/belgium-voip-0000000d", "CDR(useragent)=Arnold") in new stack
-- Executing [042770677@from-external:5] Set("PJSIP/belgium-voip-0000000d", "POSTE_EXT=028992018") in new stack
-- Executing [042770677@from-external:6] System("PJSIP/belgium-voip-0000000d", "echo "--appel_sortant --- callerid : 028992018 ---- 2018/10/17 16:35:41 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
-- Executing [042770677@from-external:7] Set("PJSIP/belgium-voip-0000000d", "REC_FILE_NAME=IN__042770677_028992018.wav") in new stack
-- Executing [042770677@from-external:8] Set("PJSIP/belgium-voip-0000000d", "RETURNED_VALUE=bel") in new stack
-- Executing [042770677@from-external:9] MixMonitor("PJSIP/belgium-voip-0000000d", "IN__042770677_028992018.wav,b V(1)") in new stack
-- Executing [042770677@from-external:10] Set("PJSIP/belgium-voip-0000000d", "CHANNEL(Musicclass)=waiting-audio") in new stack
-- Executing [042770677@from-external:11] StartMusicOnHold("PJSIP/belgium-voip-0000000d", "waiting-audio") in new stack
-- Started music on hold, class 'waiting-audio', on channel 'PJSIP/belgium-voip-0000000d'
[Oct 17 16:35:41] WARNING[20034][C-00000007]: translate.c:407 framein: no samples for ulawtolin
-- Executing [042770677@from-external:12] Dial("PJSIP/belgium-voip-0000000d", "PJSIP/115,20") in new stack
-- Called PJSIP/115
-- Stopped music on hold on PJSIP/belgium-voip-0000000d
== Begin MixMonitor Recording PJSIP/belgium-voip-0000000d
-- PJSIP/115-0000000e is ringing
-- PJSIP/115-0000000e is ringing
Only ringing tone not music.
[Oct 17 16:35:41] WARNING[20034][C-00000007]: translate.c:407 framein: no samples for ulawtolin
I think this line above have something about with what happen. However I have ulaw file of my waiting-audio.wav file:
[root@localhost waiting-audio]# ls -la /var/lib/asterisk/waiting-audio/
total 2760
drwxr-xr-x 2 asterisk asterisk 104 12 oct 13:19 .
drwxr-xr-x 15 asterisk asterisk 223 17 oct 16:41 ..
-rw-r--r-- 1 root root 877157 17 oct 12:22 waiting-audio.alaw
-rw-r--r-- 1 root root 180939 17 oct 12:22 waiting-audio.gsm
-rw-r--r-- 1 root root 877157 17 oct 12:21 waiting-audio.ulaw
-rw-rw-r-- 1 asterisk asterisk 877292 9 oct 10:45 waiting-audio.wav
[root@localhost waiting-audio]#
Try deleting these .alaw, .gsm and .ulaw from the folder and leaving only the .wav and restarting your asterisk.
Also: Do you verify if this audio is not a ring tone? hehehehe
;==========================================================================
; Music On Hold Test
exten => 196,1,NoOp(## Music On Hold Test ##)
same => n,Set(CHANNEL(Musicclass)=waiting-audio)
same => n,Dial(PJSIP/115,20,m(waiting-audio))
same => n,Hangup()
CLI Asterisk:
== Setting global variable 'SIPDOMAIN' to 'IP_Address'
-- Executing [196@from-internal:1] NoOp("PJSIP/100-000000e7", "## Music On Hold Test ##") in new stack
-- Executing [196@from-internal:2] Set("PJSIP/100-000000e7", "CHANNEL(Musicclass)=waiting-audio") in new stack
-- Executing [196@from-internal:3] Dial("PJSIP/100-000000e7", "PJSIP/115,20,m(waiting-audio)") in new stack
-- Called PJSIP/115
-- Started music on hold, class 'waiting-audio', on channel 'PJSIP/100-000000e7'
> 0x7ff4ac00dc20 -- Strict RTP learning after remote address set to: 192.168.2.48:5142
-- PJSIP/115-000000e8 is ringing
-- PJSIP/115-000000e8 is ringing
> 0x7ff4ac00dc20 -- Strict RTP switching to RTP target address 192.168.2.48:5142 as source
> 0x7ff4ac00dc20 -- Strict RTP learning complete - Locking on source address 192.168.2.48:5142
I would ask your SIP provider if they support early media. They may not permit you to play music unless you have first answered the call and started billing.
I’d try that again with Progress() before the Hello, but it would seem to confirm that the normal case applies, and you are not allowed to send early media.
The reason that only network operators can normally send early media, is that you could otherwise do the whole call as early media and neither you nor the caller would get billed. Even if early media was only towards the caller, you can operate useful automated announcement services with just early media.
In fact freephone services are typically implemented as early media.
== Setting global variable 'SIPDOMAIN' to 'Ip_Address'
-- Executing [042770677@from-external:1] NoOp("PJSIP/belgium-voip-000007b9", "## Incoming Call from "Arnold" <028992018> ##") in new stack
-- Executing [042770677@from-external:2] Progress("PJSIP/belgium-voip-000007b9", "") in new stack
-- Executing [042770677@from-external:3] Verbose("PJSIP/belgium-voip-000007b9", "Call start time: 2018-10-19 17:12:20") in new stack
Call start time: 2018-10-19 17:12:20
-- Executing [042770677@from-external:4] Set("PJSIP/belgium-voip-000007b9", "CDR(calldate)=2018-10-19 17:12:20") in new stack
-- Executing [042770677@from-external:5] Set("PJSIP/belgium-voip-000007b9", "CDR(useragent)=Arnold") in new stack
-- Executing [042770677@from-external:6] Set("PJSIP/belgium-voip-000007b9", "POSTE_EXT=028992018") in new stack
-- Executing [042770677@from-external:7] System("PJSIP/belgium-voip-000007b9", "echo "--appel_sortant --- callerid : 028992018 ---- 2018/10/19 17:12:20 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
-- Executing [042770677@from-external:8] Set("PJSIP/belgium-voip-000007b9", "REC_FILE_NAME=IN__042770677_028992018.wav") in new stack
-- Executing [042770677@from-external:9] Set("PJSIP/belgium-voip-000007b9", "RETURNED_VALUE=bel") in new stack
-- Executing [042770677@from-external:10] MixMonitor("PJSIP/belgium-voip-000007b9", "IN__042770677_028992018.wav,b V(1)") in new stack
-- Executing [042770677@from-external:11] Set("PJSIP/belgium-voip-000007b9", "CHANNEL(Musicclass)=waiting-audio") in new stack
-- Executing [042770677@from-external:12] Dial("PJSIP/belgium-voip-000007b9", "PJSIP/115,130,m(waiting-audio)") in new stack
-- Called PJSIP/115
-- Started music on hold, class 'waiting-audio', on channel 'PJSIP/belgium-voip-000007b9'
[Oct 19 17:12:20] WARNING[4012][C-00000434]: translate.c:407 framein: no samples for ulawtolin
== Begin MixMonitor Recording PJSIP/belgium-voip-000007b9
-- PJSIP/115-000007ba is ringing
-- PJSIP/115-000007ba is ringing
localhost*CLI>
I have only the ringing tone not my screening file during the ringing.
I made a test with a mobile and standalone phone who is to another telecom provider (Proximus) and the early media works for only one number on the others numbers this not works, very strange. But when I use a phone ip who is connected to the pbx server this is not work too.
And my file for the early media is not read until at the end. The playtime of the file is 1mn49. And I define in my dialplan the following parameter:
exten => ${WEBMASTER_IN},1,NoOp(## Incoming Call from ${CALLERID(all)} ##)
same => n,Progress()
same => n,Verbose(Call start time: ${CDR(start)})
same => n,Set(CDR(calldate)=${CDR(start)})
same => n,Set(CDR(useragent)=${CALLERID(name)})
same => n,Set(POSTE_EXT=${CALLERID(num)})
same => n,System(echo "--appel_sortant --- callerid : ${CALLERID(num)} ---- ${STRFTIME(${EPOCH},,%Y/%m/%d %H:%M:%S)} ----" >> /var/spool/asterisk/log/debug.txt)
same => n,Set(REC_FILE_NAME=IN_${NOW}_${EXTEN}_${POSTE_EXT}.wav)
same => n,MixMonitor(${REC_FILE_NAME},b V(1))
same => n,Set(CHANNEL(Musicclass)=waiting-audio)
same => n,Dial(PJSIP/100,130,m(waiting-audio))
same => n,VoiceMail(100@default,su)
same => n,NoOp(${DIALSTATUS})
same => n,GotoIf($["${DIALSTATUS}="BUSY"]?busy:unavail)
same => n(busy),Dial(PJSIP/100,130,m(waiting-audio))
same => n,VoiceMail(100@default,su)
same => n,Hangup()
same => n(unavail),GotoIf($["${DIALSTATUS}"="NOANSWER"]?noanswer)
same => n(noanswer),VoiceMail(100@default,su)
same => n,Hangup()
Again the early media does work. And on my portal configuration of my provider I have define the “ring for” to 1 hour. But when I make an internal call to the extension 5000, I have my early media who is read but for only 54 seconds. The file waiting-audio.wav have a time of 1 mn 49 sec.
This my syntax:
exten => 5000,1,Progress()
same => n,Set(CHANNEL(Musicclass)=waiting-audio)
same => n,Dial(PJSIP/115,120,m(waiting-audio))
same => n,Playback(ivr/REPONDEUR_2_OCCUPE_PLATEAU_VENTE)
same => n,VoiceMail(115@default,s)
same => n,Hangup()