This document discusses WebRTC and how it can be used with Sencha and Ext JS. It provides an overview of WebRTC, including what it is, its key features such as media streams and peer connections, and how it enables real-time communication directly in the browser. It also covers related concepts like NAT traversal using STUN, TURN, and ICE and provides code examples for setting up a basic WebRTC video call between two peers.
14. What is
WebRTC ?
A new
communication
Platform
Open Source
Javascript API
that enables
Real Time
Communication
(RTC)
Monday, September 23, 13
15. The need for WebRTC
•Reduce infrastructure
requirements
•Need for speed & quality
•Live streaming & data
transfers
•Easy Video/Audio chat
sessions
Monday, September 23, 13
17. Advantages
• Higher performance
• No server latency
• Less server-side infrastructure
• Easy to implement
• Privacy & Security
• No browser plugins needed
Monday, September 23, 13
18. Disadvantages
• Not fully implemented yet
• Specification still in Draft
• Cross-browser support very limited & requires
polyfill
• Broadcast activity implementation becomes
much more complex & quirky
• Data persistency
Monday, September 23, 13
19. Browser Compatibility
• PC
• Google Chrome 23
• Mozilla Firefox 22
• Mobile - only Android for the moment
• Google Chrome 28 (Enabled by default
since 29)
• Mozilla Firefox 24
• Bowser (Ericsson Labs)
Monday, September 23, 13
31. Peer Connection
//Config peer connection & add stream
PeerConnection(config, iceCallback);
addStream(stream);
//Create the local session description& apply it
createOffer(args);
setLocalDescription(type, desc);
startIce();
.
.
.
--- wait for the Callee to respond ---
.
.
.
//Got the Remote description
setRemoteDescription(type, desc);
-- Receive the call from caller --
//Create Peer connection & set description
PeerConnection(config, iceCallback);
setRemoteDescription(type, desc);
//Create local session desc & apply it
createAnswer(args);
setLocalDescription(type, desc);
startIce();
Caller CalleeTimeline
Monday, September 23, 13
32. How does communication work?
• Connections to remote peers are established using NAT-traversal
technologies such as ICE, STUN, and TURN.
• NAT - network address translation
• ICE - Interactive Connectivity Establishment
• STUN - Session Traversal Utilities for NAT
• TURN - Traversal Using Relays around NAT
• Sending the locally-produced streams to remote peers and receiving
streams from remote peers.
• Sending arbitrary data directly to remote peers.
Monday, September 23, 13
33. NAT (Network Address Translation)
• The process of modifying IP address
information into IPv4 Headers while in transit
across a traffic routing device (address:port)
Monday, September 23, 13
34. ICE (Interactive Connectivity
Establishment)
• The protocol used by NAT Traversal to create Offer/Answer Protocols.
• Uses STUN or TURN protocols
• Usage:
• Internet applications of Voice over Internet Protocol (VoIP)
• p2p communications
• video, instant messaging(chats) and other interactive media
• NAT transversal is an important component to facilitate communications
involving hosts on private networks, often located behind firewalls.
Monday, September 23, 13
35. STUN (Session Traversal Utilities for
NAT)
• It is a client-server protocol
• Returns the public IP to a client + information
from which the client can infer the type of
NAT it sits behind.
• Used to permit NAT transversal for
applications.
• Intended to be a tool to be used by other
protocols such as ICE (previous slide)
Monday, September 23, 13
36. TURN (Traversal Using Relays around
NAT )
• Places a third party server to relay messages between
two clients where peer to peer media traffic is not
allowed by a firewall.
• Turns the tables so that the client on the inside can be
on the receiving end, rather than the sending end, of a
connection that is requested by the client.
• Provides the same security functions provided by
symmetric NATs and firewalls
Monday, September 23, 13
42. Multiple Peers
• Mesh
• Chrome has hard limit of 256 peer connections
• Maximum bandwidth used by each video RTP port (media-track) is
about 1MB by default though we can force lower quality
• sdp = sdp.replace( /a=mid:videorn/g , 'a=mid:videor
nb=AS:256rn'); // Cap outgoing bandwidth at 256Kb/s
• Repeater
Monday, September 23, 13
43. Sample Multi Peer Flow
callUser(userId)
onAcceptCall
initiateVideoCall
createRoom
-- Create PeerConnection, query local media,
attach stream & become marked as
broadcaster --
-- Invite 2nd Peer --
-- Repeat above flow minus createRoom --
-- Once 2+ peer video begin streaming --
announceNewParticipant(room)
---- Peer #1 ----
onIncomingCall
acceptCall
onInitiateVideoCall
-- Create PeerConnection, query local media
& attach stream --
---- Peer #2 ----
-- Repeat above flow --
---- Peer #1 ----
onNewParticipant
-- Create another PeerConnection instance,
establish separate signaling channel & begin
exchanging SDP, attach local stream to new
Peer --
Caller CalleeTimeline
Monday, September 23, 13