SlideShare a Scribd company logo
FreeSWITCH modules for
  Asterisk developers.

       Moises Silva <moy@sangoma.com>
       Software Developer
       Sangoma Technologies




                                   05-Aug-09/ 1
Agenda
•   Why Modules?

•   Module Architecture.

•   Core Basics.

•   Module Interfaces.

•   Application skeleton.

•   Module Configuration.

•   Argument parsing.

•   Interacting with the CLI.

•   Events and actions.

                                05-Aug-09 / 2
Why modules?
•   Building blocks.

•   Extend core capabilities.

•   Distribution and bug fixing is easier.




                                             Nov 25, 2012 / 3
Examples of modular architectures
•   Linux kernel (character devices, block devices, filesystems etc).



•   PHP, Python and PERL interpreters (extensions).




•   Apache (loggers, generators, filters, mappers).




•   FreeSWITCH and Asterisk.




                                                                 05-Aug-09 / 4
Common Approach to Modules
•   Register interfaces with the core.

•   The core provides APIs to module writers.

•   The core uses the module interfaces function pointers.


                          Core APIs


      Application                          Module

                     Module interfaces



                                                        Nov 25, 2012 / 5
Core basics
•   How a call leg is abstracted?




                                     Asterisk



         Incoming call



                                    FreeSWITCH




                                                 05-Aug-09 / 6
Core basics
•   How a call leg is abstracted?




         Asterisk            struct ast_channel




                              switch_core_session_t
       FreeSWITCH




                                                      05-Aug-09 / 7
Core basics
•   How a call leg is represented?

                         switch_core_session_t

                         - Memory pool
                         - Owner thread
    FreeSWITCH           - I/O event hooks
                         - Endpoint interface
                         - Event and message queues
                         - Codec preferences
                         - Channel
                              - Direction
                              - Event hooks
                              - DTMF queue
                              - Private hash
                              - State and state handlers
                              - Caller profile


                                                           05-Aug-09 / 8
Core basics
•   How a call leg is represented?

                         struct ast_channel

                         - No memory pool
         Asterisk        - No owner thread
                         - Just audio hooks
                         - Tech interface
                         - No event or message queues
                         - Codec preferences
                         - Direction as flag AST_FLAG_OUTGOING
                         - No DTMF queue (generic frame queue)
                         - Data stores instead of private hash
                         - No generic state handlers
                         - Extension, context and ast_callerid
                         instead of caller profile.



                                                           05-Aug-09 / 9
Core basics
•   What about Asterisk struct ast_frame?

•   Represents signaling.

•   Audio.

•   DTMF.

•   And more …



    Incoming leg frames            Asterisk          Outgoing leg frames


             Asterisk frames (signaling, audio, dtmf, video, fax)



                                                                    05-Aug-09 / 10
Core basics
•    FreeSWITCH has switch_frame_t.

•    switch_frame_t just represent media.

•    Signaling is handled through switch_core_session_message_t.

•    DTMF is handled through the DTMF queue.

    Incoming leg audio                                    Outgoing leg audio


    Incoming leg dtmf                                      Outgoing leg dtmf
                                 FreeSWITCH

Incoming leg signaling                                   Outgoing leg signaling

          Different data structures for signaling, audio, dtmf etc.


                                                                      05-Aug-09 / 11
Core basics
•   How a two-leg call is handled?




     Incoming leg               Routing   Outgoing leg




                                                   05-Aug-09 / 12
Core basics
•     Asterisk making a call bridge between SIP and PRI.
              (monitor thread)
SIP: Invite
              chan_sip

                   - Allocate ast_channel
                   - Set caller data
                   - call ast_pbx_start()
    (new thread)

PBX core                                                            ISDN: SETUP
                   ast_request -> ast_call()            chan_zap

 loop
 extensions.conf calls                      ast_waitfor()          ISDN: CONNECT
 Dial() application

               Media                                 ast_bridge_call()
                                         PBX core    ast_channel_bridge()
               Exchange

                                                                            05-Aug-09 / 13
Core basics
•     FreeSWITCH making a call bridge between SIP and PRI.
              (monitor thread)
SIP: Invite
              mod_sofia

                   - call switch_core_session_request
                   - Set caller profile
                   - call switch_core_session_thread_launch()
    (new thread)                                            ISDN: SETUP
                                            mod_openzap
 State             routing state
machine            execute state
                   Bridge Application                       ISDN: CONNECT
                   switch_ivr_originate()           (new thread)
loop
                                                                  State
Handling
                                                                 machine
state changes                    Media
                                                          loop
                                 Exchange                 Handling
                                                          state changes

                                                                          05-Aug-09 / 14
Core basics
•   FreeSWITCH

     – switch_core_session_t is the call structure.

     – Each session has its own state machine thread.

     – You allocate memory using the session memory pool.

•   Asterisk

     - struct ast_chan is the call structure.

     - The initial leg thread is re-used for the outgoing leg.

     - You allocate memory from the process heap directly.




                                                                 05-Aug-09 / 15
FreeSWITCH Modules and interfaces.
•   Modules are shared objects or DLL’s.

