Hi Ivan,

You can start avmd on channel and then process ESL events waiting for a AVMD_EVENT_BEEP and AVMD_EVENT_SESSION_STOP.

To get all avmd events you can subscribe to all FS events and filter them by "Call-command":

event all
filter Call-command avmd

see: https://freeswitch.org/confluence/display/FREESWITCH/mod_avmd#mod_avmd-Events

Examples can be found here: https://freeswitch.org/confluence/display/FREESWITCH/mod_avmd#mod_avmd-SubscribetoAVMDevents
and in the source: ls src/mod/applications/mod_avmd/scripts/
avmd_get_events.pl  avmd_originate_multiple_loopback.pl  avmd_originate_multiple.pl  avmd_originate.pl  avmd_test.pl 

all the best,



Piotr Gregor
Software Engineer

M: (+44) 07483 866 525    www: dataandsignal.com






On Thu, Oct 24, 2019 at 6:30 PM ivan381eu <i.vujisic@gmail.com> wrote:
What I need is to start intro sound file playback on call answer and detect
beep sound from callee side

What I tried is:

1. start avmd
2. bridge call
3. on answer start intro sound message playback using bgapi
BUT when background playback starts avmd seems to be paused and continues
after playback is completed.

gateway dialplan is:

<extension name="mytelco">
        <condition field="destination_number" expression="^987(\d+)$">
            <action application="set"
data="effective_caller_id_number=46xxxxxxxx"/>

            <action application="set"
data="record_link=${strftime(%Y-%m-%d-%H-%M-%S)}_${destination_number}_${caller_id_number}.wav"/>
            <action application="record_session"
data="/var/www/html/freeswitch/recordings/${record_link}"/>
            <action application="lua"
data="/etc/freeswitch/scripts/beep_detection-from-call-v0.1.2.lua $1
${record_link}"/>
            <action application="hangup"/>
        </condition>
    </extension>



file beep_detection-from-call-v0.1.2.lua

#!/usr/local/bin/lua

DNID = argv[1]

if session:ready() then
   session:sleep(1000)
   session:execute("avmd_start",
"inbound_channel=1,outbound_channel=0,sample_n_continuous_streak=10,sample_n_to_skip=0,debug=1,report_status=1")

    session:execute("bridge", "{execute_on_answer=lua
/etc/freeswitch/scripts/on_answer-v0.3.lua " .. uuid ..
"}sofia/gateway/mytelco/" .. DNID)

    session:execute("avmd_stop","")

end --if




file on_answer-v0.3.lua

#!/usr/bin/lua

uuid_original = argv[1]

api = freeswitch.API()

reply = api:executeString("bgapi uuid_broadcast " .. uuid_original .. "
/usr/share/asterisk/sounds/en/dennis-ivan.gsm both")

freeswitch.consoleLog("INFO","==============================================")
freeswitch.consoleLog("INFO","API reply is:" .. reply)
freeswitch.consoleLog("INFO","==============================================")



--
Sent from: http://freeswitch-users.2379917.n2.nabble.com/

_________________________________________________________________________

The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.
Build your next product on our scalable cloud platform.

Join our online community to chat in real time https://signalwire.community

Professional FreeSWITCH Services
sales@freeswitch.com
https://freeswitch.com

Official FreeSWITCH Sites
https://freeswitch.com/oss
https://freeswitch.org/confluence
https://cluecon.com

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
https://freeswitch.com