Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Getting Started with WebRTC
Getting Started with WebRTC

Getting Started with WebRTC: If you have basic HTML and JavaScript, you're well on the way to adding real time, peer-to-peer communication to your web applications using WebRTC. This book shows you how through a totally practical, structured course.

eBook
₱1056.99 ₱1510.99
Paperback
₱1887.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Getting Started with WebRTC

Chapter 2. A More Technical Introduction to Web-based Real-Time Communication

This chapter introduces you to the technical concepts behind the new Web-based Real-Time Communication (WebRTC) standards. After reading this chapter, you will have a clear understanding of the following topics:

  • How to set up peer-to-peer communication

  • The signaling options available

  • How the key APIs relate to each other

Setting up communication


Although the basis of WebRTC communication is peer-to-peer, the initial step of setting up this communication requires some sort of coordination. This is most commonly provided by a web server and/or a signaling server. This enables two or more WebRTC capable devices or peers to find each other, exchange contact details, negotiate a session that defines how they will communicate, and then finally establish the direct peer-to-peer streams of media that flows between them.

The general flow

There are a wide range of scenarios, ranging from single web page demos running on a single device to complex distributed multi-party conferencing with a combination of media relays and archiving services. To get started, we will focus on the most common flow, which covers two web browsers using WebRTC to set up a simple video call between them.

Following is the summary of this flow:

  • Connect users

  • Start signals

  • Find candidates

  • Negotiate media sessions

  • Start RTCPeerConnection streams

Connect...

MediaStream API


The MediaStream API is designed to allow you to access streams of media from local input devices, such as cameras and microphones. It was initially focused upon the getUserMedia API or gUM for short, but has now been formalized as the broader media capture and streams API, or MediaStream API for short. However, the getUserMedia() method is still the primary way to initiate access to local input devices.

Each MediaStream object can contain a number of different MediaStreamTrack objects that each represents different input media, such as video or audio from different input sources.

Each MediaStreamTrack can then contain multiple channels (for example, the left and right audio channels). These channels are the smallest units that are defined by the MediaStream API.

