Skip to content

Commit

Permalink
RTCMultiConnection-v1.3, bandwidth and direct messages
Browse files Browse the repository at this point in the history
You can send direct messages like this:

connection.userid = 'muazkh';
connection.channels['muazkh'].send('hello Muaz!');

You can set bandwidth like this:

connection.bandwidth = {
audio: 50,
video: 256
}

or directly:

connection.bandwidth.audio  =50;
connection.bandwidth.video  =256;

Merging #31 and implemented #33
  • Loading branch information
muaz-khan committed May 29, 2013
1 parent fc52c99 commit 6df6a55
Show file tree
Hide file tree
Showing 14 changed files with 1,000 additions and 949 deletions.
84 changes: 34 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#### Realtime working WebRTC Experiments and Demos
#### Realtime working [WebRTC Experiments and Demos](https://webrtc-experiment.appspot.com/)

It is a repository of uniquely experimented WebRTC demos; written by [Muaz Khan](https://twitter.com/muazkh); contributed by you and the community!
It is a repository of uniquely experimented WebRTC demos; written by [Muaz Khan](https://github.com/muaz-khan); contributed by you and the community!

No special requirement! Just Chrome or Firefox!
----

No special requirement! Just Chrome (for desktop and android) or Firefox!

----

These demos/experiments are entirely client-side; i.e. no server installation needed! (for basic webpages only!)

Expand All @@ -21,6 +25,15 @@ These demos/experiments are entirely client-side; i.e. no server installation ne

----

1. [DataChannel.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DataChannel) — A JavaScript library for data/file/text sharing!
2. [RTCMultiConnection.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection) — A JavaScript library for streams renegotiation and sharing; multi-session establishment and much more.
3. [RecordRTC.js](https://webrtc-experiment.appspot.com/RecordRTC/) — A library to record audio/video streams
4. [Pre-recorded media streaming](https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/) — Most demanded and useful feature!
5. [Socket.io over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) — Copy/Paste/Deploy and you're done!
6. [RTCall.js](https://webrtc-experiment.appspot.com/RRTCall/) — A library for Browser-to-Browser audio-only calling

----

#### Many-to-Many style of WebRTC Experiments

1. [Group video sharing / video-conferencing](https://webrtc-experiment.appspot.com/video-conferencing/)
Expand All @@ -47,13 +60,6 @@ These demos/experiments are entirely client-side; i.e. no server installation ne
1. [One-to-one WebRTC video chat using WebSocket](https://webrtc-experiment.appspot.com/websocket/)
2. [One-to-one WebRTC video chat using socket.io](https://webrtc-experiment.appspot.com/socket.io/)

| in-Page / One-Page / Client Side |
| ------------- |
| [Text chat using RTCDataChannel APIs](https://webrtc-experiment.appspot.com/demos/client-side-datachannel.html) |
| [Simple video chat](https://webrtc-experiment.appspot.com/demos/client-side.html) |
| [Sharing video - using socket.io for signaling](https://webrtc-experiment.appspot.com/demos/client-side-socket-io.html) |
| [Sharing video - using WebSockets for signaling](https://webrtc-experiment.appspot.com/demos/client-side-websocket.html) |

----

#### [Screen sharing](https://webrtc-experiment.appspot.com/#screen-sharing)
Expand All @@ -72,7 +78,7 @@ These demos/experiments are entirely client-side; i.e. no server installation ne

----

#### WebRTC Audio + Video Recording
#### WebRTC Audio/Video Recording

[RecordRTC: WebRTC audio/video recording](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RecordRTC) / [Demo](https://webrtc-experiment.appspot.com/RecordRTC/)

Expand Down Expand Up @@ -108,6 +114,15 @@ These demos/experiments are entirely client-side; i.e. no server installation ne

----

| in-Page / One-Page / Client Side |
| ------------- |
| [Text chat using RTCDataChannel APIs](https://webrtc-experiment.appspot.com/demos/client-side-datachannel.html) |
| [Simple video chat](https://webrtc-experiment.appspot.com/demos/client-side.html) |
| [Sharing video - using socket.io for signaling](https://webrtc-experiment.appspot.com/demos/client-side-socket-io.html) |
| [Sharing video - using WebSockets for signaling](https://webrtc-experiment.appspot.com/demos/client-side-websocket.html) |

----

#### Documents for newcomers/newbies/beginners

| A few documents for newbies and beginners |
Expand Down Expand Up @@ -153,13 +168,11 @@ channel.eject(userid); // throw a user out of your room!

```javascript
connection = new RTCMultiConnection();

connection.userid = 'muazkh';
connection.session = {
audio: true,
video: true
};

// get access to local or remote streams
connection.onstream = function (e) {
if (e.type === 'local') mainVideo.src = e.blobURL;
if (e.type === 'remote') document.body.appendChild(e.mediaElement);
Expand All @@ -173,13 +186,6 @@ connection.connect('session-id');
[button-init-session].onclick = function() {
connection.open('session-id');
};

// other features
connection.eject(userid); // throw a user out of your room!
connection.onleave = function(e) {
// e.userid
// e.extra
}
```

----
Expand All @@ -192,34 +198,12 @@ connection.onleave = function(e) {

```javascript
call = new RTCall();

// "onincomingcall" fires each time if someone calls you
call.onincomingcall = function(caller) {
call.receive(caller.receiverid);
};

// "oncustomer" is fired only for admin
// you can set admin like this:
// call.admin = true;
call.oncustomer = function(customer) {
call.call(customer.callerid);
};

// "onstream" returns you remote media stream
call.onstream = function(e) {
// e.stream ---- remote media stream object
// e.callerid ---- id of the remote person

audio = e.audio;
audio.play(); // "e.audio" object is paused by default
document.documentElement.appendChild(audio);
};

// initializing "RTCall" object
call.init();

// customers can call "admin" using his caller-id
call.call('admin-caller-id');
```

----
Expand All @@ -228,16 +212,16 @@ call.call('admin-caller-id');

```javascript
connection.openSignalingChannel = function(config) {
var URL = 'http://domain.com:8888/';
var channel = config.channel || this.channel || 'default-channel';
var sender = Math.round(Math.random() * 60535) + 5000;
URL = 'http://domain.com:8888/';
channel = config.channel || this.channel || 'default-channel';
sender = Math.round(Math.random() * 60535) + 5000;

io.connect(URL).emit('new-channel', {
channel: channel,
sender : sender
});

var socket = io.connect(URL + channel);
socket = io.connect(URL + channel);
socket.channel = channel;

socket.on('connect', function () {
Expand All @@ -263,8 +247,8 @@ Remember, You must link [firebase.js](https://cdn.firebase.com/v0/firebase.js) f

```javascript
openSignalingChannel: function (config) {
var channel = config.channel || this.channel || 'WebRTC-Experiment';
var socket = new Firebase('https://chat.firebaseIO.com/' + channel);
channel = config.channel || this.channel || 'WebRTC-Experiment';
socket = new Firebase('https://chat.firebaseIO.com/' + channel);
socket.channel = channel;
socket.on('child_added', function (data) {
config.onmessage && config.onmessage(data.val());
Expand Down Expand Up @@ -324,4 +308,4 @@ recorder.stopAudio(function(recordedFileURL) {

#### License

[WebRTC Experiments](https://github.com/muaz-khan/WebRTC-Experiment) are released under [MIT licence](https://webrtc-experiment.appspot.com/licence/) . Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).
[WebRTC Experiments](https://webrtc-experiment.appspot.com/) are released under [MIT licence](https://webrtc-experiment.appspot.com/licence/) . Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).
84 changes: 74 additions & 10 deletions RTCMultiConnection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ This document is for [RTCMultiConnection-v1.3](https://webrtc-experiment.appspot
#### Second Step: Start using it!

```javascript
var connection = new RTCMultiConnection();

connection = new RTCMultiConnection();
connection.userid = 'muazkh'; // username or user-id!
connection.session = {
audio: true,
video: true
Expand Down Expand Up @@ -217,6 +217,14 @@ connection.onmessage = function (e) {
}
```

### Direct Messages

You can share data directly between two unique users using their user-ids:

```javascript
connection.channels['user-id'].send(file || data || 'text');
```

#### Progress helpers when sharing files

```javascript
Expand Down Expand Up @@ -364,20 +372,76 @@ connection.attachStream = MediaStream;

----

#### Use [your own](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) socket.io over node.js for signaling
#### Broadcasting/Conferencing/etc.

Three possible scenarios are supported:

1. One-to-Many `one-way` broadcasting
2. One-to-Many `two-way` broadcasting
3. Many-to-Many `video-conferencing`

For one-way broadcasting

```javascript
connection.stream = {
oneway: true,
screen: true
};
```

For two-way broadcasting

```javascript
connection.stream = {
broadcast: true,
audio: true
};
```

For video-conferencing; don't use `oneway` or `broadcast` values:

```javascript
connection.stream = {
audio: true,
video: true
};
```

----

#### Bandwidth

You can set bandwidth for both outgoing audio/video streams.

```javascript
connection.bandwidth = {
audio: 50,
video: 256
};

// or change them individually
connection.bandwidth.audio = 50;
connection.bandwidth.video = 256;
```

Default audio bandwidth is `50` and default video bandwidth is `256`.

----

#### Use your own [socket.io over node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) for signaling

```javascript
openSignalingChannel: function(config) {
var URL = 'http://domain.com:8888/';
var channel = config.channel || this.channel || 'Default-Socket';
var sender = Math.round(Math.random() * 60535) + 5000;
URL = 'http://domain.com:8888/';
channel = config.channel || this.channel || 'Default-Socket';
sender = Math.round(Math.random() * 60535) + 5000;

io.connect(URL).emit('new-channel', {
channel: channel,
sender : sender
});

var socket = io.connect(URL + channel);
socket = io.connect(URL + channel);
socket.channel = channel;

socket.on('connect', function () {
Expand All @@ -395,13 +459,13 @@ openSignalingChannel: function(config) {
}
```

For a ready-made socket.io over node.js implementation; [visit this link](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs).
For a `ready-made` socket.io over node.js implementation; [visit this link](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs).

----

#### Browser Support

[RTCMultiConnection.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection) supports following browsers:
[RTCMultiConnection.js](https://webrtc-experiment.appspot.com/#RTCMultiConnection) supports following browsers:

| Browser | Support |
| ------------- |:-------------|
Expand All @@ -414,4 +478,4 @@ For a ready-made socket.io over node.js implementation; [visit this link](https:

#### License

[RTCMultiConnection.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection) is released under [MIT licence](https://webrtc-experiment.appspot.com/licence/) . Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).
[RTCMultiConnection.js](https://webrtc-experiment.appspot.com/#RTCMultiConnection) is released under [MIT licence](https://webrtc-experiment.appspot.com/licence/) . Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).
Loading

0 comments on commit 6df6a55

Please sign in to comment.