plivo / plivoframework

Open Source Telephony Application Prototyping Framework
http://www.plivo.com/open-source/
Other
418 stars 179 forks source link

Record with bothLegs=false doesn't trigger `record_post_process_exec_api` #27

Closed mattwilliamson closed 13 years ago

mattwilliamson commented 13 years ago

When using the following XML I can use the record_post_process_exec_api callback to trigger a python script and upload the recording file to Amazon. If I change to bothLegs=False the record_post_process_exec_api is not triggered.

<?xml version="1.0" encoding="utf-8"?>
<Response>
    <Say>Record your message after the beep.</Say>
    <Record action="/ivr/record/callback" beep="True" bothLegs="True"/>
    <Play>http://dl.dropbox.com/u/14573179/Audio/Bugle/Tattoo.mp3</Play>
</Response>

Here is my FS config:

<action application="set" data="record_post_process_exec_api=pyrun:my_app_freeswitch.post_process $${base_dir}/recordings/,${uuid}"/>
<action application="enable_heartbeat" data="60"/>
<action application="socket" data="127.0.0.1:8084 async full"/>

Here's what I see in the FS logs for bothLegs:

EXECUTE sofia/internal/+14259065859@flowroute.com set(record_post_process_exec_api=pyrun:my_app_freeswitch.post_process  /usr/local/freeswitch/recordings/,7c304780-5ea5-4ca6-b538-c4d610c46b84)
2011-08-04 18:03:42.278126 [DEBUG] mod_dptools.c:1063 sofia/internal/+14259065859@flowroute.com SET [record_post_process_exec_api]=[pyrun:my_app_freeswitch.post_process  /usr/local/freeswitch/recordings/,7c304780-5ea5-4ca6-b538-c4d610c46b84]
EXECUTE sofia/internal/+14259065859@flowroute.com enable_heartbeat(60)
...
EXECUTE sofia/internal/+14259065859@flowroute.com record(/usr/local/freeswitch/recordings/20110804-180345_7c304780-5ea5-4ca6-b538-c4d610c46b84.mp3 3600 500 5)
...
2011-08-04 18:10:40.289726 [DEBUG] mod_python.c:183 Call python script
...
2011-08-04 18:10:40.648268 [DEBUG] mod_python.c:186 Finished calling python script

and when it's false:

EXECUTE sofia/internal/+14259065859@flowroute.com set(record_post_process_exec_api=pyrun:my_app_freeswitch.post_process  /usr/local/freeswitch/recordings/,934d6786-676a-4180-b37f-6b54616c2020)
2011-08-04 18:10:25.255307 [DEBUG] mod_dptools.c:1063 sofia/internal/+14259065859@flowroute.com SET [record_post_process_exec_api]=[pyrun:my_app_freeswitch.post_process  /usr/local/freeswitch/recordings/,934d6786-676a-4180-b37f-6b54616c2020]

2011-08-04 18:10:28.895591 [DEBUG] switch_ivr.c:576 sofia/internal/+14259065859@flowroute.com Command Execute record_session(/usr/local/freeswitch/recordings/20110804-181028_934d6786-676a-4180-b37f-6b54616c2020.mp3)
EXECUTE sofia/internal/+14259065859@flowroute.com record_session(/usr/local/freeswitch/recordings/20110804-181028_934d6786-676a-4180-b37f-6b54616c2020.mp3)
mike-plivo commented 13 years ago

Hi Matt,

I think you inverted the FS logs: if bothLegs is true : plivo use record_session() if bothLegs is false: plivo use record()

I just checked something simple using luarun and a basic script :

--  /tmp/script.lua example script

freeswitch.consoleLog("notice", "plivo test\n");

Diaplan XML :

    <extension name="plivo">
        <condition field="destination_number" expression="^1234$">
            <action application="set" data="record_post_process_exec_api=luarun:/tmp/script.lua"/>
            <action application="socket" data="127.0.0.1:8084 async full"/>
        </condition>
    </extension>

If I use bothLegs='true', it works, I can see the log "plivo test" in FS.

If I use bothLegs='false', doesn't work, script is not fired.

Checking the FS code source, seems "record_post_process_exec_api" and "record_post_process_exec_api" are used only in record_session (when bothLEgs='true')

So cannot be used with bothLegs='false' .

mattwilliamson commented 13 years ago