MediaStream objects can then be output in two key ways. First, they can be used to render output into a MediaElement such as a <video> or <audio> element (although the latter may require pre-processing...

RTCPeerConnection API


The RTCPeerConnection API is the heart of the peer-to-peer connection between each of the WebRTC enabled browsers or peers. To create an RTCPeerConnection object, you use the var peerconnection = RTCPeerConnection(configuration); constructor. The configuration variable contains at least one key named iceServers, which is an array of URL objects that contain information about STUN, and possibly TURN servers, used during the finding candidates phase.

The peerconnection object is then used in slightly different ways on each client, depending upon whether you are the caller or the callee.

The caller's flow

Here's a summary of the caller's flow after the peerconnection object is created:

  • Register the onicecandidate handler

  • Register the onaddstream handler

  • Register the message handler

  • Use getUserMedia to access the local camera

  • The JSEP offer/answer process

Register the onicecandidate handler

First, you register an onicecandidate handler that sends any ICE candidates to the other peer...

RTCDataChannel API


As well as sending media streams between peers using WebRTC, it is also possible to use the DataChannel API to send arbitrary streams of data. Although many people commonly refer to this as the RTCDataChannel API, it is more accurately defined as just the WebRTC DataChannel API and is created by using the var datachannel = peerconnection.createDataChannel(label); constructor. It is a very flexible and powerful solution that has been specifically designed to be similar to the WebSocket API through the send() method and the onmessage event.

At the time of writing this chapter, this API is still in a state of flux with the varying browser implementations still struggling with standardization.

Summary


You should now have a clear overview of the various APIs and protocols that combine to make WebRTC work.

Throughout the rest of the book, we will explore the MediaStream, RTCPeerConnection, and RTCDataChannel APIs in more detail as we work to apply these concepts to real world examples.

First, we will start by fleshing out the simple peer-to-peer video call scenario into a fully working application.

Then, we will explore how this can be simplified down to just an audio only call or extended with text-based chat and file sharing.

And then, we will explore two real-world application scenarios based upon e-learning and team communication.

Left arrow icon Right arrow icon

Key benefits

  • Set up video calls easily with a low bandwidth audio only option using WebRTC
  • Extend your application using real-time text-based chat, and collaborate easily by adding real-time drag-and-drop file sharing
  • Create your own fully working WebRTC application in minutes

Description

WebRTC delivers web-based real-time communication and is set to revolutionize our view of what the Web really is. Streaming audio and video from browser to browser, as well as opening raw access to the camera and microphone, is already creating a whole new dynamic web. WebRTC also introduces real-time data channels that will allow interaction with dynamic data feeds from sensors and other devices. This really is a great time to be a web developer! Getting Started with WebRTC provides all of the practical information you need to quickly understand what WebRTC is, how it works, and how you can add it to your own web applications. It includes clear working examples designed to help you get started building your own WebRTC-enabled applications right away. Getting Started with WebRTC will guide you through the process of creating your own WebRTC application that can be applied in a number of different real-world situations, using well documented and clearly explained code examples. You will learn how to quickly and easily create a practical peer-to-peer video chat application, an audio only call option, and how a Web-Socket-based signaling server can also be used to enable real-time text-based chat. You will also be shown how this same server and application structure can easily be extended to include simple drag-and-drop file sharing with transfer updates and thumbnail previews.

Who is this book for?

This book is ideal for developers new to the WebRTC standards who are interested in adding sensor-driven, real-time, peer-to-peer communication to their web applications. You will only need basic experience with HTML and JavaScript.

What you will learn

  • Discover how to offer an audio only option as an alternative
  • Create an extensible Web Socket signaling server
  • Detect which browsers support WebRTC
  • Extend your application with real-time text-based chat
  • Add rich collaboration with drag-and-drop file sharing
  • Use RTCDataChannels to share real-time data
  • Design a state-based user interface for WebRTC apps
  • Explore the options available for image and audio post-processing and analysis

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 25, 2013
Length: 114 pages
Edition : 1st
Language : English
ISBN-13 : 9781782166306
Vendor :
Node.js Developers
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 25, 2013
Length: 114 pages
Edition : 1st
Language : English
ISBN-13 : 9781782166306
Vendor :
Node.js Developers
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 4,235.98
Getting Started with WebRTC
₱1887.99
WebRTC Blueprints
₱2347.99
Total 4,235.98 Stars icon

Table of Contents

8 Chapters
An Introduction to Web-based Real-Time Communication Chevron down icon Chevron up icon
A More Technical Introduction to Web-based Real-Time Communication Chevron down icon Chevron up icon
Creating a Real-time Video Call Chevron down icon Chevron up icon
Creating an Audio Only Call Chevron down icon Chevron up icon
Adding Text-based Chat Chevron down icon Chevron up icon
Adding File Sharing Chevron down icon Chevron up icon
Example Application 1 – Education and E-learning Chevron down icon Chevron up icon
Example Application 2 – Team Communication Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(12 Ratings)
5 star 66.7%
4 star 16.7%
3 star 0%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




George Chen Mar 02, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A good introduction for WebRTC.If you are new to the WebRTC, you should try it to get some useful knowledge.
Amazon Verified review Amazon
nacho Dec 04, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book makes a first introduction to WebRTC in a very general way, easy to understand for everyone.After this part, more technical details have been compiled so it also gives you a general overview of how a communication using WebRTC technology works and how to build your own service. The level of details in this part of the book I think is quite good for beginners.Finally, two scenarios are described in detail so the advantages of using WebRTC are shown. I really appreciate the sections highlighting the potential issues to be taken under account for each of the scenarios.As other user commented, I wish I could have had this book some months ago. Nevertheless, I would recommend it to anyone getting into WebRTC.
Amazon Verified review Amazon
Junaid Kirkire Apr 17, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great for programmers who want a hands-on introduction to WebRTC.
Amazon Verified review Amazon
Kader Khan Dec 22, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Hi,I am not a developer since more than 10 years now. However I was curious to understand the basics of WebRTC from developer perpective. There were lot of resources in internet however was not clear enough to get started and as well to understand the whole picture.I read the "Getting Started with WebRTC" book, and i can say this book is well structured for the starters and leads to a way to advanced programming left to the one skills and imagination. The best part is the example working code and the clear exlanation is exemplenary.I for sure recommend this book for all individuals who needs to understand and excel in thier WebRTC world of Career.Best Regards,Kader.
Amazon Verified review Amazon
Peter C Salerno Nov 04, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book "Getting Started with WebRTC" by Rob Manson ( [...] )is an easy to understand introduction to building WebRTC applications. It is a good investment for anyone wanting to build the next generation of social networking services. The book can be view as having three sections: top-level, basic cookbook, and conciderations for advanced use cases.The first chapters cover the top-level information. Chapter 1 is a general introduction including a bit of the the why and who of WebRTC. Chapter 2 goes into the overall technical architecture. The information is organized and accurate, but it could benefit from a diagram or two to illustrate the text.Chapters 3 to 6 provide a cookbook approach. Starting with basic video and audio applications. There is an interesting twist where he adds a chatroulette feature to the application. Then the application is rounded out by adding in text chat and filesharing. Adding to the value of the bbok, the code for these chapters is available for download.The last two chapters focus on applying WebRTC in E-learning and Team Communication use-cases. Rob discusses consideration of the users and the network. Privacy, security and network adminstraion issues are rasied.Overall this is a very good book to get you started with WebRTC.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.