Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Dec 3, 2015
0 parents commit fdd2f73
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
23 changes: 23 additions & 0 deletions .gitignore
@@ -0,0 +1,23 @@
.DS_Store
build
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules
*.sublime*
*.node
coverage
*.orig
.idea
sandbox
19 changes: 19 additions & 0 deletions .jshintrc
@@ -0,0 +1,19 @@
{
"camelcase": true,
"curly": true,
"eqeqeq": true,
"freeze": true,
"indent": 2,
"newcap": false,
"quotmark": "single",
"maxdepth": 3,
"maxstatements": 50,
"maxlen": 80,
"eqnull": true,
"funcscope": true,
"strict": true,
"undef": true,
"unused": true,
"node": true,
"mocha": true
}
23 changes: 23 additions & 0 deletions .npmignore
@@ -0,0 +1,23 @@
.DS_Store
build
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules
*.sublime*
*.node
coverage
*.orig
.idea
sandbox
9 changes: 9 additions & 0 deletions .travis.yml
@@ -0,0 +1,9 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
- '4.0.0'
after_script:
- npm run coveralls
20 changes: 20 additions & 0 deletions LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2015 Contra <contra@maricopa.edu>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software 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:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

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.
76 changes: 76 additions & 0 deletions README.md
@@ -0,0 +1,76 @@
# rtc-everywhere [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Support us][gittip-image]][gittip-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url]


## Information

<table>
<tr>
<td>Package</td>
<td>rtc-everywhere</td>
</tr>
<tr>
<td>Description</td>
<td>Cross-everything WebRTC Adapter/Polyfill</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.10</td>
</tr>
</table>

## Usage

## Install

```
npm install rtc-everywhere --save
```
## Example

```js
EXAMPLEHERE
```

## LICENSE

(MIT License)

Copyright (c) 2015 Contra <contra@maricopa.edu>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software 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:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

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.

[gittip-url]: https://www.gittip.com/contra/
[gittip-image]: http://img.shields.io/gittip/contra.svg

[downloads-image]: http://img.shields.io/npm/dm/rtc-everywhere.svg
[npm-url]: https://npmjs.org/package/rtc-everywhere
[npm-image]: http://img.shields.io/npm/v/rtc-everywhere.svg

[travis-url]: https://travis-ci.org/contra/rtc-everywhere
[travis-image]: https://travis-ci.org/contra/rtc-everywhere.png?branch=master

[coveralls-url]: https://coveralls.io/r/contra/rtc-everywhere
[coveralls-image]: https://coveralls.io/repos/contra/rtc-everywhere/badge.png

[depstat-url]: https://david-dm.org/contra/rtc-everywhere
[depstat-image]: https://david-dm.org/contra/rtc-everywhere.png

[david-url]: https://david-dm.org/contra/rtc-everywhere
[david-image]: https://david-dm.org/contra/rtc-everywhere.png?theme=shields.io
3 changes: 3 additions & 0 deletions index.js
@@ -0,0 +1,3 @@
'use strict';

module.exports = {};
31 changes: 31 additions & 0 deletions lib/getUserMedia/browser.js
@@ -0,0 +1,31 @@
'use strict';

module.exports = function() {
if (typeof navigator === 'undefined') return;
var getUserMedia = navigator.getUserMedia
|| navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia
|| navigator.msGetUserMedia;
if (typeof getUserMedia === 'undefined') return;

return function(constraints, cb) {
// make constraints optional
if (arguments.length !== 2) {
cb = constraints;
constraints = {
video: true,
audio: true
};
}

function success(stream) {
cb(null, stream);
}

function error(err) {
cb(err);
}

getUserMedia.call(navigator, constraints, success, error);
};
};
28 changes: 28 additions & 0 deletions lib/getUserMedia/ios.js
@@ -0,0 +1,28 @@
'use strict';

module.exports = function() {
return function(constraints, cb) {
if (typeof cordova === 'undefined') return;
if (typeof cordova.plugins === 'undefined') return;
if (typeof cordova.plugins.iosrtc === 'undefined') return;

// make constraints optional
if (arguments.length !== 2) {
cb = constraints;
constraints = {
video: true,
audio: true
};
}

function success(stream) {
cb(null, stream);
}

function error(err) {
cb(err);
}

cordova.plugins.iosrtc.getUserMedia(constraints, success, error);
};
};
15 changes: 15 additions & 0 deletions lib/getUserMedia/node.js
@@ -0,0 +1,15 @@
'use strict';

