UCIUROP2015 / UCI_OmletRTC

WebRTC app for Omlet chat
MIT License
15 stars 4 forks source link

OmletRTC project

WebRTC open source project enhancement and related integrated online service and product development at UC Irvine

Overview

OmletRTC provides you utilize WebRTC "getUserMedia" API into your code to make your idea be real. We focus on video communication between peers ─ namely video chatting. Now you can create your own service in Omlet Chat with OmletRTC easier and quickly

What is WebRTC?

alt img
WebRTC is a new webstandard being developed for peer-to-peer communication on the web. This means that browsers will be able to send information, without sending information through the server. Server side this will reduce load dramatically.

Currently the WebRTC standard is very focused on the video & audio aspects of the project. In the future (hopefully near future!) they will begin implementing the data channel, which will allow arbitrary data to be sent peer-to-peer. For now the WebRTC team is focused on stabalizing and optimizing the video and audio channels.

Unfortunately, a server (or two servers) will still be required for two reasons, The media for the page must be initially supplied, and the server, in conjunction with a STUN server, is required to synchronize the connections.

Why OmletRTC?

Using WebRTC for real-time communication, now we do not need a server for storage that usually costs much money as the service is getting bigger. However, it still needs a server for signals to handle user to connect one another. Setting a server is a big obstacle to apply WebRTC for trial or real-service on application market.

What Is Included ?

This release is composed of three components:

  1. Web server based on express for URL redirection
  2. HTML5 WebRTC application
  3. Omlet API for web apps

Device Support

Browser Support

Installation

 npm install omletrtc.io

Example code

Omlet

<script>
  // How to initialize documents information. For example,
  omletrtc.initConnection = function () {
    var info = {
      'id' : Omlet.getIdentity(),
      'numOfUser' : 0,
      'timestamp' : Date.now()
    };
    return info;
  };

  // How to update documents information
  // You can create, get and update documents using these function
  Omlet.document = {
    create: function(success, error),
    get: function(reference, success, error),
    update: function(reference, func, parameters, success, error),
    watch: function(reference, onUpdate, success, error),
    unwatch: function(reference, success, error)
  }

  // How to add message into documents
  // Function for parameter handling documentApi.update
  omletrtc.addMessage = function (old, parameters) {
    old.numOfUser = old.numOfUser + 1;
    old.timestamp = Date.now();
    return old;
  };

  // How to handle message
  omletrtc.handleMessage = function (doc) {
    if (doc.numOfUser > 2) return ;
    if (doc.id.name === Omlet.getIdentity().name) {
      log('[+] sender: ' + doc.id.name + ', receiver: ' + Omlet.getIdentity().name);
    }
  };
</script>

Client

<video id="localVideo" autoplay="autoplay"></video>
<video id="remoteVideo" autoplay="autoplay"></video>

<script src="https://github.com/UCIUROP2015/UCI_OmletRTC/raw/master/omletrtc.io.js"></script>
<script>
  navigator.getUserMedia(omletrtc.constraints, omletrtc.handleUserMedia, function (error) {
    log("[-] getUserMedia: " + error);
  });
</script>

Server

var omletrtc = require('omletrtc.io');
//then a bunch of callbacks are available

Reference

License

The MIT License. Please see the license file for more information.