Webrtc Integrator's Guide
Total Page:16
File Type:pdf, Size:1020Kb
WebRTC Integrator's Guide Successfully build your very own scalable WebRTC infrastructure quickly and efficiently Altanai BIRMINGHAM - MUMBAI WebRTC Integrator's Guide Copyright © 2014 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 author, 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: October 2014 Production reference: 1251014 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78398-126-7 www.packtpub.com Cover image by Gagandeep Sharma ([email protected]) Credits Author Proofreaders Altanai Jenny Blake Stephen Copestake Reviewers Maria Gould Alessandro Arrichiello Joel T. Johnson Pasquale Boemio Antón Román Portabales Indexers Andrii Sergiienko Hemangini Bari Mariammal Chettiyar Commissioning Editor Rekha Nair Usha Iyer Graphics Acquisition Editor Ronak Dhruv Llewellyn Rozario Valentina D'silva Content Development Editor Disha Haria Akashdeep Kundu Abhinash Sahu Technical Editor Production Coordinators Menza Mathew Adonia Jones Nitesh Thakur Copy Editors Karuna Narayanan Cover Work Laxmi Subramanian Nitesh Thakur Project Coordinator Neha Thakur About the Author Altanai, born into an Indian army family, is a bubbly, vivacious, intelligent computer geek. She is an avid blogger and writes on Research and Development of evolving technologies in Telecom (http://altanaitelecom.wordpress.com). She holds a Bachelor's degree in Information Technology from Anna University, Chennai. She has worked on many Telecom projects worldwide, specifically in the development and deployment of IMS services. She firmly believes in contributing to the Open Source community and is currently working on building a WebRTC-based JS library with books for more applications. Her hobbies include photography, martial arts, oil canvas painting, river rafting, horse riding, and trekking, to name a few. This is her first book, and it contains useful insight into WebRTC for beginners and integrator in this field. The book has definitions and explanations that will cover many interesting concepts in a clear manner. Altanai can be contacted at [email protected]. About the Reviewers Alessandro Arrichiello is a computer enthusiast. He graduated in Computer Engineering from the University of Naples Federico II, Italy. He has a passion for and knowledge of GNU/Linux systems that began at age of 14 and continues today. He is an independent Android developer, who develops apps for Google Play Store, and has strong knowledge of C++, Java, and other derivatives. He also has experience with many other interpreted languages such as Perl, PHP, and Python. Alessandro is a proud open source supporter and has given his contribution to many collaborative projects developed for academic purposes. Recently, he enriched his knowledge on Network Monitoring, focusing on Penetration Testing and Network Security in general. At the moment, Alessandro is working as a software engineer in the Communications and Media Solution group of Hewlett Packard in Milan, Italy. He's involved in many business projects as a developer and technology consultant. Alessandro has worked as a reviewer and author for Packt Publishing. He has technically reviewed the book, WebRTC Blueprints, and now, he's working on a video course on developing an application using the WebRTC technology. Pasquale Boemio fell in love with Linux and the open source philosophy at the age of 12. He has a Master's degree in Computer Engineering, and he works as a researcher at the Computer Engineering department of the University of Naples Federico II, Italy. At the same time, he collaborates with Meetecho (www.meetecho.com), experimenting with a large number of innovative technologies such as WebRTC, Docker, and Node.js. Even though Pasquale is involved in such activities, he still releases free software on GitHub (www.github.com/helloIAmPau). Antón Román Portabales is the CTO of Quobis. After graduating as a telecommunications engineer, he began working in Motorola as an IMS developer. In 2008, he left Motorola to join Quobis, a Spanish company focused on SIP interconnection. It works for major operators and companies in Europe and South America. In 2010, he finished a Pre-PhD program in Telematics Engineering as the main author of a paper about the use of IMS networks to transmit real-time data from the electrical grid; he presented this paper in an IEEE conference in 2011. He has been actively working on WebRTC since 2012, when Quobis decided to focus on this technology. He has recently got involved in the activities of IETF, along with other colleagues from Quobis. He also frequently participates in VoIP-related open source events. Andrii Sergiienko is an entrepreneur who's passionate about IT and also about travelling. He has lived in different places, such as Ukraine, Russia, Belarus, Mongolia, Buryatia, and Siberia, spending a considerable number of years in every place. He also likes to travel by an auto rickshaw. From his early childhood, Andrii was interested in computer programming and hardware. He took the first steps in this field more than 20 years ago. Andrii has experience in a wide set of languages and technologies, including C, C++, Java, Assembler, Erlang, JavaScript, PHP, Riak, shell scripting, computer networks, security, and so on. During his career, Andrii has worked for both small, local companies, such as domestic ISP; and large world corporations, such as Hewlett Packard. He also started his own companies; some of them were relatively successful, while others were a total failure. Today, Andrii is working on growing Oslikas, his company, headquartered in Estonia. The company is focused on modern IT technologies and solutions. They also develop a full-stack framework to create rich media WebRTC applications and services. You can find them athttp://www.oslikas.com . www.PacktPub.com Support files, eBooks, discount offers, and more You might want to visit www.PacktPub.com for support files and downloads related to your book. 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. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Chapter 1: Running WebRTC with and without SIP 7 JavaScript Session Establishment Protocol (JSEP) 7 Signal and media flows 8 Running WebRTC without SIP 10 Sending media over WebSockets 10 getUserMedia 10 RTCPeerConnection 12 RTCDataChannel 18 Media traversal in WebRTC clients 23 WebRTC through WebSocket signaling servers 24 Node.js 24 Making a peer-to-peer audio call using Node.js for signaling 26 Running WebRTC with SIP 32 Session Initiation Protocol (SIP) 32 JavaScript-based SIP libraries 36 Summary 37 Chapter 2: Making a Standalone WebRTC Communication Client 39 Description of the WebRTC client-server model 40 The sipML5 WebRTC client 41 Developing a minified webphone application using Tomcat 42 Developing our customized version of the sipML5 client 46 The jsSIP WebRTC client 49 Developing our version of the jsSIP client 50 SIP servers 53 SIP-WS to SIP-WS 55 SIP2SIP 56 OfficeSIP 57 SIP WS to SIP and vice-versa 58 The gateway to convert SIP over WebSocket to native SIP 59 The WebRTC2SIP gateway 59 Table of Contents The WebRTC client with Brekeke SIP server 64 The WebRTC client with the Kamailio SIP server 66 Limitations of the existing setup 74 Firewall and NAT issues 75 Media transcoding 75 Summary 79 Chapter 3: WebRTC with SIP and IMS 81 The Interaction with core IMS nodes 82 The Call Session Control Function 83 Home Subscriber System 83 The IP Multimedia Subsystem core 85 The OpenIMS Core 86 The Telecom server 96 The Mobicents Telecom Application Server 96 The Media Server 99 The FreeSWITCH Media Server 99 Media Services 103 WebRTC over firewalls and proxies 109 The final architecture for the WebRTC-to-IMS