diff --git a/src/angular/frontend/package.json b/src/angular/frontend/package.json index 0cb5227..1863bbd 100644 --- a/src/angular/frontend/package.json +++ b/src/angular/frontend/package.json @@ -26,7 +26,7 @@ "core-js": "^2.4.1", "hammerjs": "^2.0.8", "jquery": "^2.2.4", - "openvidu-browser": "1.0.4-beta.3", + "openvidu-browser": "1.0.5-beta.3", "rxjs": "^5.1.0", "zone.js": "^0.7.6" }, diff --git a/src/main/resources/static/inline.bundle.js.map b/src/main/resources/static/inline.bundle.js.map index c36384f..7b8b670 100644 --- a/src/main/resources/static/inline.bundle.js.map +++ b/src/main/resources/static/inline.bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 8dfd54b77af483fedc06"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAQ,oBAAoB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAY,2BAA2B;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAI;AACJ;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA,kDAA0C,oBAAoB,WAAW","file":"inline.bundle.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId])\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length)\n \t\t\tresolves.shift()();\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t4: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tif(installedChunks[chunkId] === 0)\n \t\t\treturn Promise.resolve();\n\n \t\t// an Promise means \"currently loading\".\n \t\tif(installedChunks[chunkId]) {\n \t\t\treturn installedChunks[chunkId][2];\n \t\t}\n \t\t// start chunk loading\n \t\tvar head = document.getElementsByTagName('head')[0];\n \t\tvar script = document.createElement('script');\n \t\tscript.type = 'text/javascript';\n \t\tscript.charset = 'utf-8';\n \t\tscript.async = true;\n \t\tscript.timeout = 120000;\n\n \t\tif (__webpack_require__.nc) {\n \t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t}\n \t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".chunk.js\";\n \t\tvar timeout = setTimeout(onScriptComplete, 120000);\n \t\tscript.onerror = script.onload = onScriptComplete;\n \t\tfunction onScriptComplete() {\n \t\t\t// avoid mem leaks in IE.\n \t\t\tscript.onerror = script.onload = null;\n \t\t\tclearTimeout(timeout);\n \t\t\tvar chunk = installedChunks[chunkId];\n \t\t\tif(chunk !== 0) {\n \t\t\t\tif(chunk) chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));\n \t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t}\n \t\t};\n\n \t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\tinstalledChunks[chunkId] = [resolve, reject];\n \t\t});\n \t\tinstalledChunks[chunkId][2] = promise;\n\n \t\thead.appendChild(script);\n \t\treturn promise;\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 8dfd54b77af483fedc06"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 4bc04afe97d1c5ead5ce"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAQ,oBAAoB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAY,2BAA2B;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAI;AACJ;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA,kDAA0C,oBAAoB,WAAW","file":"inline.bundle.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId])\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length)\n \t\t\tresolves.shift()();\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t4: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tif(installedChunks[chunkId] === 0)\n \t\t\treturn Promise.resolve();\n\n \t\t// an Promise means \"currently loading\".\n \t\tif(installedChunks[chunkId]) {\n \t\t\treturn installedChunks[chunkId][2];\n \t\t}\n \t\t// start chunk loading\n \t\tvar head = document.getElementsByTagName('head')[0];\n \t\tvar script = document.createElement('script');\n \t\tscript.type = 'text/javascript';\n \t\tscript.charset = 'utf-8';\n \t\tscript.async = true;\n \t\tscript.timeout = 120000;\n\n \t\tif (__webpack_require__.nc) {\n \t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t}\n \t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".chunk.js\";\n \t\tvar timeout = setTimeout(onScriptComplete, 120000);\n \t\tscript.onerror = script.onload = onScriptComplete;\n \t\tfunction onScriptComplete() {\n \t\t\t// avoid mem leaks in IE.\n \t\t\tscript.onerror = script.onload = null;\n \t\t\tclearTimeout(timeout);\n \t\t\tvar chunk = installedChunks[chunkId];\n \t\t\tif(chunk !== 0) {\n \t\t\t\tif(chunk) chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));\n \t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t}\n \t\t};\n\n \t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\tinstalledChunks[chunkId] = [resolve, reject];\n \t\t});\n \t\tinstalledChunks[chunkId][2] = promise;\n\n \t\thead.appendChild(script);\n \t\treturn promise;\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 4bc04afe97d1c5ead5ce"],"sourceRoot":""} \ No newline at end of file diff --git a/src/main/resources/static/main.bundle.js b/src/main/resources/static/main.bundle.js index 4a71412..4a10cae 100644 --- a/src/main/resources/static/main.bundle.js +++ b/src/main/resources/static/main.bundle.js @@ -1,13 +1,1172 @@ webpackJsonp([1,4],{ -/***/ 1119: +/***/ 1048: +/***/ (function(module, exports) { + +function Mapper() { + var sources = {}; + this.forEach = function (callback) { + for (var key in sources) { + var source = sources[key]; + for (var key2 in source) + callback(source[key2]); + } + ; + }; + this.get = function (id, source) { + var ids = sources[source]; + if (ids == undefined) + return undefined; + return ids[id]; + }; + this.remove = function (id, source) { + var ids = sources[source]; + if (ids == undefined) + return; + delete ids[id]; + // Check it's empty + for (var i in ids) { + return false; + } + delete sources[source]; + }; + this.set = function (value, id, source) { + if (value == undefined) + return this.remove(id, source); + var ids = sources[source]; + if (ids == undefined) + sources[source] = ids = {}; + ids[id] = value; + }; +} +; +Mapper.prototype.pop = function (id, source) { + var value = this.get(id, source); + if (value == undefined) + return undefined; + this.remove(id, source); + return value; +}; +module.exports = Mapper; + + +/***/ }), + +/***/ 1049: +/***/ (function(module, exports, __webpack_require__) { + +/* + * (C) Copyright 2014 Kurento (http://kurento.org/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +var JsonRpcClient = __webpack_require__(1050); +exports.JsonRpcClient = JsonRpcClient; + + +/***/ }), + +/***/ 1050: +/***/ (function(module, exports, __webpack_require__) { + +/* + * (C) Copyright 2014 Kurento (http://kurento.org/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +var RpcBuilder = __webpack_require__(523); +var WebSocketWithReconnection = __webpack_require__(522); +Date.now = Date.now || function () { + return +new Date; +}; +var PING_INTERVAL = 5000; +var RECONNECTING = 'RECONNECTING'; +var CONNECTED = 'CONNECTED'; +var DISCONNECTED = 'DISCONNECTED'; +var Logger = console; +/** + * + * heartbeat: interval in ms for each heartbeat message, + * sendCloseMessage : true / false, before closing the connection, it sends a closeSession message + *
+ * ws : {
+ * 	uri : URI to conntect to,
+ *  useSockJS : true (use SockJS) / false (use WebSocket) by default,
+ * 	onconnected : callback method to invoke when connection is successful,
+ * 	ondisconnect : callback method to invoke when the connection is lost,
+ * 	onreconnecting : callback method to invoke when the client is reconnecting,
+ * 	onreconnected : callback method to invoke when the client succesfully reconnects,
+ * 	onerror : callback method to invoke when there is an error
+ * },
+ * rpc : {
+ * 	requestTimeout : timeout for a request,
+ * 	sessionStatusChanged: callback method for changes in session status,
+ * 	mediaRenegotiation: mediaRenegotiation
+ * }
+ * 
+ */ +function JsonRpcClient(configuration) { + var self = this; + var wsConfig = configuration.ws; + var notReconnectIfNumLessThan = -1; + var pingNextNum = 0; + var enabledPings = true; + var pingPongStarted = false; + var pingInterval; + var status = DISCONNECTED; + var onreconnecting = wsConfig.onreconnecting; + var onreconnected = wsConfig.onreconnected; + var onconnected = wsConfig.onconnected; + var onerror = wsConfig.onerror; + configuration.rpc.pull = function (params, request) { + request.reply(null, "push"); + }; + wsConfig.onreconnecting = function () { + Logger.debug("--------- ONRECONNECTING -----------"); + if (status === RECONNECTING) { + Logger.error("Websocket already in RECONNECTING state when receiving a new ONRECONNECTING message. Ignoring it"); + return; + } + status = RECONNECTING; + if (onreconnecting) { + onreconnecting(); + } + }; + wsConfig.onreconnected = function () { + Logger.debug("--------- ONRECONNECTED -----------"); + if (status === CONNECTED) { + Logger.error("Websocket already in CONNECTED state when receiving a new ONRECONNECTED message. Ignoring it"); + return; + } + status = CONNECTED; + enabledPings = true; + updateNotReconnectIfLessThan(); + usePing(); + if (onreconnected) { + onreconnected(); + } + }; + wsConfig.onconnected = function () { + Logger.debug("--------- ONCONNECTED -----------"); + if (status === CONNECTED) { + Logger.error("Websocket already in CONNECTED state when receiving a new ONCONNECTED message. Ignoring it"); + return; + } + status = CONNECTED; + enabledPings = true; + usePing(); + if (onconnected) { + onconnected(); + } + }; + wsConfig.onerror = function (error) { + Logger.debug("--------- ONERROR -----------"); + status = DISCONNECTED; + if (onerror) { + onerror(error); + } + }; + var ws = new WebSocketWithReconnection(wsConfig); + Logger.debug('Connecting websocket to URI: ' + wsConfig.uri); + var rpcBuilderOptions = { + request_timeout: configuration.rpc.requestTimeout, + ping_request_timeout: configuration.rpc.heartbeatRequestTimeout + }; + var rpc = new RpcBuilder(RpcBuilder.packers.JsonRPC, rpcBuilderOptions, ws, function (request) { + Logger.debug('Received request: ' + JSON.stringify(request)); + try { + var func = configuration.rpc[request.method]; + if (func === undefined) { + Logger.error("Method " + request.method + " not registered in client"); + } + else { + func(request.params, request); + } + } + catch (err) { + Logger.error('Exception processing request: ' + JSON.stringify(request)); + Logger.error(err); + } + }); + this.send = function (method, params, callback) { + if (method !== 'ping') { + Logger.debug('Request: method:' + method + " params:" + JSON.stringify(params)); + } + var requestTime = Date.now(); + rpc.encode(method, params, function (error, result) { + if (error) { + try { + Logger.error("ERROR:" + error.message + " in Request: method:" + + method + " params:" + JSON.stringify(params) + " request:" + + error.request); + if (error.data) { + Logger.error("ERROR DATA:" + JSON.stringify(error.data)); + } + } + catch (e) { } + error.requestTime = requestTime; + } + if (callback) { + if (result != undefined && result.value !== 'pong') { + Logger.debug('Response: ' + JSON.stringify(result)); + } + callback(error, result); + } + }); + }; + function updateNotReconnectIfLessThan() { + Logger.debug("notReconnectIfNumLessThan = " + pingNextNum + ' (old=' + + notReconnectIfNumLessThan + ')'); + notReconnectIfNumLessThan = pingNextNum; + } + function sendPing() { + if (enabledPings) { + var params = null; + if (pingNextNum == 0 || pingNextNum == notReconnectIfNumLessThan) { + params = { + interval: configuration.heartbeat || PING_INTERVAL + }; + } + pingNextNum++; + self.send('ping', params, (function (pingNum) { + return function (error, result) { + if (error) { + Logger.debug("Error in ping request #" + pingNum + " (" + + error.message + ")"); + if (pingNum > notReconnectIfNumLessThan) { + enabledPings = false; + updateNotReconnectIfLessThan(); + Logger.debug("Server did not respond to ping message #" + + pingNum + ". Reconnecting... "); + ws.reconnectWs(); + } + } + }; + })(pingNextNum)); + } + else { + Logger.debug("Trying to send ping, but ping is not enabled"); + } + } + /* + * If configuration.hearbeat has any value, the ping-pong will work with the interval + * of configuration.hearbeat + */ + function usePing() { + if (!pingPongStarted) { + Logger.debug("Starting ping (if configured)"); + pingPongStarted = true; + if (configuration.heartbeat != undefined) { + pingInterval = setInterval(sendPing, configuration.heartbeat); + sendPing(); + } + } + } + this.close = function () { + Logger.debug("Closing jsonRpcClient explicitly by client"); + if (pingInterval != undefined) { + Logger.debug("Clearing ping interval"); + clearInterval(pingInterval); + } + pingPongStarted = false; + enabledPings = false; + if (configuration.sendCloseMessage) { + Logger.debug("Sending close message"); + this.send('closeSession', null, function (error, result) { + if (error) { + Logger.error("Error sending close message: " + JSON.stringify(error)); + } + ws.close(); + }); + } + else { + ws.close(); + } + }; + // This method is only for testing + this.forceClose = function (millis) { + ws.forceClose(millis); + }; + this.reconnect = function () { + ws.reconnectWs(); + }; +} +module.exports = JsonRpcClient; + + +/***/ }), + +/***/ 1051: +/***/ (function(module, exports, __webpack_require__) { + +/* + * (C) Copyright 2014 Kurento (http://kurento.org/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +var WebSocketWithReconnection = __webpack_require__(522); +exports.WebSocketWithReconnection = WebSocketWithReconnection; + + +/***/ }), + +/***/ 1052: +/***/ (function(module, exports) { + +/** + * JsonRPC 2.0 packer + */ +/** + * Pack a JsonRPC 2.0 message + * + * @param {Object} message - object to be packaged. It requires to have all the + * fields needed by the JsonRPC 2.0 message that it's going to be generated + * + * @return {String} - the stringified JsonRPC 2.0 message + */ +function pack(message, id) { + var result = { + jsonrpc: "2.0" + }; + // Request + if (message.method) { + result.method = message.method; + if (message.params) + result.params = message.params; + // Request is a notification + if (id != undefined) + result.id = id; + } + else if (id != undefined) { + if (message.error) { + if (message.result !== undefined) + throw new TypeError("Both result and error are defined"); + result.error = message.error; + } + else if (message.result !== undefined) + result.result = message.result; + else + throw new TypeError("No result or error is defined"); + result.id = id; + } + ; + return JSON.stringify(result); +} +; +/** + * Unpack a JsonRPC 2.0 message + * + * @param {String} message - string with the content of the JsonRPC 2.0 message + * + * @throws {TypeError} - Invalid JsonRPC version + * + * @return {Object} - object filled with the JsonRPC 2.0 message content + */ +function unpack(message) { + var result = message; + if (typeof message === 'string' || message instanceof String) { + result = JSON.parse(message); + } + // Check if it's a valid message + var version = result.jsonrpc; + if (version !== '2.0') + throw new TypeError("Invalid JsonRPC version '" + version + "': " + message); + // Response + if (result.method == undefined) { + if (result.id == undefined) + throw new TypeError("Invalid message: " + message); + var result_defined = result.result !== undefined; + var error_defined = result.error !== undefined; + // Check only result or error is defined, not both or none + if (result_defined && error_defined) + throw new TypeError("Both result and error are defined: " + message); + if (!result_defined && !error_defined) + throw new TypeError("No result or error is defined: " + message); + result.ack = result.id; + delete result.id; + } + // Return unpacked message + return result; +} +; +exports.pack = pack; +exports.unpack = unpack; + + +/***/ }), + +/***/ 1053: +/***/ (function(module, exports) { + +function pack(message) { + throw new TypeError("Not yet implemented"); +} +; +function unpack(message) { + throw new TypeError("Not yet implemented"); +} +; +exports.pack = pack; +exports.unpack = unpack; + + +/***/ }), + +/***/ 1054: +/***/ (function(module, exports, __webpack_require__) { + +var JsonRPC = __webpack_require__(1052); +var XmlRPC = __webpack_require__(1053); +exports.JsonRPC = JsonRPC; +exports.XmlRPC = XmlRPC; + + +/***/ }), + +/***/ 1055: +/***/ (function(module, exports, __webpack_require__) { + +/* + * (C) Copyright 2014-2015 Kurento (http://kurento.org/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var freeice = __webpack_require__(768); +var inherits = __webpack_require__(481); +var UAParser = __webpack_require__(1062); +var uuid = __webpack_require__(1064); +var hark = __webpack_require__(770); +var EventEmitter = __webpack_require__(480).EventEmitter; +var recursive = __webpack_require__(774).recursive.bind(undefined, true); +var sdpTranslator = __webpack_require__(1044); +var logger = window.Logger || console; +// var gUM = navigator.mediaDevices.getUserMedia || function (constraints) { +// return new Promise(navigator.getUserMedia(constraints, function (stream) { +// videoStream = stream +// start() +// }).eror(callback)); +// } +try { + __webpack_require__(773); +} +catch (error) { + if (typeof getScreenConstraints === 'undefined') { + logger.warn('screen sharing is not available'); + getScreenConstraints = function getScreenConstraints(sendSource, callback) { + callback(new Error("This library is not enabled for screen sharing")); + }; + } +} +var MEDIA_CONSTRAINTS = { + audio: true, + video: { + width: 640, + framerate: 15 + } +}; +// Somehow, the UAParser constructor gets an empty window object. +// We need to pass the user agent string in order to get information +var ua = (window && window.navigator) ? window.navigator.userAgent : ''; +var parser = new UAParser(ua); +var browser = parser.getBrowser(); +var usePlanB = false; +if (browser.name === 'Chrome' || browser.name === 'Chromium') { + logger.debug(browser.name + ": using SDP PlanB"); + usePlanB = true; +} +function noop(error) { + if (error) + logger.error(error); +} +function trackStop(track) { + track.stop && track.stop(); +} +function streamStop(stream) { + stream.getTracks().forEach(trackStop); +} +/** + * Returns a string representation of a SessionDescription object. + */ +var dumpSDP = function (description) { + if (typeof description === 'undefined' || description === null) { + return ''; + } + return 'type: ' + description.type + '\r\n' + description.sdp; +}; +function bufferizeCandidates(pc, onerror) { + var candidatesQueue = []; + pc.addEventListener('signalingstatechange', function () { + if (this.signalingState === 'stable') { + while (candidatesQueue.length) { + var entry = candidatesQueue.shift(); + this.addIceCandidate(entry.candidate, entry.callback, entry.callback); + } + } + }); + return function (candidate, callback) { + callback = callback || onerror; + switch (pc.signalingState) { + case 'closed': + callback(new Error('PeerConnection object is closed')); + break; + case 'stable': + if (pc.remoteDescription) { + pc.addIceCandidate(candidate, callback, callback); + break; + } + default: + candidatesQueue.push({ + candidate: candidate, + callback: callback + }); + } + }; +} +/* Simulcast utilities */ +function removeFIDFromOffer(sdp) { + var n = sdp.indexOf("a=ssrc-group:FID"); + if (n > 0) { + return sdp.slice(0, n); + } + else { + return sdp; + } +} +function getSimulcastInfo(videoStream) { + var videoTracks = videoStream.getVideoTracks(); + if (!videoTracks.length) { + logger.warn('No video tracks available in the video stream'); + return ''; + } + var lines = [ + 'a=x-google-flag:conference', + 'a=ssrc-group:SIM 1 2 3', + 'a=ssrc:1 cname:localVideo', + 'a=ssrc:1 msid:' + videoStream.id + ' ' + videoTracks[0].id, + 'a=ssrc:1 mslabel:' + videoStream.id, + 'a=ssrc:1 label:' + videoTracks[0].id, + 'a=ssrc:2 cname:localVideo', + 'a=ssrc:2 msid:' + videoStream.id + ' ' + videoTracks[0].id, + 'a=ssrc:2 mslabel:' + videoStream.id, + 'a=ssrc:2 label:' + videoTracks[0].id, + 'a=ssrc:3 cname:localVideo', + 'a=ssrc:3 msid:' + videoStream.id + ' ' + videoTracks[0].id, + 'a=ssrc:3 mslabel:' + videoStream.id, + 'a=ssrc:3 label:' + videoTracks[0].id + ]; + lines.push(''); + return lines.join('\n'); +} +/** + * Wrapper object of an RTCPeerConnection. This object is aimed to simplify the + * development of WebRTC-based applications. + * + * @constructor module:kurentoUtils.WebRtcPeer + * + * @param {String} mode Mode in which the PeerConnection will be configured. + * Valid values are: 'recv', 'send', and 'sendRecv' + * @param localVideo Video tag for the local stream + * @param remoteVideo Video tag for the remote stream + * @param {MediaStream} videoStream Stream to be used as primary source + * (typically video and audio, or only video if combined with audioStream) for + * localVideo and to be added as stream to the RTCPeerConnection + * @param {MediaStream} audioStream Stream to be used as second source + * (typically for audio) for localVideo and to be added as stream to the + * RTCPeerConnection + */ +function WebRtcPeer(mode, options, callback) { + if (!(this instanceof WebRtcPeer)) { + return new WebRtcPeer(mode, options, callback); + } + WebRtcPeer.super_.call(this); + if (options instanceof Function) { + callback = options; + options = undefined; + } + options = options || {}; + callback = (callback || noop).bind(this); + var self = this; + var localVideo = options.localVideo; + var remoteVideo = options.remoteVideo; + var videoStream = options.videoStream; + var audioStream = options.audioStream; + var mediaConstraints = options.mediaConstraints; + var connectionConstraints = options.connectionConstraints; + var pc = options.peerConnection; + var sendSource = options.sendSource || 'webcam'; + var dataChannelConfig = options.dataChannelConfig; + var useDataChannels = options.dataChannels || false; + var dataChannel; + var guid = uuid.v4(); + var configuration = recursive({ + iceServers: freeice() + }, options.configuration); + var onicecandidate = options.onicecandidate; + if (onicecandidate) + this.on('icecandidate', onicecandidate); + var oncandidategatheringdone = options.oncandidategatheringdone; + if (oncandidategatheringdone) { + this.on('candidategatheringdone', oncandidategatheringdone); + } + var simulcast = options.simulcast; + var multistream = options.multistream; + var interop = new sdpTranslator.Interop(); + var candidatesQueueOut = []; + var candidategatheringdone = false; + Object.defineProperties(this, { + 'peerConnection': { + get: function () { + return pc; + } + }, + 'id': { + value: options.id || guid, + writable: false + }, + 'remoteVideo': { + get: function () { + return remoteVideo; + } + }, + 'localVideo': { + get: function () { + return localVideo; + } + }, + 'dataChannel': { + get: function () { + return dataChannel; + } + }, + /** + * @member {(external:ImageData|undefined)} currentFrame + */ + 'currentFrame': { + get: function () { + // [ToDo] Find solution when we have a remote stream but we didn't set + // a remoteVideo tag + if (!remoteVideo) + return; + if (remoteVideo.readyState < remoteVideo.HAVE_CURRENT_DATA) + throw new Error('No video stream data available'); + var canvas = document.createElement('canvas'); + canvas.width = remoteVideo.videoWidth; + canvas.height = remoteVideo.videoHeight; + canvas.getContext('2d').drawImage(remoteVideo, 0, 0); + return canvas; + } + } + }); + // Init PeerConnection + if (!pc) { + pc = new RTCPeerConnection(configuration); + if (useDataChannels && !dataChannel) { + var dcId = 'WebRtcPeer-' + self.id; + var dcOptions = undefined; + if (dataChannelConfig) { + dcId = dataChannelConfig.id || dcId; + dcOptions = dataChannelConfig.options; + } + dataChannel = pc.createDataChannel(dcId, dcOptions); + if (dataChannelConfig) { + dataChannel.onopen = dataChannelConfig.onopen; + dataChannel.onclose = dataChannelConfig.onclose; + dataChannel.onmessage = dataChannelConfig.onmessage; + dataChannel.onbufferedamountlow = dataChannelConfig.onbufferedamountlow; + dataChannel.onerror = dataChannelConfig.onerror || noop; + } + } + } + pc.addEventListener('icecandidate', function (event) { + var candidate = event.candidate; + if (EventEmitter.listenerCount(self, 'icecandidate') || + EventEmitter.listenerCount(self, 'candidategatheringdone')) { + if (candidate) { + var cand; + if (multistream && usePlanB) { + cand = interop.candidateToUnifiedPlan(candidate); + } + else { + cand = candidate; + } + self.emit('icecandidate', cand); + candidategatheringdone = false; + } + else if (!candidategatheringdone) { + self.emit('candidategatheringdone'); + candidategatheringdone = true; + } + } + else if (!candidategatheringdone) { + // Not listening to 'icecandidate' or 'candidategatheringdone' events, queue + // the candidate until one of them is listened + candidatesQueueOut.push(candidate); + if (!candidate) + candidategatheringdone = true; + } + }); + pc.ontrack = options.onaddstream; + pc.onnegotiationneeded = options.onnegotiationneeded; + this.on('newListener', function (event, listener) { + if (event === 'icecandidate' || event === 'candidategatheringdone') { + while (candidatesQueueOut.length) { + var candidate = candidatesQueueOut.shift(); + if (!candidate === (event === 'candidategatheringdone')) { + listener(candidate); + } + } + } + }); + var addIceCandidate = bufferizeCandidates(pc); + /** + * Callback function invoked when an ICE candidate is received. Developers are + * expected to invoke this function in order to complete the SDP negotiation. + * + * @function module:kurentoUtils.WebRtcPeer.prototype.addIceCandidate + * + * @param iceCandidate - Literal object with the ICE candidate description + * @param callback - Called when the ICE candidate has been added. + */ + this.addIceCandidate = function (iceCandidate, callback) { + var candidate; + if (multistream && usePlanB) { + candidate = interop.candidateToPlanB(iceCandidate); + } + else { + candidate = new RTCIceCandidate(iceCandidate); + } + logger.debug('Remote ICE candidate received', iceCandidate); + callback = (callback || noop).bind(this); + addIceCandidate(candidate, callback); + }; + this.generateOffer = function (callback) { + callback = callback.bind(this); + var offerAudio = true; + var offerVideo = true; + // Constraints must have both blocks + if (mediaConstraints) { + offerAudio = (typeof mediaConstraints.audio === 'boolean') ? + mediaConstraints.audio : true; + offerVideo = (typeof mediaConstraints.video === 'boolean') ? + mediaConstraints.video : true; + } + var browserDependantConstraints = { + offerToReceiveAudio: (mode !== 'sendonly' && offerAudio), + offerToReceiveVideo: (mode !== 'sendonly' && offerVideo) + }; + //FIXME: clarify possible constraints passed to createOffer() + /*var constraints = recursive(browserDependantConstraints, + connectionConstraints)*/ + var constraints = browserDependantConstraints; + logger.debug('constraints: ' + JSON.stringify(constraints)); + pc.createOffer(constraints).then(function (offer) { + logger.debug('Created SDP offer'); + offer = mangleSdpToAddSimulcast(offer); + return pc.setLocalDescription(offer); + }).then(function () { + var localDescription = pc.localDescription; + logger.debug('Local description set', localDescription.sdp); + if (multistream && usePlanB) { + localDescription = interop.toUnifiedPlan(localDescription); + logger.debug('offer::origPlanB->UnifiedPlan', dumpSDP(localDescription)); + } + callback(null, localDescription.sdp, self.processAnswer.bind(self)); + }).catch(callback); + }; + this.getLocalSessionDescriptor = function () { + return pc.localDescription; + }; + this.getRemoteSessionDescriptor = function () { + return pc.remoteDescription; + }; + function setRemoteVideo() { + if (remoteVideo) { + var stream = pc.getRemoteStreams()[0]; + var url = stream ? URL.createObjectURL(stream) : ''; + remoteVideo.pause(); + remoteVideo.src = url; + remoteVideo.load(); + logger.debug('Remote URL:', url); + } + } + this.showLocalVideo = function () { + localVideo.src = URL.createObjectURL(videoStream); + localVideo.muted = true; + }; + this.send = function (data) { + if (dataChannel && dataChannel.readyState === 'open') { + dataChannel.send(data); + } + else { + logger.warn('Trying to send data over a non-existing or closed data channel'); + } + }; + /** + * Callback function invoked when a SDP answer is received. Developers are + * expected to invoke this function in order to complete the SDP negotiation. + * + * @function module:kurentoUtils.WebRtcPeer.prototype.processAnswer + * + * @param sdpAnswer - Description of sdpAnswer + * @param callback - + * Invoked after the SDP answer is processed, or there is an error. + */ + this.processAnswer = function (sdpAnswer, callback) { + callback = (callback || noop).bind(this); + var answer = new RTCSessionDescription({ + type: 'answer', + sdp: sdpAnswer + }); + if (multistream && usePlanB) { + var planBAnswer = interop.toPlanB(answer); + logger.debug('asnwer::planB', dumpSDP(planBAnswer)); + answer = planBAnswer; + } + logger.debug('SDP answer received, setting remote description'); + if (pc.signalingState === 'closed') { + return callback('PeerConnection is closed'); + } + pc.setRemoteDescription(answer, function () { + setRemoteVideo(); + callback(); + }, callback); + }; + /** + * Callback function invoked when a SDP offer is received. Developers are + * expected to invoke this function in order to complete the SDP negotiation. + * + * @function module:kurentoUtils.WebRtcPeer.prototype.processOffer + * + * @param sdpOffer - Description of sdpOffer + * @param callback - Called when the remote description has been set + * successfully. + */ + this.processOffer = function (sdpOffer, callback) { + callback = callback.bind(this); + var offer = new RTCSessionDescription({ + type: 'offer', + sdp: sdpOffer + }); + if (multistream && usePlanB) { + var planBOffer = interop.toPlanB(offer); + logger.debug('offer::planB', dumpSDP(planBOffer)); + offer = planBOffer; + } + logger.debug('SDP offer received, setting remote description'); + if (pc.signalingState === 'closed') { + return callback('PeerConnection is closed'); + } + pc.setRemoteDescription(offer).then(function () { + return setRemoteVideo(); + }).then(function () { + return pc.createAnswer(); + }).then(function (answer) { + answer = mangleSdpToAddSimulcast(answer); + logger.debug('Created SDP answer'); + return pc.setLocalDescription(answer); + }).then(function () { + var localDescription = pc.localDescription; + if (multistream && usePlanB) { + localDescription = interop.toUnifiedPlan(localDescription); + logger.debug('answer::origPlanB->UnifiedPlan', dumpSDP(localDescription)); + } + logger.debug('Local description set', localDescription.sdp); + callback(null, localDescription.sdp); + }).catch(callback); + }; + function mangleSdpToAddSimulcast(answer) { + if (simulcast) { + if (browser.name === 'Chrome' || browser.name === 'Chromium') { + logger.debug('Adding multicast info'); + answer = new RTCSessionDescription({ + 'type': answer.type, + 'sdp': removeFIDFromOffer(answer.sdp) + getSimulcastInfo(videoStream) + }); + } + else { + logger.warn('Simulcast is only available in Chrome browser.'); + } + } + return answer; + } + /** + * This function creates the RTCPeerConnection object taking into account the + * properties received in the constructor. It starts the SDP negotiation + * process: generates the SDP offer and invokes the onsdpoffer callback. This + * callback is expected to send the SDP offer, in order to obtain an SDP + * answer from another peer. + */ + function start() { + if (pc.signalingState === 'closed') { + callback('The peer connection object is in "closed" state. This is most likely due to an invocation of the dispose method before accepting in the dialogue'); + } + if (videoStream && localVideo) { + self.showLocalVideo(); + } + if (videoStream) { + pc.addStream(videoStream); + } + if (audioStream) { + pc.addStream(audioStream); + } + // [Hack] https://code.google.com/p/chromium/issues/detail?id=443558 + var browser = parser.getBrowser(); + if (mode === 'sendonly' && + (browser.name === 'Chrome' || browser.name === 'Chromium') && + browser.major === 39) { + mode = 'sendrecv'; + } + callback(); + } + if (mode !== 'recvonly' && !videoStream && !audioStream) { + function getMedia(constraints) { + if (constraints === undefined) { + constraints = MEDIA_CONSTRAINTS; + } + navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { + videoStream = stream; + start(); + }).catch(callback); + } + if (sendSource === 'webcam') { + getMedia(mediaConstraints); + } + else { + getScreenConstraints(sendSource, function (error, constraints_) { + if (error) + return callback(error); + constraints = [mediaConstraints]; + constraints.unshift(constraints_); + getMedia(recursive.apply(undefined, constraints)); + }, guid); + } + } + else { + setTimeout(start, 0); + } + this.on('_dispose', function () { + if (localVideo) { + localVideo.pause(); + localVideo.src = ''; + localVideo.load(); + //Unmute local video in case the video tag is later used for remote video + localVideo.muted = false; + } + if (remoteVideo) { + remoteVideo.pause(); + remoteVideo.src = ''; + remoteVideo.load(); + } + self.removeAllListeners(); + if (window.cancelChooseDesktopMedia !== undefined) { + window.cancelChooseDesktopMedia(guid); + } + }); +} +inherits(WebRtcPeer, EventEmitter); +function createEnableDescriptor(type) { + var method = 'get' + type + 'Tracks'; + return { + enumerable: true, + get: function () { + // [ToDo] Should return undefined if not all tracks have the same value? + if (!this.peerConnection) + return; + var streams = this.peerConnection.getLocalStreams(); + if (!streams.length) + return; + for (var i = 0, stream; stream = streams[i]; i++) { + var tracks = stream[method](); + for (var j = 0, track; track = tracks[j]; j++) + if (!track.enabled) + return false; + } + return true; + }, + set: function (value) { + function trackSetEnable(track) { + track.enabled = value; + } + this.peerConnection.getLocalStreams().forEach(function (stream) { + stream[method]().forEach(trackSetEnable); + }); + } + }; +} +Object.defineProperties(WebRtcPeer.prototype, { + 'enabled': { + enumerable: true, + get: function () { + return this.audioEnabled && this.videoEnabled; + }, + set: function (value) { + this.audioEnabled = this.videoEnabled = value; + } + }, + 'audioEnabled': createEnableDescriptor('Audio'), + 'videoEnabled': createEnableDescriptor('Video') +}); +WebRtcPeer.prototype.getLocalStream = function (index) { + if (this.peerConnection) { + return this.peerConnection.getLocalStreams()[index || 0]; + } +}; +WebRtcPeer.prototype.getRemoteStream = function (index) { + if (this.peerConnection) { + return this.peerConnection.getRemoteStreams()[index || 0]; + } +}; +/** + * @description This method frees the resources used by WebRtcPeer. + * + * @function module:kurentoUtils.WebRtcPeer.prototype.dispose + */ +WebRtcPeer.prototype.dispose = function () { + logger.debug('Disposing WebRtcPeer'); + var pc = this.peerConnection; + var dc = this.dataChannel; + try { + if (dc) { + if (dc.signalingState === 'closed') + return; + dc.close(); + } + if (pc) { + if (pc.signalingState === 'closed') + return; + pc.getLocalStreams().forEach(streamStop); + // FIXME This is not yet implemented in firefox + // if(videoStream) pc.removeStream(videoStream); + // if(audioStream) pc.removeStream(audioStream); + pc.close(); + } + } + catch (err) { + logger.warn('Exception disposing webrtc peer ' + err); + } + this.emit('_dispose'); +}; +// +// Specialized child classes +// +function WebRtcPeerRecvonly(options, callback) { + if (!(this instanceof WebRtcPeerRecvonly)) { + return new WebRtcPeerRecvonly(options, callback); + } + WebRtcPeerRecvonly.super_.call(this, 'recvonly', options, callback); +} +inherits(WebRtcPeerRecvonly, WebRtcPeer); +function WebRtcPeerSendonly(options, callback) { + if (!(this instanceof WebRtcPeerSendonly)) { + return new WebRtcPeerSendonly(options, callback); + } + WebRtcPeerSendonly.super_.call(this, 'sendonly', options, callback); +} +inherits(WebRtcPeerSendonly, WebRtcPeer); +function WebRtcPeerSendrecv(options, callback) { + if (!(this instanceof WebRtcPeerSendrecv)) { + return new WebRtcPeerSendrecv(options, callback); + } + WebRtcPeerSendrecv.super_.call(this, 'sendrecv', options, callback); +} +inherits(WebRtcPeerSendrecv, WebRtcPeer); +function harkUtils(stream, options) { + return hark(stream, options); +} +exports.bufferizeCandidates = bufferizeCandidates; +exports.WebRtcPeerRecvonly = WebRtcPeerRecvonly; +exports.WebRtcPeerSendonly = WebRtcPeerSendonly; +exports.WebRtcPeerSendrecv = WebRtcPeerSendrecv; +exports.hark = harkUtils; + + +/***/ }), + +/***/ 1056: +/***/ (function(module, exports, __webpack_require__) { + +/* + * (C) Copyright 2014 Kurento (http://kurento.org/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +/** + * This module contains a set of reusable components that have been found useful + * during the development of the WebRTC applications with Kurento. + * + * @module kurentoUtils + * + * @copyright 2014 Kurento (http://kurento.org/) + * @license ALv2 + */ +var WebRtcPeer = __webpack_require__(1055); +exports.WebRtcPeer = WebRtcPeer; + + +/***/ }), + +/***/ 1057: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* - * (C) Copyright 2016 OpenVidu (http://kurento.org/) + * (C) Copyright 2017 OpenVidu (http://openvidu.io/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,16 +1181,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); * limitations under the License. * */ -var OpenViduInternal_1 = __webpack_require__(1121); -var Session_1 = __webpack_require__(555); -var Publisher_1 = __webpack_require__(554); -var adapter = __webpack_require__(561); +var OpenViduInternal_1 = __webpack_require__(1059); +var Session_1 = __webpack_require__(525); +var Publisher_1 = __webpack_require__(524); +var adapter = __webpack_require__(528); if (window) { window["adapter"] = adapter; } -var OpenVidu = (function () { +var OpenVidu = /** @class */ (function () { function OpenVidu() { this.openVidu = new OpenViduInternal_1.OpenViduInternal(); + console.info("'OpenVidu' initialized"); } ; OpenVidu.prototype.initSession = function (param1, param2) { @@ -69,7 +1229,9 @@ var OpenVidu = (function () { } }; } - return new Publisher_1.Publisher(this.openVidu.initPublisherTagged(parentId, cameraOptions, callback), parentId); + var publisher = new Publisher_1.Publisher(this.openVidu.initPublisherTagged(parentId, cameraOptions, callback), parentId); + console.info("'Publisher' initialized"); + return publisher; } else { alert("Browser not supported"); @@ -93,10 +1255,16 @@ var OpenVidu = (function () { navigator.mediaDevices.enumerateDevices().then(function (deviceInfos) { callback(null, deviceInfos); }).catch(function (error) { - console.log("Error getting devices: " + error); + console.error("Error getting devices", error); callback(error, null); }); }; + OpenVidu.prototype.enableProdMode = function () { + console.log = function () { }; + console.debug = function () { }; + console.info = function () { }; + console.warn = function () { }; + }; return OpenVidu; }()); exports.OpenVidu = OpenVidu; @@ -104,7 +1272,7 @@ exports.OpenVidu = OpenVidu; /***/ }), -/***/ 1120: +/***/ 1058: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -113,24 +1281,24 @@ function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); -__export(__webpack_require__(1119)); -__export(__webpack_require__(555)); -__export(__webpack_require__(554)); -__export(__webpack_require__(556)); -__export(__webpack_require__(325)); -__export(__webpack_require__(557)); +__export(__webpack_require__(1057)); +__export(__webpack_require__(525)); +__export(__webpack_require__(524)); +__export(__webpack_require__(526)); +__export(__webpack_require__(307)); +__export(__webpack_require__(527)); /***/ }), -/***/ 1121: +/***/ 1059: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* - * (C) Copyright 2016 OpenVidu (http://kurento.org/) + * (C) Copyright 2017 OpenVidu (http://openvidu.io/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,28 +1313,27 @@ Object.defineProperty(exports, "__esModule", { value: true }); * limitations under the License. * */ -var SessionInternal_1 = __webpack_require__(1122); -var Stream_1 = __webpack_require__(325); -var RpcBuilder = __webpack_require__(500); -var OpenViduInternal = (function () { +var SessionInternal_1 = __webpack_require__(1060); +var Stream_1 = __webpack_require__(307); +var RpcBuilder = __webpack_require__(523); +var OpenViduInternal = /** @class */ (function () { function OpenViduInternal() { this.remoteStreams = []; } ; /* NEW METHODS */ OpenViduInternal.prototype.initSession = function (sessionId) { - console.log("Session initialized!"); + console.info("'Session' initialized with 'sessionId' [" + sessionId + "]"); this.session = new SessionInternal_1.SessionInternal(this, sessionId); return this.session; }; OpenViduInternal.prototype.initPublisherTagged = function (parentId, cameraOptions, callback) { var _this = this; - console.log("Publisher tagged initialized!"); this.getCamera(cameraOptions); if (callback == null) { this.camera.requestCameraAccess(function (error, camera) { if (error) { - console.log("Error accessing the camera"); + console.error("Error accessing the camera", error); } else { _this.camera.setVideoElement(_this.cameraReady(camera, parentId)); @@ -194,7 +1361,6 @@ var OpenViduInternal = (function () { return videoElement; }; OpenViduInternal.prototype.initPublisher = function (cameraOptions, callback) { - console.log("Publisher initialized!"); this.getCamera(cameraOptions); this.camera.requestCameraAccess(function (error, camera) { if (error) @@ -283,7 +1449,7 @@ var OpenViduInternal = (function () { } }; OpenViduInternal.prototype.disconnectCallback = function () { - console.log('Websocket connection lost'); + console.warn('Websocket connection lost'); if (this.isRoomAvailable()) { this.session.onLostConnection(); } @@ -292,7 +1458,7 @@ var OpenViduInternal = (function () { } }; OpenViduInternal.prototype.reconnectingCallback = function () { - console.log('Websocket connection lost (reconnecting)'); + console.warn('Websocket connection lost (reconnecting)'); if (this.isRoomAvailable()) { this.session.onLostConnection(); } @@ -301,7 +1467,7 @@ var OpenViduInternal = (function () { } }; OpenViduInternal.prototype.reconnectedCallback = function () { - console.log('Websocket reconnected'); + console.warn('Websocket reconnected'); }; OpenViduInternal.prototype.onParticipantJoined = function (params) { if (this.isRoomAvailable()) { @@ -356,11 +1522,11 @@ var OpenViduInternal = (function () { for (var index in this.rpcParams) { if (this.rpcParams.hasOwnProperty(index)) { params[index] = this.rpcParams[index]; - console.log('RPC param added to request {' + index + ': ' + this.rpcParams[index] + '}'); + console.debug('RPC param added to request {' + index + ': ' + this.rpcParams[index] + '}'); } } } - console.log('Sending request: { method:"' + method + '", params: ' + JSON.stringify(params) + ' }'); + console.debug('Sending request: {method:"' + method + '", params: ' + JSON.stringify(params) + '}'); this.jsonRpcClient.send(method, params, callback); }; OpenViduInternal.prototype.close = function (forced) { @@ -470,16 +1636,16 @@ exports.OpenViduInternal = OpenViduInternal; /***/ }), -/***/ 1122: +/***/ 1060: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var Connection_1 = __webpack_require__(557); -var EventEmitter = __webpack_require__(147); +var Connection_1 = __webpack_require__(527); +var EventEmitter = __webpack_require__(135); var SECRET_PARAM = '?secret='; -var SessionInternal = (function () { +var SessionInternal = /** @class */ (function () { function SessionInternal(openVidu, sessionId) { this.openVidu = openVidu; this.ee = new EventEmitter(); @@ -652,12 +1818,12 @@ var SessionInternal = (function () { stream.subscribe(); }; SessionInternal.prototype.unsuscribe = function (stream) { - console.log("Unsubscribing from " + stream.getId()); + console.info("Unsubscribing from " + stream.getId()); this.openVidu.sendRequest('unsubscribeFromVideo', { sender: stream.getId() }, function (error, response) { if (error) { - console.error(error); + console.error("Error unsubscribing from Subscriber", error); } else { console.info("Unsubscribed correctly from " + stream.getId()); @@ -666,15 +1832,25 @@ var SessionInternal = (function () { }; SessionInternal.prototype.onParticipantPublished = function (options) { options.metadata = this.participants[options.id].data; - var connection = new Connection_1.Connection(this.openVidu, false, this, options); + // Get the existing Connection created on 'onParticipantJoined' for + // existing participants or create a new one for new participants + var connection = this.participants[options.id]; + if (connection) { + // Update existing Connection + connection.options = options; + connection.initStreams(options); + } + else { + // Create new Connection + connection = new Connection_1.Connection(this.openVidu, false, this, options); + } var pid = connection.connectionId; if (!(pid in this.participants)) { - console.info("Publisher not found in participants list by its id", pid); + console.debug("Remote Connection not found in connections list by its id [" + pid + "]"); } else { - console.log("Publisher found in participants list by its id", pid); + console.debug("Remote Connection found in connections list by its id [" + pid + "]"); } - //replacing old connection (this one has streams) connection.creationTime = this.participants[pid].creationTime; this.participants[pid] = connection; this.ee.emitEvent('participant-published', [{ connection: connection }]); @@ -694,13 +1870,12 @@ var SessionInternal = (function () { connection.creationTime = new Date().getTime(); var pid = connection.connectionId; if (!(pid in this.participants)) { - console.log("New participant to participants list with id", pid); this.participants[pid] = connection; } else { //use existing so that we don't lose streams info - console.info("Participant already exists in participants list with " + - "the same id, old:", this.participants[pid], ", joined now:", connection); + console.warn("Connection already exists in connections list with " + + "the same connectionId, old:", this.participants[pid], ", joined now:", connection); connection = this.participants[pid]; } this.ee.emitEvent('participant-joined', [{ @@ -750,7 +1925,7 @@ var SessionInternal = (function () { }; ; SessionInternal.prototype.onNewMessage = function (msg) { - console.log("New message: " + JSON.stringify(msg)); + console.info("New message: " + JSON.stringify(msg)); var room = msg.room; var user = msg.user; var message = msg.message; @@ -793,7 +1968,7 @@ var SessionInternal = (function () { } }; SessionInternal.prototype.onRoomClosed = function (msg) { - console.log("Room closed: " + JSON.stringify(msg)); + console.info("Room closed: " + JSON.stringify(msg)); var room = msg.room; if (room !== undefined) { this.ee.emitEvent('room-closed', [{ @@ -813,7 +1988,7 @@ var SessionInternal = (function () { ; return; } - console.log('Lost connection in room ' + this.id); + console.warn('Lost connection in Session ' + this.id); var room = this.id; if (room !== undefined) { this.ee.emitEvent('lost-connection', [{ room: room }]); @@ -839,7 +2014,7 @@ var SessionInternal = (function () { */ SessionInternal.prototype.leave = function (forced, jsonRpcClient) { forced = !!forced; - console.log("Leaving room (forced=" + forced + ")"); + console.info("Leaving Session (forced=" + forced + ")"); if (this.connected && !forced) { this.openVidu.sendRequest('leaveRoom', function (error, response) { if (error) { @@ -868,7 +2043,7 @@ var SessionInternal = (function () { delete this.participants[connection.connectionId]; connection.dispose(); if (connection === this.localParticipant) { - console.log("Unpublishing my media (I'm " + connection.connectionId + ")"); + console.info("Unpublishing my media (I'm " + connection.connectionId + ")"); delete this.localParticipant; this.openVidu.sendRequest('unpublishVideo', function (error, response) { if (error) { @@ -892,7 +2067,7 @@ var SessionInternal = (function () { if (connection === this.localParticipant) { delete this.participants[connection.connectionId]; connection.dispose(); - console.log("Unpublishing my media (I'm " + connection.connectionId + ")"); + console.info("Unpublishing my media (I'm " + connection.connectionId + ")"); delete this.localParticipant; this.openVidu.sendRequest('unpublishVideo', function (error, response) { if (error) { @@ -940,24 +2115,24 @@ exports.SessionInternal = SessionInternal; /***/ }), -/***/ 1138: +/***/ 1077: /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(563); +module.exports = __webpack_require__(530); /***/ }), -/***/ 291: +/***/ 277: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(80); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(73); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Observable___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__authentication_service__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Rx__ = __webpack_require__(502); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__authentication_service__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Rx__ = __webpack_require__(483); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Rx___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_rxjs_Rx__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LessonService; }); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -1066,15 +2241,15 @@ var LessonService = (function () { /***/ }), -/***/ 292: +/***/ 278: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(80); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(73); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Observable___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__authentication_service__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__authentication_service__ = __webpack_require__(42); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return VideoSessionService; }); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -1137,15 +2312,15 @@ var VideoSessionService = (function () { /***/ }), -/***/ 325: +/***/ 307: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var EventEmitter = __webpack_require__(147); -var kurentoUtils = __webpack_require__(816); -var adapter = __webpack_require__(561); +var EventEmitter = __webpack_require__(135); +var kurentoUtils = __webpack_require__(1056); +var adapter = __webpack_require__(528); if (window) { window["adapter"] = adapter; } @@ -1158,7 +2333,7 @@ function show(id) { function hide(id) { document.getElementById(jq(id)).style.display = 'none'; } -var Stream = (function () { +var Stream = /** @class */ (function () { function Stream(openVidu, local, room, options) { var _this = this; this.openVidu = openVidu; @@ -1191,22 +2366,22 @@ var Stream = (function () { this.mediaConstraints = options.mediaConstraints; this.audioOnly = options.audioOnly || false; this.addEventListener('src-added', function (srcEvent) { - _this.videoSrc = srcEvent.src; + _this.videoSrcObject = srcEvent.srcObject; if (_this.video) - _this.video.src = srcEvent.src; - console.warn("Videosrc [" + srcEvent.src + "] added to stream [" + _this.getId() + "]"); + _this.video.srcObject = srcEvent.srcObject; + console.debug("Video srcObject [" + srcEvent.srcObject + "] added to stream [" + _this.getId() + "]"); }); } Stream.prototype.emitSrcEvent = function (wrstream) { this.ee.emitEvent('src-added', [{ - src: URL.createObjectURL(wrstream) + srcObject: wrstream }]); }; Stream.prototype.emitStreamReadyEvent = function () { this.ee.emitEvent('stream-ready'), [{}]; }; - Stream.prototype.getVideoSrc = function () { - return this.videoSrc; + Stream.prototype.getVideoSrcObject = function () { + return this.videoSrcObject; }; Stream.prototype.removeVideo = function (parentElement) { if (typeof parentElement === "string") { @@ -1260,11 +2435,11 @@ var Stream = (function () { return this.dataChannelOpened; }; Stream.prototype.onDataChannelOpen = function (event) { - console.log('Data channel is opened'); + console.debug('Data channel is opened'); this.dataChannelOpened = true; }; Stream.prototype.onDataChannelClosed = function (event) { - console.log('Data channel is closed'); + console.debug('Data channel is closed'); this.dataChannelOpened = false; }; Stream.prototype.sendData = function (data) { @@ -1274,7 +2449,7 @@ var Stream = (function () { if (!this.dataChannelOpened) { throw new Error('Data channel is not opened'); } - console.log("Sending through data channel: " + data); + console.info("Sending through data channel: " + data); this.wp.send(data); }; Stream.prototype.getWrStream = function () { @@ -1307,17 +2482,21 @@ var Stream = (function () { }; Stream.prototype.playOnlyVideo = function (parentElement, thumbnailId) { // TO-DO: check somehow if the stream is audio only, so the element created is