•   The core loads the shared object on startup or on demand.

•   You must register your interfaces on module load.

•   Interface types:

     –   Endpoints (switch_endpoint_interface_t -> ast_channel_tech)
     –   Codec (switch_codec_interface_t -> ast_translator)
     –   Files (switch_file_interface_t -> ast_format)
     –   Application (switch_application_interface_t -> ast_app)
     –   API (switch_api_interface_t -> no exact match)

•   More interfaces defined in src/include/switch_module_interfaces.h.



                                                                  05-Aug-09 / 16
Asterisk application skeleton.
•   Fundamental steps.

     –   static int app_exec(struct ast_channel *c, const char *data);
     –   Define static int load_module() and static int unload_module();
     –   AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, “Desc”);
     –   Call ast_register_application_xml() on in load_module() to register
         app_exec

•   Your app_exec function will be called if the app is called from the
    dial plan.

•   Call ast_unregister_application in unload_module().

•   Module loading and registering relies on gcc constructor-destructor
    attributes.




                                                                   05-Aug-09 / 17
FreeSWITCH application skeleton.
•   Fundamental steps.

     – SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dummy_shutdo
       wn)

     – SWITCH_MODULE_RUNTIME_FUNCTION(mod_dummy_run)

     – SWITCH_MODULE_LOAD_FUNCTION(mod_dummy_load)

     – SWITCH_MODULE_DEFINITION(mod_dummy,
       mod_dummy_shutdown, mod_dummy_run, mod_dummy_load)

•   This is true for all modules, regardless of the exported interfaces.

•   The runtime routine is called once all modules have been loaded.




                                                                 05-Aug-09 / 18
FreeSWITCH application skeleton.
•   Define your main application function.


     – SWITCH_STANDARD_APP(dummy_function){
       // arguments received are:
       // switch_core_session_t *session, const char *data
     }


•   Register your application interface.

     – SWITCH_MODULE_LOAD_FUNCTION(dummy_load) { ….
       switch_application_interface_t *app_interface;
       *module_interface = switch_loadable_module_create_interface(pool, modname);
       SWITCH_ADD_APP(app_interface, “dummy”, “dummy app”, “” );
     …}



                                                                             05-Aug-09 / 19
FreeSWITCH application skeleton.
•   Load function prototype:

     – switch_status_t dummy_load(switch_loadable_module_interface_t
       **module_interface, switch_memory_pool_t *pool);

•   The module_interface argument is the place holder for all the
    possible interfaces your module may implement (endpoint, codec,
    application, api etc).

•   Your module may implement as many interfaces as you want.


•   Runtime and shutdown routines have no arguments.

•   SWITCH_MODULE_DEFINITION will declare static const char
    modname[] and the module function table.

•   Each module has a memory pool, use it for your allocations.
                                                              05-Aug-09 / 20
Asterisk module configuration.

•   Asterisk has a configuration API abstract from the backend engine.

•   struct ast_config is your handle to the configuration.

•   To get your handle you call ast_config_load().

•   You then use some functions to retrieve the configuration values:

     –   const char *ast_variable_retrieve(struct ast_config *c, char *category, char *variable);

     –   char *ast_category_browse(struct ast_config *c, const char *prev)

     –   ast_variable_browse(struct ast_config *c, const char *category)




                                                                                       05-Aug-09 / 21
Asterisk module configuration.

•   Assuming we have an application configuration like this:


[section]
parameter-x1=123
parameter-x2=456




                                                               05-Aug-09 / 22
Asterisk module configuration.




                                 05-Aug-09 / 23
FreeSWITCH module configuration.

•   FreeSWITCH configuration is composed of a big chunk of XML

•   An XML configuration API is already there for you to use.

•   For simple things, no much difference than asterisk config

•   XML allows more advanced configuration setup.

•   Simple usage guide lines:

     –   Use switch_xml_open_cfg() to get a handle to the configuration chunk you want.

     –   Get the section (equivalent to asterisk category) through switch_xml_child()

     –   Retrieve variable values through switch_xml_attr_soft




                                                                                        05-Aug-09 / 24
FreeSWITCH module configuration.

•   Assuming we have an application configuration like this:


<configuration name=”myconf.conf” description=“test config”>
   <section>
        <parameter name=“parameter-x1” value=“123”/>
         <parameter name=“parameter-x2” value=“456”/>
   </section>
</configuration>




                                                               05-Aug-09 / 25
FreeSWITCH module configuration.




                                   05-Aug-09 / 26
Application return value.

•   Both FreeSWITCH and Asterisk applications return values to the
    user through dial plan variables.

•   Asterisk uses pbx_builtin_setvar_helper(chan, “var”, “value”);

•   FreeSWITCH uses switch_channel_set_variable(chan, ”var”, “val”);




                                                              05-Aug-09 / 27
Interacting with the Asterisk CLI.

•   Asterisk has a very flexible and dynamic CLI.

•   Any Asterisk sub-system may register CLI entries.

