├── .bithoundrc ├── .gitignore ├── .travis.yml ├── .zuul.yml ├── AUTHORS ├── LICENSE ├── README.md ├── bower.json ├── defaultconfig.js ├── dist ├── rtc.js ├── rtc.js.map ├── rtc.min.js └── rtc.min.js.map ├── examples ├── datachannel-demo.html ├── layout.css └── simple.html ├── index.js ├── package.json └── test ├── all.js ├── connect.js └── datachannel.js /.bithoundrc: -------------------------------------------------------------------------------- 1 | { 2 | "ignore": [ 3 | "**/node_modules/**", 4 | "**/dist/**", 5 | "**/examples/**", 6 | "**/test/**", 7 | "**/Gruntfile.js", 8 | "**/gulpfile.js" 9 | ] 10 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log 4 | .travis -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.1 4 | notifications: 5 | email: 6 | - damon.oehlman@nicta.com.au 7 | irc: irc.freenode.org#rtc.io 8 | env: 9 | global: 10 | - secure: BvYpTVFZ6EhHV2jtLQ3whIdyXgTJLzSbqWJQBCK0oAsrsXQswskSgbz8H+7xS3T71bt3VW0WKBytSlraLBm4oJb8BTHHcWKoaUSL7VRmkEdgO/wLJL4WBQpDr0a6WVq1VEkGGRo+BbYSqRf6gwGprHWOvx2IjRaTK0xj/Itymi4= 11 | - secure: gGFQZ7PlU9fTqEebsN1mnSnDgjkTfJwj6tXWFhJsbQdQuGzv57TwHrkc7QEPyjqZZJ2J79l62U/phtu2WrRONg16rsaQb81f7gYtyvaS8D8HHNN4ztf/ouSO9GbXi+2RZMaP9lYWOHHhVVNe/vuxAd17VGOdCQLJpG1rVNr36l4= 12 | -------------------------------------------------------------------------------- /.zuul.yml: -------------------------------------------------------------------------------- 1 | ui: mocha-qunit 2 | browsers: 3 | - name: chrome 4 | version: 41..latest 5 | 6 | - name: firefox 7 | version: 36..latest 8 | 9 | # server: ./test/server.js 10 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Damon Oehlman (https://github.com/DamonOehlman) 2 | Silvia Pfeiffer (https://github.com/silviapfeiffer) 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2013 National ICT Australia Limited (NICTA) 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rtc 2 | 3 | This is a package that will provide you a "one-stop shop" for building WebRTC applications. It aggregates together a variety of packages (primarily from the [rtc.io](https://github.com/rtc-io) suite) to deliver a single package for building a WebRTC application. 4 | 5 | [![NPM](https://nodei.co/npm/rtc.png)](https://nodei.co/npm/rtc/) 6 | 7 | [![Build Status](https://img.shields.io/travis/rtc-io/rtc.svg?branch=master)](https://travis-ci.org/rtc-io/rtc) 8 | [![unstable](https://img.shields.io/badge/stability-unstable-yellowgreen.svg)](https://github.com/dominictarr/stability#unstable) 9 | [![bitHound Score](https://www.bithound.io/github/rtc-io/rtc/badges/score.svg)](https://www.bithound.io/github/rtc-io/rtc) 10 | [![Gitter chat](https://badges.gitter.im/rtc-io/discuss.png)](https://gitter.im/rtc-io/discuss) 11 | 12 | ## Getting Started 13 | 14 | Probably the easiest way to get started with `RTC` is to take it for a testdrive using [jsbin](http://jsbin.com/dahuka/edit?html,css,js,output). This demo uses the minified JS file (and associated sourcemaps for debugging) from: 15 | 16 | `//cdn.jsdelivr.net/rtc/latest/rtc.min.js` 17 | 18 | If you wish to use a specific version, then you can replace `latest` with the version number (from `3.0.1` onwards): 19 | 20 | `//cdn.jsdelivr.net/rtc/3.2.3/rtc.min.js` 21 | 22 | ### Package Managers FTW! 23 | 24 | I'd recommend using a package manager if you aren't already and here are the relevant instructions for installing `RTC` from a number of popular options: 25 | 26 | - __npm__: `npm install rtc --save` 27 | - __bower__: `bower install rtc-io/rtc` 28 | 29 | ## Basic Usage 30 | 31 | Establish a connection and render local and remote video feeds. 32 | 33 | ```html 34 | 35 | 36 | rtc.io simple conferencing 37 | 38 | 39 | 40 | 41 |
42 |
43 |
44 |
45 | 46 | 47 | 48 | ``` 49 | 50 | In this example, the [default configuration options](defaultconfig.js) are used for configuration, which are displayed below for informational purposes: 51 | 52 | ```js 53 | // a default configuration that is used by the rtc package 54 | module.exports = { 55 | // simple constraints for defaults 56 | constraints: { 57 | video: true, 58 | audio: true 59 | }, 60 | 61 | // use the public switchboard for signalling 62 | signaller: 'https://switchboard.rtc.io', 63 | 64 | // no room is defined by default 65 | // rtc-quickconnect will autogenerate using a location.hash 66 | room: undefined, 67 | 68 | // specify ice servers or a generator function to create ice servers 69 | ice: [], 70 | 71 | // any data channels that we want to create for the conference 72 | // by default a chat channel is created, but other channels can be added also 73 | // additionally options can be supplied to customize the data channel config 74 | // see: 75 | channels: { 76 | chat: true 77 | }, 78 | 79 | // the selector that will be used to identify the localvideo container 80 | localContainer: '#l-video', 81 | 82 | // the selector that will be used to identify the remotevideo container 83 | remoteContainer: '#r-video', 84 | 85 | // should we atempt to load any plugins? 86 | plugins: [], 87 | 88 | // common options overrides that are used across rtc.io packages 89 | options: {} 90 | }; 91 | ``` 92 | 93 | ## Diving Deeper 94 | 95 | If there is a specific application that you are looking to build with [rtc.io](http://rtc.io/) feel free to [open an issue](https://github.com/rtc-io/rtc/issues/new) and outline a few of your requirements (video, audio, data, etc) and we can give you some advice. In most cases, the following is a good rule of thumb for working our where you should jump in with rtc.io packages. 96 | 97 | - Video and/or audio is crucial to my application and I haven't done a lot of work with [browserify](http://browserify.org) 98 | 99 | _Use the `rtc` distribution files from the CDN, and build your app_ 100 | 101 | - I feel comfortable using browserify, and find it a great way of building apps. 102 | 103 | _Configure your application using npm, and start by including the rtc package (`npm install --save rtc`). If you need more flexibility than what is offered through this package, take something like [`rtc-quickconnect`](https://github.com/rtc-io/rtc-quickconnect) for a spin._ 104 | 105 | - I am building something that isn't really media related, and just want to play with data channels. 106 | 107 | _You are going to want to use [`rtc-quickconnect`](https://github.com/rtc-io/rtc-quickconnect) and we'd strongly recommend getting comfortable with browserify if you aren't already as it's going to make your life a lot easier._ 108 | 109 | 110 | ## Other Simple Demos / Tutorials 111 | 112 | - [Data Channels Only Demo](http://jsbin.com/rimexe/edit?html,js,output) - if you really don't want to go down the [`rtc-quickconnect`](https://github.com/rtc-io/rtc-quickconnect) and browserify road. 113 | 114 | 115 | ## License(s) 116 | 117 | ### Apache 2.0 118 | 119 | Copyright 2014-2015 National ICT Australia Limited (NICTA) 120 | 121 | Licensed under the Apache License, Version 2.0 (the "License"); 122 | you may not use this file except in compliance with the License. 123 | You may obtain a copy of the License at 124 | 125 | http://www.apache.org/licenses/LICENSE-2.0 126 | 127 | Unless required by applicable law or agreed to in writing, software 128 | distributed under the License is distributed on an "AS IS" BASIS, 129 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130 | See the License for the specific language governing permissions and 131 | limitations under the License. 132 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rtc", 3 | "main": "dist/rtc.min.js", 4 | "version": "3.4.0", 5 | "authors": [ 6 | "Damon Oehlman " 7 | ], 8 | "description": "Build WebRTC conferencing applications with easy using rtc.io. This package provides a super-friendly entry point for working with WebRTC, dive into underling rtc.io modules for more configuration and customization opportunities", 9 | "moduleType": [ 10 | "amd", 11 | "globals", 12 | "node" 13 | ], 14 | "keywords": [ 15 | "webrtc", 16 | "rtc.io" 17 | ], 18 | "license": "Apache 2.0", 19 | "homepage": "http://rtc.io/", 20 | "ignore": [ 21 | "node_modules", 22 | "bower_components", 23 | "examples", 24 | "test", 25 | "tests" 26 | ] 27 | } -------------------------------------------------------------------------------- /defaultconfig.js: -------------------------------------------------------------------------------- 1 | // a default configuration that is used by the rtc package 2 | module.exports = { 3 | // simple constraints for defaults 4 | constraints: { 5 | video: true, 6 | audio: true 7 | }, 8 | 9 | // use the public development switchboard for signalling 10 | signaller: 'https://switchboard.rtc.io/', 11 | 12 | // no room is defined by default 13 | // rtc-quickconnect will autogenerate using a location.hash 14 | room: undefined, 15 | 16 | // specify ice servers or a generator function to create ice servers 17 | ice: [], 18 | 19 | // any data channels that we want to create for the conference 20 | // by default a chat channel is created, but other channels can be added also 21 | // additionally options can be supplied to customize the data channel config 22 | // see: 23 | channels: {}, 24 | 25 | // the selector that will be used to identify the localvideo container 26 | localContainer: '#l-video', 27 | 28 | // the selector that will be used to identify the remotevideo container 29 | remoteContainer: '#r-video', 30 | 31 | // should we atempt to load any plugins? 32 | plugins: [], 33 | 34 | // common options overrides that are used across rtc.io packages 35 | options: {} 36 | }; 37 | -------------------------------------------------------------------------------- /examples/datachannel-demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | rtc.io simple chat 4 | 5 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | width: 100%; 3 | height: 100%; 4 | overflow: hidden; 5 | margin: 0; 6 | } 7 | 8 | video { 9 | background: black; 10 | object-fit: cover; 11 | } 12 | 13 | #l-video > * { 14 | max-width: 100%; 15 | } 16 | 17 | #r-video { 18 | overflow: hidden; 19 | } 20 | 21 | #r-video > * { 22 | width: 50%; 23 | } 24 | 25 | #r-video > *:only-child { 26 | width: 100%; 27 | height: 100%; 28 | } 29 | -------------------------------------------------------------------------------- /examples/simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | rtc.io simple conferencing 4 | 5 | 6 | 7 | 8 |
9 |
10 |
11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var defaults = require('cog/defaults'); 2 | var extend = require('cog/extend'); 3 | var attach = require('rtc-attach'); 4 | var capture = require('rtc-capture'); 5 | var quickconnect = require('rtc-quickconnect'); 6 | var chain = require('whisk/chain'); 7 | var append = require('fdom/append'); 8 | var tweak = require('fdom/classtweak'); 9 | var qsa = require('fdom/qsa'); 10 | var kgo = require('kgo'); 11 | 12 | module.exports = function(config) { 13 | var conference; 14 | 15 | // extend our configuration with the defaults 16 | config = defaults({}, config, require('./defaultconfig.js')); 17 | 18 | // remap our options based on top level settings 19 | config.options = extend({ 20 | room: config.room, 21 | ice: config.ice, 22 | plugins: config.plugins, 23 | expectedLocalStreams: config.constraints ? 1 : 0 24 | }, config.options); 25 | 26 | // create our conference instance 27 | conference = quickconnect(config.signaller, config.options); 28 | 29 | conference 30 | .on('call:ended', removeRemoteVideos) 31 | .on('stream:added', remoteVideo(conference, config)); 32 | 33 | Object.keys(config.channels || {}).forEach(function(name) { 34 | var channelConfig = config.channels[name]; 35 | 36 | conference.createDataChannel(name, channelConfig === true ? null : channelConfig); 37 | }); 38 | 39 | // if we have constraints, then capture video 40 | if (config.constraints) { 41 | localVideo(conference, config); 42 | } 43 | 44 | return conference; 45 | }; 46 | 47 | function flagOwnership(peerId) { 48 | return function(el) { 49 | el.dataset.peer = peerId; 50 | }; 51 | } 52 | 53 | function localVideo(qc, config) { 54 | // use kgo to help with flow control 55 | kgo(config) 56 | ('capture', [ 'constraints', 'options' ], capture) 57 | ('attach', [ 'capture', 'options' ], attach.local) 58 | ('render-local', [ 'attach' ], chain([ 59 | tweak('+rtc'), 60 | tweak('+localvideo'), 61 | append.to((config || {}).localContainer || '#l-video') 62 | ])) 63 | ('start-conference', [ 'capture' ], qc.addStream) 64 | .on('error', reportError(qc, config)); 65 | } 66 | 67 | function remoteVideo(qc, config) { 68 | return function(id, stream) { 69 | kgo(extend({ stream: stream }, config)) 70 | ('attach', [ 'stream', 'options' ], attach) 71 | ('render-remote', [ 'attach' ], chain([ 72 | tweak('+rtc'), 73 | tweak('+remotevideo'), 74 | flagOwnership(id), 75 | append.to((config || {}).remoteContainer || '#r-video') 76 | ])) 77 | .on('error', reportError(qc, config)); 78 | }; 79 | } 80 | 81 | function removeRemoteVideos(id) { 82 | qsa('[data-peer="' + id + '"]').forEach(function(el) { 83 | el.parentNode.removeChild(el); 84 | }); 85 | } 86 | 87 | function reportError(qc, config) { 88 | return function(err) { 89 | console.error(err); 90 | }; 91 | } 92 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rtc", 3 | "version": "3.4.0", 4 | "description": "Build WebRTC conferencing applications with easy using rtc.io. This package provides a super-friendly entry point for working with WebRTC, dive into underling rtc.io modules for more configuration and customization opportunities", 5 | "main": "index.js", 6 | "scripts": { 7 | "browserify": "mkdir -p dist && browserify index.js -s RTC --debug | exorcist dist/rtc.js.map > dist/rtc.js", 8 | "uglify": "uglifyjs --screw-ie8 --mangle --compress --in-source-map dist/rtc.js.map --source-map-include-sources --source-map dist/rtc.min.js.map --source-map-url rtc.min.js.map --output dist/rtc.min.js dist/rtc.js", 9 | "build": "npm dedupe && npm run browserify && npm run uglify", 10 | "prepublish": "npm run build", 11 | "test": "zuul -- test/all.js" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/rtc-io/rtc.git" 16 | }, 17 | "keywords": [ 18 | "webrtc", 19 | "rtc.io" 20 | ], 21 | "author": "Damon Oehlman ", 22 | "license": "Apache 2.0", 23 | "bugs": { 24 | "url": "https://github.com/rtc-io/rtc/issues" 25 | }, 26 | "homepage": "https://github.com/rtc-io/rtc", 27 | "dependencies": { 28 | "cog": "^1.0.0", 29 | "fdom": "^1.0.0", 30 | "kgo": "^2.0.0", 31 | "rtc-attach": "^2.0.1", 32 | "rtc-capture": "^1.0.1", 33 | "rtc-quickconnect": "^4.1.0", 34 | "whisk": "^1.0.0" 35 | }, 36 | "devDependencies": { 37 | "browserify": "^9.0.3", 38 | "exorcist": "^0.3.0", 39 | "mocha": "^2.1.0", 40 | "uglify-js": "^2.4.15", 41 | "uuid": "^2.0.1", 42 | "zuul": "^2.0.0" 43 | } 44 | } -------------------------------------------------------------------------------- /test/all.js: -------------------------------------------------------------------------------- 1 | mocha.globals(['Primus']); 2 | 3 | require('./connect'); 4 | require('./datachannel'); 5 | -------------------------------------------------------------------------------- /test/connect.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var uuid = require('uuid'); 3 | var RTC = require('../'); 4 | var connections = []; 5 | var roomId = uuid.v4(); 6 | 7 | suite('connectivity'); 8 | 9 | test('create connection:0', function() { 10 | var conn = RTC({ room: roomId, constraints: null }); 11 | 12 | assert(conn); 13 | assert(conn.id); 14 | connections.push(conn); 15 | }); 16 | 17 | test('create connection:1', function() { 18 | var conn = RTC({ room: roomId, constraints: null }); 19 | 20 | assert(conn); 21 | assert(conn.id); 22 | connections.push(conn); 23 | }); 24 | 25 | test('receive call:started events for both connections', function(done) { 26 | var expected = 2; 27 | 28 | function checkExpected() { 29 | expected--; 30 | if (expected <= 0) { 31 | done(); 32 | } 33 | } 34 | 35 | this.timeout(10e3); 36 | 37 | connections[0].once('call:started', function(id) { 38 | assert.equal(id, connections[1].id); 39 | checkExpected(); 40 | }); 41 | 42 | connections[1].once('call:started', function(id) { 43 | assert.equal(id, connections[0].id); 44 | checkExpected(); 45 | }); 46 | }); 47 | 48 | test('close connections', function() { 49 | connections.splice(0).forEach(function(conn) { 50 | conn.close(); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /test/datachannel.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var uuid = require('uuid'); 3 | var RTC = require('../'); 4 | var connections = []; 5 | var roomId = uuid.v4(); 6 | var dcs = []; 7 | 8 | suite('datachannels connectivity'); 9 | 10 | test('create connection:0', function() { 11 | var conn = RTC({ room: roomId, constraints: null }); 12 | 13 | // create the datachannel 14 | conn.createDataChannel('test'); 15 | 16 | assert(conn); 17 | assert(conn.id); 18 | connections.push(conn); 19 | }); 20 | 21 | test('create connection:1', function() { 22 | var conn = RTC({ room: roomId, constraints: null }); 23 | 24 | // create the datachannel 25 | conn.createDataChannel('test'); 26 | 27 | assert(conn); 28 | assert(conn.id); 29 | connections.push(conn); 30 | }); 31 | 32 | test('receive channel:opened:test events for both connections', function(done) { 33 | var expected = 2; 34 | 35 | function checkExpected() { 36 | expected--; 37 | if (expected <= 0) { 38 | done(); 39 | } 40 | } 41 | 42 | this.timeout(10e3); 43 | 44 | connections[0].once('channel:opened:test', function(id, dc) { 45 | assert.equal(id, connections[1].id); 46 | dcs[0] = dc; 47 | 48 | checkExpected(); 49 | }); 50 | 51 | connections[1].once('channel:opened:test', function(id, dc) { 52 | assert.equal(id, connections[0].id); 53 | dcs[1] = dc; 54 | 55 | checkExpected(); 56 | }); 57 | }); 58 | 59 | test('close connections', function() { 60 | connections.splice(0).forEach(function(conn) { 61 | conn.close(); 62 | }); 63 | }); 64 | --------------------------------------------------------------------------------