WebRTC makes building peer to peer real time web applications easier. First, we'll discuss in short what WebRTC is, how it works. Then we will explore ways to build the signalling system of a WebRTC app using Python.
This talk will first introduce the audience to WebRTC and then discuss about how to implement the server side logic of a WebRTC app using Python.
The main functions of WebRTC can be broadly categorized into three types.
- Access and acquire video and audio streams
- Establish a connection between peers and stream audio/video.
- Communicate arbitrary data.
- MediaStream (aka getUserMedia)
MediaStream API performs the task of accessing the webcam and/or microphone of the device and acquire the video and/or audio stream from them. RTCPeerConnection API establishes connection between peers and streams audio and video data. This API also does all the encoding and decoding of audio/video data. The third API, RTCDataChannel helps to communicate arbitrary data from one client to the other.
There will be short demos to demonstrate the functionalities of these APIs.
Signaling and Session Control
WebRTC uses RTCPeerConnection to communicate streaming data between browsers, but some sort of mechanism is needed to coordinate this communication and to send control messages. This process is known as signaling.
Signaling is used to exchange three types of information.
- Session control messages: to initialize or close communication and report errors.
- Network configuration: to the outside world, what's my computer's IP address and port?
- Media capabilities: what codecs and resolutions can be handled by my browser and the browser it wants to communicate with?
This can be implemented using any appropriate two way communication channel.
Implementing signaling in Python
Next, we will have a look at how to implement this signaling mechanism in Python. ( Demonstration with annotated code and live application.)
Google AppEngine and the Channel API
Flask and gevent
We'll implement the same signaling system again, this time on top of Flask using gevent for the persistent connection between the browser and our application.
Outline of the talk
Intro (5 min)
- Who are we?
- What is WebRTC?
- Functions of WebRTC.
WebRTC APIs and Demos (3 min)
- MediaStream (getUserMedia) API
- RTCPeerConnection API
- RTCDataChannel API
Signaling in WebRTC Applications (3 min)
- What is signaling?
- Why is it needed?
- How to implement it?
Implementation of signaling (16 min)
- Implementation using Google AppEngine and Channel API
- Implementation using Flask and gevent