mirror of https://github.com/OpenVidu/openvidu.git
Use NPM dependencies for openvidu-browser
This avoid to include several scripts in every webpage using OpenVidu. It also make easier to update dependency versions.pull/1/head
parent
47b6a979bd
commit
648bb2f071
|
@ -0,0 +1,2 @@
|
|||
/node_modules/
|
||||
/yarn.lock
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "openvidu",
|
||||
"version": "0.0.1",
|
||||
"description": "OpenVidu Browser",
|
||||
"main": "OpenVidu.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"kurento-jsonrpc": "5.1.3",
|
||||
"wolfy87-eventemitter": "4.2.9",
|
||||
"@types/wolfy87-eventemitter": "4.2.31",
|
||||
"webrtc-adapter":"2.0.4",
|
||||
"kurento-utils":"6.6.0",
|
||||
"uuid": "~2.0.1",
|
||||
"sdp-translator": "^0.1.15"
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +0,0 @@
|
|||
export { Session } from './Session';
|
||||
export { Participant } from './Participant';
|
||||
export { Stream } from './Stream';
|
||||
export { OpenVidu } from './OpenVidu';
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
console.error("Error: Cannot find module 'kurento-browser-extensions' from '/home/mica/Data/Kurento/OpenVidu/git2/openvidu/openvidu-browser/src/main/resources/node_modules/kurento-utils/lib'");
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,12 @@
|
|||
import { OpenVidu } from './OpenVidu';
|
||||
|
||||
//This export with --standalone option allows using OpenVidu from bowser with namespace
|
||||
//export { OpenVidu } from './OpenVidu';
|
||||
|
||||
//This "hack" allows to use OpenVidu from the global space window
|
||||
if(window){
|
||||
window["OpenVidu"] = OpenVidu;
|
||||
}
|
||||
|
||||
//Command to generate bundle.js without namespace
|
||||
//watchify Main.ts -p [ tsify ] --exclude kurento-browser-extensions --debug -o ../static/js/OpenVidu.js -v
|
|
@ -14,11 +14,9 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
import { Session, SessionOptions } from './Session';
|
||||
import { Stream } from './Stream';
|
||||
|
||||
declare var RpcBuilder: any;
|
||||
import * as RpcBuilder from 'kurento-jsonrpc';
|
||||
|
||||
export type Callback<T> = ( error?: any, openVidu?: T ) => void;
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
import { Stream } from './Stream';
|
||||
import { OpenVidu } from './OpenVidu';
|
||||
import { Participant, ParticipantOptions } from './Participant';
|
||||
|
||||
declare let EventEmitter;
|
||||
import EventEmitter = require('wolfy87-eventemitter');
|
||||
|
||||
export interface SessionOptions {
|
||||
sessionId: string;
|
|
@ -8,16 +8,26 @@
|
|||
import { Participant } from './Participant';
|
||||
import { Session } from './Session';
|
||||
import { OpenVidu, Callback } from './OpenVidu';
|
||||
import EventEmitter = require('wolfy87-eventemitter');
|
||||
import * as kurentoUtils from 'kurento-utils';
|
||||
|
||||
declare type JQuery = any;
|
||||
declare var $: JQuery;
|
||||
declare var kurentoUtils: any;
|
||||
declare var getUserMedia: any;
|
||||
//See http://stackoverflow.com/questions/37112074/how-to-use-webrtc-adapter-adapter-js-shim-in-webpack
|
||||
//declare function require(moduleName: string)
|
||||
//require('webrtc-adapter');
|
||||
import 'webrtc-adapter';
|
||||
declare var navigator: any;
|
||||
declare var RTCSessionDescription: any;
|
||||
declare var EventEmitter: any;
|
||||
|
||||
function jq(id: string) {
|
||||
return "#" + id.replace(/(@|:|\.|\[|\]|,)/g, "\\$1");
|
||||
function jq(id: string):string {
|
||||
return /*"#" +*/ id.replace(/(@|:|\.|\[|\]|,)/g, "\\$1");
|
||||
}
|
||||
|
||||
function show(id: string){
|
||||
document.getElementById(jq(id))!.style.display = 'block';
|
||||
}
|
||||
|
||||
function hide(id: string){
|
||||
document.getElementById(jq(id))!.style.display = 'none';
|
||||
}
|
||||
|
||||
export interface StreamOptions {
|
||||
|
@ -156,7 +166,7 @@ export class Stream {
|
|||
|
||||
hideSpinner( spinnerId?: string ) {
|
||||
spinnerId = ( spinnerId === undefined ) ? this.getId() : spinnerId;
|
||||
$( jq( 'progress-' + spinnerId ) ).hide();
|
||||
hide( 'progress-' + spinnerId );
|
||||
}
|
||||
|
||||
playOnlyVideo( parentElement, thumbnailId ) {
|
||||
|
@ -167,7 +177,7 @@ export class Stream {
|
|||
this.video.controls = false;
|
||||
if ( this.wrStream ) {
|
||||
this.video.src = URL.createObjectURL( this.wrStream );
|
||||
$( jq( thumbnailId ) ).show();
|
||||
show( thumbnailId );
|
||||
this.hideSpinner();
|
||||
} else {
|
||||
console.log( "No wrStream yet for", this.getId() );
|
||||
|
@ -254,7 +264,7 @@ export class Stream {
|
|||
}
|
||||
};
|
||||
|
||||
getUserMedia( constraints, userStream => {
|
||||
navigator.getUserMedia( constraints, userStream => {
|
||||
this.wrStream = userStream;
|
||||
callback(undefined, this);
|
||||
}, error => {
|
||||
|
@ -425,7 +435,7 @@ export class Stream {
|
|||
video.src = URL.createObjectURL( this.wrStream );
|
||||
video.onplay = () => {
|
||||
console.log( this.getId() + ': ' + 'Video playing' );
|
||||
$( jq( thumbnailId ) ).show();
|
||||
show(thumbnailId);
|
||||
this.hideSpinner( this.getId() );
|
||||
};
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
declare module "kurento-jsonrpc";
|
||||
declare module "webrtc-adapter";
|
||||
declare module "kurento-utils";
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"module": "commonjs",
|
||||
//"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
//"noUnusedLocals": true,
|
|
@ -5,22 +5,13 @@
|
|||
<meta charset="utf-8">
|
||||
<link rel="styleSheet" href="style.css" type="text/css" media="screen">
|
||||
|
||||
<script src="./js/adapter.js"></script>
|
||||
<script src="./js/jquery-2.1.1.min.js"></script>
|
||||
<script src="./js/kurento-utils.js"></script>
|
||||
<script src="./js/kurento-jsonrpc.js"></script>
|
||||
<script src="./js/OpenVidu.js"></script>
|
||||
|
||||
<script src="./js/console.js"></script>
|
||||
<script src="./js/EventEmitter.js"></script>
|
||||
<script src="webjars/system.js/0.19.17/dist/system.js"></script>
|
||||
<script src="./ts_js/OpenVidu.js"></script>
|
||||
<script src="./js/testapp.js"></script>
|
||||
<script src="./js/color.js"></script>
|
||||
<script src="./js/stats.js"></script>
|
||||
|
||||
<script>
|
||||
System.import('Main').then(function(m){ OpenVidu = m.OpenVidu; }, console.error.bind(console));
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
@ -33,7 +24,7 @@
|
|||
placeholder="User" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" name="room" value="" id="roomId"
|
||||
<input type="text" name="room" value="a" id="roomId"
|
||||
placeholder="Room" required>
|
||||
</p>
|
||||
<p class="submit">
|
||||
|
@ -52,4 +43,5 @@
|
|||
</div>
|
||||
<div id="console"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,472 +0,0 @@
|
|||
/*!
|
||||
* EventEmitter v4.2.11 - git.io/ee
|
||||
* Unlicense - http://unlicense.org/
|
||||
* Oliver Caldwell - http://oli.me.uk/
|
||||
* @preserve
|
||||
*/
|
||||
|
||||
;(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Class for managing events.
|
||||
* Can be extended to provide event functionality in other classes.
|
||||
*
|
||||
* @class EventEmitter Manages event registering and emitting.
|
||||
*/
|
||||
function EventEmitter() {}
|
||||
|
||||
// Shortcuts to improve speed and size
|
||||
var proto = EventEmitter.prototype;
|
||||
var exports = this;
|
||||
var originalGlobalValue = exports.EventEmitter;
|
||||
|
||||
/**
|
||||
* Finds the index of the listener for the event in its storage array.
|
||||
*
|
||||
* @param {Function[]} listeners Array of listeners to search through.
|
||||
* @param {Function} listener Method to look for.
|
||||
* @return {Number} Index of the specified listener, -1 if not found
|
||||
* @api private
|
||||
*/
|
||||
function indexOfListener(listeners, listener) {
|
||||
var i = listeners.length;
|
||||
while (i--) {
|
||||
if (listeners[i].listener === listener) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias a method while keeping the context correct, to allow for overwriting of target method.
|
||||
*
|
||||
* @param {String} name The name of the target method.
|
||||
* @return {Function} The aliased method
|
||||
* @api private
|
||||
*/
|
||||
function alias(name) {
|
||||
return function aliasClosure() {
|
||||
return this[name].apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the listener array for the specified event.
|
||||
* Will initialise the event object and listener arrays if required.
|
||||
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
|
||||
* Each property in the object response is an array of listener functions.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to return the listeners from.
|
||||
* @return {Function[]|Object} All listener functions for the event.
|
||||
*/
|
||||
proto.getListeners = function getListeners(evt) {
|
||||
var events = this._getEvents();
|
||||
var response;
|
||||
var key;
|
||||
|
||||
// Return a concatenated array of all matching events if
|
||||
// the selector is a regular expression.
|
||||
if (evt instanceof RegExp) {
|
||||
response = {};
|
||||
for (key in events) {
|
||||
if (events.hasOwnProperty(key) && evt.test(key)) {
|
||||
response[key] = events[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
response = events[evt] || (events[evt] = []);
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a list of listener objects and flattens it into a list of listener functions.
|
||||
*
|
||||
* @param {Object[]} listeners Raw listener objects.
|
||||
* @return {Function[]} Just the listener functions.
|
||||
*/
|
||||
proto.flattenListeners = function flattenListeners(listeners) {
|
||||
var flatListeners = [];
|
||||
var i;
|
||||
|
||||
for (i = 0; i < listeners.length; i += 1) {
|
||||
flatListeners.push(listeners[i].listener);
|
||||
}
|
||||
|
||||
return flatListeners;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to return the listeners from.
|
||||
* @return {Object} All listener functions for an event in an object.
|
||||
*/
|
||||
proto.getListenersAsObject = function getListenersAsObject(evt) {
|
||||
var listeners = this.getListeners(evt);
|
||||
var response;
|
||||
|
||||
if (listeners instanceof Array) {
|
||||
response = {};
|
||||
response[evt] = listeners;
|
||||
}
|
||||
|
||||
return response || listeners;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a listener function to the specified event.
|
||||
* The listener will not be added if it is a duplicate.
|
||||
* If the listener returns true then it will be removed after it is called.
|
||||
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to attach the listener to.
|
||||
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.addListener = function addListener(evt, listener) {
|
||||
var listeners = this.getListenersAsObject(evt);
|
||||
var listenerIsWrapped = typeof listener === 'object';
|
||||
var key;
|
||||
|
||||
for (key in listeners) {
|
||||
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
|
||||
listeners[key].push(listenerIsWrapped ? listener : {
|
||||
listener: listener,
|
||||
once: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of addListener
|
||||
*/
|
||||
proto.on = alias('addListener');
|
||||
|
||||
/**
|
||||
* Semi-alias of addListener. It will add a listener that will be
|
||||
* automatically removed after its first execution.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to attach the listener to.
|
||||
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.addOnceListener = function addOnceListener(evt, listener) {
|
||||
return this.addListener(evt, {
|
||||
listener: listener,
|
||||
once: true
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of addOnceListener.
|
||||
*/
|
||||
proto.once = alias('addOnceListener');
|
||||
|
||||
/**
|
||||
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
|
||||
* You need to tell it what event names should be matched by a regex.
|
||||
*
|
||||
* @param {String} evt Name of the event to create.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.defineEvent = function defineEvent(evt) {
|
||||
this.getListeners(evt);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses defineEvent to define multiple events.
|
||||
*
|
||||
* @param {String[]} evts An array of event names to define.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.defineEvents = function defineEvents(evts) {
|
||||
for (var i = 0; i < evts.length; i += 1) {
|
||||
this.defineEvent(evts[i]);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a listener function from the specified event.
|
||||
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to remove the listener from.
|
||||
* @param {Function} listener Method to remove from the event.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.removeListener = function removeListener(evt, listener) {
|
||||
var listeners = this.getListenersAsObject(evt);
|
||||
var index;
|
||||
var key;
|
||||
|
||||
for (key in listeners) {
|
||||
if (listeners.hasOwnProperty(key)) {
|
||||
index = indexOfListener(listeners[key], listener);
|
||||
|
||||
if (index !== -1) {
|
||||
listeners[key].splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of removeListener
|
||||
*/
|
||||
proto.off = alias('removeListener');
|
||||
|
||||
/**
|
||||
* Adds listeners in bulk using the manipulateListeners method.
|
||||
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
|
||||
* You can also pass it a regular expression to add the array of listeners to all events that match it.
|
||||
* Yeah, this function does quite a bit. That's probably a bad thing.
|
||||
*
|
||||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
|
||||
* @param {Function[]} [listeners] An optional array of listener functions to add.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.addListeners = function addListeners(evt, listeners) {
|
||||
// Pass through to manipulateListeners
|
||||
return this.manipulateListeners(false, evt, listeners);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes listeners in bulk using the manipulateListeners method.
|
||||
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
|
||||
* You can also pass it an event name and an array of listeners to be removed.
|
||||
* You can also pass it a regular expression to remove the listeners from all events that match it.
|
||||
*
|
||||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
|
||||
* @param {Function[]} [listeners] An optional array of listener functions to remove.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.removeListeners = function removeListeners(evt, listeners) {
|
||||
// Pass through to manipulateListeners
|
||||
return this.manipulateListeners(true, evt, listeners);
|
||||
};
|
||||
|
||||
/**
|
||||
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
|
||||
* The first argument will determine if the listeners are removed (true) or added (false).
|
||||
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
|
||||
* You can also pass it an event name and an array of listeners to be added/removed.
|
||||
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
|
||||
*
|
||||
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
|
||||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
|
||||
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
|
||||
var i;
|
||||
var value;
|
||||
var single = remove ? this.removeListener : this.addListener;
|
||||
var multiple = remove ? this.removeListeners : this.addListeners;
|
||||
|
||||
// If evt is an object then pass each of its properties to this method
|
||||
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
|
||||
for (i in evt) {
|
||||
if (evt.hasOwnProperty(i) && (value = evt[i])) {
|
||||
// Pass the single listener straight through to the singular method
|
||||
if (typeof value === 'function') {
|
||||
single.call(this, i, value);
|
||||
}
|
||||
else {
|
||||
// Otherwise pass back to the multiple function
|
||||
multiple.call(this, i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// So evt must be a string
|
||||
// And listeners must be an array of listeners
|
||||
// Loop over it and pass each one to the multiple method
|
||||
i = listeners.length;
|
||||
while (i--) {
|
||||
single.call(this, evt, listeners[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all listeners from a specified event.
|
||||
* If you do not specify an event then all listeners will be removed.
|
||||
* That means every event will be emptied.
|
||||
* You can also pass a regex to remove all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.removeEvent = function removeEvent(evt) {
|
||||
var type = typeof evt;
|
||||
var events = this._getEvents();
|
||||
var key;
|
||||
|
||||
// Remove different things depending on the state of evt
|
||||
if (type === 'string') {
|
||||
// Remove all listeners for the specified event
|
||||
delete events[evt];
|
||||
}
|
||||
else if (evt instanceof RegExp) {
|
||||
// Remove all events matching the regex.
|
||||
for (key in events) {
|
||||
if (events.hasOwnProperty(key) && evt.test(key)) {
|
||||
delete events[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Remove all listeners in all events
|
||||
delete this._events;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of removeEvent.
|
||||
*
|
||||
* Added to mirror the node API.
|
||||
*/
|
||||
proto.removeAllListeners = alias('removeEvent');
|
||||
|
||||
/**
|
||||
* Emits an event of your choice.
|
||||
* When emitted, every listener attached to that event will be executed.
|
||||
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
|
||||
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
|
||||
* So they will not arrive within the array on the other side, they will be separate.
|
||||
* You can also pass a regular expression to emit to all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
|
||||
* @param {Array} [args] Optional array of arguments to be passed to each listener.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.emitEvent = function emitEvent(evt, args) {
|
||||
var listeners = this.getListenersAsObject(evt);
|
||||
var listener;
|
||||
var i;
|
||||
var key;
|
||||
var response;
|
||||
|
||||
for (key in listeners) {
|
||||
if (listeners.hasOwnProperty(key)) {
|
||||
i = listeners[key].length;
|
||||
|
||||
while (i--) {
|
||||
// If the listener returns true then it shall be removed from the event
|
||||
// The function is executed either with a basic call or an apply if there is an args array
|
||||
listener = listeners[key][i];
|
||||
|
||||
if (listener.once === true) {
|
||||
this.removeListener(evt, listener.listener);
|
||||
}
|
||||
|
||||
response = listener.listener.apply(this, args || []);
|
||||
|
||||
if (response === this._getOnceReturnValue()) {
|
||||
this.removeListener(evt, listener.listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of emitEvent
|
||||
*/
|
||||
proto.trigger = alias('emitEvent');
|
||||
|
||||
/**
|
||||
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
|
||||
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
|
||||
* @param {...*} Optional additional arguments to be passed to each listener.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.emit = function emit(evt) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
return this.emitEvent(evt, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the current value to check against when executing listeners. If a
|
||||
* listeners return value matches the one set here then it will be removed
|
||||
* after execution. This value defaults to true.
|
||||
*
|
||||
* @param {*} value The new value to check for when executing listeners.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.setOnceReturnValue = function setOnceReturnValue(value) {
|
||||
this._onceReturnValue = value;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the current value to check against when executing listeners. If
|
||||
* the listeners return value matches this one then it should be removed
|
||||
* automatically. It will return true by default.
|
||||
*
|
||||
* @return {*|Boolean} The current value to check for or the default, true.
|
||||
* @api private
|
||||
*/
|
||||
proto._getOnceReturnValue = function _getOnceReturnValue() {
|
||||
if (this.hasOwnProperty('_onceReturnValue')) {
|
||||
return this._onceReturnValue;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the events object and creates one if required.
|
||||
*
|
||||
* @return {Object} The events storage object.
|
||||
* @api private
|
||||
*/
|
||||
proto._getEvents = function _getEvents() {
|
||||
return this._events || (this._events = {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
|
||||
*
|
||||
* @return {Function} Non conflicting EventEmitter class.
|
||||
*/
|
||||
EventEmitter.noConflict = function noConflict() {
|
||||
exports.EventEmitter = originalGlobalValue;
|
||||
return EventEmitter;
|
||||
};
|
||||
|
||||
// Expose the class either via AMD, CommonJS or the global object
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(function () {
|
||||
return EventEmitter;
|
||||
});
|
||||
}
|
||||
else if (typeof module === 'object' && module.exports){
|
||||
module.exports = EventEmitter;
|
||||
}
|
||||
else {
|
||||
exports.EventEmitter = EventEmitter;
|
||||
}
|
||||
}.call(this));
|
|
@ -1,536 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree.
|
||||
*/
|
||||
|
||||
/* More information about these options at jshint.com/docs/options */
|
||||
/* jshint browser: true, camelcase: true, curly: true, devel: true,
|
||||
eqeqeq: true, forin: false, globalstrict: true, node: true,
|
||||
quotmark: single, undef: true, unused: strict */
|
||||
/* global mozRTCIceCandidate, mozRTCPeerConnection, Promise,
|
||||
mozRTCSessionDescription, webkitRTCPeerConnection, MediaStreamTrack */
|
||||
/* exported trace,requestUserMedia */
|
||||
|
||||
'use strict';
|
||||
|
||||
var getUserMedia = null;
|
||||
var attachMediaStream = null;
|
||||
var reattachMediaStream = null;
|
||||
var webrtcDetectedBrowser = null;
|
||||
var webrtcDetectedVersion = null;
|
||||
var webrtcMinimumVersion = null;
|
||||
var webrtcUtils = {
|
||||
log: function() {
|
||||
// suppress console.log output when being included as a module.
|
||||
if (typeof module !== 'undefined' ||
|
||||
typeof require === 'function' && typeof define === 'function') {
|
||||
return;
|
||||
}
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
function trace(text) {
|
||||
// This function is used for logging.
|
||||
if (text[text.length - 1] === '\n') {
|
||||
text = text.substring(0, text.length - 1);
|
||||
}
|
||||
if (window.performance) {
|
||||
var now = (window.performance.now() / 1000).toFixed(3);
|
||||
webrtcUtils.log(now + ': ' + text);
|
||||
} else {
|
||||
webrtcUtils.log(text);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window === 'object') {
|
||||
if (window.HTMLMediaElement &&
|
||||
!('srcObject' in window.HTMLMediaElement.prototype)) {
|
||||
// Shim the srcObject property, once, when HTMLMediaElement is found.
|
||||
Object.defineProperty(window.HTMLMediaElement.prototype, 'srcObject', {
|
||||
get: function() {
|
||||
// If prefixed srcObject property exists, return it.
|
||||
// Otherwise use the shimmed property, _srcObject
|
||||
return 'mozSrcObject' in this ? this.mozSrcObject : this._srcObject;
|
||||
},
|
||||
set: function(stream) {
|
||||
if ('mozSrcObject' in this) {
|
||||
this.mozSrcObject = stream;
|
||||
} else {
|
||||
// Use _srcObject as a private property for this shim
|
||||
this._srcObject = stream;
|
||||
// TODO: revokeObjectUrl(this.src) when !stream to release resources?
|
||||
this.src = URL.createObjectURL(stream);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Proxy existing globals
|
||||
getUserMedia = window.navigator && window.navigator.getUserMedia;
|
||||
}
|
||||
|
||||
// Attach a media stream to an element.
|
||||
attachMediaStream = function(element, stream) {
|
||||
element.srcObject = stream;
|
||||
};
|
||||
|
||||
reattachMediaStream = function(to, from) {
|
||||
to.srcObject = from.srcObject;
|
||||
};
|
||||
|
||||
if (typeof window === 'undefined' || !window.navigator) {
|
||||
webrtcUtils.log('This does not appear to be a browser');
|
||||
webrtcDetectedBrowser = 'not a browser';
|
||||
} else if (navigator.mozGetUserMedia && window.mozRTCPeerConnection) {
|
||||
webrtcUtils.log('This appears to be Firefox');
|
||||
|
||||
webrtcDetectedBrowser = 'firefox';
|
||||
|
||||
// the detected firefox version.
|
||||
webrtcDetectedVersion =
|
||||
parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1], 10);
|
||||
|
||||
// the minimum firefox version still supported by adapter.
|
||||
webrtcMinimumVersion = 31;
|
||||
|
||||
// The RTCPeerConnection object.
|
||||
window.RTCPeerConnection = function(pcConfig, pcConstraints) {
|
||||
if (webrtcDetectedVersion < 38) {
|
||||
// .urls is not supported in FF < 38.
|
||||
// create RTCIceServers with a single url.
|
||||
if (pcConfig && pcConfig.iceServers) {
|
||||
var newIceServers = [];
|
||||
for (var i = 0; i < pcConfig.iceServers.length; i++) {
|
||||
var server = pcConfig.iceServers[i];
|
||||
if (server.hasOwnProperty('urls')) {
|
||||
for (var j = 0; j < server.urls.length; j++) {
|
||||
var newServer = {
|
||||
url: server.urls[j]
|
||||
};
|
||||
if (server.urls[j].indexOf('turn') === 0) {
|
||||
newServer.username = server.username;
|
||||
newServer.credential = server.credential;
|
||||
}
|
||||
newIceServers.push(newServer);
|
||||
}
|
||||
} else {
|
||||
newIceServers.push(pcConfig.iceServers[i]);
|
||||
}
|
||||
}
|
||||
pcConfig.iceServers = newIceServers;
|
||||
}
|
||||
}
|
||||
return new mozRTCPeerConnection(pcConfig, pcConstraints); // jscs:ignore requireCapitalizedConstructors
|
||||
};
|
||||
|
||||
// The RTCSessionDescription object.
|
||||
window.RTCSessionDescription = mozRTCSessionDescription;
|
||||
|
||||
// The RTCIceCandidate object.
|
||||
window.RTCIceCandidate = mozRTCIceCandidate;
|
||||
|
||||
// getUserMedia constraints shim.
|
||||
getUserMedia = function(constraints, onSuccess, onError) {
|
||||
var constraintsToFF37 = function(c) {
|
||||
if (typeof c !== 'object' || c.require) {
|
||||
return c;
|
||||
}
|
||||
var require = [];
|
||||
Object.keys(c).forEach(function(key) {
|
||||
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
|
||||
return;
|
||||
}
|
||||
var r = c[key] = (typeof c[key] === 'object') ?
|
||||
c[key] : {ideal: c[key]};
|
||||
if (r.min !== undefined ||
|
||||
r.max !== undefined || r.exact !== undefined) {
|
||||
require.push(key);
|
||||
}
|
||||
if (r.exact !== undefined) {
|
||||
if (typeof r.exact === 'number') {
|
||||
r.min = r.max = r.exact;
|
||||
} else {
|
||||
c[key] = r.exact;
|
||||
}
|
||||
delete r.exact;
|
||||
}
|
||||
if (r.ideal !== undefined) {
|
||||
c.advanced = c.advanced || [];
|
||||
var oc = {};
|
||||
if (typeof r.ideal === 'number') {
|
||||
oc[key] = {min: r.ideal, max: r.ideal};
|
||||
} else {
|
||||
oc[key] = r.ideal;
|
||||
}
|
||||
c.advanced.push(oc);
|
||||
delete r.ideal;
|
||||
if (!Object.keys(r).length) {
|
||||
delete c[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
if (require.length) {
|
||||
c.require = require;
|
||||
}
|
||||
return c;
|
||||
};
|
||||
if (webrtcDetectedVersion < 38) {
|
||||
webrtcUtils.log('spec: ' + JSON.stringify(constraints));
|
||||
if (constraints.audio) {
|
||||
constraints.audio = constraintsToFF37(constraints.audio);
|
||||
}
|
||||
if (constraints.video) {
|
||||
constraints.video = constraintsToFF37(constraints.video);
|
||||
}
|
||||
webrtcUtils.log('ff37: ' + JSON.stringify(constraints));
|
||||
}
|
||||
return navigator.mozGetUserMedia(constraints, onSuccess, onError);
|
||||
};
|
||||
|
||||
navigator.getUserMedia = getUserMedia;
|
||||
|
||||
// Shim for mediaDevices on older versions.
|
||||
if (!navigator.mediaDevices) {
|
||||
navigator.mediaDevices = {getUserMedia: requestUserMedia,
|
||||
addEventListener: function() { },
|
||||
removeEventListener: function() { }
|
||||
};
|
||||
}
|
||||
navigator.mediaDevices.enumerateDevices =
|
||||
navigator.mediaDevices.enumerateDevices || function() {
|
||||
return new Promise(function(resolve) {
|
||||
var infos = [
|
||||
{kind: 'audioinput', deviceId: 'default', label: '', groupId: ''},
|
||||
{kind: 'videoinput', deviceId: 'default', label: '', groupId: ''}
|
||||
];
|
||||
resolve(infos);
|
||||
});
|
||||
};
|
||||
|
||||
if (webrtcDetectedVersion < 41) {
|
||||
// Work around http://bugzil.la/1169665
|
||||
var orgEnumerateDevices =
|
||||
navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);
|
||||
navigator.mediaDevices.enumerateDevices = function() {
|
||||
return orgEnumerateDevices().catch(function(e) {
|
||||
if (e.name === 'NotFoundError') {
|
||||
return [];
|
||||
}
|
||||
throw e;
|
||||
});
|
||||
};
|
||||
}
|
||||
} else if (navigator.webkitGetUserMedia && !!window.chrome) {
|
||||
webrtcUtils.log('This appears to be Chrome');
|
||||
|
||||
webrtcDetectedBrowser = 'chrome';
|
||||
|
||||
// the detected chrome version.
|
||||
webrtcDetectedVersion =
|
||||
parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2], 10);
|
||||
|
||||
// the minimum chrome version still supported by adapter.
|
||||
webrtcMinimumVersion = 38;
|
||||
|
||||
// The RTCPeerConnection object.
|
||||
window.RTCPeerConnection = function(pcConfig, pcConstraints) {
|
||||
// Translate iceTransportPolicy to iceTransports,
|
||||
// see https://code.google.com/p/webrtc/issues/detail?id=4869
|
||||
if (pcConfig && pcConfig.iceTransportPolicy) {
|
||||
pcConfig.iceTransports = pcConfig.iceTransportPolicy;
|
||||
}
|
||||
|
||||
var pc = new webkitRTCPeerConnection(pcConfig, pcConstraints); // jscs:ignore requireCapitalizedConstructors
|
||||
var origGetStats = pc.getStats.bind(pc);
|
||||
pc.getStats = function(selector, successCallback, errorCallback) { // jshint ignore: line
|
||||
var self = this;
|
||||
var args = arguments;
|
||||
|
||||
// If selector is a function then we are in the old style stats so just
|
||||
// pass back the original getStats format to avoid breaking old users.
|
||||
if (arguments.length > 0 && typeof selector === 'function') {
|
||||
return origGetStats(selector, successCallback);
|
||||
}
|
||||
|
||||
var fixChromeStats = function(response) {
|
||||
var standardReport = {};
|
||||
var reports = response.result();
|
||||
reports.forEach(function(report) {
|
||||
var standardStats = {
|
||||
id: report.id,
|
||||
timestamp: report.timestamp,
|
||||
type: report.type
|
||||
};
|
||||
report.names().forEach(function(name) {
|
||||
standardStats[name] = report.stat(name);
|
||||
});
|
||||
standardReport[standardStats.id] = standardStats;
|
||||
});
|
||||
|
||||
return standardReport;
|
||||
};
|
||||
|
||||
if (arguments.length >= 2) {
|
||||
var successCallbackWrapper = function(response) {
|
||||
args[1](fixChromeStats(response));
|
||||
};
|
||||
|
||||
return origGetStats.apply(this, [successCallbackWrapper, arguments[0]]);
|
||||
}
|
||||
|
||||
// promise-support
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (args.length === 1 && selector === null) {
|
||||
origGetStats.apply(self, [
|
||||
function(response) {
|
||||
resolve.apply(null, [fixChromeStats(response)]);
|
||||
}, reject]);
|
||||
} else {
|
||||
origGetStats.apply(self, [resolve, reject]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return pc;
|
||||
};
|
||||
|
||||
// add promise support
|
||||
['createOffer', 'createAnswer'].forEach(function(method) {
|
||||
var nativeMethod = webkitRTCPeerConnection.prototype[method];
|
||||
webkitRTCPeerConnection.prototype[method] = function() {
|
||||
var self = this;
|
||||
if (arguments.length < 1 || (arguments.length === 1 &&
|
||||
typeof(arguments[0]) === 'object')) {
|
||||
var opts = arguments.length === 1 ? arguments[0] : undefined;
|
||||
return new Promise(function(resolve, reject) {
|
||||
nativeMethod.apply(self, [resolve, reject, opts]);
|
||||
});
|
||||
} else {
|
||||
return nativeMethod.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
['setLocalDescription', 'setRemoteDescription',
|
||||
'addIceCandidate'].forEach(function(method) {
|
||||
var nativeMethod = webkitRTCPeerConnection.prototype[method];
|
||||
webkitRTCPeerConnection.prototype[method] = function() {
|
||||
var args = arguments;
|
||||
var self = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
nativeMethod.apply(self, [args[0],
|
||||
function() {
|
||||
resolve();
|
||||
if (args.length >= 2) {
|
||||
args[1].apply(null, []);
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
reject(err);
|
||||
if (args.length >= 3) {
|
||||
args[2].apply(null, [err]);
|
||||
}
|
||||
}]
|
||||
);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// getUserMedia constraints shim.
|
||||
var constraintsToChrome = function(c) {
|
||||
if (typeof c !== 'object' || c.mandatory || c.optional) {
|
||||
return c;
|
||||
}
|
||||
var cc = {};
|
||||
Object.keys(c).forEach(function(key) {
|
||||
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
|
||||
return;
|
||||
}
|
||||
var r = (typeof c[key] === 'object') ? c[key] : {ideal: c[key]};
|
||||
if (r.exact !== undefined && typeof r.exact === 'number') {
|
||||
r.min = r.max = r.exact;
|
||||
}
|
||||
var oldname = function(prefix, name) {
|
||||
if (prefix) {
|
||||
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
|
||||
}
|
||||
return (name === 'deviceId') ? 'sourceId' : name;
|
||||
};
|
||||
if (r.ideal !== undefined) {
|
||||
cc.optional = cc.optional || [];
|
||||
var oc = {};
|
||||
if (typeof r.ideal === 'number') {
|
||||
oc[oldname('min', key)] = r.ideal;
|
||||
cc.optional.push(oc);
|
||||
oc = {};
|
||||
oc[oldname('max', key)] = r.ideal;
|
||||
cc.optional.push(oc);
|
||||
} else {
|
||||
oc[oldname('', key)] = r.ideal;
|
||||
cc.optional.push(oc);
|
||||
}
|
||||
}
|
||||
if (r.exact !== undefined && typeof r.exact !== 'number') {
|
||||
cc.mandatory = cc.mandatory || {};
|
||||
cc.mandatory[oldname('', key)] = r.exact;
|
||||
} else {
|
||||
['min', 'max'].forEach(function(mix) {
|
||||
if (r[mix] !== undefined) {
|
||||
cc.mandatory = cc.mandatory || {};
|
||||
cc.mandatory[oldname(mix, key)] = r[mix];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (c.advanced) {
|
||||
cc.optional = (cc.optional || []).concat(c.advanced);
|
||||
}
|
||||
return cc;
|
||||
};
|
||||
|
||||
getUserMedia = function(constraints, onSuccess, onError) {
|
||||
if (constraints.audio) {
|
||||
constraints.audio = constraintsToChrome(constraints.audio);
|
||||
}
|
||||
if (constraints.video) {
|
||||
constraints.video = constraintsToChrome(constraints.video);
|
||||
}
|
||||
webrtcUtils.log('chrome: ' + JSON.stringify(constraints));
|
||||
return navigator.webkitGetUserMedia(constraints, onSuccess, onError);
|
||||
};
|
||||
navigator.getUserMedia = getUserMedia;
|
||||
|
||||
if (!navigator.mediaDevices) {
|
||||
navigator.mediaDevices = {getUserMedia: requestUserMedia,
|
||||
enumerateDevices: function() {
|
||||
return new Promise(function(resolve) {
|
||||
var kinds = {audio: 'audioinput', video: 'videoinput'};
|
||||
return MediaStreamTrack.getSources(function(devices) {
|
||||
resolve(devices.map(function(device) {
|
||||
return {label: device.label,
|
||||
kind: kinds[device.kind],
|
||||
deviceId: device.id,
|
||||
groupId: ''};
|
||||
}));
|
||||
});
|
||||
});
|
||||
}};
|
||||
}
|
||||
|
||||
// A shim for getUserMedia method on the mediaDevices object.
|
||||
// TODO(KaptenJansson) remove once implemented in Chrome stable.
|
||||
if (!navigator.mediaDevices.getUserMedia) {
|
||||
navigator.mediaDevices.getUserMedia = function(constraints) {
|
||||
return requestUserMedia(constraints);
|
||||
};
|
||||
} else {
|
||||
// Even though Chrome 45 has navigator.mediaDevices and a getUserMedia
|
||||
// function which returns a Promise, it does not accept spec-style
|
||||
// constraints.
|
||||
var origGetUserMedia = navigator.mediaDevices.getUserMedia.
|
||||
bind(navigator.mediaDevices);
|
||||
navigator.mediaDevices.getUserMedia = function(c) {
|
||||
webrtcUtils.log('spec: ' + JSON.stringify(c)); // whitespace for alignment
|
||||
c.audio = constraintsToChrome(c.audio);
|
||||
c.video = constraintsToChrome(c.video);
|
||||
webrtcUtils.log('chrome: ' + JSON.stringify(c));
|
||||
return origGetUserMedia(c);
|
||||
};
|
||||
}
|
||||
|
||||
// Dummy devicechange event methods.
|
||||
// TODO(KaptenJansson) remove once implemented in Chrome stable.
|
||||
if (typeof navigator.mediaDevices.addEventListener === 'undefined') {
|
||||
navigator.mediaDevices.addEventListener = function() {
|
||||
webrtcUtils.log('Dummy mediaDevices.addEventListener called.');
|
||||
};
|
||||
}
|
||||
if (typeof navigator.mediaDevices.removeEventListener === 'undefined') {
|
||||
navigator.mediaDevices.removeEventListener = function() {
|
||||
webrtcUtils.log('Dummy mediaDevices.removeEventListener called.');
|
||||
};
|
||||
}
|
||||
|
||||
// Attach a media stream to an element.
|
||||
attachMediaStream = function(element, stream) {
|
||||
if (webrtcDetectedVersion >= 43) {
|
||||
element.srcObject = stream;
|
||||
} else if (typeof element.src !== 'undefined') {
|
||||
element.src = URL.createObjectURL(stream);
|
||||
} else {
|
||||
webrtcUtils.log('Error attaching stream to element.');
|
||||
}
|
||||
};
|
||||
reattachMediaStream = function(to, from) {
|
||||
if (webrtcDetectedVersion >= 43) {
|
||||
to.srcObject = from.srcObject;
|
||||
} else {
|
||||
to.src = from.src;
|
||||
}
|
||||
};
|
||||
|
||||
} else if (navigator.mediaDevices && navigator.userAgent.match(
|
||||
/Edge\/(\d+).(\d+)$/)) {
|
||||
webrtcUtils.log('This appears to be Edge');
|
||||
webrtcDetectedBrowser = 'edge';
|
||||
|
||||
webrtcDetectedVersion =
|
||||
parseInt(navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)[2], 10);
|
||||
|
||||
// the minimum version still supported by adapter.
|
||||
webrtcMinimumVersion = 12;
|
||||
} else {
|
||||
webrtcUtils.log('Browser does not appear to be WebRTC-capable');
|
||||
}
|
||||
|
||||
// Returns the result of getUserMedia as a Promise.
|
||||
function requestUserMedia(constraints) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
getUserMedia(constraints, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
var webrtcTesting = {};
|
||||
Object.defineProperty(webrtcTesting, 'version', {
|
||||
set: function(version) {
|
||||
webrtcDetectedVersion = version;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
var RTCPeerConnection;
|
||||
if (typeof window !== 'undefined') {
|
||||
RTCPeerConnection = window.RTCPeerConnection;
|
||||
}
|
||||
module.exports = {
|
||||
RTCPeerConnection: RTCPeerConnection,
|
||||
getUserMedia: getUserMedia,
|
||||
attachMediaStream: attachMediaStream,
|
||||
reattachMediaStream: reattachMediaStream,
|
||||
webrtcDetectedBrowser: webrtcDetectedBrowser,
|
||||
webrtcDetectedVersion: webrtcDetectedVersion,
|
||||
webrtcMinimumVersion: webrtcMinimumVersion,
|
||||
webrtcTesting: webrtcTesting
|
||||
//requestUserMedia: not exposed on purpose.
|
||||
//trace: not exposed on purpose.
|
||||
};
|
||||
} else if ((typeof require === 'function') && (typeof define === 'function')) {
|
||||
// Expose objects and functions when RequireJS is doing the loading.
|
||||
define([], function() {
|
||||
return {
|
||||
RTCPeerConnection: window.RTCPeerConnection,
|
||||
getUserMedia: getUserMedia,
|
||||
attachMediaStream: attachMediaStream,
|
||||
reattachMediaStream: reattachMediaStream,
|
||||
webrtcDetectedBrowser: webrtcDetectedBrowser,
|
||||
webrtcDetectedVersion: webrtcDetectedVersion,
|
||||
webrtcMinimumVersion: webrtcMinimumVersion,
|
||||
webrtcTesting: webrtcTesting
|
||||
//requestUserMedia: not exposed on purpose.
|
||||
//trace: not exposed on purpose.
|
||||
};
|
||||
});
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -17,9 +17,10 @@
|
|||
var openVidu;
|
||||
var session;
|
||||
|
||||
window.onload = function() {
|
||||
window.addEventListener('load', function(){
|
||||
console = new Console('console', console);
|
||||
}
|
||||
document.getElementById("userId").value = Math.floor(Math.random() * 100);
|
||||
});
|
||||
|
||||
function addVideoTag(stream) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue