mod_lua play file into conference
OK so I've successfully managed to get a lua script working to enhance the functionality of the "mad boss" intercom via conference example however I'm having trouble getting an audio file to stream into the conference at the beginning. Here is what I'm trying: Dialplan: <extension name="outbound-socket"> <condition field="destination_number" expression="^3402$"> <action application="lua" data="/usr/local/freeswitch/scripts/test.lua 3402"/> </condition> </extension> Snip of test.lua: session:execute("conference", argv[1] .. "@default") session:execute("set", "tmp=${conference " .. argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav}") I've also tried: session:execute("conference", argv[1] .. "@default") api = freeswitch.API() confplay = api:execute("conference", argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav ") In watching fs_cli it appears freeswitch never executes the entry that would set this file. What am I doing wrong here? I've got the FreeSWITCH 1.0.6 book and I can't seem to find my answer there either. Oh, playing a sound on participant entry won't work because it will play that sound for EVERY user that enters the conference. When 80 extensions are auto-joined to the conference at the same time it is useless for a while playing entry sounds for all those extensions. Thanks! Josh Patten Brazos County Network Engineer 979.361.4676
On Mon, May 9, 2011 at 12:29 PM, Josh M. Patten <jpatten@co.brazos.tx.us>wrote:
OK so I’ve successfully managed to get a lua script working to enhance the functionality of the “mad boss” intercom via conference example however I’m having trouble getting an audio file to stream into the conference at the beginning.
An audio file to stream at the beginning of what, exactly? When the first person enters the conference? Or when every participant enters? I'm just trying to understand what problem you're solving. Please describe it in plain language: when user enters he hears xyz, when next user enters he and the conference hear abc, etc. -MC
Here is what I’m trying:
Dialplan:
<extension name="outbound-socket">
<condition field="destination_number" expression="^3402$">
<action application="lua" data="/usr/local/freeswitch/scripts/test.lua 3402"/>
</condition>
</extension>
Snip of test.lua:
session:execute("conference", argv[1] .. "@default")
session:execute("set", "tmp=${conference " .. argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav}")
I’ve also tried:
session:execute("conference", argv[1] .. "@default")
api = freeswitch.API()
confplay = api:execute("conference", argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav ")
In watching fs_cli it appears freeswitch never executes the entry that would set this file.
What am I doing wrong here? I’ve got the FreeSWITCH 1.0.6 book and I can’t seem to find my answer there either.
Oh, playing a sound on participant entry won’t work because it will play that sound for EVERY user that enters the conference. When 80 extensions are auto-joined to the conference at the same time it is useless for a while playing entry sounds for all those extensions.
Thanks!
Josh Patten
Brazos County Network Engineer
979.361.4676
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I would like to stream the file as soon as the conference is started, no matter who is in there. What I'm asking isn't really time dependent though. I'm trying to find out why I can't stream an audio file into a conference with lua. Basically I'm looking to implement a paging system based on the the "Mad Boss" example located here: http://wiki.freeswitch.org/wiki/Conferencing_and_Intercom but implemented in lua using a postgres database to store what extensions to page for what "page group" (I promise to post my code, honest). In most overhead paging environments there is either a short tone or sound before the page is broadcast. I'm trying to replicate that by streaming a short wav file once the conference is established. Let me know if you need any more info. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Michael Collins [msc@freeswitch.org] Sent: Monday, May 09, 2011 5:41 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference On Mon, May 9, 2011 at 12:29 PM, Josh M. Patten <jpatten@co.brazos.tx.us<mailto:jpatten@co.brazos.tx.us>> wrote: OK so I’ve successfully managed to get a lua script working to enhance the functionality of the “mad boss” intercom via conference example however I’m having trouble getting an audio file to stream into the conference at the beginning. An audio file to stream at the beginning of what, exactly? When the first person enters the conference? Or when every participant enters? I'm just trying to understand what problem you're solving. Please describe it in plain language: when user enters he hears xyz, when next user enters he and the conference hear abc, etc. -MC Here is what I’m trying: Dialplan: <extension name="outbound-socket"> <condition field="destination_number" expression="^3402$"> <action application="lua" data="/usr/local/freeswitch/scripts/test.lua 3402"/> </condition> </extension> Snip of test.lua: session:execute("conference", argv[1] .. "@default") session:execute("set", "tmp=${conference " .. argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav}") I’ve also tried: session:execute("conference", argv[1] .. "@default") api = freeswitch.API() confplay = api:execute("conference", argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav ") In watching fs_cli it appears freeswitch never executes the entry that would set this file. What am I doing wrong here? I’ve got the FreeSWITCH 1.0.6 book and I can’t seem to find my answer there either. Oh, playing a sound on participant entry won’t work because it will play that sound for EVERY user that enters the conference. When 80 extensions are auto-joined to the conference at the same time it is useless for a while playing entry sounds for all those extensions. Thanks! Josh Patten Brazos County Network Engineer 979.361.4676 _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I was thinking about this a few days ago. Slightly different scenario: I want to stream audio into a conference every ten minutes or so. My ideas was to do it by connecting another extension to the conference. This extra extension would (theoretically) run a Lua script to stream the audio, and then sleep, and every few seconds it would look to see if it was the only extension still connected to the conference. In your case, if you're doing the "mad boss" and inviting all the participants to the conference, it should be easy to add one more extension to the list of invites. Just have the extension's script wait 10 seconds or so before streaming the audio, and then it can just hang up. Something like this: streamwelcomefile.lua <code> if ( session:ready() ) then session:answer(); session:sleep(10000) -- wait for 10 seconds for other people to join conference. session:streamFile("ivr/8000/ivr-welcome.wav"); session:streamFile("ivr/8000/ivr-thank_you_for_calling.wav"); session:hangup("NORMAL_CLEARING"); end </code> And the dialplan might look like this: <code> <extension name="StreamWelcome"> <condition field="destination_number" expression="^000111$"> <action application="lua" data="streamwelcomefile.lua" /> </condition> </extension> </code> Disclaimer: I haven't actually tested this in a conference. Good luck! :-)
Only problem is session:streamFile doesn't make it into conference. The only way I've found to do this so far is to conference_set_auto_outcall a loopback extension to a non-user extension that simply streams a file in a context: session:execute("conference_set_auto_outcall","loopback/3041/custom/") but if I want to mute the conference so only the originator is heard (a standard "overhead" style page) using: session:execute("set", "conference_auto_outcall_flags=mute") then this is never heard because this loopback "participant" is muted as well. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Tom C [mel0torme@gmail.com] Sent: Tuesday, May 10, 2011 12:08 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference I was thinking about this a few days ago. Slightly different scenario: I want to stream audio into a conference every ten minutes or so. My ideas was to do it by connecting another extension to the conference. This extra extension would (theoretically) run a Lua script to stream the audio, and then sleep, and every few seconds it would look to see if it was the only extension still connected to the conference. In your case, if you're doing the "mad boss" and inviting all the participants to the conference, it should be easy to add one more extension to the list of invites. Just have the extension's script wait 10 seconds or so before streaming the audio, and then it can just hang up. Something like this: streamwelcomefile.lua <code> if ( session:ready() ) then session:answer(); session:sleep(10000) -- wait for 10 seconds for other people to join conference. session:streamFile("ivr/8000/ivr-welcome.wav"); session:streamFile("ivr/8000/ivr-thank_you_for_calling.wav"); session:hangup("NORMAL_CLEARING"); end </code> And the dialplan might look like this: <code> <extension name="StreamWelcome"> <condition field="destination_number" expression="^000111$"> <action application="lua" data="streamwelcomefile.lua" /> </condition> </extension> </code> Disclaimer: I haven't actually tested this in a conference. Good luck! :-)
It seems the way this could be accomplished is to allow asynchronous execution capabilities in lua. However I don't think this exists. Is there a better way to "execute and forget" the conference app so the script can move on to the next bit of code? ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Josh M. Patten [jpatten@co.brazos.tx.us] Sent: Tuesday, May 10, 2011 1:21 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference Only problem is session:streamFile doesn't make it into conference. The only way I've found to do this so far is to conference_set_auto_outcall a loopback extension to a non-user extension that simply streams a file in a context: session:execute("conference_set_auto_outcall","loopback/3041/custom/") but if I want to mute the conference so only the originator is heard (a standard "overhead" style page) using: session:execute("set", "conference_auto_outcall_flags=mute") then this is never heard because this loopback "participant" is muted as well. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Tom C [mel0torme@gmail.com] Sent: Tuesday, May 10, 2011 12:08 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference I was thinking about this a few days ago. Slightly different scenario: I want to stream audio into a conference every ten minutes or so. My ideas was to do it by connecting another extension to the conference. This extra extension would (theoretically) run a Lua script to stream the audio, and then sleep, and every few seconds it would look to see if it was the only extension still connected to the conference. In your case, if you're doing the "mad boss" and inviting all the participants to the conference, it should be easy to add one more extension to the list of invites. Just have the extension's script wait 10 seconds or so before streaming the audio, and then it can just hang up. Something like this: streamwelcomefile.lua <code> if ( session:ready() ) then session:answer(); session:sleep(10000) -- wait for 10 seconds for other people to join conference. session:streamFile("ivr/8000/ivr-welcome.wav"); session:streamFile("ivr/8000/ivr-thank_you_for_calling.wav"); session:hangup("NORMAL_CLEARING"); end </code> And the dialplan might look like this: <code> <extension name="StreamWelcome"> <condition field="destination_number" expression="^000111$"> <action application="lua" data="streamwelcomefile.lua" /> </condition> </extension> </code> Disclaimer: I haven't actually tested this in a conference. Good luck! :-)
For now I'll have to use a combination of lua and PHP to accomplish this as fs_ivrd is async capable. I'll post the code somewhere when I'm done. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Josh M. Patten [jpatten@co.brazos.tx.us] Sent: Tuesday, May 10, 2011 1:34 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference It seems the way this could be accomplished is to allow asynchronous execution capabilities in lua. However I don't think this exists. Is there a better way to "execute and forget" the conference app so the script can move on to the next bit of code? ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Josh M. Patten [jpatten@co.brazos.tx.us] Sent: Tuesday, May 10, 2011 1:21 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference Only problem is session:streamFile doesn't make it into conference. The only way I've found to do this so far is to conference_set_auto_outcall a loopback extension to a non-user extension that simply streams a file in a context: session:execute("conference_set_auto_outcall","loopback/3041/custom/") but if I want to mute the conference so only the originator is heard (a standard "overhead" style page) using: session:execute("set", "conference_auto_outcall_flags=mute") then this is never heard because this loopback "participant" is muted as well. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Tom C [mel0torme@gmail.com] Sent: Tuesday, May 10, 2011 12:08 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference I was thinking about this a few days ago. Slightly different scenario: I want to stream audio into a conference every ten minutes or so. My ideas was to do it by connecting another extension to the conference. This extra extension would (theoretically) run a Lua script to stream the audio, and then sleep, and every few seconds it would look to see if it was the only extension still connected to the conference. In your case, if you're doing the "mad boss" and inviting all the participants to the conference, it should be easy to add one more extension to the list of invites. Just have the extension's script wait 10 seconds or so before streaming the audio, and then it can just hang up. Something like this: streamwelcomefile.lua <code> if ( session:ready() ) then session:answer(); session:sleep(10000) -- wait for 10 seconds for other people to join conference. session:streamFile("ivr/8000/ivr-welcome.wav"); session:streamFile("ivr/8000/ivr-thank_you_for_calling.wav"); session:hangup("NORMAL_CLEARING"); end </code> And the dialplan might look like this: <code> <extension name="StreamWelcome"> <condition field="destination_number" expression="^000111$"> <action application="lua" data="streamwelcomefile.lua" /> </condition> </extension> </code> Disclaimer: I haven't actually tested this in a conference. Good luck! :-)
http://wiki.sipfoundry.org/display/sipXecs/Potential+paging+system+replaceme... I'm not exactly a coder...but this works pretty well. It allows users that are in a page group to set a temporary "time out" so they don't get paged for a little while if they're in a meeting or otherwise don't wish to be disturbed. Josh Patten Brazos County Network Engineer 979.361.4676 From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh M. Patten Sent: Tuesday, May 10, 2011 10:09 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference For now I'll have to use a combination of lua and PHP to accomplish this as fs_ivrd is async capable. I'll post the code somewhere when I'm done. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Josh M. Patten [jpatten@co.brazos.tx.us] Sent: Tuesday, May 10, 2011 1:34 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference It seems the way this could be accomplished is to allow asynchronous execution capabilities in lua. However I don't think this exists. Is there a better way to "execute and forget" the conference app so the script can move on to the next bit of code? ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Josh M. Patten [jpatten@co.brazos.tx.us] Sent: Tuesday, May 10, 2011 1:21 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference Only problem is session:streamFile doesn't make it into conference. The only way I've found to do this so far is to conference_set_auto_outcall a loopback extension to a non-user extension that simply streams a file in a context: session:execute("conference_set_auto_outcall","loopback/3041/custom/") but if I want to mute the conference so only the originator is heard (a standard "overhead" style page) using: session:execute("set", "conference_auto_outcall_flags=mute") then this is never heard because this loopback "participant" is muted as well. ________________________________ From: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] on behalf of Tom C [mel0torme@gmail.com] Sent: Tuesday, May 10, 2011 12:08 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference I was thinking about this a few days ago. Slightly different scenario: I want to stream audio into a conference every ten minutes or so. My ideas was to do it by connecting another extension to the conference. This extra extension would (theoretically) run a Lua script to stream the audio, and then sleep, and every few seconds it would look to see if it was the only extension still connected to the conference. In your case, if you're doing the "mad boss" and inviting all the participants to the conference, it should be easy to add one more extension to the list of invites. Just have the extension's script wait 10 seconds or so before streaming the audio, and then it can just hang up. Something like this: streamwelcomefile.lua <code> if ( session:ready() ) then session:answer(); session:sleep(10000) -- wait for 10 seconds for other people to join conference. session:streamFile("ivr/8000/ivr-welcome.wav"); session:streamFile("ivr/8000/ivr-thank_you_for_calling.wav"); session:hangup("NORMAL_CLEARING"); end </code> And the dialplan might look like this: <code> <extension name="StreamWelcome"> <condition field="destination_number" expression="^000111$"> <action application="lua" data="streamwelcomefile.lua" /> </condition> </extension> </code> Disclaimer: I haven't actually tested this in a conference. Good luck! :-)
On Mon, May 9, 2011 at 11:34 PM, Josh M. Patten <jpatten@co.brazos.tx.us>wrote:
It seems the way this could be accomplished is to allow asynchronous execution capabilities in lua. However I don't think this exists.
Is there a better way to "execute and forget" the conference app so the script can move on to the next bit of code?
Try using an API instead of messing with session:xxx and all that stuff: api = freeswitch.API(); res = api:execute("conference",conf_name .. " play /path/to/file.wav"; conf_name is the name of the conference you are using. If you're not sure what name you have then just start up a conference and then type "conference list" at fs_cli and you'll see the name. You can use channel variables, etc. if the name changes depending on the destination number. -MC
If you look at my original post you'll see I tried to do that with the same results: session:execute("conference", argv[1] .. "@default") api = freeswitch.API() confplay = api:execute("conference", argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav ") What is happening in Lua is because it's not a threadable language you can't do an "execute and forget" on a particular command. So when the conference is run Lua will stop executing at that point. Josh Patten Brazos County Network Engineer 979.361.4676 From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Wednesday, May 11, 2011 12:48 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] mod_lua play file into conference On Mon, May 9, 2011 at 11:34 PM, Josh M. Patten <jpatten@co.brazos.tx.us<mailto:jpatten@co.brazos.tx.us>> wrote: It seems the way this could be accomplished is to allow asynchronous execution capabilities in lua. However I don't think this exists. Is there a better way to "execute and forget" the conference app so the script can move on to the next bit of code? Try using an API instead of messing with session:xxx and all that stuff: api = freeswitch.API(); res = api:execute("conference",conf_name .. " play /path/to/file.wav"; conf_name is the name of the conference you are using. If you're not sure what name you have then just start up a conference and then type "conference list" at fs_cli and you'll see the name. You can use channel variables, etc. if the name changes depending on the destination number. -MC
When you api:execute('conference'...) the function blocks. Then you have to stream from outside, possibly using an inbound socket application. Maybe alternatively you can call http://wiki.freeswitch.org/wiki/Mod_commands#sched_api just before put someone on the conference. On Wed, May 11, 2011 at 11:23 AM, Josh M. Patten <jpatten@co.brazos.tx.us>wrote:
If you look at my original post you’ll see I tried to do that with the same results:
session:execute("conference", argv[1] .. "@default")
api = freeswitch.API()
confplay = api:execute("conference", argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav ")
What is happening in Lua is because it’s not a threadable language you can’t do an “execute and forget” on a particular command. So when the conference is run Lua will stop executing at that point.
Josh Patten
Brazos County Network Engineer
979.361.4676
*From:* freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] *On Behalf Of *Michael Collins *Sent:* Wednesday, May 11, 2011 12:48 AM
*To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] mod_lua play file into conference
On Mon, May 9, 2011 at 11:34 PM, Josh M. Patten <jpatten@co.brazos.tx.us> wrote:
It seems the way this could be accomplished is to allow asynchronous execution capabilities in lua. However I don't think this exists.
Is there a better way to "execute and forget" the conference app so the script can move on to the next bit of code?
Try using an API instead of messing with session:xxx and all that stuff:
api = freeswitch.API();
res = api:execute("conference",conf_name .. " play /path/to/file.wav";
conf_name is the name of the conference you are using. If you're not sure what name you have then just start up a conference and then type "conference list" at fs_cli and you'll see the name. You can use channel variables, etc. if the name changes depending on the destination number.
-MC
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Wed, May 11, 2011 at 7:51 AM, Fernando Testa < testa@voicetechnology.com.br> wrote:
When you api:execute('conference'...) the function blocks. Then you have to stream from outside, possibly using an inbound socket application. Maybe alternatively you can call http://wiki.freeswitch.org/wiki/Mod_commands#sched_api just before put someone on the conference.
Try this: api = freeswitch.API() confplay = api:execute("bgapi", "conference " .. argv[1] .. " play /usr/local/freeswitch/sounds/tones/norstar.wav ") Let us know if that works... -MC
Setting conference_set_auto_outcall_flags=mute only sets the initial state to muted. The attendees can still press 0 to unmute (if the key mappings are left at their default values). So you can use send_dtmf to unmute the loopback extension, and then stream the audio. E.g., expanding my code from earlier: streamwelcomefile.lua <code> if ( session:ready() ) then session:answer(); -- Must wait a couple seconds after connecting before sending DTMF, -- or it will get lost: session:sleep(2000) -- Unmute this attendee: session:execute("send_dtmf","0@200") session:sleep(1000) session:streamFile("ivr/8000/ivr-welcome.wav"); session:streamFile("ivr/8000/ivr-thank_you_for_calling.wav"); session:hangup("NORMAL_CLEARING"); end </code>
participants (4)
-
Fernando Testa
-
Josh M. Patten
-
Michael Collins
-
Tom C