Skip to content

Commit 6df6a55

Browse files
committed
RTCMultiConnection-v1.3, bandwidth and direct messages
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 muaz-khan#31 and implemented muaz-khan#33
1 parent fc52c99 commit 6df6a55

File tree

14 files changed

+1000
-949
lines changed

14 files changed

+1000
-949
lines changed

README.md

+34-50
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
#### Realtime working WebRTC Experiments and Demos
1+
#### Realtime working [WebRTC Experiments and Demos](https://webrtc-experiment.appspot.com/)
22

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

5-
No special requirement! Just Chrome or Firefox!
5+
----
6+
7+
No special requirement! Just Chrome (for desktop and android) or Firefox!
8+
9+
----
610

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

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

2226
----
2327

28+
1. [DataChannel.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DataChannel) — A JavaScript library for data/file/text sharing!
29+
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.
30+
3. [RecordRTC.js](https://webrtc-experiment.appspot.com/RecordRTC/) — A library to record audio/video streams
31+
4. [Pre-recorded media streaming](https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/) — Most demanded and useful feature!
32+
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!
33+
6. [RTCall.js](https://webrtc-experiment.appspot.com/RRTCall/) — A library for Browser-to-Browser audio-only calling
34+
35+
----
36+
2437
#### Many-to-Many style of WebRTC Experiments
2538

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

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

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

7379
----
7480

75-
#### WebRTC Audio + Video Recording
81+
#### WebRTC Audio/Video Recording
7682

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

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

109115
----
110116

117+
| in-Page / One-Page / Client Side |
118+
| ------------- |
119+
| [Text chat using RTCDataChannel APIs](https://webrtc-experiment.appspot.com/demos/client-side-datachannel.html) |
120+
| [Simple video chat](https://webrtc-experiment.appspot.com/demos/client-side.html) |
121+
| [Sharing video - using socket.io for signaling](https://webrtc-experiment.appspot.com/demos/client-side-socket-io.html) |
122+
| [Sharing video - using WebSockets for signaling](https://webrtc-experiment.appspot.com/demos/client-side-websocket.html) |
123+
124+
----
125+
111126
#### Documents for newcomers/newbies/beginners
112127

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

154169
```javascript
155170
connection = new RTCMultiConnection();
156-
171+
connection.userid = 'muazkh';
157172
connection.session = {
158173
audio: true,
159174
video: true
160175
};
161-
162-
// get access to local or remote streams
163176
connection.onstream = function (e) {
164177
if (e.type === 'local') mainVideo.src = e.blobURL;
165178
if (e.type === 'remote') document.body.appendChild(e.mediaElement);
@@ -173,13 +186,6 @@ connection.connect('session-id');
173186
[button-init-session].onclick = function() {
174187
connection.open('session-id');
175188
};
176-
177-
// other features
178-
connection.eject(userid); // throw a user out of your room!
179-
connection.onleave = function(e) {
180-
// e.userid
181-
// e.extra
182-
}
183189
```
184190

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

193199
```javascript
194200
call = new RTCall();
195-
196-
// "onincomingcall" fires each time if someone calls you
197201
call.onincomingcall = function(caller) {
198202
call.receive(caller.receiverid);
199203
};
200-
201-
// "oncustomer" is fired only for admin
202-
// you can set admin like this:
203-
// call.admin = true;
204204
call.oncustomer = function(customer) {
205205
call.call(customer.callerid);
206206
};
207-
208-
// "onstream" returns you remote media stream
209-
call.onstream = function(e) {
210-
// e.stream ---- remote media stream object
211-
// e.callerid ---- id of the remote person
212-
213-
audio = e.audio;
214-
audio.play(); // "e.audio" object is paused by default
215-
document.documentElement.appendChild(audio);
216-
};
217-
218-
// initializing "RTCall" object
219-
call.init();
220-
221-
// customers can call "admin" using his caller-id
222-
call.call('admin-caller-id');
223207
```
224208

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

229213
```javascript
230214
connection.openSignalingChannel = function(config) {
231-
var URL = 'http://domain.com:8888/';
232-
var channel = config.channel || this.channel || 'default-channel';
233-
var sender = Math.round(Math.random() * 60535) + 5000;
215+
URL = 'http://domain.com:8888/';
216+
channel = config.channel || this.channel || 'default-channel';
217+
sender = Math.round(Math.random() * 60535) + 5000;
234218

235219
io.connect(URL).emit('new-channel', {
236220
channel: channel,
237221
sender : sender
238222
});
239223

240-
var socket = io.connect(URL + channel);
224+
socket = io.connect(URL + channel);
241225
socket.channel = channel;
242226

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

264248
```javascript
265249
openSignalingChannel: function (config) {
266-
var channel = config.channel || this.channel || 'WebRTC-Experiment';
267-
var socket = new Firebase('https://chat.firebaseIO.com/' + channel);
250+
channel = config.channel || this.channel || 'WebRTC-Experiment';
251+
socket = new Firebase('https://chat.firebaseIO.com/' + channel);
268252
socket.channel = channel;
269253
socket.on('child_added', function (data) {
270254
config.onmessage && config.onmessage(data.val());
@@ -324,4 +308,4 @@ recorder.stopAudio(function(recordedFileURL) {
324308

325309
#### License
326310

327-
[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).
311+
[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).

RTCMultiConnection/README.md

+74-10
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ This document is for [RTCMultiConnection-v1.3](https://webrtc-experiment.appspot
2828
#### Second Step: Start using it!
2929

3030
```javascript
31-
var connection = new RTCMultiConnection();
32-
31+
connection = new RTCMultiConnection();
32+
connection.userid = 'muazkh'; // username or user-id!
3333
connection.session = {
3434
audio: true,
3535
video: true
@@ -217,6 +217,14 @@ connection.onmessage = function (e) {
217217
}
218218
```
219219

220+
### Direct Messages
221+
222+
You can share data directly between two unique users using their user-ids:
223+
224+
```javascript
225+
connection.channels['user-id'].send(file || data || 'text');
226+
```
227+
220228
#### Progress helpers when sharing files
221229

222230
```javascript
@@ -364,20 +372,76 @@ connection.attachStream = MediaStream;
364372

365373
----
366374

367-
#### Use [your own](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) socket.io over node.js for signaling
375+
#### Broadcasting/Conferencing/etc.
376+
377+
Three possible scenarios are supported:
378+
379+
1. One-to-Many `one-way` broadcasting
380+
2. One-to-Many `two-way` broadcasting
381+
3. Many-to-Many `video-conferencing`
382+
383+
For one-way broadcasting
384+
385+
```javascript
386+
connection.stream = {
387+
oneway: true,
388+
screen: true
389+
};
390+
```
391+
392+
For two-way broadcasting
393+
394+
```javascript
395+
connection.stream = {
396+
broadcast: true,
397+
audio: true
398+
};
399+
```
400+
401+
For video-conferencing; don't use `oneway` or `broadcast` values:
402+
403+
```javascript
404+
connection.stream = {
405+
audio: true,
406+
video: true
407+
};
408+
```
409+
410+
----
411+
412+
#### Bandwidth
413+
414+
You can set bandwidth for both outgoing audio/video streams.
415+
416+
```javascript
417+
connection.bandwidth = {
418+
audio: 50,
419+
video: 256
420+
};
421+
422+
// or change them individually
423+
connection.bandwidth.audio = 50;
424+
connection.bandwidth.video = 256;
425+
```
426+
427+
Default audio bandwidth is `50` and default video bandwidth is `256`.
428+
429+
----
430+
431+
#### Use your own [socket.io over node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) for signaling
368432

369433
```javascript
370434
openSignalingChannel: function(config) {
371-
var URL = 'http://domain.com:8888/';
372-
var channel = config.channel || this.channel || 'Default-Socket';
373-
var sender = Math.round(Math.random() * 60535) + 5000;
435+
URL = 'http://domain.com:8888/';
436+
channel = config.channel || this.channel || 'Default-Socket';
437+
sender = Math.round(Math.random() * 60535) + 5000;
374438

375439
io.connect(URL).emit('new-channel', {
376440
channel: channel,
377441
sender : sender
378442
});
379443

380-
var socket = io.connect(URL + channel);
444+
socket = io.connect(URL + channel);
381445
socket.channel = channel;
382446

383447
socket.on('connect', function () {
@@ -395,13 +459,13 @@ openSignalingChannel: function(config) {
395459
}
396460
```
397461

398-
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).
462+
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).
399463

400464
----
401465

402466
#### Browser Support
403467

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

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

415479
#### License
416480

417-
[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).
481+
[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).

0 commit comments

Comments
 (0)