Node.Js Come Into the Picture
Total Page:16
File Type:pdf, Size:1020Kb
WebRTC Integrator's Guide Altanai Chapter No. 1 "Running WebRTC with and without SIP" In this package, you will find: The author’s biography A preview chapter from the book, Chapter no.1 "Running WebRTC with and without SIP" A synopsis of the book’s content Information on where to buy this book 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]. For More Information: www.packtpub.com/web-development/webrtc-integrators-guide WebRTC Integrator's Guide WebRTC Integrator's Guide is a deep dive into the world of real-time telecommunication and its integration with the telecom network. This book covers a wide range of WebRTC solutions, such as GSM, PSTN, and IMS, designed for specific network requirement. It also addresses the implementation woes by describing every minute detail of the WebRTC platform setup from the APIs to the architecture, code-to-server installations, RCS-to-Codec interoperability, and much more. It also describes various enterprise-based use cases that can be built around WebRTC. What This Book Covers Chapter 1, Running WebRTC with and without SIP, is a quick brush-up of WebRTC basics such as Media APIs. It also describes the use of plain WebSocket signaling to deliver WebRTC-based browser-to-browser communication. Chapter 2, Making a Standalone WebRTC Communication Client, talks about the use of the Session Initiation Protocol (SIP) as the signaling mechanism for WebRTC. It describes the setup of the SIP server for this purpose. Chapter 3, WebRTC with SIP and IMS, outlines the interaction of a SIP-based WebRTC client with the IP Multimedia Subsystem (IMS). Chapter 4, WebRTC Integration with Intelligent Network, describes the ways in which WebRTC can be made interoperable with mobile phones, as the majority of mobile communications today are still on GSM under the IN model. Chapter 5, WebRTC Integration with PSTN, describes the backward compatibility of the WebRTC technology to the old, fixed-line telephones. Chapter 6, Basic Features of WebRTC over SIP, describes the basic WebRTC SIP services such as audio/video call, messaging, call transfer, call hold/resume, and others. Chapter 7, WebRTC with Industry Standard Frameworks, discusses the development of the WebRTC client over the industry-adopted framework (that is, Model- View-Controller). For More Information: www.packtpub.com/web-development/webrtc-integrators-guide Chapter 8, WebRTC and Rich Communication Services, discusses how RCS enriches the communication technology with features such as file transfer, Presence, phonebook, and others. Chapter 9, Native SIP Application and Interaction with WebRTC Clients, addresses a very important concern, that is, the WebRTC interoperability with other SIP endpoints such as desktop clients, SIP hardphones, and mobile-based SIP applications. Chapter 10, Other WebRTC Use Cases, presents an interesting array of WebRTC use cases that are both innovative and practical with the current WebRTC standards. For More Information: www.packtpub.com/web-development/webrtc-integrators-guide Running WebRTC with and without SIP WebRTC lets us make calls right from a web page without any plugin. This was made possible using media APIs of the browser to fetch user media, WebSocket for transportation, and HTML5 to render the media on the web page. Thus, WebRTC is an evolved form of WebSocket communication. WebSocket is a Transport Layer protocol that carries data. The WebSocket API is an Application Programming Interface (API) that enables web pages to use the WebSocket protocol for (duplex) communication with a remote host. In this chapter, we will study how WebRTC really works. We will also demonstrate the use of WebRTC media APIs to capture and render input from a user's microphone and camera onto a web page. In the later part of chapter, we will fi nd out how to build a simple standalone WebRTC client using the plain WebSocket protocol as the signaling mechanism. JavaScript Session Establishment Protocol (JSEP) The communication model between a client and remote host is based on the JSEP architecture, which differentiates the signaling and media transaction into different layers. For More Information: www.packtpub.com/web-development/webrtc-integrators-guide Running WebRTC with and without SIP The differentiation is shown in the following fi gure: WebRTC: JSEP Approach Signaling vs Media Network Signaling Signaling App App App SessionDescription SessionDescription WebRTC Browser Browser Media Caller Callee JSEP signaling and media As an example, let's consider two peers, A and B, where A initiates communication with B. Initially, in the fi rst case, A being the offerer will have to call the createOffer function to begin a session. A also mentions details such as codecs through a setLocalDescription function, which sets up its local confi g. The remote party, B, reads the offer and stores it using the setRemoteDescription function. The remote party, B, calls the createAnswer function to generate an appropriate answer, applies it using the setLocalDescription function, and sends the answer back to the initiator over the signaling channel. When A gets the answer, it also stores it using the setRemoteDescription function, and the initial setup is complete. This is repeated for multiple offers and answers. The latest on JSEP specifi cations can be read from the Internet Engineering Task Force (IETF) site at http://datatracker. ietf.org/doc/draft-ietf-rtcweb-jsep/. Signal and media fl ows The differentiation between signal and media fl ows is an important aspect of the WebRTC call setup. The signaling mechanism can be any among HTTP/REST, JavaScript Object Notation (JSON) via XMLHttpRequest (XHR), Session Initiation Protocol (SIP) over websockets, XMPP, or any custom or proprietary protocol. The media (audio/video) is defi ned through the Session Description Protocol (SDP) and fl ows from peer to peer. [ 8 ] For More Information: www.packtpub.com/web-development/webrtc-integrators-guide Chapter 1 A few instances of end-to-end signaling and media fl ow variants are shown in the following screenshot: JSONvia XMLHttpRequest Network JSONvia XMLHttpRequest Signaling Signaling App App App SessionDescription SessionDescription WebRTC RTP Browser Browser Media Caller Callee websocket subprotocol JSON XMR The preceding fi gure depicts signaling over the WebRTC API in the JSON format via XHR. Now, the following fi gure depicts signaling over the WebRTC API in eXtensible Messaging and Presence Protocol (XMPP): XMPP Network XMPP Signaling Signaling App App App SessionDescription SessionDescription WebRTC Browser Browser Media Caller Callee eXtensible Messaging and Presence Protocol (XMPP) [ 9 ] For More Information: www.packtpub.com/web-development/webrtc-integrators-guide Running WebRTC with and without SIP While it's very popular to use the WebRTC API with SIP support through JavaScript libraries such as JSSIP, SIPML5, PJSIP, and so on, these libraries cater to the SIP/IMS (IP Multimedia Subsystem) world and are not mandatory for setting up enterprise-level WebRTC Infrastructure. In fact, it is a misconception that WebRTC is coupled with SIP in itself; it isn't. IP Multimedia System (IMS) is part of the Next Generation Network (NGN) model for IP-based communication. Running WebRTC without SIP HTML5 websockets can be defi ned by ws:// followed by the URL in the server fi eld while readying a WebRTC client for registration. This enables bidirectional, duplex communications with server-side processes, that is, server-side push events to the client. It also enables the handshake after sharing media metadata such as ports, codecs, and so on. It should be noted that WebRTC works in an offer/answer mode and has ways of traversing the Network Address Translation (NAT) and fi rewalls by means of Interactive Connectivity Establishment (ICE). ICE makes use of the Session Traversal Utilities for NAT (STUN) protocol and its extension, Traversal Using Relay NAT (TURN). This is covered later in the chapter. Sending media over WebSockets WebRTC mainly comprises three operations: fetching user media from a camera/microphone, transmitting media over a channel, and sending messages over the channel. Now, let's take a look at the summarized description of every operation type. getUserMedia The JavaScript getUserMedia function (also known as MediaStream) is used to allow the web page to access users' media devices such as camera and microphone using the browser's native API, without the need of any other third-party plugins such as Adobe Flash and Microsoft Silverlight. [ 10 ] For More Information: www.packtpub.com/web-development/webrtc-integrators-guide