•   Registering CLI entires involves:

     –   Defining your CLI handlers static char *handler(struct ast_cli_entry *e, int cmd, struct
         ast_cli_args *a);

     –   Create an array of the CLI entries (Use the helper macro AST_CLI_ENTRY).

     –   Call ast_cli_register_multiple to register the array with the Asterisk core.

     –   Handle CLI requests like CLI_INIT, CLI_GENERATE and CLI_HANDLER.




                                                                                        05-Aug-09 / 28
Interacting with the Asterisk CLI.




                                     05-Aug-09 / 29
Interacting with the FreeSWITCH CLI.

•   CLI commands exist as APIs.

•   An added benefit is availability of the function from other interfaces
    (ie mod_event_socket etc).

•   In general, your API can be used via switch_api_execute().

•   No dynamic completion yet.

•   Simple usage:

     –   Define your API function using SWITCH_STANDARD_API macro.

     –   Add your API interface to your module interface using SWITCH_ADD_API.

     –   Add command completion using switch_console_set_complete.



                                                                                 05-Aug-09 / 30
Interacting with the FreeSWITCH CLI.




                                       05-Aug-09 / 31
Asterisk events and actions.

•   The Asterisk manager is built-in.

•   The module needlessly has to care about event protocol formatting
    through rn.

•   The manager is, by definition, tied to the TCP event protocol
    implementation.

•   Every new output format for events has to be coded right into the
    core.

•   manager_custom_hook helps, but not quite robust solution.

•   Basically you can do 2 things with the manager API:

     –   Register and handle manager actions.

     –   Send manager events.
                                                               05-Aug-09 / 32
Registering Asterisk actions.




                                05-Aug-09 / 33
Launching Asterisk events.



                   Manager session or HTTP session


        enqueue
         event

                       Read event queue




                        Write to session


                                                     05-Aug-09 / 34
FreeSWITCH events.

•   Completely abstract API to the event sub-system is provided.

•   The core fires built-in events and applications fire custom events.

•   Modules can reserve and fire custom events.

•   mod_event_socket is a module that does what the Asterisk
    manager does.

•   Different priorities:

     –   SWITCH_PRIORITY_NORMAL
     –   SWITCH_PRIORITY_LOW
     –   SWITCH_PRIORITY_HIGH




                                                                05-Aug-09 / 35
Firing FreeSWITCH events.




                            05-Aug-09 / 36
Listening for FreeSWITCH events.




                                   05-Aug-09 / 37
FreeSWITCH Actions???.

•   No need for actions, you already registered APIs.

•   The APIs may be executed through mod_event_socket.

•   APIs are the closest thing to manager actions that FreeSWITCH
    has.

•   APIs work both as CLI commands and “manager actions”, but are
    not limited to just that.

mod_event_socket

                           switch_api_execute()          Your
                                                        module
FreeSWITCH CLI



                                                            05-Aug-09 / 38
Conclusion.

•   We are in a race for scalability, feature set and adoption.

•   FreeSWITCH is in need of more features and applications on top of
    it.

•   Asterisk is in need of more core improvements to be a better media
    and telephony engine.

•   Open source is the clear winner of the competition we are seeing
    between this two open source telephony engines.




                                                                  05-Aug-09 / 39
References

- src/include/switch_types.h
- src/include/switch_loadable_module.h
- src/include/switch_channel.h
- src/include/switch_xml_config.h

- http://docs.freeswitch.org/
- http://wiki.freeswitch.org/wiki/Core_Outline_of_FreeSWITCH




                                                               Nov 25, 2012 / 40
Thank You!

           Questions and Comments?


Contact e-mail: moy@sangoma.com

Presentation URL: http://www.moythreads.com/congresos/cluecon2009/




                                                       Nov 25, 2012 / 41

More Related Content

What's hot

NETCONF Call Home
NETCONF Call Home NETCONF Call Home
NETCONF Call Home
ADVA
 
Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017
Giacomo Vacca
 
Ext4 write barrier
Ext4 write barrierExt4 write barrier
Ext4 write barrier
Somdutta Roy
 
Deep Dive into Keystone Tokens and Lessons Learned
Deep Dive into Keystone Tokens and Lessons LearnedDeep Dive into Keystone Tokens and Lessons Learned
Deep Dive into Keystone Tokens and Lessons Learned
Priti Desai
 
FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)
Kirill Tsym
 
SMP/What?
SMP/What?SMP/What?
SMP/What?
Michael Erichsen
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
rtpengine - Media Relaying and Beyond
rtpengine - Media Relaying and Beyondrtpengine - Media Relaying and Beyond
rtpengine - Media Relaying and Beyond
Andreas Granig
 
An Introduction to RISC-V bootflow
An Introduction to RISC-V bootflowAn Introduction to RISC-V bootflow
An Introduction to RISC-V bootflow
Atish Patra
 
Kernel debug log and console on openSUSE
Kernel debug log and console on openSUSEKernel debug log and console on openSUSE
Kernel debug log and console on openSUSE
SUSE Labs Taipei
 
Kamailio - API Based SIP Routing
Kamailio - API Based SIP RoutingKamailio - API Based SIP Routing
Kamailio - API Based SIP Routing
Daniel-Constantin Mierla
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
ScyllaDB
 
