[Freeswitch-dev] Howto keep control over read and write frames in my own module after initiating a new call

Achim Stamm stamm at lyth.de
Thu Jul 29 00:35:28 PDT 2010


Hi,

I found a solution for making an outbound call and having control
over read and write frames in a while loop.

First step is make outbound call without Caller Session:
switch_ivr_originate(NULL,peerSession,cause,"user/1010 at 192.168"....);

Second step is transfer peerSession to an extension in Dialplan doing 
the while-loop (read and write frames):
switch_core_session_execute_exten(peerSession,"Test","XML","default");

regards

Achim Stamm

Anthony Minessale schrieb:
> That's a little much to explain over email.
> maybe you should just study the code a little and look at examples in 
> switch_ivr_async.c
>
> On Tue, Jul 27, 2010 at 6:25 AM, Achim Stamm <stamm at lyth.de 
> <mailto:stamm at lyth.de>> wrote:
>
>     Hi,
>
>     thanks for your reply.
>     I found a Core Library called Media Bugs with several functions.
>     How can i use this functions ?
>     Can you give me an example using media bugs.
>     Whats the difference between using hooks and using media bugs?
>
>     regards
>
>     Achim Stamm
>
>
>     Anthony Minessale schrieb:
>     > You can't, that's all wrong.
>     >
>     > look for media bugs.
>     >
>     >
>     > On Mon, Jul 26, 2010 at 5:08 AM, Achim Stamm <stamm at lyth.de
>     <mailto:stamm at lyth.de>
>     > <mailto:stamm at lyth.de <mailto:stamm at lyth.de>>> wrote:
>     >
>     >     Hello!
>     >
>     >     I have following problem:
>     >     My current session is connected to my own module which uses the
>     >     freeswitch API doing Read and write frames in the while loop.
>     >     I want bridge my current session to make an outbound call within
>     >     my while loop.
>     >     The calling of method bridge runs in a thread using
>     modificated bgapi.
>     >     The outbounded phone rings and after picking it up the
>     reading and
>     >     writing of frames is done only by freeswitch core and not
>     any more
>     >     in my while
>     >     loop. But after bridging I want to keep control over reading and
>     >     writing
>     >     frames.
>     >
>     >     How can i gain control back or keep it over reading and writing
>     >     frames after bridging ?
>     >
>     >     A solution may be to run an extension instead of making the call
>     >     in while loop.
>     >     How can i execute an extension with
>     >     switch_core_session_execute_exten ?
>     >
>     >     Here is a snippet of my Dialplan:
>     >
>     >     <extension name="Caller">
>     >          <condition field="destination_number" expression="^1000$">
>     >                 <action application="answer"/>
>     >                     <action application="info"/>
>     >                     <action application="set"
>     >     data="hangup_after_bridge=false"/>
>     >                     <action application="set"
>     >     data="ignore_early_media=true"/>
>     >                     <action application="myapplication"
>     >     data="DoingReadAndWriteFrames"/>
>     >          </condition>
>     >        </extension>
>     >
>     >     Here is a snippet of my DoingReadAndWriteFrames from
>     myapplication:
>     >
>     >     static switch_status_t DoingBridge(switch_core_session_t
>     *session,
>     >     switch_input_args_t *args)
>     >     {
>     >            switch_codec_t codec = { 0 };
>     >            switch_status_t status;
>     >            switch_frame_t *read_frame;
>     >            switch_channel_t *channel =
>     >     switch_core_session_get_channel(session);
>     >            switch_stream_handle_t dstream = { 0 };
>     >
>     >            // Bridge to phone in a thread:
>     >            SWITCH_STANDARD_STREAM(dstream);
>     >            mybg_bridge("user/1012 at 192.168.1.30
>     <mailto:1012 at 192.168.1.30>
>     >     <mailto:1012 at 192.168.1.30 <mailto:1012 at 192.168.1.30>>" ,60,
>     session, &dstream);
>     >
>     >            while (switch_channel_ready(channel))
>     >            {
>     >                    // Read Frame :
>     >                    status = switch_core_session_read_frame(session,
>     >     &read_frame, SWITCH_IO_FLAG_NONE, 0);
>     >                    ...
>     >
>     >    
>      CControlThirdPartyApplication::getInstance().setAudio(session,vucInAudio);
>     >
>     >                    // Write Frame :
>     >                    vucOutAudio =
>     >     CControlThirdPartyApplication::getInstance().getAudio(session);
>     >                    ...
>     >                    switch_status_t tstatus_caller =
>     >     switch_core_session_write_frame(session, read_frame,
>     >     SWITCH_IO_FLAG_NONE, 0);
>     >
>     >                    // Make Outbound Call:
>     >                    string dialNumber =
>     >    
>     CControlThirdPartyApplication::getInstance().getDialNumber(session);
>     >                    if (!dialNumber.empty())
>     >                    {
>     >                            // @ ToDo Dial outbound:
>     >                            // execute another extension
>     ("Test"), that
>     >     is doing our outbound call ??:
>     >
>     >    
>      switch_core_session_execute_exten(session,"Test","XML","default");
>     >                            // or Bridge to dialNumber in a thread:
>     >                            //SWITCH_STANDARD_STREAM(dstream);
>     >                            dialNumber = "user/" + dialNumber;
>     >                            dialNumber = dialNumber +
>     "@192.168.1.30 <http://192.168.1.30>
>     >     <http://192.168.1.30>";
>     >                            mybg(dialNumber.c_str(), 60, session,
>     >     &dstream);
>     >                            // if dialNumber pickup, than freeswitch
>     >     core read and write frames ?? I want control over read and
>     write frame
>     >                    }
>     >            }
>     >     }
>     >
>     >     regards
>     >
>     >     Achim Stamm
>     >
>     >     --
>     >     Achim Stamm, Dipl.-Inform. (FH)
>     >
>     >
>     >     Lyncker & Theis GmbH
>     >     Wilhelmstr. 16
>     >     65185 Wiesbaden
>     >     Germany
>     >
>     >     Fon +49 611/9006951
>     >     Fax +49 611/9406125
>     >
>     >
>     >     Handelsregister: HRB 23156 Amtsgericht Wiesbaden
>     >     Steuernummer: 04323897052
>     >     USt-IdNr.: DE255806399
>     >
>     >     Geschäftsführer:
>     >     Filip Lyncker,
>     >     Armin Theis
>     >
>     >
>     >     _______________________________________________
>     >     FreeSWITCH-dev mailing list
>     >     FreeSWITCH-dev at lists.freeswitch.org
>     <mailto:FreeSWITCH-dev at lists.freeswitch.org>
>     >     <mailto:FreeSWITCH-dev at lists.freeswitch.org
>     <mailto:FreeSWITCH-dev at lists.freeswitch.org>>
>     >     http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>     >    
>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>     >     http://www.freeswitch.org
>     >
>     >
>     >
>     >
>     > --
>     > Anthony Minessale II
>     >
>     > FreeSWITCH http://www.freeswitch.org/
>     > ClueCon http://www.cluecon.com/
>     > Twitter: http://twitter.com/FreeSWITCH_wire
>     >
>     > AIM: anthm
>     > MSN:anthony_minessale at hotmail.com
>     <mailto:MSN%3Aanthony_minessale at hotmail.com>
>     > <mailto:MSN%3Aanthony_minessale at hotmail.com
>     <mailto:MSN%253Aanthony_minessale at hotmail.com>>
>     > GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
>     <mailto:PAYPAL%3Aanthony.minessale at gmail.com>
>     > <mailto:PAYPAL%3Aanthony.minessale at gmail.com
>     <mailto:PAYPAL%253Aanthony.minessale at gmail.com>>
>     > IRC: irc.freenode.net <http://irc.freenode.net>
>     <http://irc.freenode.net> #freeswitch
>     >
>     > FreeSWITCH Developer Conference
>     > sip:888 at conference.freeswitch.org
>     <mailto:sip%3A888 at conference.freeswitch.org>
>     > <mailto:sip%3A888 at conference.freeswitch.org
>     <mailto:sip%253A888 at conference.freeswitch.org>>
>     > googletalk:conf+888 at conference.freeswitch.org
>     <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org>
>     > <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org
>     <mailto:googletalk%253Aconf%252B888 at conference.freeswitch.org>>
>     > pstn:+19193869900
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > FreeSWITCH-dev mailing list
>     > FreeSWITCH-dev at lists.freeswitch.org
>     <mailto:FreeSWITCH-dev at lists.freeswitch.org>
>     > http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>     >
>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>     > http://www.freeswitch.org
>     >
>
>
>     --
>     Achim Stamm, Dipl.-Inform. (FH)
>
>
>     Lyncker & Theis GmbH
>     Wilhelmstr. 16
>     65185 Wiesbaden
>     Germany
>
>     Fon +49 611/9006951
>     Fax +49 611/9406125
>
>
>     Handelsregister: HRB 23156 Amtsgericht Wiesbaden
>     Steuernummer: 04323897052
>     USt-IdNr.: DE255806399
>
>     Geschäftsführer:
>     Filip Lyncker,
>     Armin Theis
>
>
>     _______________________________________________
>     FreeSWITCH-dev mailing list
>     FreeSWITCH-dev at lists.freeswitch.org
>     <mailto:FreeSWITCH-dev at lists.freeswitch.org>
>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>     http://www.freeswitch.org
>
>
>
>
> -- 
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
>
> AIM: anthm
> MSN:anthony_minessale at hotmail.com 
> <mailto:MSN%3Aanthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com 
> <mailto:PAYPAL%3Aanthony.minessale at gmail.com>
> IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org 
> <mailto:sip%3A888 at conference.freeswitch.org>
> googletalk:conf+888 at conference.freeswitch.org 
> <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org>
> pstn:+19193869900
> ------------------------------------------------------------------------
>
> _______________________________________________
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>   


-- 
Achim Stamm, Dipl.-Inform. (FH)


Lyncker & Theis GmbH
Wilhelmstr. 16
65185 Wiesbaden
Germany

Fon +49 611/9006951
Fax +49 611/9406125


Handelsregister: HRB 23156 Amtsgericht Wiesbaden
Steuernummer: 04323897052
USt-IdNr.: DE255806399

Geschäftsführer:
Filip Lyncker,
Armin Theis 




More information about the FreeSWITCH-dev mailing list