• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A bare bones WebRTC video chat implementation

Simple WebRTC Demo

WebRTC is a peer to peer standard proposal from Google allowing browsers to connect directly and transfer information without a central server. This allows browsers to share raw data as well as audio/video.

This is a very simple video chat using WebRTC. I worked on it because I couldn't completely grok what was going on in apprtc.appspot.com - Google's canonical example. My version uses websockets instead of Google App Engine Channels, so you can see what the socket responses are doing, and I think the front end code is a bit simpler too.

Get It Running

git clone https://github.com/keithnorm/simple-webrtc-video-chat.git
cd simple-webrtc-vide-chat
npm install
./node_modules/coffee-script/bin/coffee app.coffee

Then open up two browser windows pointed to localhost:3002/room_name.

You should see something like this:

screenshot1

WebRTC in a nutshell

Firstly read through the article on HTML5 Rocks. Here are the steps to create a successful connection in high-level pseudo-code:

pc = new PeerConnection
ws = new WebSocket

// gets called when connection is complete
// this is when a remote peer can stream video 
// to your browser 
pc.onaddstream (event) ->
  remoteVid.src = event.stream

// local peer
pc.createOffer (description) ->
  pc.setLocalDescription(description)
  // over websockets
  ws.send description

ws.on 'create_offer', (data) ->
  // now this acts on a remote peer
  pc.setRemoteDescription(data)
  pc.createAnswer (description) ->
    pc.setLocalDescription(description)
    ws.send description

ws.on 'create_answer', (data) ->
  // back on local 
  pc.setRemoteDescription(data)

// called when handshake is complete
pc.onicecandidate = (event) ->
  // forward to remote
  ws.send event.candidate

ws.on 'ice_candidate', (data) ->
  pc.addIceCandidate(candidate)

So this song and dance is mainly complicated by the need to talk to the remote host via some transport method (websockets in this case). Check out public/javascripts/simple.js for an example of connecting two peers within the same browser window for an example of the PeerConnection API without the transport layer.

If you have any questions feel free to email me keithnorm@gmail.

More Repositories

1

Rubex

A simple copy cat of Rubular
JavaScript
31
star
2

VineStylee

Vine Style video recorder for iOS that saves to local Photos Library instead of the internet
Objective-C
23
star
3

SpainJS-Pipedream-Demo

A demo of a Backbone app that works on the client and server
JavaScript
22
star
4

Backbone-Extensions

some Rails inspired Backbone extensions
JavaScript
13
star
5

javascript-groupon-api-wrapper

Javascript wrapper for the Groupon API
JavaScript
10
star
6

jquery.keybinding.js

For binding events to key sequences, like Gmail
JavaScript
10
star
7

groupon-wordpress-widget

wordpress widgetized plugin version of groupon widget
JavaScript
8
star
8

jquery.truncate

truncate the innerHTML of elements
JavaScript
7
star
9

Protoquery

Some bridge code to aid in porting large applications from Prototype to jQuery
JavaScript
5
star
10

groupon-javascript-widget

nothing to see here
JavaScript
4
star
11

deku

description pending
Ruby
3
star
12

Arrrrdio

An Rdio app used to demo Backbone.js
JavaScript
3
star
13

name-pending-git-log-gui

A for-fun simple utility app for viewing git log data and file diffs
JavaScript
3
star
14

twitter_auth-with-mongo_mapper

some minor tweaks to the twitter_auth gem to make it work with mongo_mapper
Ruby
2
star
15

keithnorm

keithnorm
Ruby
2
star
16

Idea-Machine

infrantry stage of an idea gathering app
Ruby
2
star
17

WP-Asset-Packager

Rails style Javascript packager for Wordpress
PHP
1
star
18

Todo-app

just playing with JavascriptMVC and Sinatra
JavaScript
1
star
19

gifinabox

gifinabox.com
JavaScript
1
star
20

JSConsole

jQuery plugin to turn textareas into console prompts
JavaScript
1
star
21

ResponderChainTest

testing responder chain.. possible bug with UITableViewCell
Objective-C
1
star
22

jquery.behavior

A Lowpro like behavior method built on jQuery UI
JavaScript
1
star
23

Classy-langspec

Xcode langspec file for https://github.com/cloudkite/Classy
Shell
1
star