Skip to content

Commit

Permalink
Merged #37 and RTCMultiConnection-v1.3 testing demo added
Browse files Browse the repository at this point in the history
https://webrtc-experiment.appspot.com/RTCMultiConnection-v1.3/

According to #37 by @FreCap:

"Everyone has a laptop, if he has an high volume, will be killed by
echoes.

Sometimes Firefox crashes while echoing and you have to hard reboot your
PC ( Ubuntu 13.04, FF 21 )"

So, local media streams are now "muted" by default (in all
RTCMultiConnection releases).
  • Loading branch information
muaz-khan committed Jun 2, 2013
1 parent 07bc5cc commit 2a5d63a
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 116 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

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 (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 @@ -25,12 +21,19 @@ These demos/experiments are entirely client-side; i.e. no server installation ne

----

### Simplest Libraries Ever!

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
4. [RTCall.js](https://webrtc-experiment.appspot.com/RTCall/) — A library for Browser-to-Browser audio-only calling

Scroll to bottom of the page to see how to use these four unique libraries!

----

1. [Pre-recorded media streaming](https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/) — Most demanded and useful feature!
2. [Socket.io over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) — Copy/Paste/Deploy and you're done!

----

Expand Down Expand Up @@ -112,6 +115,7 @@ These demos/experiments are entirely client-side; i.e. no server installation ne
11. [Manual session establishment + extra data transmission + video conferencing](https://webrtc-experiment.appspot.com/RTCMultiConnection/manual-session-establishment-plus-extra-data-transmission-plus-videoconferencing/)
12. [Users ejection and presence detection](https://webrtc-experiment.appspot.com/RTCMultiConnection/users-ejection/)
13. [Customizing Bandwidth](https://webrtc-experiment.appspot.com/RTCMultiConnection/bandwidth/)
14. [RTCMultiConnection-v1.3 testing demo](https://webrtc-experiment.appspot.com/RTCMultiConnection-v1.3/)

----

Expand Down Expand Up @@ -205,16 +209,16 @@ call.oncustomer = function(customer) {
```javascript
// openSignalingChannel or openSocket!
openSignalingChannel: function(config) {
var URL = 'http://domain.com:8888/';
var SIGNALING_SERVER = 'http://domain.com:8888/';
var channel = config.channel || this.channel || 'one-to-one-video-chat';
var sender = Math.round(Math.random() * 60535) + 5000;

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

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

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

```javascript
openSignalingChannel: function (config) {
var SIGNALING_SERVER = 'https://chat.firebaseIO.com/';
var channel = config.channel || this.channel || 'WebRTC-Experiment';
var socket = new Firebase('https://chat.firebaseIO.com/' + channel);
socket.channel = channel;
socket.on('child_added', function (data) {
var firebase = new Firebase(SIGNALING_SERVER + channel);
firebase.channel = channel;
firebase.on('child_added', function (data) {
config.onmessage && config.onmessage(data.val());
});
socket.send = function (data) {
firebase.send = function (data) {
this.push(data);
};
config.onopen && setTimeout(config.onopen, 1);
socket.onDisconnect().remove();
return socket;
firebase.onDisconnect().remove();
return firebase;
}
```

Expand Down
5 changes: 5 additions & 0 deletions RTCMultiConnection/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
`RTCMultiConnection-v1.3` is still under developement; see a [testing demo](https://webrtc-experiment.appspot.com/RTCMultiConnection-v1.3/). You're recommended to try [v1.2](https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RTCMultiConnection/RTCMultiConnection-v1.2-and-earlier.md) until `v1.3` gets ready.

----

#### [RTCMultiConnection](https://webrtc-experiment.appspot.com/#RTCMultiConnection): A simple library to handle advance tasks!

Supports features like
Expand Down Expand Up @@ -478,6 +482,7 @@ For a `ready-made` socket.io over node.js implementation; [visit this link](http
11. [Manual session establishment + extra data transmission + video conferencing](https://webrtc-experiment.appspot.com/RTCMultiConnection/manual-session-establishment-plus-extra-data-transmission-plus-videoconferencing/)
12. [Users ejection and presence detection](https://webrtc-experiment.appspot.com/RTCMultiConnection/users-ejection/)
13. [Customizing Bandwidth](https://webrtc-experiment.appspot.com/RTCMultiConnection/bandwidth/)
14. [RTCMultiConnection-v1.3 testing demo](https://webrtc-experiment.appspot.com/RTCMultiConnection-v1.3/)

----

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>RTCMultiConnection-v1.3.js testing demo! ® Muaz Khan</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="author" type="text/html" href="https://plus.google.com/100325991024054712503">
<meta name="author" content="Muaz Khan">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script>
var hash = window.location.hash.replace('#', '');
if (!hash.length) {
location.href = location.href + '#' + ((Math.random() * new Date().getTime()).toString(36).toUpperCase().replace(/\./g, '-'));
location.reload();
}
</script>
<script src="/firebase.js"></script>
<script src="/RTCMultiConnection-v1.3.js"></script>
</head>

<body>
<button id="new-session">Open New Session</button>
<input type="checkbox" id="audio-renegotiation" checked>
<label for="audio-renegotiation">Renegotiate Audio</label>
<input type="checkbox" id="video-renegotiation" checked>
<label for="video-renegotiation">Renegotiate Video</label>
<input type="checkbox" id="screen-renegotiation">
<label for="screen-renegotiation">Renegotiate Screen</label>
<input type="checkbox" id="one-way">
<label for="one-way">Is One Way?</label>
<a href="https://webrtc-experiment.appspot.com/">Goto "WebRTC Experiments & Demos" Homepage</a>

<div id="local-video-container" class="local-video-container"></div>
<div id="remote-videos-container" class="remote-videos-container"></div>

<h2>How it works?</h2>

<p>Renegotiation means using pre-created peer connections to add additional streams by renegotiating offer/answer session descriptions.</p>
<p>In this demo; at first time; only data connection is opened. Later on, same peer connections are used to renegotiate audio, video or screen streams.</p>
<p>It is runtime insertion of streams!</p>
<br />
<br />
<p>Remeber, it is a testing demo for <a href="https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RTCMultiConnection/RTCMultiConnection-v1.3.js" target="_blank">RTCMultiConnection-v1.3.js<a/> library. Documentation <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection" target="_blank">available here</a>.</p>
<!--
begins -->
<script>
var connection = new RTCMultiConnection(hash);
connection.session = {
data: true
};
</script>
<!-- data events -->
<script>
connection.onopen = function (e) {
inputMessage.disabled = false;
connection.send('Hi, I\'m ' + e.userid);

// only session initiator can add streams for renegotiation
if (connection.isInitiator)
connection.addStream({
audio: !! document.getElementById('audio-renegotiation').checked,
video: !! document.getElementById('video-renegotiation').checked,
screen: !! document.getElementById('screen-renegotiation').checked,
oneway: !! document.getElementById('one-way').checked
});
};

connection.onmessage = function (e) {
appendDIV(e.data);
};
</script>
<!-- streams events -->
<script>
var remoteVideosContainer = document.getElementById('remote-videos-container');
connection.onstream = function (e) {
video = getVideo(e);
if (e.type === 'local') document.getElementById('local-video-container').appendChild(video);
if (e.type === 'remote') remoteVideosContainer.appendChild(video, remoteVideosContainer.firstChild);
};
</script>
<!-- initialization -->
<script>
connection.connect();

document.getElementById('new-session').onclick = function () {
connection.open();
this.disabled = true;
};
</script>
<script>
function getVideo(e) {
div = document.createElement('div');
div.className = 'video-container';
div.id = e.userid || 'You';
div.appendChild(e.mediaElement);

h2 = document.createElement('h2');
h2.innerHTML = e.userid || 'You';
div.appendChild(h2);
return div
}
</script>
<script>
connection.onleave = function (e) {
var video = document.getElementById(e.userid);
if (video) video.parentNode.removeChild(video);
};
</script>
<style>
* {
-webkit-user-select:none;
font-family:'Segoe UI Light';
}
html{overflow: hidden;}
.local-video-container {
border: 2px solid red;
width:40%;
float:left;
background: rgb(253, 104, 104);
border-bottom-left-radius: 5%;
border-bottom-right-radius: 5%;
text-align: center;
overflow: hidden;
}
video {
width:100%;
}
.remote-videos-container {
border: 2px solid rgb(5, 129, 160);
width: 58%;
float: left;
background: rgb(104, 170, 253);
border-bottom-left-radius: 5%;
border-bottom-right-radius: 5%;
text-align: center;
overflow: hidden;
}
.video-container {
display: inline-block overflow: hidden;
background: white;
vertical-align: top;
}
.video-container h2 {
border: 0;
border-top: 1px solid black;
margin: 0;
text-align: center;
display: block;
}
.video-container button {
position: absolute;
z-index: 200;
margin: .2em;
}
button {
-moz-border-radius: 3px;
-moz-transition: none;
-webkit-transition: none;
background: #0370ea;
background: -moz-linear-gradient(top, #008dfd 0, #0370ea 100%);
background: -webkit-linear-gradient(top, #008dfd 0, #0370ea 100%);
border: 1px solid #076bd2;
border-radius: 3px;
color: #fff;
display: inline-block;
font-size: 1.3em;
line-height: 1.3;
padding: 5px 12px;
text-align: center;
text-shadow: 1px 1px 1px #076bd2;
font-family: inherit;
}
button:hover {
background: rgb(9, 147, 240);
}
button:active {
background: rgb(10, 118, 190);
}
button[disabled] {
background: none;
border: 1px solid rgb(187, 181, 181);
color: gray;
text-shadow: none;
}
footer {
position:absolute;
bottom: 0;
left:0;
right:0;
border-top:2px solid black;
background: white;
max-height: 200px;
overflow-y: scroll;
overflow-x: hidden;
}
input[type=text] {
width:100%;
font-size:1.4em;
-webkit-user-select:initial;
}
#messages div {
border-bottom: 1px solid black;
padding:.4em .8em;
font-size: 1.4em;
}
</style>
<footer>
<div id="messages"></div>
<input type="text" id="input-message" disabled>
</footer>
<script>
var messages = document.getElementById('messages');
var inputMessage = document.getElementById('input-message');

inputMessage.onkeypress = function (e) {
if (e.keyCode != 13) return;
appendDIV(this.value);
connection.send(this.value);
this.value = '';
};

function appendDIV(message) {
div = document.createElement('div');
div.innerHTML = message;
messages.appendChild(div);

inputMessage.focus();
}
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions RTCMultiConnection/RTCMultiConnection-v1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ function RTCMultiConnection(channel) {
self.config.attachStream = stream;
callback && callback();

// issue #37: Sometimes Firefox crashes while echoing and you have to hard reboot your PC ( Ubuntu 13.04, FF 21 )
mediaElement.muted = true;
self.onstream({
stream: stream,
mediaElement: mediaElement,
Expand Down
2 changes: 2 additions & 0 deletions RTCMultiConnection/RTCMultiConnection-v1.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@
self.config.attachStream = stream;
callback && callback();

// issue #37: Sometimes Firefox crashes while echoing and you have to hard reboot your PC ( Ubuntu 13.04, FF 21 )
mediaElement.muted = true;
self.onstream({
stream: stream,
mediaElement: mediaElement,
Expand Down
Loading

0 comments on commit 2a5d63a

Please sign in to comment.