module.exports = function() {
return function(constraints, cb) {

// make constraints optional
if (arguments.length !== 2) {
cb = constraints;
}

var err = new Error('MediaStreamError');
err.name = 'NotSupportedError';
return cb(err);
};
};
41 changes: 41 additions & 0 deletions lib/index.js
@@ -0,0 +1,41 @@
'use strict';

var browser = require('detect-browser');

var getUserMedia, rtc;
switch (browser.name) {
case 'node':
getUserMedia = require('./getUserMedia/node');
rtc = require('./rtc/node');
break;
case 'ios':
getUserMedia = require('./getUserMedia/ios');
rtc = require('./rtc/ios');
break;
case 'chrome':
getUserMedia = require('./getUserMedia/browser');
rtc = require('./rtc/chrome');
break;
case 'firefox':
getUserMedia = require('./getUserMedia/browser');
rtc = require('./rtc/firefox');
break;
case 'edge':
getUserMedia = require('./getUserMedia/browser');
rtc = require('./rtc/edge');
break;
default:
getUserMedia = require('./getUserMedia/browser');
rtc = require('./rtc/unsupported');
break;
}

module.exports = function() {
var ctors = rtc();
return {
getUserMedia: getUserMedia(),
RTCPeerConnection: ctors.RTCPeerConnection,
RTCSessionDescription: ctors.RTCSessionDescription,
RTCIceCandidate: ctors.RTCIceCandidate
};
};
10 changes: 10 additions & 0 deletions lib/rtc/chrome.js
@@ -0,0 +1,10 @@
'use strict';

module.exports = function() {
if (typeof window === 'undefined') return;
return {
RTCPeerConnection: window.RTCPeerConnection || window.webkitRTCPeerConnection,
RTCSessionDescription: window.RTCSessionDescription || window.webkitRTCSessionDescription,
RTCIceCandidate: window.RTCIceCandidate || window.webkitRTCIceCandidate
};
};
10 changes: 10 additions & 0 deletions lib/rtc/edge.js
@@ -0,0 +1,10 @@
'use strict';

module.exports = function() {
var ortc = require('ortc-adapter');
return {
RTCPeerConnection: ortc.RTCPeerConnection,
RTCSessionDescription: ortc.RTCSessionDescription,
RTCIceCandidate: ortc.RTCIceCandidate
};
};
10 changes: 10 additions & 0 deletions lib/rtc/firefox.js
@@ -0,0 +1,10 @@
'use strict';

module.exports = function() {
if (typeof window === 'undefined') return;
return {
RTCPeerConnection: window.RTCPeerConnection || window.mozRTCPeerConnection,
RTCSessionDescription: window.RTCSessionDescription || window.mozRTCSessionDescription,
RTCIceCandidate: window.RTCIceCandidate || window.mozRTCIceCandidate
};
};
13 changes: 13 additions & 0 deletions lib/rtc/ios.js
@@ -0,0 +1,13 @@
'use strict';

module.exports = function() {
if (typeof cordova === 'undefined') return;
if (typeof cordova.plugins === 'undefined') return;
if (typeof cordova.plugins.iosrtc === 'undefined') return;

return {
RTCPeerConnection: cordova.plugins.iosrtc.RTCPeerConnection,
RTCSessionDescription: cordova.plugins.iosrtc.RTCSessionDescription,
RTCIceCandidate: cordova.plugins.iosrtc.RTCIceCandidate
};
};
10 changes: 10 additions & 0 deletions lib/rtc/node.js
@@ -0,0 +1,10 @@
'use strict';

module.exports = function() {
var wrtc = require('wrtc');
return {
RTCPeerConnection: wrtc.RTCPeerConnection,
RTCSessionDescription: wrtc.RTCSessionDescription,
RTCIceCandidate: wrtc.RTCIceCandidate
};
};

0 comments on commit fdd2f73

Please sign in to comment.