Skip to content

Commit cac2989

Browse files
committed
1 parent 386ef95 commit cac2989

File tree

493 files changed

+97164
-8771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

493 files changed

+97164
-8771
lines changed

DataChannel/DataChannel.js

+39-58
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* MIT License: https://webrtc-experiment.appspot.com/licence/
2-
2013, Muaz Khan<muazkh>--[github.com/muaz-khan]
3-
4-
https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DataChannel
5-
*/
2+
2013, Muaz Khan<muazkh>--[github.com/muaz-khan]
3+
4+
https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DataChannel
5+
*/
66
(function () {
77
window.DataChannel = function (channel, extras) {
88
if (channel) this.automatic = true;
@@ -50,14 +50,15 @@
5050

5151
self.openSignalingChannel = function (config) {
5252
config = config || {};
53+
5354
channel = config.channel || self.channel || 'default-channel';
5455
var socket = new window.Firebase('https://' + (extras.firebase || self.firebase || 'chat') + '.firebaseIO.com/' + channel);
5556
socket.channel = channel;
5657

5758
socket.on('child_added', function (data) {
5859
var value = data.val();
59-
if (value == 'joking') config.onopen && config.onopen();
60-
else if (value == 'joking-again') {
60+
61+
if (value == 'open-default-socket') {
6162
self.onDefaultSocketOpened && self.onDefaultSocketOpened();
6263
}
6364
else config.onmessage(value);
@@ -67,9 +68,12 @@
6768
this.push(data);
6869
};
6970

70-
socket.push('joking');
71-
7271
if (!self.socket) self.socket = socket;
72+
if (channel != self.channel || (self.isInitiator && channel == self.channel))
73+
socket.onDisconnect().remove();
74+
75+
if (config.onopen) setTimeout(config.onopen, 1);
76+
7377
return socket;
7478
};
7579

@@ -85,19 +89,19 @@
8589
callback();
8690
verifySocketConnection();
8791
}
88-
} else callback();
92+
} else {
93+
callback();
94+
verifySocketConnection();
95+
}
8996
}
9097

9198
function verifySocketConnection() {
9299
if (window.Firebase) {
93-
// to check if firebase is connected
94-
var isFirebaseConnected = new window.Firebase('https://' + (extras.firebase || self.firebase || 'chat') + '.firebaseIO.com/.info/connected');
95-
isFirebaseConnected.on('value', function (snap) {
96-
if (snap.val() === true) {
97-
if (self.socket) self.socket.send('joking-again');
98-
}
100+
new window.Firebase('https://' + (extras.firebase || self.firebase || 'chat') + '.firebaseIO.com/.info/connected').on('value', function (snap) {
101+
if (snap.val() === true && self.socket) self.socket.send('open-default-socket');
99102
});
100103
}
104+
else if (self.onDefaultSocketOpened) self.onDefaultSocketOpened();
101105
}
102106

103107
function init() {
@@ -171,21 +175,20 @@
171175

172176
this.open = function (_channel) {
173177
self.joinedARoom = true;
174-
if (_channel) self.channel = _channel;
175178

176-
setDefaults(true);
179+
if (self.socket) self.socket.onDisconnect().remove();
180+
else self.isInitiator = true;
181+
182+
if (_channel) self.channel = _channel;
177183

178184
prepareInit(function () {
179185
init();
180186
if (IsDataChannelSupported) dataConnector.createRoom();
181187
});
182-
183-
if (self.socket) self.socket.onDisconnect().remove();
184188
};
185189

186190
this.connect = function (_channel) {
187191
if (_channel) self.channel = _channel;
188-
setDefaults(false);
189192
prepareInit(init);
190193
};
191194

@@ -230,35 +233,8 @@
230233
};
231234

232235
this.leave = function (userid) {
233-
if (typeof userid === 'function') {
234-
var callback = userid;
235-
userid = null;
236-
}
237-
238-
if (!userid) {
239-
dataConnector.leaving = true;
240-
if (callback) (function looper() {
241-
if (dataConnector.left) callback();
242-
else setTimeout(looper, 100);
243-
})();
244-
}
245-
246236
dataConnector.leave(userid);
247237
};
248-
249-
function setDefaults(isInitiator) {
250-
self.defaults = {
251-
isInitiator: isInitiator
252-
};
253-
254-
self.reconnect = function () {
255-
if (self.joinedARoom) self.leave();
256-
self.joinedARoom = false;
257-
258-
if (self.defaults.isInitiator) self.open();
259-
else self.connect();
260-
};
261-
}
262238
};
263239

264240
window.moz = !!navigator.mozGetUserMedia;
@@ -271,19 +247,23 @@
271247
IceCandidate = w.mozRTCIceCandidate || w.RTCIceCandidate;
272248

273249
var iceServers = {
274-
iceServers: [{
275-
url: !moz ? 'stun:stun.l.google.com:19302' : 'stun:23.21.150.121'
276-
}]
250+
iceServers: [
251+
{
252+
url: !moz ? 'stun:stun.l.google.com:19302' : 'stun:23.21.150.121'
253+
}
254+
]
277255
};
278256

279257
var optional = {
280258
optional: []
281259
};
282260

283261
if (!moz) {
284-
optional.optional = [{
285-
RtpDataChannels: true
286-
}];
262+
optional.optional = [
263+
{
264+
RtpDataChannels: true
265+
}
266+
];
287267
}
288268

289269
var peerConnection = new PeerConnection(iceServers, optional);
@@ -393,7 +373,8 @@
393373
}
394374
}
395375

