How to have a music in the same time of ringing during a call?

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)
...

It is not really pratical, I think…

Hello @lordaker,

Why not send the calls to the queue application? it would solve your problems.

Thank you,

Daniel Friedman
Trixton LTD.

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.

Hi @GuilhermeBiz

It’s the same thing too.

  == 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

It’s the same thing. I do not hear the audio file.

If you define a extension like this in your dialplan and call it from an ‘internal’ extension do you hear music?

exten => 5000,1,Answer()
same => n,Set(TIMEOUT(absolute)=60)
same => n,MusicOnHold(waiting-audio)
same => n,Hangup()

Yes, This is what I write for the internal test:

;==========================================================================
;						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

OK, So that works.

Is it only when you are being called externally that it does not work?

Yes, It’s when I have a external call.

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.

You can test this with the Playback app

If you modify your incoming dialplan to do this:

Playback(hello-world,noanswer)
Answer()
Playback(goodbye)
Hangup()

Do you only hear Goodbye or do you hear both hello-world and then goodbye?

I only hear Goodbye.

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.

I try this syntax in internal

exten => 5000,1,Progress()
 same => n,Playback(demo-abouttotry,noanswer)
 same => n,Dial(PJSIP/115,20,r)
 same => n,Hangup()

Asterisk CLI:

localhost*CLI>
  == Setting global variable 'SIPDOMAIN' to 'Ip_Address'
    -- Executing [5000@from-internal:1] Progress("PJSIP/100-00000377", "") in new stack
    -- Executing [5000@from-internal:2] Playback("PJSIP/100-00000377", "demo-abouttotry,noanswer") in new stack
       > 0x7ff4c001ce10 -- Strict RTP learning after remote address set to: 192.168.2.48:5154
    -- <PJSIP/100-00000377> Playing 'demo-abouttotry.g722' (language 'fr')
       > 0x7ff4c001ce10 -- Strict RTP switching to RTP target address 192.168.2.48:5154 as source
    -- Channel PJSIP/104-00000373 left 'simple_bridge' basic-bridge <7b25db8b-33a5-45ce-bdcb-abbde5f7413f>
  == Spawn extension (from-internal, 081746464, 26) exited non-zero on 'PJSIP/104-00000373'
  == MixMonitor close filestream (mixed)
    -- Channel PJSIP/belgium-voip-00000374 left 'simple_bridge' basic-bridge <7b25db8b-33a5-45ce-bdcb-abbde5f7413f>
  == End MixMonitor Recording PJSIP/104-00000373
[Oct 18 13:00:53] ERROR[20699]: cdr_odbc.c:176 odbc_log: Unable to retrieve database handle.  CDR failed.
       > 0x7ff4c001ce10 -- Strict RTP learning complete - Locking on source address 192.168.2.48:5154
    -- Executing [5000@from-internal:3] Dial("PJSIP/100-00000377", "PJSIP/115,20,r") in new stack
    -- Called PJSIP/115
    -- PJSIP/115-00000378 is ringing
    -- PJSIP/115-00000378 is ringing

I hear the demo-abouttotry before the ip phone ring. Not in same time.

Hello @everyone,

I go to the portal of my provider and add my audio file that I want to be play like the early media for my DID number:

See bellow:

But It’s always the same thing in my CLI:

== 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.

My provider tell me the interface that he use is 3CX. Are there someone who is use the same type of pbx and who have already try the early media ?

I would expect the ITSP to block it for commercial reasons, even if technically supported.

Hi,

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()

He read the file only until at 54 seconds.

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()

Any idea to resolve that ?