20
Video Conference Our goal is to make a Video Conference system in our solution such that developers can communicate with each other. Therefore, we first try the most common solution which is using flash player at the client side and streaming server at the server side.

video conference (peer to peer)

Embed Size (px)

DESCRIPTION

how to make a peer to peer video conference system using webRTC APIS

Citation preview

Page 1: video conference (peer to peer)

Video Conference Our goal is to make a Video Conference system in our solution such that developers can communicate with each other. Therefore, we first try the most common solution which is using flash player at the client side and streaming server at the server side.

Page 2: video conference (peer to peer)

OpenTokOne of the famous platforms that implement

this architecture is OpenTok which allows developers to integrate live, face-to-face video directly into their own website.

However, OpenTok is not free and very expensive to use it inside a social network that may contain thousands of users.

Page 3: video conference (peer to peer)

Streaming server vs peer to peerTherefore, we think about building our own

system but the problem was that streaming server is very expensive too.

We try to found a peer-to-peer solution without a streaming server so that each browser can send and receive stream from other browser peer to peer so we can save the cost of using expensive streaming server.

Page 4: video conference (peer to peer)

WebRTC (Real Time communication)WebRTC has implemented three APIs

◦ 1. MediaStream API (getUserMedia) ◦ 2. RTCPeerConnection ◦ 3. RTCDataChanal

Page 5: video conference (peer to peer)

MediaStream API (getUserMedia)

getUserMedia is available in Chrome, Opera and Firefox Nightly/Aurora and can be used in Internet Explorer using Chromo Frame plugin.

the getuserMedia API is responsible for access the camera and microphone .presents synchronized streams of media.

For example, a stream taken from camera and microphone input has synchronized

video and audio tracks.

Page 6: video conference (peer to peer)

The getUserMedia() method takes three parameters: ◦ 1. Constraints object. ◦ 2. A success callback which, if called, is

passed a LocalMediaStream. ◦ 3. A failure callback which, if called, is

passed an error object.

Page 7: video conference (peer to peer)

Here is some sample code

Page 8: video conference (peer to peer)

Signaling: Session Control, Network and Media Information

WebRTC uses RTCPeerConnection to communicate streaming data between browsers (peers), but also needs a mechanism to coordinate communication and to send control messages, a process known as signaling.

Page 9: video conference (peer to peer)
Page 10: video conference (peer to peer)

1-First choice is to use XHR and the Channel

API as the signaling mechanism (google app engine) and this is the easy way and most common used but it is not free and you have to pay to use this service.

2-Second choice is to implement signaling mechanism on your server using websockets

Page 11: video conference (peer to peer)

WebSockets using node.jsNode.js is a platform built on Chrome's

JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Node.js is used to run JavaScript without a browser so you can use it to create a server

side application and create WebSockets.

Page 12: video conference (peer to peer)

Implemetation of WebSockets

java Node.js

pro - A multi-threaded language. - It is an old language, have a good community and there are many resources on the internet. - It is a strong typed language with can save a lot of error and java good IDEs.

- It is built completely on asynchronous callback architecture when it receive a request it execute it in a callback function asynchronous on another thread so we create thread only when we execute callback function not for every connection like java.

con It is a multithread language and every connection to a WebSocket will need a thread this will need a high performance server.

- Node.js use JavaScript which is not strong typed language which can cause a lot of errors. - Very difficult to debug.

Page 13: video conference (peer to peer)

Our decisionWe decided to use node.js platform because

it is very efficient and doesn’t need a high performance server so we can save the costs.

Page 14: video conference (peer to peer)

ScenarioStep 1: Each user connect to a socket on the

server using socket.io API.

Page 15: video conference (peer to peer)

Step 2: We need to add some data in sockets

at the server side so we can identify who is connected on the server, who is online, and busy.

Socket is JSON object we add the following data to it

1-Socket.devos.username=null; 2-Socket.devos.reciever=null; 3-Socket.devos.status=0;

Page 16: video conference (peer to peer)
Page 17: video conference (peer to peer)

Step 3: 1. If we want to send a message to a user you

have to add some header data which are the sender user_id and the receiver user_id so at the server read the message and search to the reciever socket by user_id and forward the message to the receiving user.

2. assume that browser 1 is Alice and browser 2 is Bob .Alice want to make a video call with Bob so she first send a message that contain her user_id as a sender and Bob user_id as a receiver and type of the message is call_request.

3. Then Bob response with a message contain his user_id as a sender and Alice user_id as a receiver and message type call_response and action is accept

Page 18: video conference (peer to peer)
Page 19: video conference (peer to peer)

Step 4: After Alice receive Bob response 1. she create a peer connection and create and offer and send

it to Bob as session description which contain information about the video format and other data.

2. Bob receive the session description offer and create a peer connection and add the remote session description to the peer connection and then create and answer as session description and send it back to Alice.

3. Bob use the ice server framework, which used in webRTC peer connection API to get the shortest path to Alice and send here his IP and port number as message called candidate message.

4. Alice receive the answer session description and add it as a remote session on her peer connection.

5. Alice use the ice server framework which used in webRTC peer connection API to get the shortest path to Bob and send here his IP and port number as message called candidate message.

6. Peer connection complete setup after both of them receive the candidate message the a stream flow peer to peer between them.

Page 20: video conference (peer to peer)