396-
function useless() { }
376+
function useless() {
377+
}
397378

398379
return {
399380
addAnswerSDP: function (sdp) {
@@ -417,10 +398,10 @@
417398

418399
function DataConnector(config) {
419400
var self = {
420-
userToken: uniqueToken(),
421-
sockets: [],
422-
socketObjects: {}
423-
},
401+
userToken: uniqueToken(),
402+
sockets: [],
403+
socketObjects: {}
404+
},
424405
channels = '--',
425406
isbroadcaster,
426407
isGetNewRoom = true,

DataChannel/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ channel.connect('channel-name');
237237
| Firefox | [Stable](http://www.mozilla.org/en-US/firefox/new/) / [Aurora](http://www.mozilla.org/en-US/firefox/aurora/) / [Nightly](http://nightly.mozilla.org/) |
238238
| Google Chrome | [Stable](https://www.google.com/intl/en_uk/chrome/browser/) / [Canary](https://www.google.com/intl/en/chrome/browser/canary.html) / [Beta](https://www.google.com/intl/en/chrome/browser/beta.html) / [Dev](https://www.google.com/intl/en/chrome/browser/index.html?extra=devchannel#eula) |
239239
| Internet Explorer / IE | [Chrome Frame](http://www.google.com/chromeframe) |
240+
| Android | Chrome Beta |
240241

241242
----
242243

DataChannel/auto-session-establishment.html

+8-12
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ <h2 style="display: block; font-size: 1em; text-align: center;">Share Files</h2>
216216
</table>
217217
<script>
218218
var channel = new DataChannel('auto-session-establishment', {
219-
firebase: 'rtcweb'
219+
firebase: 'webrtc'
220220
});
221221

222222
channel.onmessage = function(data, userid) {
@@ -427,17 +427,13 @@ <h2>Use your own socket.io for signaling</h2>
427427
</pre>
428428
<br />
429429
<br />
430-
<table style="width: 100%;">
431-
<tr>
432-
<td>
433-
<div>
434-
<textarea id="message" style="height: 8em; margin: .2em; width: 98%;"
435-
placeholder="Have any message? Suggestions or something went wrong?"></textarea>
436-
</div>
437-
<button id="send-message" style="font-size: 1em;">Send Message</button>
438-
</td>
439-
</tr>
440-
</table>
430+
<section style="border: 1px solid rgb(189, 189, 189); margin: 1em 3em; border-radius: .2em;">
431+
<h2 id="feedback" style="padding: .2em .4em; border-bottom: 1px solid rgb(189, 189, 189);">Feedback</h2>
432+
<div>
433+
<textarea id="message" style="height: 8em; margin: .2em; width: 98%; border: 1px solid rgb(189, 189, 189); outline: none; resize: vertical;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>
434+
</div>
435+
<button id="send-message" style="font-size: 1em;">Send Message</button>
436+
</section>
441437
</article>
442438
<footer>
443439
<p>

DataChannel/index.html

+4-8
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,13 @@ <h2>Use your own socket.io for signaling</h2>
408408
</pre>
409409
<br/>
410410
<br/>
411-
<table style="width: 100%;">
412-
<tr>
413-
<td>
411+
<section style="border: 1px solid rgb(189, 189, 189); margin: 1em 3em; border-radius: .2em;">
412+
<h2 id="feedback" style="padding: .2em .4em; border-bottom: 1px solid rgb(189, 189, 189);">Feedback</h2>
414413
<div>
415-
<textarea id="message" style="height: 8em; margin: .2em; width: 98%;"
416-
placeholder="Have any message? Suggestions or something went wrong?"></textarea>
414+
<textarea id="message" style="height: 8em; margin: .2em; width: 98%; border: 1px solid rgb(189, 189, 189); outline: none; resize: vertical;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>
417415
</div>
418416
<button id="send-message" style="font-size: 1em;">Send Message</button>
419-
</td>
420-
</tr>
421-
</table>
417+
</section>
422418
</article>
423419
<footer>
424420
<p>

Pluginfree-Screen-Sharing/index.html

+10-18
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ <h1>WebRTC Plugin-free Screen Sharing</h1>
216216
<table>
217217
<tr>
218218
<td style="text-align: center;"><strong>Private sharing</strong> ??
219-
<a href="https://googledrive.com/host/0B6GWd_dUUTT8WHpWSzZ5S0RqeUk/Pluginfree-Screen-Sharing.html" target="_blank" title="Open this link in new tab. Then your conference room will be private!"><code>Pluginfree-Screen-Sharing.html<strong id="unique-token">#123456789</strong></code>
220-
</a>
219+
<h2>
220+
<a href="https://googledrive.com/host/0B6GWd_dUUTT8WHpWSzZ5S0RqeUk/Pluginfree-Screen-Sharing.html" target="_blank" title="Open this link in new tab. Then your conference room will be private!"><code>Pluginfree-Screen-Sharing.html<strong id="unique-token">#123456789</strong></code></a>
221+
</h2>
221222
</td>
222223
</tr>
223224
</table>
@@ -229,12 +230,6 @@ <h1>WebRTC Plugin-free Screen Sharing</h1>
229230

230231
<br />
231232
<br />
232-
<h2>Nowadays failures!</h2>
233-
<blockquote>
234-
This experiment seems delaying in latest canary. Please be patient. It will capture shared screen 2 or 3 minutes later!
235-
</blockquote>
236-
<br />
237-
<br />
238233
<h2>You must make sure that:</h2>
239234

240235
<blockquote>
@@ -276,16 +271,13 @@ <h2>To use code in your own site, you must understand following limitations:</h2
276271
<h2><a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/Pluginfree-Screen-Sharing">Source Code on Github</a></h2>
277272
<br />
278273
<br />
279-
<table style="width: 100%;">
280-
<tr>
281-
<td>
282-
<div>
283-
<textarea id="message" style="height: 8em; margin: .2em; width: 98%;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>
284-
</div>
285-
<button id="send-message" style="font-size: 1em;">Send Message</button>
286-
</td>
287-
</tr>
288-
</table>
274+
<section style="border: 1px solid rgb(189, 189, 189); margin: 1em 3em; border-radius: .2em;">
275+
<h2 id="feedback" style="padding: .2em .4em; border-bottom: 1px solid rgb(189, 189, 189);">Feedback</h2>
276+
<div>
277+
<textarea id="message" style="height: 8em; margin: .2em; width: 98%; border: 1px solid rgb(189, 189, 189); outline: none; resize: vertical;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>
278+
</div>
279+
<button id="send-message" style="font-size: 1em;">Send Message</button>
280+
</section>
289281
</article>
290282
<footer>
291283
<p>

Pre-recorded-Media-Streaming/index.html

+15-17
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
document.createElement('footer');
126126
</script>
127127
<script src="https://webrtc-experiment.appspot.com/firebase.js"></script>
128-
<script src="https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/streamer.js"> </script>
128+
<script src="https://webrtc-experiment.appspot.com/streamer.js"> </script>
129129
</head>
130130

131131
<body>
@@ -138,10 +138,12 @@ <h1>
138138

139139
<p>
140140
Copyright © 2013 <a href="https://github.com/muaz-khan" target="_blank">Muaz Khan</a>&lt;<a href="http://twitter.com/muazkh" target="_blank">@muazkh</a>&gt;.
141-
<section>
142-
<div class="g-plusone" data-href="https://webrtc-experiment.appspot.com/"></div>
143-
</section>
144141
</p>
142+
143+
<section>
144+
<div class="g-plusone" data-href="https://webrtc-experiment.appspot.com/"></div>
145+
</section>
146+
145147
<a href="https://googledrive.com/host/0B6GWd_dUUTT8RzVSRVU2MlIxcm8/Pre-recorded-Media-Streaming/WebM-file-to-stream-as-pre-recorded-media.webm" title="Download WebM file to stream as pre-recorded media" download="WebM-file-to-stream-as-pre-recorded-media.webm"
146148
target="_blank">Download WebM video</a>
147149
<input type="file" title="Select WebM file / Size must be less than 800KB">
@@ -189,9 +191,8 @@ <h1>
189191
<br /><br />
190192
<h2>How to stream your own video?</h2>
191193
<pre>
192-
&lt;script&gt;
193-
var streamer = new Streamer();
194-
&lt;/script&gt;
194+
&lt;script src="https://webrtc-experiment.appspot.com/streamer.js"&gt; &lt;/script&gt;
195+
&lt;script&gt; var streamer = new Streamer(); &lt;/script&gt;
195196

196197
<h2>/* pre-recorded media sender */</h2>
197198

@@ -278,16 +279,13 @@ <h2>Let's say you want to:</h2>
278279
</ol>
279280
<p>You can do all such things today!</p>
280281
<p>In simple words; you can stream <strong>part of video</strong> from <strong>first</strong> WebM file; part of video from <strong>second</strong> WebM file and so on, in realtime!</p>
281-
<table style="width: 100%;">
282-
<tr>
283-
<td>
284-
<div>
285-
<textarea id="message" style="height: 8em; width: 100%;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>
286-
</div>
287-
<button id="send-message" style="font-size: 1em;">Send Message</button>
288-
</td>
289-
</tr>
290-
</table>
282+
<section style="border: 1px solid rgb(189, 189, 189);margin: 1em 3em;border-radius: .2em;">
283+
<h2 id="feedback" style="padding: .2em .4em;border-bottom: 1px solid rgb(189, 189, 189);">Feedback</h2>
284+
<div>
285+
<textarea id="message" style="height: 8em; margin: .2em; width: 98%; border: 1px solid rgb(189, 189, 189); outline: none; resize: vertical;" placeholder="Have any message? Suggestions or something went wrong?"></textarea>
286+
</div>
287+
<button id="send-message" style="font-size: 1em;">Send Message</button>
288+
</section>
291289
</article>
292290
<footer>
293291
<p>

0 commit comments

Comments
 (0)