-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged #37 and RTCMultiConnection-v1.3 testing demo added
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
Showing
13 changed files
with
394 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
232 changes: 232 additions & 0 deletions
232
RTCMultiConnection/RTCMultiConnection-Demos/RTCMultiConnection-v1.3-demo.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.