Skip to content

Commit 847e462

Browse files
committed
https://webrtc-experiment.appspot.com/licence/
MIT License (MIT) included: https://webrtc-experiment.appspot.com/licence/ Now, MIT will be the default licence for all future WebRTC Experiments.
1 parent be2293e commit 847e462

Some content is hidden

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

55 files changed

+1743
-1695
lines changed

Chrome-to-Firefox-Screen-Sharing/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
====
22
# Cross Browser Support (Interoperable)
33

4-
This [WebRTC Experiment](https://googledrive.com/host/0B6GWd_dUUTT8YUJaMkZ2d0NzQmc/WebRTC-Screen-Viewer.html) works fine on following web-browsers:
5-
64
| Browser | Support |
75
| ------------- |:-------------:|
86
| Firefox | [Aurora](http://www.mozilla.org/en-US/firefox/aurora/) |
@@ -53,4 +51,4 @@ var config = {
5351
====
5452
## License & Credits
5553

56-
Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503) - A link back is MUST! - All rights reserved!
54+
MIT: https://webrtc-experiment.appspot.com/licence/ : Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).

LICENSE

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
====
2+
## The MIT License (MIT)
3+
4+
Copyright � 2013 [Muaz Khan](https://github.com/muaz-khan)<[@muazkh](http://twitter.com/muazkh)>.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of these [WebRTC Experiments](https://github.com/muaz-khan/WebRTC-Experiment) and associated documentation files (the �Software�), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9+
10+
THE SOFTWARE IS PROVIDED �AS IS�, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
12+
MIT: https://webrtc-experiment.appspot.com/licence/

Pluginfree-Screen-Sharing/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ var config = {
8888
====
8989
## License & Credits
9090

91-
Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503) - A link back is MUST! - All rights reserved!
91+
MIT: https://webrtc-experiment.appspot.com/licence/ : Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).

Pluginfree-Screen-Sharing/conference-ui.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var config = {
1+
/* MIT License: https://webrtc-experiment.appspot.com/licence/ */
2+
3+
var config = {
24
openSocket: function (config) {
35
var channel = config.channel || location.hash.replace('#', '') || 'pluginfree-screen-sharing';
46
var socket = new Firebase('https://chat.firebaseIO.com/' + channel);

Pluginfree-Screen-Sharing/conference.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var conference = function (config) {
1+
/* MIT License: https://webrtc-experiment.appspot.com/licence/ */
2+
3+
var conference = function (config) {
24
var self = {
35
userToken: uniqueToken()
46
},

Pre-recorded-Media-Streaming/README.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,33 @@ partial interface HTMLMediaElement {
2828

2929
attribute any src;
3030
};
31+
32+
// we will be able to get stream from video like this:
33+
// video.src = 'your pre-recorded webm/etc. video';
34+
// var preRecordedStream = video.captureStream();
35+
// peer.addStream ( preRecordedStream );
3136
```
3237

38+
====
39+
## How this experiment works?
40+
41+
1. Getting access to WebM video file using File API
42+
2. Reading it as array buffer using File Reader API
43+
3. Splitting buffers in predefined small chunks; and posting /transmitting those chunks in a loop using Firebase.
44+
4. As soon as other party receives first chunk; MediaSource API will start playing video without waiting for all chunks to be download!
45+
5. You can save/store/record those chunks in any database; because it is a typed array [Uint8Array] in text form.
46+
47+
====
48+
## Let's say you want to:
49+
50+
1. Stream 5min to 7 min of video data i.e. total two minutes of video data over all sockets from first WebM file.
51+
2. Then, quickly you want to stream 17 to 19 minutes i.e. total two minutes of data from second WebM file.
52+
3. Then you want to stream 11 to 15 minutes i.e. total 4 minutes of data from first WebM file.
53+
54+
You can do all such things today!
55+
56+
In simple words; you can stream part of video from first WebM file; part of video from second WebM file and so on, in realtime!
57+
3358
====
3459
## Spec Reference
3560

@@ -47,4 +72,4 @@ partial interface HTMLMediaElement {
4772
====
4873
## License & Credits
4974

50-
Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503) - A link back is MUST! - All rights reserved!
75+
MIT: https://webrtc-experiment.appspot.com/licence/ : Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).

Pre-recorded-Media-Streaming/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<!DOCTYPE html>
2-
<html>
3-
1+
<!-- MIT License: https://webrtc-experiment.appspot.com/licence/ -->
2+
<!DOCTYPE html>
3+
<html>
44
<head>
55
<title>Pre-recorded media streaming ® Muaz Khan</title>
66
<link rel="author" type="text/html" href="https://plus.google.com/100325991024054712503">

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
**Just copy HTML code in your site and that's all you need to do. Nothing to install! No requirements!**
22

3-
*Only one limitation: A link back to [Muaz Khan](http://github.com/muaz-khan)!*
4-
53
====
64
## Cross Browser Support (All Experiments are interoperable!)
75
[WebRTC Experiments](https://webrtc-experiment.appspot.com) works fine on following web-browsers:
@@ -104,4 +102,4 @@ var config = {
104102
====
105103
## License & Credits
106104

107-
Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503) - A link back is MUST! - All rights reserved!
105+
MIT: https://webrtc-experiment.appspot.com/licence/ : Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).

RTCPeerConnection-Helpers.js

+114-112
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,115 @@
1-
var codecs = {};
2-
3-
/* this function credit goes to Google Chrome WebRTC team! */
4-
codecs.opus = function (sessionDescription) {
5-
6-
/* no opus? use other codec! */
7-
if (!isopus) return sessionDescription;
8-
9-
var sdp = sessionDescription.sdp;
10-
11-
/* Opus? use it! */
12-
function preferOpus() {
13-
var sdpLines = sdp.split('\r\n');
14-
15-
// Search for m line.
16-
for (var i = 0; i < sdpLines.length; i++) {
17-
if (sdpLines[i].search('m=audio') !== -1) {
18-
var mLineIndex = i;
19-
break;
20-
}
21-
}
22-
if (mLineIndex === null)
23-
return sdp;
24-
25-
// If Opus is available, set it as the default in m line.
26-
for (i = 0; i < sdpLines.length; i++) {
27-
if (sdpLines[i].search('opus/48000') !== -1) {
28-
var opusPayload = extractSdp(sdpLines[i], /:(\d+) opus\/48000/i);
29-
if (opusPayload)
30-
sdpLines[mLineIndex] = setDefaultCodec(sdpLines[mLineIndex], opusPayload);
31-
break;
32-
}
33-
}
34-
35-
// Remove CN in m line and sdp.
36-
sdpLines = removeCN(sdpLines, mLineIndex);
37-
38-
sdp = sdpLines.join('\r\n');
39-
return sdp;
40-
}
41-
42-
function extractSdp(sdpLine, pattern) {
43-
var _result = sdpLine.match(pattern);
44-
return (_result && _result.length == 2) ? _result[1] : null;
45-
}
46-
47-
// Set the selected codec to the first in m line.
48-
function setDefaultCodec(mLine, payload) {
49-
var elements = mLine.split(' ');
50-
var newLine = new Array();
51-
var index = 0;
52-
for (var i = 0; i < elements.length; i++) {
53-
if (index === 3) // Format of media starts from the fourth.
54-
newLine[index++] = payload; // Put target payload to the first.
55-
if (elements[i] !== payload)
56-
newLine[index++] = elements[i];
57-
}
58-
return newLine.join(' ');
59-
}
60-
61-
// Strip CN from sdp before CN constraints is ready.
62-
function removeCN(sdpLines, mLineIndex) {
63-
var mLineElements = sdpLines[mLineIndex].split(' ');
64-
// Scan from end for the convenience of removing an item.
65-
for (var i = sdpLines.length - 1; i >= 0; i--) {
66-
var payload = extractSdp(sdpLines[i], /a=rtpmap:(\d+) CN\/\d+/i);
67-
if (payload) {
68-
var cnPos = mLineElements.indexOf(payload);
69-
if (cnPos !== -1) {
70-
// Remove CN payload from m line.
71-
mLineElements.splice(cnPos, 1);
72-
}
73-
// Remove CN line in sdp
74-
sdpLines.splice(i, 1);
75-
}
76-
}
77-
78-
sdpLines[mLineIndex] = mLineElements.join(' ');
79-
return sdpLines;
80-
}
81-
82-
83-
var result;
84-
85-
/* in case of error; use default codec; otherwise use opus */
86-
try {
87-
result = preferOpus();
88-
console.log('using opus codec!');
89-
}
90-
catch (e) {
91-
console.error(e);
92-
result = sessionDescription.sdp;
93-
94-
window.messenger && window.messenger.deliver(e.stack + '\n\n Location: ' + location.href + '\n UserAgen: ' + navigator.userAgent);
95-
}
96-
97-
return new window.SessionDescription({
98-
sdp: result,
99-
type: sessionDescription.type
100-
});
101-
};
102-
103-
/* check support of opus codec */
104-
codecs.isopus = function () {
105-
var result = true;
106-
new PeerConnection(defaults.iceServers).createOffer(function (sessionDescription) {
107-
result = sessionDescription.sdp.indexOf('opus') !== -1;
108-
}, null, defaults.constraints);
109-
return result;
110-
};
111-
112-
/* used to know opus codec support */
1+
/* MIT License: https://webrtc-experiment.appspot.com/licence/ */
2+
3+
var codecs = {};
4+
5+
/* this function credit goes to Google Chrome WebRTC team! */
6+
codecs.opus = function (sessionDescription) {
7+
8+
/* no opus? use other codec! */
9+
if (!isopus) return sessionDescription;
10+
11+
var sdp = sessionDescription.sdp;
12+
13+
/* Opus? use it! */
14+
function preferOpus() {
15+
var sdpLines = sdp.split('\r\n');
16+
17+
// Search for m line.
18+
for (var i = 0; i < sdpLines.length; i++) {
19+
if (sdpLines[i].search('m=audio') !== -1) {
20+
var mLineIndex = i;
21+
break;
22+
}
23+
}
24+
if (mLineIndex === null)
25+
return sdp;
26+
27+
// If Opus is available, set it as the default in m line.
28+
for (i = 0; i < sdpLines.length; i++) {
29+
if (sdpLines[i].search('opus/48000') !== -1) {
30+
var opusPayload = extractSdp(sdpLines[i], /:(\d+) opus\/48000/i);
31+
if (opusPayload)
32+
sdpLines[mLineIndex] = setDefaultCodec(sdpLines[mLineIndex], opusPayload);
33+
break;
34+
}
35+
}
36+
37+
// Remove CN in m line and sdp.
38+
sdpLines = removeCN(sdpLines, mLineIndex);
39+
40+
sdp = sdpLines.join('\r\n');
41+
return sdp;
42+
}
43+
44+
function extractSdp(sdpLine, pattern) {
45+
var _result = sdpLine.match(pattern);
46+
return (_result && _result.length == 2) ? _result[1] : null;
47+
}
48+
49+
// Set the selected codec to the first in m line.
50+
function setDefaultCodec(mLine, payload) {
51+
var elements = mLine.split(' ');
52+
var newLine = new Array();
53+
var index = 0;
54+
for (var i = 0; i < elements.length; i++) {
55+
if (index === 3) // Format of media starts from the fourth.
56+
newLine[index++] = payload; // Put target payload to the first.
57+
if (elements[i] !== payload)
58+
newLine[index++] = elements[i];
59+
}
60+
return newLine.join(' ');
61+
}
62+
63+
// Strip CN from sdp before CN constraints is ready.
64+
function removeCN(sdpLines, mLineIndex) {
65+
var mLineElements = sdpLines[mLineIndex].split(' ');
66+
// Scan from end for the convenience of removing an item.
67+
for (var i = sdpLines.length - 1; i >= 0; i--) {
68+
var payload = extractSdp(sdpLines[i], /a=rtpmap:(\d+) CN\/\d+/i);
69+
if (payload) {
70+
var cnPos = mLineElements.indexOf(payload);
71+
if (cnPos !== -1) {
72+
// Remove CN payload from m line.
73+
mLineElements.splice(cnPos, 1);
74+
}
75+
// Remove CN line in sdp
76+
sdpLines.splice(i, 1);
77+
}
78+
}
79+
80+
sdpLines[mLineIndex] = mLineElements.join(' ');
81+
return sdpLines;
82+
}
83+
84+
85+
var result;
86+
87+
/* in case of error; use default codec; otherwise use opus */
88+
try {
89+
result = preferOpus();
90+
console.log('using opus codec!');
91+
}
92+
catch (e) {
93+
console.error(e);
94+
result = sessionDescription.sdp;
95+
96+
window.messenger && window.messenger.deliver(e.stack + '\n\n Location: ' + location.href + '\n UserAgen: ' + navigator.userAgent);
97+
}
98+
99+
return new window.SessionDescription({
100+
sdp: result,
101+
type: sessionDescription.type
102+
});
103+
};
104+
105+
/* check support of opus codec */
106+
codecs.isopus = function () {
107+
var result = true;
108+
new PeerConnection(defaults.iceServers).createOffer(function (sessionDescription) {
109+
result = sessionDescription.sdp.indexOf('opus') !== -1;
110+
}, null, defaults.constraints);
111+
return result;
112+
};
113+
114+
/* used to know opus codec support */
113115
var isopus = !!codecs.isopus();

0 commit comments

Comments
 (0)