32,39 €
FreeSWITCH 1.6 Cookbook is written for anyone who wants to learn more about using FreeSWITCH in production. The information is presented in such a way that you can get up and running quickly. The cookbook approach eschews much of the foundational concepts, and instead focuses on discrete examples that illustrate specific features. If you need to implement a particular feature as quickly as possible, then this book is for you.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 225
Veröffentlichungsjahr: 2015
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2012
Second Edition: July 2015
Production reference: 1170715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-091-7
www.packtpub.com
Authors
Anthony Minessale II
Michael S Collins
Giovanni Maruzzelli
Reviewers
Ayobami Adewole
Josh Richesin
Gabe Shepard
Brian Wiese
Commissioning Editor
Amarabha Banerjee
Acquisition Editors
Usha Iyer
Kevin Colaco
Content Development Editor
Arshiya Ayaz Umer
Technical Editor
Ryan Kochery
Copy Editors
Miss Yesha G
Vikrant Phadke
Project Coordinator
Sanjeet Rao
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph
Anthony Minessale II is the primary author and founding member of the FreeSWITCH open source softswitch. He has spent almost 20 years working with open source software. In 2001, he spent a great deal of time as an Asterisk developer and authored numerous features and fixes to that project. Anthony started coding a new idea for an open source voice application in 2005. The FreeSWITCH project was officially opened to the public on January 1, 2006. In the years that followed, Anthony has actively maintained and led software development for this project.
Michael S Collins is a telephony and open source software enthusiast. Having worked as a PBX technician for 5 years and the head of IT for a call center for more than 9 years, he is a PBX veteran. He is an active member of the FreeSWITCH community and has coauthored FreeSWITCH Cookbook, by Packt Publishing in 2012. Michael lives in Central California with his wife and two children.
Giovanni Maruzzelli (available at OpenTelecom.IT) is heavily engaged with FreeSWITCH. In it, he wrote interfacing with Skype and cellular phones. He's a consultant in the telecommunication sector, developing software and conducting training courses for FreeSWITCH, SIP, WebRTC, Kamailio, and OpenSIPS.
An Internet technology pioneer, he was the cofounder of Italia Online in 1996. It is the most popular Italian portal and consumer ISP. Also, he was the architect of its Internet technologies (www.italiaonline.it). Then, Giovanni was the supervisor of Internet operations and the architect of the first engine for paid access to ilsole24ore.com, the most read financial newspaper in Italy, and its databases (migrated from the mainframe).
After that, he was the CEO of the venture-capital-funded company Matrice, developing telemail unified messaging and multiple-language phone access to e-mail (text to speech). He was also the CTO of the incubator-funded company Open4, an open source managed applications provider.
For 2 years, Giovanni worked in Serbia as an Internet and telecommunication investment expert for IFC, an arm of The World Bank.
Since 2005, he has been based in Italy and serves ICT and telecommunication companies worldwide.
For my first book, first and foremost I want to thank my late guru, Marco Amante, who taught me to work, to write, "computerism," the most important things in life, as well as their order. Thanks, master!
Also, I want to thank Gisella Genna for her continued, incredible, and precious support and love. Thanks, my beloved!
Ayobami Adewole is a software engineer who has spent the last 4 years working on various cutting-edge VoIP solutions using FreeSwitch IP-PBX. He graduated with a degree in computer science from the Ladoke Akintola University of Technology, Ogbomoso, Nigeria. He has developed applications and authored solutions for different projects, such as land administration and geographical information systems, enterprise-level application integrations, and unified communication and software applications for the education and business sectors. In his spare time, he enjoys experimenting with new technologies.
I would like to acknowledge my parents for instilling in me the culture of discipline and hard work. Also, my gratitude goes to my partner for always encouraging me. Lastly, I want to thank everyone who had assisted me and given me the opportunity to pursue my passion for technology.
Josh Richesin is a cofounder of Sureline Broadband, a broadband and telephony company based in Madras, Oregon, USA. He also has his own private consulting practice, primarily for service providers. He has been in the telecommunication industry for his entire career and has always had a focus on large, mission-critical networks in the service providers' realm. You can contact Josh and read his blog at www.joshrichesin.com.
Gabe Shepard is a master developer at Star2Star Communications and has been dabbling in the VoIP world for nearly a decade. Prior to that, he focused on Linux systems administration and web development. He currently lives in Sarasota, Florida, USA, with his wife, Kelli, and their two daughters, Charlotte and Lucille. You can contact him at extrema.net.
Brian Wiese has always been passionate about technology and enjoys sharing his knowledge with others. Employed by an educational software and consulting company serving the requirements of schools throughout the United States, he continues to fulfill his personal commitment in finding sustainable and cost-effective solutions for educators. Brian's more than 10 years of experience in telephony helps him identify winning strategies for VoIP integration.
First, I wish to thank the authors of this cookbook for giving me the opportunity to review it after reviewing FreeSWITCH 1.2. Again, I'd like to recognize the accomplishments of Anthony and the rest of the community in making FreeSWITCH an amazing telephony platform. Finally, I send a most sincere thank you to my parents and friends for all of their encouragement, support, and inspiration.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
FreeSWITCH is increasingly becoming the "serious choice" for companies to base their products and offerings on. Its usage is widespread, scaling from Raspberry Pis to "Big Irons" in the data center.
There is a growing need for books and training, and with Packt Publishing, we decided to begin serving this burgeoning demand. This cookbook is a primer; then there will be a Mastering FreeSWITCH book, followed by a new edition of the classic FreeSWITCH book.
Obviously, nothing can beat a training camp or codeveloping in collaboration with an old hand, but these FreeSWITCH titles will form the basis on which a company or a consultant can begin embracing, deploying, and implementing FreeSWITCH.
This book is a complete update, rewrite, and integration of the old FreeSWITCH cookbook. This new edition covers FreeSWITCH 1.6.x, and a lot of new ground.
All the examples here have been updated and tested with the new FreeSWITCH series, while a new section has been added about connecting to Skype, and two entire chapters are on WebRTC and Lua programming.
Anthony Minessale II, Giovanni Maruzzelli
July 5 2015
Chapter 1, Routing Calls, shows that getting calls from one endpoint to another is the primary function of FreeSWITCH. This chapter discusses techniques of efficiently routing calls between phones and service providers.
Chapter 2, Connecting Telephones and Service Providers, assists in quickly getting your FreeSWITCH server connected to other VoIP devices. Telephones and service providers have specific requirements for connecting to FreeSWITCH.
Chapter 3, Processing Call Detail Records, discusses a number of ways to extract CDR data from your FreeSWITCH server. Call detail records, or CDRs, are very important for businesses.
Chapter 4, External Control, presents a number of real-world examples of controlling FreeSWITCH from an external process. FreeSWITCH can be controlled externally by the powerful and versatile event socket interface.
Chapter 5, PBX Functionality, is the largest chapter in this book. This chapter shows how to deploy features such as voicemail, conference calls, faxing, IVRs, and more, which most telephone systems have, in a FreeSWITCH server.
Chapter 6, WebRTC and Mod_Verto, features the new disruptive technology that allows real-time audio/video/data-secure communication from hundreds of millions of browsers. FreeSWITCH is ready to serve as a gateway and an application server.
Chapter 7, Dialplan Scripting with Lua, covers Lua, the scripting language of choice for programming complex logic in FreeSWITCH. Accessing databases, calling web servers, and interacting with user's choices now becomes easy.
FreeSWITCH 1.6 Cookbook is an essential addition to any VoIP administrator's or WebRTC developer's library. PBX implementers will also gain from the thoroughly distilled recipes presented here.
Whether you are a FreeSWITCH expert or are just getting started, this book will take your skills to the next level.
FreeSWITCH 1.6 Cookbook is written for anyone who wants to learn more about using FreeSWITCH in production. The information is presented in such a way that you can get up and running quickly. The cookbook approach eschews much of the foundational concepts, and instead focuses on discrete examples that illustrate specific features. If you need to implement a particular feature as quickly as possible, then this book is for you.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use the following sections.
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make you more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Many of the techniques employed in Local_Extension are discussed in this chapter."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "You should see an application named directory in the list."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/B04231_ColoredImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we will discuss routing calls in various scenarios, as follows:
Routing calls is at the core of any FreeSWITCH server. There are many techniques for accomplishing the surprisingly complex task of connecting one phone to another. However, it is important to make sure that you have the basic tools necessary to complete this task.
The most basic component of routing calls is the dialplan, which is essentially a list of actions to perform depending upon which digits were dialed (as we will see in some of the recipes in this book, there are other factors that can affect routing of calls). The dialplan is broken down into one or morecontexts. Each context is a group of one or moreextensions. Finally, each extension contains specific actions to be performed on the call. The dialplan processor uses regular expressions, which are a pattern-matching system used to determine which extensions and actions to execute.
To make best use of the recipes in this chapter, it is especially important to understand how to use regular expressions and the three contexts in the default configuration.
FreeSWITCH usesPerl-compatible regular expressions (PCRE) for pattern matching. Consider this dialplan excerpt:
This example demonstrates the most common uses of regular expressions in the dialplan: matching against the destination_number field (that is, the digits that the user dialed) and capturing, using parentheses, the matched value in a special variable named $1. Let's say that a user dials 1025. Our example extension will match 1025 against the ^(10\d\d)$ pattern and determine that this is indeed a match. All actions inside the condition tag will be executed. The action tag in our example will execute the log application. The log application will then print a message to the console, using the INFO log level, which will be in green text by default. The value in $1 is expanded (or interpolated) when printed:
2015-02-22 15:15:50.664585 [INFO] mod_dptools.c:1628 dialed number is [1025]
Understanding these basic principles will help you create effective dialplan extensions.
For more tips on using regular expressions, be sure to visit http://freeswitch.org/confluence/display/FREESWITCH/Regular+Expression.
Contexts are logical groups of extensions. The default FreeSWITCH configuration contains three contexts:
Each of these contexts serves a purpose, and knowing about them will help you leverage their value for your needs.
The most used context in the default configuration is the default context. All users whose calls are authenticated by FreeSWITCH will have their calls passing through this context, unless there have been modifications. Some common modifications include using ACLs or disabling authentication altogether (see the The public context section that follows). The default context can be thought of as internal in nature; that is, it services users who are connected directly to the FreeSWITCH server, as opposed to outside callers (again, see the The public context section).
Many characteristics related to PBX (Private Branch Exchange) are defined in the default context, as are various utility extensions. It is good to open conf/dialplan/default.xml and study the extensions there. Start with simple extensions such as show_info, which performs a simple info dump to the console, and vmain, which allows a user to log in to their voicemail box.
A particularly useful extension to review is Local_Extension. This extension does many things, as follows:
Many of the techniques employed in Local_Extension are discussed in this chapter (see the The features context section for a discussion on the in-call features found in this extension).
The public context is used to route incoming calls that originate from outside the local network. Calls that initially come to the public context are treated as untrusted. If they are not specifically routed to an extension in the default context, then they are simply disconnected. As mentioned before, disabling authentication or using ACLs to let calls into the system will route them into the public context (this is a security precaution, which can be overridden if absolutely required). We will use the public context in the Incoming DID (also known as DDI) calls recipe.
The features context is used to make certain features available for calls that are in progress. Consider this excerpt from Local_Extension in conf/dialplan/default.xml:
This is just one of several features that are enabled for the recipient of the call. The bind_meta_app application listens on the audio stream for a touch-tone *