ALU 7360 5520_gpon_basic_configuration
ALU  7360 5520_gpon_basic_configurationALU  7360 5520_gpon_basic_configuration
ALU 7360 5520_gpon_basic_configuration
Wahyu Nasution
 
StarlingX - A Platform for the Distributed Edge | Ildiko Vancsa
StarlingX - A Platform for the Distributed Edge | Ildiko VancsaStarlingX - A Platform for the Distributed Edge | Ildiko Vancsa
StarlingX - A Platform for the Distributed Edge | Ildiko Vancsa
Vietnam Open Infrastructure User Group
 
From DTrace to Linux
From DTrace to LinuxFrom DTrace to Linux
From DTrace to Linux
Brendan Gregg
 
Scaling FreeSWITCH Performance
Scaling FreeSWITCH PerformanceScaling FreeSWITCH Performance
Scaling FreeSWITCH Performance
Moises Silva
 
〜Apache Geode 入門 gfsh によるクラスター構築・管理
〜Apache Geode 入門 gfsh によるクラスター構築・管理〜Apache Geode 入門 gfsh によるクラスター構築・管理
〜Apache Geode 入門 gfsh によるクラスター構築・管理
Akihiro Kitada
 
ZYNQ BRAM Implementation
ZYNQ BRAM ImplementationZYNQ BRAM Implementation
ZYNQ BRAM Implementation
Vincent Claes
 
Freeswitch
FreeswitchFreeswitch
Freeswitch
Suneet Saini
 
Oracle Extended Clusters for Oracle RAC
Oracle Extended Clusters for Oracle RACOracle Extended Clusters for Oracle RAC
Oracle Extended Clusters for Oracle RAC
Markus Michalewicz
 

What's hot (20)

NETCONF Call Home
NETCONF Call Home NETCONF Call Home
NETCONF Call Home
 
Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017
 
Ext4 write barrier
Ext4 write barrierExt4 write barrier
Ext4 write barrier
 
Deep Dive into Keystone Tokens and Lessons Learned
Deep Dive into Keystone Tokens and Lessons LearnedDeep Dive into Keystone Tokens and Lessons Learned
Deep Dive into Keystone Tokens and Lessons Learned
 
FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)
 
SMP/What?
SMP/What?SMP/What?
SMP/What?
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
rtpengine - Media Relaying and Beyond
rtpengine - Media Relaying and Beyondrtpengine - Media Relaying and Beyond
rtpengine - Media Relaying and Beyond
 
An Introduction to RISC-V bootflow
An Introduction to RISC-V bootflowAn Introduction to RISC-V bootflow
An Introduction to RISC-V bootflow
 
Kernel debug log and console on openSUSE
Kernel debug log and console on openSUSEKernel debug log and console on openSUSE
Kernel debug log and console on openSUSE
 
Kamailio - API Based SIP Routing
Kamailio - API Based SIP RoutingKamailio - API Based SIP Routing
Kamailio - API Based SIP Routing
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
 
ALU 7360 5520_gpon_basic_configuration
ALU  7360 5520_gpon_basic_configurationALU  7360 5520_gpon_basic_configuration
ALU 7360 5520_gpon_basic_configuration
 
StarlingX - A Platform for the Distributed Edge | Ildiko Vancsa
StarlingX - A Platform for the Distributed Edge | Ildiko VancsaStarlingX - A Platform for the Distributed Edge | Ildiko Vancsa
StarlingX - A Platform for the Distributed Edge | Ildiko Vancsa
 
From DTrace to Linux
From DTrace to LinuxFrom DTrace to Linux
From DTrace to Linux
 
Scaling FreeSWITCH Performance
Scaling FreeSWITCH PerformanceScaling FreeSWITCH Performance
Scaling FreeSWITCH Performance
 
〜Apache Geode 入門 gfsh によるクラスター構築・管理
〜Apache Geode 入門 gfsh によるクラスター構築・管理〜Apache Geode 入門 gfsh によるクラスター構築・管理
〜Apache Geode 入門 gfsh によるクラスター構築・管理
 
ZYNQ BRAM Implementation
ZYNQ BRAM ImplementationZYNQ BRAM Implementation
ZYNQ BRAM Implementation
 
Freeswitch
FreeswitchFreeswitch
Freeswitch
 
Oracle Extended Clusters for Oracle RAC
Oracle Extended Clusters for Oracle RACOracle Extended Clusters for Oracle RAC
Oracle Extended Clusters for Oracle RAC
 

Similar to FreeSWITCH Modules for Asterisk Developers

Five cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterFive cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark faster
Tim Ellison
 
Cell Technology for Graphics and Visualization
Cell Technology for Graphics and VisualizationCell Technology for Graphics and Visualization
Cell Technology for Graphics and Visualization
Slide_N
 
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Intel® Software
 
Lecture10_RealTimeOperatingSystems.pptx
Lecture10_RealTimeOperatingSystems.pptxLecture10_RealTimeOperatingSystems.pptx
Lecture10_RealTimeOperatingSystems.pptx
SekharSankuri1
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924poly
Gary Dare
 
hyperlynx_compress.pdf
hyperlynx_compress.pdfhyperlynx_compress.pdf
hyperlynx_compress.pdf
raimonribal
 
Web Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfWeb Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdf
SamHoney6
 
MIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SW
MIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SWMIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SW
MIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SW
MIPI Alliance
 
infraXstructure Alexis Dacquay, "How to win back visibility into your network...
infraXstructure Alexis Dacquay, "How to win back visibility into your network...infraXstructure Alexis Dacquay, "How to win back visibility into your network...
infraXstructure Alexis Dacquay, "How to win back visibility into your network...
PROIDEA
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemc
SUBRAHMANYA S
 
L05 parallel
L05 parallelL05 parallel
The Potential Impact of Software Defined Networking SDN on Security
The Potential Impact of Software Defined Networking SDN on SecurityThe Potential Impact of Software Defined Networking SDN on Security
The Potential Impact of Software Defined Networking SDN on Security
Brent Salisbury
 
Digital Design Flow
Digital Design FlowDigital Design Flow
Digital Design Flow
Mostafa Khamis
 
Kognitio - an overview
Kognitio - an overviewKognitio - an overview
Kognitio - an overview
Kognitio
 
Timothy J Cash Career Portfolio
Timothy J Cash Career PortfolioTimothy J Cash Career Portfolio
Timothy J Cash Career Portfolio
Timothy Cash
 
Data Centre Design for Canadian Small & Medium Sized Businesses
Data Centre Design for Canadian Small & Medium Sized BusinessesData Centre Design for Canadian Small & Medium Sized Businesses
Data Centre Design for Canadian Small & Medium Sized BusinessesCisco Canada
 
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław BorekPLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PROIDEA
 
Design for manufacture techniques for PCB design
Design for manufacture techniques for PCB designDesign for manufacture techniques for PCB design
Design for manufacture techniques for PCB design
Devangsingh Sankhala
 
Active network
Active networkActive network
Active network
Michel Burger
 

Similar to FreeSWITCH Modules for Asterisk Developers (20)

Five cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterFive cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark faster
 
Cell Technology for Graphics and Visualization
Cell Technology for Graphics and VisualizationCell Technology for Graphics and Visualization
Cell Technology for Graphics and Visualization
 
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
Embree Ray Tracing Kernels | Overview and New Features | SIGGRAPH 2018 Tech S...
 
Lecture10_RealTimeOperatingSystems.pptx
Lecture10_RealTimeOperatingSystems.pptxLecture10_RealTimeOperatingSystems.pptx
Lecture10_RealTimeOperatingSystems.pptx
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924poly
 
hyperlynx_compress.pdf
hyperlynx_compress.pdfhyperlynx_compress.pdf
hyperlynx_compress.pdf
 
Web Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfWeb Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdf
 
MIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SW
MIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SWMIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SW
MIPI DevCon 2016: How MIPI Debug Specifications Help Me to Develop System SW
 
infraXstructure Alexis Dacquay, "How to win back visibility into your network...
infraXstructure Alexis Dacquay, "How to win back visibility into your network...infraXstructure Alexis Dacquay, "How to win back visibility into your network...
infraXstructure Alexis Dacquay, "How to win back visibility into your network...
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemc
 
L05 parallel
L05 parallelL05 parallel
L05 parallel
 
The Potential Impact of Software Defined Networking SDN on Security
The Potential Impact of Software Defined Networking SDN on SecurityThe Potential Impact of Software Defined Networking SDN on Security
The Potential Impact of Software Defined Networking SDN on Security
 
Digital Design Flow
Digital Design FlowDigital Design Flow
Digital Design Flow
 
Kognitio - an overview
Kognitio - an overviewKognitio - an overview
Kognitio - an overview
 
SOC design
SOC design SOC design
SOC design
 
Timothy J Cash Career Portfolio
Timothy J Cash Career PortfolioTimothy J Cash Career Portfolio
Timothy J Cash Career Portfolio
 
Data Centre Design for Canadian Small & Medium Sized Businesses
Data Centre Design for Canadian Small & Medium Sized BusinessesData Centre Design for Canadian Small & Medium Sized Businesses
Data Centre Design for Canadian Small & Medium Sized Businesses
 
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław BorekPLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
 
Design for manufacture techniques for PCB design
Design for manufacture techniques for PCB designDesign for manufacture techniques for PCB design
Design for manufacture techniques for PCB design
 
Active network
Active networkActive network
Active network
 

More from Moises Silva

Interfaces de Scripting para librerias en C
Interfaces de Scripting para librerias en CInterfaces de Scripting para librerias en C
Interfaces de Scripting para librerias en C
Moises Silva
 
Vulnerabilidades en Aplicaciones Web PHP
Vulnerabilidades en Aplicaciones Web PHPVulnerabilidades en Aplicaciones Web PHP
Vulnerabilidades en Aplicaciones Web PHP
Moises Silva
 
