05-Aug-09/ 1 FreeSWITCH modules for Asterisk developers. Moises Silva Software Developer Sangoma Technologies.

Slides:



Advertisements
Similar presentations
Purdue University Center for Education and Research in Information Assurance and Security Building a distributed intrusion detection system with Perl Diego.
Advertisements

SIP and Instant Messaging. SIP Summit SIP and Instant Messaging What Does Presence Have to Do With SIP? How to Deliver.
How to use TinyOS Jason Hill Rob Szewczyk Alec Woo David Culler An event based execution environment for Networked Sensors.
MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
CSCC69: Operating Systems
1 © 2006 Cisco Systems, Inc. All rights reserved. Session Number Presentation_ID Using the Cisco Technical Support & Documentation Website for Voice Issues.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
Computer Systems/Operating Systems - Class 8
Technical Architectures
Server Architecture Models Operating Systems Hebrew University Spring 2004.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
OS Spring’03 Introduction Operating Systems Spring 2003.
Internet Telephony Helen J. Wang Network Reading Group, Jan 27, 99 Acknowledgement: Jimmy, Bhaskar.
Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 Operating System Organization.
02 Aug-2010 / 1 FreeTDM PRI Passive Call Recording Moises Silva Senior Software Engineer. Sangoma Technologies.
Achieving optimal scalability and voice quality in open source telephony Konrad Hammel Software Engineer Sangoma Technologies.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Woomera Accelerating access to VoIP Cluecon 2009, 7 August 2009 Craig Southeren.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
CINEMA’s UbiComp Subsystem Stefan Berger and Henning Schulzrinne Department of Computer Science Columbia University
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Extensibility, Safety and Performance in the SPIN Operating System Ashwini Kulkarni Operating Systems Winter 2006.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Origin of FreeSWITCH Asterisk Developer Meeting (March, 2005) 5 days of coding (initial design of the core) 7 months of discussion. 3 months prep work.
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Apache Mina Dima Ionut Daniel. Contents What is Apache Mina? Why Apache Mina? Mina Architecture Mina Core Mina Advanced JMX Support Spring Integration.
A Comparative Study of the Linux and Windows Device Driver Architectures with a focus on IEEE1394 (high speed serial bus) drivers Melekam Tsegaye
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Middleware for FIs Apeego House 4B, Tardeo Rd. Mumbai Tel: Fax:
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
H.323, IP Multicast Conferencing, And TAPI 3.0 Don Ryan Development Lead Windows Networking And Communications Microsoft Corporation.
Real-time multimedia and communication in packet networks iLanga.
© 2002 IBM Corporation Confidential | Date | Other Information, if necessary © Wind River Systems, released under EPL 1.0. All logos are TM of their respective.
7. CBM collaboration meetingXDAQ evaluation - J.Adamczewski1.
Media Handling in FreeSWITCH Moisés Silva Software Engineer / Manager
OS2014 PROJECT 2 Supplemental Information. Outline Sequence Diagram of Project 2 Kernel Modules Kernel Sockets Work Queues Synchronization.
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
06-Apr-10/ 1 FreeTDM Moises Silva Senior Software Engineer. Sangoma Technologies.
SKYPIAX, how to add Skype capabilities to FreeSWITCH (and Asterisk) CHICAGO, USA, September 2009.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Interfacing Device Drivers with the Kernel
How to write a MSGQ Transport (MQT) Overview Nov 29, 2005 Todd Mullanix.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
By Ruizhe Ma, Avinash Madineni Sidoine Lafleur Kamgang Nov,
Opportunities in Deploying Open Source Applications Using LumenVox Speech Recognition on Asterisk.
EPICS and LabVIEW Tony Vento, National Instruments
AFS/OSD Project R.Belloni, L.Giammarino, A.Maslennikov, G.Palumbo, H.Reuter, R.Toebbicke.
Asterisk Architecture. Architecture APIs Defined for loadable modules Facilitates hardware and protocol abstraction The Asterisk core does not have to.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Operating Systems Concepts
Adopting the Python language for On-board Programmable Payload Autonomy Steven Doran 2016 Flight Software Workshop 12/14/2016.
Processes and threads.
VoIP with asterisk © Mathias Weyland.
Digium | Switchvox Product Announcement
ASTERISK “Open Source Communications Platform”
Out-of-Process Components
Processes The most important processes used in Web-based systems and their internal organization.
CS179G, Project In Computer Science
Out-of-Process Components
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