I appreciate you looking into this for me. Does this mean I'll have to branch the freeswitch source and add the hook for record_session?

On Aug 5, 2011, at 4:40, tamielreply@reply.github.com wrote:

Hi Matt,

I think you inverted the FS logs: if bothLegs is true : plivo use record_session() if bothLegs is false: plivo use record()

I just checked something simple using luarun and a basic script :

--  /tmp/script.lua example script

freeswitch.consoleLog("notice", "plivo test\n");

Diaplan XML :

   <extension name="plivo">
       <condition field="destination_number" expression="^1234$">
           <action application="set" data="record_post_process_exec_api=luarun:/tmp/script.lua"/>
           <action application="socket" data="127.0.0.1:8084 async full"/>
       </condition>
   </extension>

If I use bothLegs='true', it works, I can see the log "plivo test" in FS.

If I use bothLegs='false', doesn't work, script is not fired.

Checking the FS code source, seems "record_post_process_exec_api" and "record_post_process_exec_api" are used only in record_session (when bothLEgs='true')

So cannot be used with bothLegs='false' .

Reply to this email directly or view it on GitHub: https://github.com/plivo/plivo/issues/27#issuecomment-1733790

mike-plivo commented 13 years ago

Get the last git freeswitch source and reinstall FS.

And retry with it, we will see if it helps you =)

mattwilliamson commented 13 years ago

We recompiled freeswitch and it didn't seem to fix the issue. Looking over the gti.freeswitch.org logs, I don't see a commit that might fix it either.

mike-plivo commented 13 years ago

ok I will test with a python script and see what happens .

efinkelman commented 13 years ago

This apparently is still not working.

mike-plivo commented 13 years ago

Update to the last plivo revision.

I checked and worked for me.

Here what I have done to test :

I record in background using bothLegs="true" and set maxLength="10", so after 10 seconds, background recording is stopped and the python script is fired.

RESTXML :

<Response>
<Record bothLegs="true" maxLength="10" playBeep="true"/>
<Speak loop="20">Recording is in progress in background</Speak>
</Response>

FS DIALPLAN XML

    <extension name="plivo">
        <condition field="destination_number" expression="^1234$">
            <action application="set" data="record_post_process_exec_api=pyrun:fstest"/>
            <action application="socket" data="127.0.0.1:8084 async full"/>
        </condition>
    </extension>

Python script fstest.py

import os
from freeswitch import *

def runtime(args):
    consoleLog("info", "test pyrun record_session postprocessing\n")
    consoleLog("info", "test pyrun args => %s\n" % str(args))

I have installed freeswitch.py from freeswitch source and fstest.py into my python path.

FS logs for the python script :

2011-08-16 17:04:01.202207 [NOTICE] mod_python.c:114 Invoking py module: fstest
2011-08-16 17:04:01.202207 [DEBUG] mod_python.c:183 Call python script
2011-08-16 17:04:01.202207 [INFO] switch_cpp.cpp:1197 test pyrun record_session postprocessing
2011-08-16 17:04:01.202207 [INFO] switch_cpp.cpp:1197 test pyrun args => 
2011-08-16 17:04:01.202207 [DEBUG] mod_python.c:186 Finished calling python script
mattwilliamson commented 13 years ago

So the fix is in plivo, not freeswitch?

mike-plivo commented 13 years ago

Seems in plivo, so now I think it will work for you.

mattwilliamson commented 13 years ago

It looks like this is indeed a freeswitch bug. I've submitted http://jira.freeswitch.org/browse/FS-3505 to them. Closing this issue.

mike-plivo commented 13 years ago

You're a lucky guy, the fix has been commited to freeswitch =)

mattwilliamson commented 13 years ago

I saw that. And in under 10 minutes too!

On Aug 17, 2011, at 3:40, tamielreply@reply.github.com wrote:

You're a lucky guy, the patch was commited to freeswitch =)

Reply to this email directly or view it on GitHub: https://github.com/plivo/plivo/issues/27#issuecomment-1824176

mattwilliamson commented 13 years ago

It's also working

On Aug 17, 2011, at 3:40, tamielreply@reply.github.com wrote:

You're a lucky guy, the patch was commited to freeswitch =)

Reply to this email directly or view it on GitHub: https://github.com/plivo/plivo/issues/27#issuecomment-1824176