Manejo de Medios en FreeSWITCH
Manejo de Medios en FreeSWITCHManejo de Medios en FreeSWITCH
Manejo de Medios en FreeSWITCH
Moises Silva
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in Asterisk
Moises Silva
 
FreeSWITCH: Asterisk con Esteroides
FreeSWITCH: Asterisk con EsteroidesFreeSWITCH: Asterisk con Esteroides
FreeSWITCH: Asterisk con Esteroides
Moises Silva
 
Negociacion de Codecs en Asterisk
Negociacion de Codecs en AsteriskNegociacion de Codecs en Asterisk
Negociacion de Codecs en AsteriskMoises Silva
 
Sangoma en el Ecosistema Open Source
Sangoma en el Ecosistema Open SourceSangoma en el Ecosistema Open Source
Sangoma en el Ecosistema Open Source
Moises Silva
 
Media Handling in FreeSWITCH
Media Handling in FreeSWITCHMedia Handling in FreeSWITCH
Media Handling in FreeSWITCH
Moises Silva
 
FreeTDM PRI Passive Recording
FreeTDM PRI Passive RecordingFreeTDM PRI Passive Recording
FreeTDM PRI Passive Recording
Moises Silva
 
Asterisk PRI Passive Call Recording
Asterisk PRI Passive Call RecordingAsterisk PRI Passive Call Recording
Asterisk PRI Passive Call Recording
Moises Silva
 
OpenR2 in Asterisk
OpenR2 in AsteriskOpenR2 in Asterisk
OpenR2 in Asterisk
Moises Silva
 

More from Moises Silva (11)

Interfaces de Scripting para librerias en C
Interfaces de Scripting para librerias en CInterfaces de Scripting para librerias en C
Interfaces de Scripting para librerias en C
 
Vulnerabilidades en Aplicaciones Web PHP
Vulnerabilidades en Aplicaciones Web PHPVulnerabilidades en Aplicaciones Web PHP
Vulnerabilidades en Aplicaciones Web PHP
 
Manejo de Medios en FreeSWITCH
Manejo de Medios en FreeSWITCHManejo de Medios en FreeSWITCH
Manejo de Medios en FreeSWITCH
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in Asterisk
 
FreeSWITCH: Asterisk con Esteroides
FreeSWITCH: Asterisk con EsteroidesFreeSWITCH: Asterisk con Esteroides
FreeSWITCH: Asterisk con Esteroides
 
Negociacion de Codecs en Asterisk
Negociacion de Codecs en AsteriskNegociacion de Codecs en Asterisk
Negociacion de Codecs en Asterisk
 
Sangoma en el Ecosistema Open Source
Sangoma en el Ecosistema Open SourceSangoma en el Ecosistema Open Source
Sangoma en el Ecosistema Open Source
 
Media Handling in FreeSWITCH
Media Handling in FreeSWITCHMedia Handling in FreeSWITCH
Media Handling in FreeSWITCH
 
FreeTDM PRI Passive Recording
FreeTDM PRI Passive RecordingFreeTDM PRI Passive Recording
FreeTDM PRI Passive Recording
 
Asterisk PRI Passive Call Recording
Asterisk PRI Passive Call RecordingAsterisk PRI Passive Call Recording
Asterisk PRI Passive Call Recording
 
OpenR2 in Asterisk
OpenR2 in AsteriskOpenR2 in Asterisk
OpenR2 in Asterisk
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 