05-Aug-09/ 1 FreeSWITCH modules for Asterisk developers. Moises Silva Software Developer Sangoma Technologies

05-Aug-09 / 2 Agenda Why Modules? Module Architecture. Core Basics. Module Interfaces. Application skeleton. Module Configuration. Argument parsing. Interacting with the CLI. Events and actions.

10-Aug-15 / 3 Why modules? Building blocks. Extend core capabilities. Distribution and bug fixing is easier.

05-Aug-09 / 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.

10-Aug-15 / 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. Application Module Core APIs Module interfaces

05-Aug-09 / 6 Core basics How a call leg is abstracted? Incoming call Asterisk FreeSWITCH

05-Aug-09 / 7 Core basics How a call leg is abstracted? Asterisk FreeSWITCH struct ast_channel switch_core_session_t

05-Aug-09 / 8 Core basics How a call leg is represented? FreeSWITCH switch_core_session_t - Memory pool - Owner thread - 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 / 9 Core basics How a call leg is represented? struct ast_channel - No memory pool - 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. Asterisk

05-Aug-09 / 10 Core basics What about Asterisk struct ast_frame? Represents signaling. Audio. DTMF. And more … Incoming leg frames Asterisk frames (signaling, audio, dtmf, video, fax) Asterisk Outgoing leg frames

05-Aug-09 / 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 Different data structures for signaling, audio, dtmf etc. FreeSWITCH Incoming leg dtmf Incoming leg signaling Outgoing leg audio Outgoing leg dtmf Outgoing leg signaling

05-Aug-09 / 12 Core basics How a two-leg call is handled? Incoming leg Routing Outgoing leg

05-Aug-09 / 13 Core basics Asterisk making a call bridge between SIP and PRI. chan_sip SIP: Invite - Allocate ast_channel - Set caller data - call ast_pbx_start() (new thread) (monitor thread) PBX core loop extensions.conf calls Dial() application chan_zap ast_request -> ast_call() ISDN: SETUP ast_waitfor() PBX core ISDN: CONNECT ast_bridge_call() ast_channel_bridge() Media Exchange

05-Aug-09 / 14 Core basics FreeSWITCH making a call bridge between SIP and PRI. mod_sofia SIP: Invite - call switch_core_session_request - Set caller profile - call switch_core_session_thread_launch() (new thread) (monitor thread) State machine loop Handling state changes mod_openzap routing state execute state Bridge Application switch_ivr_originate() ISDN: SETUP ISDN: CONNECT Media Exchange (new thread) State machine loop Handling state changes

05-Aug-09 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 22 Asterisk module configuration. Assuming we have an application configuration like this: [section] parameter-x1=123 parameter-x2=456

05-Aug-09 / 23 Asterisk module configuration.

05-Aug-09 / 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 / 25 FreeSWITCH module configuration. Assuming we have an application configuration like this:

05-Aug-09 / 26 FreeSWITCH module configuration.

05-Aug-09 / 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 / 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 / 29 Interacting with the Asterisk CLI.

05-Aug-09 / 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 / 31 Interacting with the FreeSWITCH CLI.

05-Aug-09 / 32 Asterisk events and actions. The Asterisk manager is built-in. The module needlessly has to care about event protocol formatting through \r\n. 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 / 33 Registering Asterisk actions.

05-Aug-09 / 34 Launching Asterisk events. enqueue event Read event queue Manager session or HTTP session Write to session

05-Aug-09 / 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 / 36 Firing FreeSWITCH events.

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

05-Aug-09 / 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 FreeSWITCH CLI switch_api_execute() Your module

05-Aug-09 / 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.

10-Aug-15 / 40 References - src/include/switch_types.h - src/include/switch_loadable_module.h - src/include/switch_channel.h - src/include/switch_xml_config.h

10-Aug-15 / 41 Thank You! Questions and Comments? Contact Presentation URL: