I've tried all variations of ringback and pre_answer order. 
I've found solution that works for me, but it appears to be a bug in displace_session or uuid_displace implementation.

Method1: 
Thing that works:
<action application="pre_answer"/>
<action application="set" data="send_silence_when_idle=1400"/>
<action application="displace_session" data="tone_stream://%(1000,4000,425);loops=-1 0 mux}"/>
<action application="sleep" data="8000"/>

Thing that doesn't work: the above plays tone_stream during sleep, but stop fails
<action application="stop_displace_session" data="tone_stream://%(1000,4000,425);loops=-1}"/>. It doesn't stop displace.

Method 2. Use uuid_displace instead of displace_session:
<action application="set" data="api_result=${uuid_displace ${uuid} start tone_stream://L=5;%(1000,4000,425)}"/>
<action application="sleep" data="8000"/>
<action application="set" data="api_result=${uuid_displace ${uuid} stop tone_stream://L=5;%(1000,4000,425);}"/>

It works, but there is a problem: it incorrectly interprets tone_stream syntax of this: "tone_stream://%(1000,4000,425);loops=-1" and plays some strange DTMF (possibly it interpretes some symbols as DTMF) after generated sound.



2016-06-03 11:25 GMT+03:00 David Villasmil <david.villasmil.work@gmail.com>:
Have you tried moving the "pre_answer" to before the ringback?
ᐧ

On Tue, May 31, 2016 at 1:57 PM, Dmitry Sytchev <kbdfck@gmail.com> wrote:
Hi all!

I'd like to resolve some unclear ringback behavior in early media
mode. I'm trying to implement ringback while no bridge active.
A calls FS, FS does something, then searching for B and bridges A to B.

I'd like to start playing custom ringback immediately after call from
A gets into FS, not when we start bridge to B.

I'm doing something like that:

<action application="set" data="ringback=%(2000, 4000, 440.0, 480.0)"/>
<action application="set" data="instant_ringback=true"/>
<action application="set" data="bridge_early_media=true"/>
<action application="pre_answer"/>
<action application="sleep" data="10000"/>
...
<action application="bridge" data="some bridge data"/>

There is no ringback to A in such scenario until bridge is called in
further dialplan processing. I've tried all combinations of
ignore/bridge early media, but with no luck. Pre_answer can be called
directly or by FS when call is recorded, with no difference. There is
a wiki page that recommends usage of ring_ready:

https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools%3A+ring_ready

ring_ready works, but it can give only Ringing to calling side, so  I
can't pass custom RBT to calling party. It would be enough for me, but
once somebody calls pre_answer, no early media is passed until bridge
attempt.

What can be done to resolve this? Thanks in advance.







--
Best regards,

Dmitry Sytchev,
IT Engineer

_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.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
http://www.freeswitch.org


_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.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
http://www.freeswitch.org



--
Best regards,

Dmitry Sytchev,
IT Engineer