FreeSWITCH Modules for Asterisk Developers

  • 1. FreeSWITCH modules for Asterisk developers. Moises Silva <moy@sangoma.com> Software Developer Sangoma Technologies 05-Aug-09/ 1
  • 2. Agenda • Why Modules? • Module Architecture. • Core Basics. • Module Interfaces. • Application skeleton. • Module Configuration. • Argument parsing. • Interacting with the CLI. • Events and actions. 05-Aug-09 / 2
  • 3. Why modules? • Building blocks. • Extend core capabilities. • Distribution and bug fixing is easier. Nov 25, 2012 / 3
  • 4. Examples of modular architectures • Linux kernel (character devices, block devices, filesystems etc). • PHP, Python and PERL interpreters (extensions). • Apache (loggers, generators, filters, mappers). • FreeSWITCH and Asterisk. 05-Aug-09 / 4
  • 5. Common Approach to Modules • Register interfaces with the core. • The core provides APIs to module writers. • The core uses the module interfaces function pointers. Core APIs Application Module Module interfaces Nov 25, 2012 / 5
  • 6. Core basics • How a call leg is abstracted? Asterisk Incoming call FreeSWITCH 05-Aug-09 / 6
  • 7. Core basics • How a call leg is abstracted? Asterisk struct ast_channel switch_core_session_t FreeSWITCH 05-Aug-09 / 7
  • 8. Core basics • How a call leg is represented? switch_core_session_t - Memory pool - Owner thread FreeSWITCH - I/O event hooks - Endpoint interface - Event and message queues - Codec preferences - Channel - Direction - Event hooks - DTMF queue - Private hash - State and state handlers - Caller profile 05-Aug-09 / 8
  • 9. Core basics • How a call leg is represented? struct ast_channel - No memory pool Asterisk - No owner thread - Just audio hooks - Tech interface - No event or message queues - Codec preferences - Direction as flag AST_FLAG_OUTGOING - No DTMF queue (generic frame queue) - Data stores instead of private hash - No generic state handlers - Extension, context and ast_callerid instead of caller profile. 05-Aug-09 / 9
  • 10. Core basics • What about Asterisk struct ast_frame? • Represents signaling. • Audio. • DTMF. • And more … Incoming leg frames Asterisk Outgoing leg frames Asterisk frames (signaling, audio, dtmf, video, fax) 05-Aug-09 / 10
  • 11. Core basics • FreeSWITCH has switch_frame_t. • switch_frame_t just represent media. • Signaling is handled through switch_core_session_message_t. • DTMF is handled through the DTMF queue. Incoming leg audio Outgoing leg audio Incoming leg dtmf Outgoing leg dtmf FreeSWITCH Incoming leg signaling Outgoing leg signaling Different data structures for signaling, audio, dtmf etc. 05-Aug-09 / 11
  • 12. Core basics • How a two-leg call is handled? Incoming leg Routing Outgoing leg 05-Aug-09 / 12
  • 13. Core basics • Asterisk making a call bridge between SIP and PRI. (monitor thread) SIP: Invite chan_sip - Allocate ast_channel - Set caller data - call ast_pbx_start() (new thread) PBX core ISDN: SETUP ast_request -> ast_call() chan_zap loop extensions.conf calls ast_waitfor() ISDN: CONNECT Dial() application Media ast_bridge_call() PBX core ast_channel_bridge() Exchange 05-Aug-09 / 13
  • 14. Core basics • FreeSWITCH making a call bridge between SIP and PRI. (monitor thread) SIP: Invite mod_sofia - call switch_core_session_request - Set caller profile - call switch_core_session_thread_launch() (new thread) ISDN: SETUP mod_openzap State routing state machine execute state Bridge Application ISDN: CONNECT switch_ivr_originate() (new thread) loop State Handling machine state changes Media loop Exchange Handling state changes 05-Aug-09 / 14
  • 15. Core basics • FreeSWITCH – switch_core_session_t is the call structure. – Each session has its own state machine thread. – You allocate memory using the session memory pool. • Asterisk - struct ast_chan is the call structure. - The initial leg thread is re-used for the outgoing leg. - You allocate memory from the process heap directly. 05-Aug-09 / 15
  • 16. FreeSWITCH Modules and interfaces. • Modules are shared objects or DLL’s. • The core loads the shared object on startup or on demand. • You must register your interfaces on module load. • Interface types: – Endpoints (switch_endpoint_interface_t -> ast_channel_tech) – Codec (switch_codec_interface_t -> ast_translator) – Files (switch_file_interface_t -> ast_format) – Application (switch_application_interface_t -> ast_app) – API (switch_api_interface_t -> no exact match) • More interfaces defined in src/include/switch_module_interfaces.h. 05-Aug-09 / 16
  • 17. Asterisk application skeleton. • Fundamental steps. – static int app_exec(struct ast_channel *c, const char *data); – Define static int load_module() and static int unload_module(); – AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, “Desc”); – Call ast_register_application_xml() on in load_module() to register app_exec • Your app_exec function will be called if the app is called from the dial plan. • Call ast_unregister_application in unload_module(). • Module loading and registering relies on gcc constructor-destructor attributes. 05-Aug-09 / 17
  • 18. FreeSWITCH application skeleton. • Fundamental steps. – SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dummy_shutdo wn) – SWITCH_MODULE_RUNTIME_FUNCTION(mod_dummy_run) – SWITCH_MODULE_LOAD_FUNCTION(mod_dummy_load) – SWITCH_MODULE_DEFINITION(mod_dummy, mod_dummy_shutdown, mod_dummy_run, mod_dummy_load) • This is true for all modules, regardless of the exported interfaces. • The runtime routine is called once all modules have been loaded. 05-Aug-09 / 18
  • 19. FreeSWITCH application skeleton. • Define your main application function. – SWITCH_STANDARD_APP(dummy_function){ // arguments received are: // switch_core_session_t *session, const char *data } • Register your application interface. – SWITCH_MODULE_LOAD_FUNCTION(dummy_load) { …. switch_application_interface_t *app_interface; *module_interface = switch_loadable_module_create_interface(pool, modname); SWITCH_ADD_APP(app_interface, “dummy”, “dummy app”, “” ); …} 05-Aug-09 / 19
  • 20. FreeSWITCH application skeleton. • Load function prototype: – switch_status_t dummy_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool); • The module_interface argument is the place holder for all the possible interfaces your module may implement (endpoint, codec, application, api etc). • Your module may implement as many interfaces as you want. • Runtime and shutdown routines have no arguments. • SWITCH_MODULE_DEFINITION will declare static const char modname[] and the module function table. • Each module has a memory pool, use it for your allocations. 05-Aug-09 / 20
  • 21. Asterisk module configuration. • Asterisk has a configuration API abstract from the backend engine. • struct ast_config is your handle to the configuration. • To get your handle you call ast_config_load(). • You then use some functions to retrieve the configuration values: – const char *ast_variable_retrieve(struct ast_config *c, char *category, char *variable); – char *ast_category_browse(struct ast_config *c, const char *prev) – ast_variable_browse(struct ast_config *c, const char *category) 05-Aug-09 / 21
  • 22. Asterisk module configuration. • Assuming we have an application configuration like this: [section] parameter-x1=123 parameter-x2=456 05-Aug-09 / 22
  • 24. FreeSWITCH module configuration. • FreeSWITCH configuration is composed of a big chunk of XML • An XML configuration API is already there for you to use. • For simple things, no much difference than asterisk config • XML allows more advanced configuration setup. • Simple usage guide lines: – Use switch_xml_open_cfg() to get a handle to the configuration chunk you want. – Get the section (equivalent to asterisk category) through switch_xml_child() – Retrieve variable values through switch_xml_attr_soft 05-Aug-09 / 24
  • 25. FreeSWITCH module configuration. • Assuming we have an application configuration like this: <configuration name=”myconf.conf” description=“test config”> <section> <parameter name=“parameter-x1” value=“123”/> <parameter name=“parameter-x2” value=“456”/> </section> </configuration> 05-Aug-09 / 25
  • 27. Application return value. • Both FreeSWITCH and Asterisk applications return values to the user through dial plan variables. • Asterisk uses pbx_builtin_setvar_helper(chan, “var”, “value”); • FreeSWITCH uses switch_channel_set_variable(chan, ”var”, “val”); 05-Aug-09 / 27
  • 28. Interacting with the Asterisk CLI. • Asterisk has a very flexible and dynamic CLI. • Any Asterisk sub-system may register CLI entries. • Registering CLI entires involves: – Defining your CLI handlers static char *handler(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); – Create an array of the CLI entries (Use the helper macro AST_CLI_ENTRY). – Call ast_cli_register_multiple to register the array with the Asterisk core. – Handle CLI requests like CLI_INIT, CLI_GENERATE and CLI_HANDLER. 05-Aug-09 / 28
  • 29. Interacting with the Asterisk CLI. 05-Aug-09 / 29
  • 30. Interacting with the FreeSWITCH CLI. • CLI commands exist as APIs. • An added benefit is availability of the function from other interfaces (ie mod_event_socket etc). • In general, your API can be used via switch_api_execute(). • No dynamic completion yet. • Simple usage: – Define your API function using SWITCH_STANDARD_API macro. – Add your API interface to your module interface using SWITCH_ADD_API. – Add command completion using switch_console_set_complete. 05-Aug-09 / 30
  • 31. Interacting with the FreeSWITCH CLI. 05-Aug-09 / 31
  • 32. Asterisk events and actions. • The Asterisk manager is built-in. • The module needlessly has to care about event protocol formatting through rn. • The manager is, by definition, tied to the TCP event protocol implementation. • Every new output format for events has to be coded right into the core. • manager_custom_hook helps, but not quite robust solution. • Basically you can do 2 things with the manager API: – Register and handle manager actions. – Send manager events. 05-Aug-09 / 32
  • 34. Launching Asterisk events. Manager session or HTTP session enqueue event Read event queue Write to session 05-Aug-09 / 34
  • 35. FreeSWITCH events. • Completely abstract API to the event sub-system is provided. • The core fires built-in events and applications fire custom events. • Modules can reserve and fire custom events. • mod_event_socket is a module that does what the Asterisk manager does. • Different priorities: – SWITCH_PRIORITY_NORMAL – SWITCH_PRIORITY_LOW – SWITCH_PRIORITY_HIGH 05-Aug-09 / 35
  • 36. Firing FreeSWITCH events. 05-Aug-09 / 36
  • 37. Listening for FreeSWITCH events. 05-Aug-09 / 37
  • 38. FreeSWITCH Actions???. • No need for actions, you already registered APIs. • The APIs may be executed through mod_event_socket. • APIs are the closest thing to manager actions that FreeSWITCH has. • APIs work both as CLI commands and “manager actions”, but are not limited to just that. mod_event_socket switch_api_execute() Your module FreeSWITCH CLI 05-Aug-09 / 38
  • 39. Conclusion. • We are in a race for scalability, feature set and adoption. • FreeSWITCH is in need of more features and applications on top of it. • Asterisk is in need of more core improvements to be a better media and telephony engine. • Open source is the clear winner of the competition we are seeing between this two open source telephony engines. 05-Aug-09 / 39
  • 40. References - src/include/switch_types.h - src/include/switch_loadable_module.h - src/include/switch_channel.h - src/include/switch_xml_config.h - http://docs.freeswitch.org/ - http://wiki.freeswitch.org/wiki/Core_Outline_of_FreeSWITCH Nov 25, 2012 / 40
  • 41. Thank You! Questions and Comments? Contact e-mail: moy@sangoma.com Presentation URL: http://www.moythreads.com/congresos/cluecon2009/ Nov 25, 2012 / 41