From 5aea138f6a16e092035bc6be837185342d60c41f Mon Sep 17 00:00:00 2001 From: bmamihai Date: Mon, 31 Oct 2022 12:17:07 +0200 Subject: [PATCH 001/121] added build.sh --- .gitignore | 1 + build.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 build.sh diff --git a/.gitignore b/.gitignore index 07e6e47..8225baa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +/dist diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..041c169 --- /dev/null +++ b/build.sh @@ -0,0 +1,48 @@ +#/!bin/bash +## PREBUILD PROCESS +# check dist dir to be present and empty +if [ ! -d "dist" ]; then + ## MAKE DIR + mkdir "dist" + echo "Directory dist created." +else + ## CLEANUP + rm -fr dist/* +fi +# Install dependencies +#npm install + +## PROJECT NEEDS +echo "Building app... from $(git rev-parse --abbrev-ref HEAD)" +#npm run-script build +cp -r {.env,app.js,package.json,server,public} dist/ + +#Add version control for pm2 +cd dist +#Add version control for pm2 +version=$(git describe) +file_pkg="package.json" +key=" \"version\": \"" + +count=$(echo ${version%%-*} | grep -o "\." | wc -l) +if (( $count > 1 )); then + version=${version%%-*} +else + version="${version%%-*}.0" +fi +if [ -f "$file_pkg" ] && [ ! -z "$version" ]; then + version=" \"version\": \"$version\"," + sed -i "s|^.*$key.*|${version//\//\\/}|g" $file_pkg + text=$(cat $file_pkg | grep -c "$version") + if [ $text -eq 0 ]; then + echo "Version couldn't be set" + else + echo "Version $version successfully applied to App" + fi +fi + +## POST BUILD + +cd - + + -- 2.37.1 From 75d0e3aee779df257f2f225a19a08df98630c7db Mon Sep 17 00:00:00 2001 From: Bozieru Mihai Date: Mon, 31 Oct 2022 22:26:08 +0000 Subject: [PATCH 002/121] exe right for build.sh --- build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 -- 2.37.1 From 9179a67f64ee9cfa615748933049070cc4d69803 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Mon, 21 Nov 2022 22:59:41 +0200 Subject: [PATCH 003/121] LH-265: Enable audio on video server --- public/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.js b/public/index.js index affb71b..5c3d177 100644 --- a/public/index.js +++ b/public/index.js @@ -135,7 +135,7 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: false, + audio: true, video: { width: { min: 640, -- 2.37.1 From 8860423e21a063c51f0f768e8e7a639d74c5d1ac Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 10:28:45 +0200 Subject: [PATCH 004/121] LH-265: Update client config --- public/config.js | 3 +-- public/index.js | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/config.js b/public/config.js index d12c148..fa3612f 100644 --- a/public/config.js +++ b/public/config.js @@ -1,5 +1,4 @@ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', - mediasoupAddress: 'https://video.safemobile.org/mediasoup', - // mediasoupAddress: 'http://localhost:3000/mediasoup', + mediasoupAddress: 'https://video.safemobile.org', } \ No newline at end of file diff --git a/public/index.js b/public/index.js index 5c3d177..60a48e1 100644 --- a/public/index.js +++ b/public/index.js @@ -12,6 +12,8 @@ let callId = parseInt(urlParams.get('callId')) || null; const IS_PRODUCER = urlParams.get('producer') === 'true' ? true : false console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', callId, ' | IS_PRODUCER', IS_PRODUCER) +console.log('🟩 config', config) + let socket hub = io(config.hubAddress) -- 2.37.1 From 39ad9cad274e3f6a978436cbf553f5741bdab4d5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:10:05 +0200 Subject: [PATCH 005/121] Update bundle --- public/bundle.js | 1076 +++++++++++++++++----------------------------- 1 file changed, 388 insertions(+), 688 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 0b0166f..8bae239 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -305,17 +305,9 @@ Backoff.prototype.setJitter = function(jitter){ * Copyright (c) 2012 Niklas von Hertzen * Licensed under the MIT license. */ -(function(){ +(function(chars){ "use strict"; - var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - // Use a lookup table to find the index. - var lookup = new Uint8Array(256); - for (var i = 0; i < chars.length; i++) { - lookup[chars.charCodeAt(i)] = i; - } - exports.encode = function(arraybuffer) { var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = ""; @@ -352,10 +344,10 @@ Backoff.prototype.setJitter = function(jitter){ bytes = new Uint8Array(arraybuffer); for (i = 0; i < len; i+=4) { - encoded1 = lookup[base64.charCodeAt(i)]; - encoded2 = lookup[base64.charCodeAt(i+1)]; - encoded3 = lookup[base64.charCodeAt(i+2)]; - encoded4 = lookup[base64.charCodeAt(i+3)]; + encoded1 = chars.indexOf(base64[i]); + encoded2 = chars.indexOf(base64[i+1]); + encoded3 = chars.indexOf(base64[i+2]); + encoded4 = chars.indexOf(base64[i+3]); bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); @@ -364,7 +356,7 @@ Backoff.prototype.setJitter = function(jitter){ return arraybuffer; }; -})(); +})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); },{}],6:[function(require,module,exports){ 'use strict' @@ -2405,7 +2397,7 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":6,"buffer":10,"ieee754":37}],11:[function(require,module,exports){ +},{"base64-js":6,"buffer":10,"ieee754":36}],11:[function(require,module,exports){ /** * Slice reference. */ @@ -2544,6 +2536,13 @@ Emitter.prototype.removeEventListener = function(event, fn){ break; } } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + return this; }; @@ -2557,9 +2556,14 @@ Emitter.prototype.removeEventListener = function(event, fn){ Emitter.prototype.emit = function(event){ this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) + + var args = new Array(arguments.length - 1) , callbacks = this._callbacks['$' + event]; + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) { @@ -2604,399 +2608,17 @@ module.exports = function(a, b){ a.prototype.constructor = a; }; },{}],14:[function(require,module,exports){ -(function (process){(function (){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; +module.exports = (function () { + if (typeof self !== 'undefined') { + return self; + } else if (typeof window !== 'undefined') { + return window; + } else { + return Function('return this')(); // eslint-disable-line no-new-func } +})(); - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } - - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - -}).call(this)}).call(this,require('_process')) -},{"./debug":15,"_process":78}],15:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - exports.names = []; - exports.skips = []; - - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":75}],16:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ module.exports = require('./socket'); @@ -3008,8 +2630,7 @@ module.exports = require('./socket'); */ module.exports.parser = require('engine.io-parser'); -},{"./socket":17,"engine.io-parser":27}],17:[function(require,module,exports){ -(function (global){(function (){ +},{"./socket":16,"engine.io-parser":26}],16:[function(require,module,exports){ /** * Module dependencies. */ @@ -3057,7 +2678,7 @@ function Socket (uri, opts) { } this.secure = null != opts.secure ? opts.secure - : (global.location && 'https:' === location.protocol); + : (typeof location !== 'undefined' && 'https:' === location.protocol); if (opts.hostname && !opts.port) { // if no port is specified manually, use the protocol default @@ -3066,8 +2687,8 @@ function Socket (uri, opts) { this.agent = opts.agent || false; this.hostname = opts.hostname || - (global.location ? location.hostname : 'localhost'); - this.port = opts.port || (global.location && location.port + (typeof location !== 'undefined' ? location.hostname : 'localhost'); + this.port = opts.port || (typeof location !== 'undefined' && location.port ? location.port : (this.secure ? 443 : 80)); this.query = opts.query || {}; @@ -3078,6 +2699,7 @@ function Socket (uri, opts) { this.jsonp = false !== opts.jsonp; this.forceBase64 = !!opts.forceBase64; this.enablesXDR = !!opts.enablesXDR; + this.withCredentials = false !== opts.withCredentials; this.timestampParam = opts.timestampParam || 't'; this.timestampRequests = opts.timestampRequests; this.transports = opts.transports || ['polling', 'websocket']; @@ -3097,18 +2719,20 @@ function Socket (uri, opts) { } // SSL options for Node.js client - this.pfx = opts.pfx || null; - this.key = opts.key || null; - this.passphrase = opts.passphrase || null; - this.cert = opts.cert || null; - this.ca = opts.ca || null; - this.ciphers = opts.ciphers || null; + this.pfx = opts.pfx || undefined; + this.key = opts.key || undefined; + this.passphrase = opts.passphrase || undefined; + this.cert = opts.cert || undefined; + this.ca = opts.ca || undefined; + this.ciphers = opts.ciphers || undefined; this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized; this.forceNode = !!opts.forceNode; - // other options for Node.js client - var freeGlobal = typeof global === 'object' && global; - if (freeGlobal.global === freeGlobal) { + // detect ReactNative environment + this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative'); + + // other options for Node.js or ReactNative client + if (typeof self === 'undefined' || this.isReactNative) { if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) { this.extraHeaders = opts.extraHeaders; } @@ -3193,6 +2817,7 @@ Socket.prototype.createTransport = function (name) { jsonp: options.jsonp || this.jsonp, forceBase64: options.forceBase64 || this.forceBase64, enablesXDR: options.enablesXDR || this.enablesXDR, + withCredentials: options.withCredentials || this.withCredentials, timestampRequests: options.timestampRequests || this.timestampRequests, timestampParam: options.timestampParam || this.timestampParam, policyPort: options.policyPort || this.policyPort, @@ -3208,7 +2833,8 @@ Socket.prototype.createTransport = function (name) { forceNode: options.forceNode || this.forceNode, localAddress: options.localAddress || this.localAddress, requestTimeout: options.requestTimeout || this.requestTimeout, - protocols: options.protocols || void (0) + protocols: options.protocols || void (0), + isReactNative: this.isReactNative }); return transport; @@ -3754,8 +3380,7 @@ Socket.prototype.filterUpgrades = function (upgrades) { return filteredUpgrades; }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./transport":18,"./transports/index":19,"component-emitter":12,"debug":25,"engine.io-parser":27,"indexof":38,"parseqs":76,"parseuri":77}],18:[function(require,module,exports){ +},{"./transport":17,"./transports/index":18,"component-emitter":12,"debug":24,"engine.io-parser":26,"indexof":37,"parseqs":75,"parseuri":76}],17:[function(require,module,exports){ /** * Module dependencies. */ @@ -3788,6 +3413,7 @@ function Transport (opts) { this.agent = opts.agent || false; this.socket = opts.socket; this.enablesXDR = opts.enablesXDR; + this.withCredentials = opts.withCredentials; // SSL options for Node.js client this.pfx = opts.pfx; @@ -3799,6 +3425,9 @@ function Transport (opts) { this.rejectUnauthorized = opts.rejectUnauthorized; this.forceNode = opts.forceNode; + // results of ReactNative environment detection + this.isReactNative = opts.isReactNative; + // other options for Node.js client this.extraHeaders = opts.extraHeaders; this.localAddress = opts.localAddress; @@ -3914,13 +3543,12 @@ Transport.prototype.onClose = function () { this.emit('close'); }; -},{"component-emitter":12,"engine.io-parser":27}],19:[function(require,module,exports){ -(function (global){(function (){ +},{"component-emitter":12,"engine.io-parser":26}],18:[function(require,module,exports){ /** * Module dependencies */ -var XMLHttpRequest = require('xmlhttprequest-ssl'); +var XMLHttpRequest = require('./xmlhttprequest'); var XHR = require('./polling-xhr'); var JSONP = require('./polling-jsonp'); var websocket = require('./websocket'); @@ -3945,7 +3573,7 @@ function polling (opts) { var xs = false; var jsonp = false !== opts.jsonp; - if (global.location) { + if (typeof location !== 'undefined') { var isSSL = 'https:' === location.protocol; var port = location.port; @@ -3970,16 +3598,14 @@ function polling (opts) { } } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polling-jsonp":20,"./polling-xhr":21,"./websocket":23,"xmlhttprequest-ssl":24}],20:[function(require,module,exports){ -(function (global){(function (){ - +},{"./polling-jsonp":19,"./polling-xhr":20,"./websocket":22,"./xmlhttprequest":23}],19:[function(require,module,exports){ /** * Module requirements. */ var Polling = require('./polling'); var inherit = require('component-inherit'); +var globalThis = require('../globalThis'); /** * Module exports. @@ -4022,8 +3648,7 @@ function JSONPPolling (opts) { // we do this here (lazily) to avoid unneeded global pollution if (!callbacks) { // we need to consider multiple engines in the same page - if (!global.___eio) global.___eio = []; - callbacks = global.___eio; + callbacks = globalThis.___eio = (globalThis.___eio || []); } // callback identifier @@ -4039,8 +3664,8 @@ function JSONPPolling (opts) { this.query.j = this.index; // prevent spurious errors from being emitted when the window is unloaded - if (global.document && global.addEventListener) { - global.addEventListener('beforeunload', function () { + if (typeof addEventListener === 'function') { + addEventListener('beforeunload', function () { if (self.script) self.script.onerror = empty; }, false); } @@ -4205,18 +3830,19 @@ JSONPPolling.prototype.doWrite = function (data, fn) { } }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polling":22,"component-inherit":13}],21:[function(require,module,exports){ -(function (global){(function (){ +},{"../globalThis":14,"./polling":21,"component-inherit":13}],20:[function(require,module,exports){ +/* global attachEvent */ + /** * Module requirements. */ -var XMLHttpRequest = require('xmlhttprequest-ssl'); +var XMLHttpRequest = require('./xmlhttprequest'); var Polling = require('./polling'); var Emitter = require('component-emitter'); var inherit = require('component-inherit'); var debug = require('debug')('engine.io-client:polling-xhr'); +var globalThis = require('../globalThis'); /** * Module exports. @@ -4243,7 +3869,7 @@ function XHR (opts) { this.requestTimeout = opts.requestTimeout; this.extraHeaders = opts.extraHeaders; - if (global.location) { + if (typeof location !== 'undefined') { var isSSL = 'https:' === location.protocol; var port = location.port; @@ -4252,7 +3878,7 @@ function XHR (opts) { port = isSSL ? 443 : 80; } - this.xd = opts.hostname !== global.location.hostname || + this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) || port !== opts.port; this.xs = opts.secure !== isSSL; } @@ -4285,6 +3911,7 @@ XHR.prototype.request = function (opts) { opts.agent = this.agent || false; opts.supportsBinary = this.supportsBinary; opts.enablesXDR = this.enablesXDR; + opts.withCredentials = this.withCredentials; // SSL options for Node.js client opts.pfx = this.pfx; @@ -4358,6 +3985,7 @@ function Request (opts) { this.isBinary = opts.isBinary; this.supportsBinary = opts.supportsBinary; this.enablesXDR = opts.enablesXDR; + this.withCredentials = opts.withCredentials; this.requestTimeout = opts.requestTimeout; // SSL options for Node.js client @@ -4432,7 +4060,7 @@ Request.prototype.create = function () { // ie6 check if ('withCredentials' in xhr) { - xhr.withCredentials = true; + xhr.withCredentials = this.withCredentials; } if (this.requestTimeout) { @@ -4451,7 +4079,7 @@ Request.prototype.create = function () { if (xhr.readyState === 2) { try { var contentType = xhr.getResponseHeader('Content-Type'); - if (self.supportsBinary && contentType === 'application/octet-stream') { + if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') { xhr.responseType = 'arraybuffer'; } } catch (e) {} @@ -4463,7 +4091,7 @@ Request.prototype.create = function () { // make sure the `error` event handler that's user-set // does not throw in the same tick and gets caught here setTimeout(function () { - self.onError(xhr.status); + self.onError(typeof xhr.status === 'number' ? xhr.status : 0); }, 0); } }; @@ -4481,7 +4109,7 @@ Request.prototype.create = function () { return; } - if (global.document) { + if (typeof document !== 'undefined') { this.index = Request.requestsCount++; Request.requests[this.index] = this; } @@ -4543,7 +4171,7 @@ Request.prototype.cleanup = function (fromError) { } catch (e) {} } - if (global.document) { + if (typeof document !== 'undefined') { delete Request.requests[this.index]; } @@ -4563,7 +4191,7 @@ Request.prototype.onLoad = function () { try { contentType = this.xhr.getResponseHeader('Content-Type'); } catch (e) {} - if (contentType === 'application/octet-stream') { + if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') { data = this.xhr.response || this.xhr.responseText; } else { data = this.xhr.responseText; @@ -4583,7 +4211,7 @@ Request.prototype.onLoad = function () { */ Request.prototype.hasXDR = function () { - return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR; + return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR; }; /** @@ -4605,11 +4233,12 @@ Request.prototype.abort = function () { Request.requestsCount = 0; Request.requests = {}; -if (global.document) { - if (global.attachEvent) { - global.attachEvent('onunload', unloadHandler); - } else if (global.addEventListener) { - global.addEventListener('beforeunload', unloadHandler, false); +if (typeof document !== 'undefined') { + if (typeof attachEvent === 'function') { + attachEvent('onunload', unloadHandler); + } else if (typeof addEventListener === 'function') { + var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload'; + addEventListener(terminationEvent, unloadHandler, false); } } @@ -4621,8 +4250,7 @@ function unloadHandler () { } } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polling":22,"component-emitter":12,"component-inherit":13,"debug":25,"xmlhttprequest-ssl":24}],22:[function(require,module,exports){ +},{"../globalThis":14,"./polling":21,"./xmlhttprequest":23,"component-emitter":12,"component-inherit":13,"debug":24}],21:[function(require,module,exports){ /** * Module dependencies. */ @@ -4645,7 +4273,7 @@ module.exports = Polling; */ var hasXHR2 = (function () { - var XMLHttpRequest = require('xmlhttprequest-ssl'); + var XMLHttpRequest = require('./xmlhttprequest'); var xhr = new XMLHttpRequest({ xdomain: false }); return null != xhr.responseType; })(); @@ -4755,7 +4383,7 @@ Polling.prototype.onData = function (data) { debug('polling got data %s', data); var callback = function (packet, index, total) { // if its the first message we consider the transport open - if ('opening' === self.readyState) { + if ('opening' === self.readyState && packet.type === 'open') { self.onOpen(); } @@ -4869,8 +4497,8 @@ Polling.prototype.uri = function () { return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query; }; -},{"../transport":18,"component-inherit":13,"debug":25,"engine.io-parser":27,"parseqs":76,"xmlhttprequest-ssl":24,"yeast":94}],23:[function(require,module,exports){ -(function (global){(function (){ +},{"../transport":17,"./xmlhttprequest":23,"component-inherit":13,"debug":24,"engine.io-parser":26,"parseqs":75,"yeast":93}],22:[function(require,module,exports){ +(function (Buffer){(function (){ /** * Module dependencies. */ @@ -4881,8 +4509,15 @@ var parseqs = require('parseqs'); var inherit = require('component-inherit'); var yeast = require('yeast'); var debug = require('debug')('engine.io-client:websocket'); -var BrowserWebSocket = global.WebSocket || global.MozWebSocket; -var NodeWebSocket; + +var BrowserWebSocket, NodeWebSocket; + +if (typeof WebSocket !== 'undefined') { + BrowserWebSocket = WebSocket; +} else if (typeof self !== 'undefined') { + BrowserWebSocket = self.WebSocket || self.MozWebSocket; +} + if (typeof window === 'undefined') { try { NodeWebSocket = require('ws'); @@ -4895,10 +4530,7 @@ if (typeof window === 'undefined') { * interface exposed by `ws` for Node-like environment. */ -var WebSocket = BrowserWebSocket; -if (!WebSocket && typeof window === 'undefined') { - WebSocket = NodeWebSocket; -} +var WebSocketImpl = BrowserWebSocket || NodeWebSocket; /** * Module exports. @@ -4922,7 +4554,7 @@ function WS (opts) { this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode; this.protocols = opts.protocols; if (!this.usingBrowserWebSocket) { - WebSocket = NodeWebSocket; + WebSocketImpl = NodeWebSocket; } Transport.call(this, opts); } @@ -4961,19 +4593,23 @@ WS.prototype.doOpen = function () { var uri = this.uri(); var protocols = this.protocols; - var opts = { - agent: this.agent, - perMessageDeflate: this.perMessageDeflate - }; - // SSL options for Node.js client - opts.pfx = this.pfx; - opts.key = this.key; - opts.passphrase = this.passphrase; - opts.cert = this.cert; - opts.ca = this.ca; - opts.ciphers = this.ciphers; - opts.rejectUnauthorized = this.rejectUnauthorized; + var opts = {}; + + if (!this.isReactNative) { + opts.agent = this.agent; + opts.perMessageDeflate = this.perMessageDeflate; + + // SSL options for Node.js client + opts.pfx = this.pfx; + opts.key = this.key; + opts.passphrase = this.passphrase; + opts.cert = this.cert; + opts.ca = this.ca; + opts.ciphers = this.ciphers; + opts.rejectUnauthorized = this.rejectUnauthorized; + } + if (this.extraHeaders) { opts.headers = this.extraHeaders; } @@ -4982,7 +4618,12 @@ WS.prototype.doOpen = function () { } try { - this.ws = this.usingBrowserWebSocket ? (protocols ? new WebSocket(uri, protocols) : new WebSocket(uri)) : new WebSocket(uri, protocols, opts); + this.ws = + this.usingBrowserWebSocket && !this.isReactNative + ? protocols + ? new WebSocketImpl(uri, protocols) + : new WebSocketImpl(uri) + : new WebSocketImpl(uri, protocols, opts); } catch (err) { return this.emit('error', err); } @@ -5049,7 +4690,7 @@ WS.prototype.write = function (packets) { } if (self.perMessageDeflate) { - var len = 'string' === typeof data ? global.Buffer.byteLength(data) : data.length; + var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length; if (len < self.perMessageDeflate.threshold) { opts.compress = false; } @@ -5155,15 +4796,15 @@ WS.prototype.uri = function () { */ WS.prototype.check = function () { - return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name); + return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name); }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../transport":18,"component-inherit":13,"debug":25,"engine.io-parser":27,"parseqs":76,"ws":9,"yeast":94}],24:[function(require,module,exports){ -(function (global){(function (){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"../transport":17,"buffer":10,"component-inherit":13,"debug":24,"engine.io-parser":26,"parseqs":75,"ws":9,"yeast":93}],23:[function(require,module,exports){ // browser shim for xmlhttprequest module var hasCORS = require('has-cors'); +var globalThis = require('../globalThis'); module.exports = function (opts) { var xdomain = opts.xdomain; @@ -5194,13 +4835,12 @@ module.exports = function (opts) { if (!xdomain) { try { - return new global[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); + return new globalThis[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); } catch (e) { } } }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"has-cors":36}],25:[function(require,module,exports){ +},{"../globalThis":14,"has-cors":35}],24:[function(require,module,exports){ (function (process){(function (){ /** * This is the web browser implementation of `debug()`. @@ -5399,7 +5039,7 @@ function localstorage() { } }).call(this)}).call(this,require('_process')) -},{"./debug":26,"_process":78}],26:[function(require,module,exports){ +},{"./debug":25,"_process":77}],25:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -5626,7 +5266,7 @@ function coerce(val) { return val; } -},{"ms":75}],27:[function(require,module,exports){ +},{"ms":74}],26:[function(require,module,exports){ /** * Module dependencies. */ @@ -6233,7 +5873,7 @@ exports.decodePayloadAsBinary = function (data, binaryType, callback) { }); }; -},{"./keys":28,"./utf8":29,"after":1,"arraybuffer.slice":2,"base64-arraybuffer":5,"blob":7,"has-binary2":35}],28:[function(require,module,exports){ +},{"./keys":27,"./utf8":28,"after":1,"arraybuffer.slice":2,"base64-arraybuffer":5,"blob":7,"has-binary2":34}],27:[function(require,module,exports){ /** * Gets the keys for an object. @@ -6254,7 +5894,7 @@ module.exports = Object.keys || function keys (obj){ return arr; }; -},{}],29:[function(require,module,exports){ +},{}],28:[function(require,module,exports){ /*! https://mths.be/utf8js v2.1.2 by @mathias */ var stringFromCharCode = String.fromCharCode; @@ -6466,7 +6106,7 @@ module.exports = { decode: utf8decode }; -},{}],30:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -6965,7 +6605,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) { } } -},{}],31:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ const debug = require('debug')('h264-profile-level-id'); /* eslint-disable no-console */ @@ -7420,7 +7060,7 @@ function isLevelAsymmetryAllowed(params = {}) ); } -},{"debug":32}],32:[function(require,module,exports){ +},{"debug":31}],31:[function(require,module,exports){ (function (process){(function (){ /* eslint-env browser */ @@ -7693,7 +7333,7 @@ formatters.j = function (v) { }; }).call(this)}).call(this,require('_process')) -},{"./common":33,"_process":78}],33:[function(require,module,exports){ +},{"./common":32,"_process":77}],32:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -7969,7 +7609,7 @@ function setup(env) { module.exports = setup; -},{"ms":34}],34:[function(require,module,exports){ +},{"ms":33}],33:[function(require,module,exports){ /** * Helpers. */ @@ -8133,7 +7773,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],35:[function(require,module,exports){ +},{}],34:[function(require,module,exports){ (function (Buffer){(function (){ /* global Blob File */ @@ -8201,7 +7841,7 @@ function hasBinary (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":10,"isarray":39}],36:[function(require,module,exports){ +},{"buffer":10,"isarray":38}],35:[function(require,module,exports){ /** * Module exports. @@ -8220,7 +7860,7 @@ try { module.exports = false; } -},{}],37:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -8307,7 +7947,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],38:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ var indexOf = [].indexOf; @@ -8318,14 +7958,14 @@ module.exports = function(arr, obj){ } return -1; }; -},{}],39:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],40:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Consumer = void 0; @@ -8507,7 +8147,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.Consumer = Consumer; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./errors":50}],41:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./errors":49}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataConsumer = void 0; @@ -8663,7 +8303,7 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.DataConsumer = DataConsumer; -},{"./EnhancedEventEmitter":44,"./Logger":45}],42:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataProducer = void 0; @@ -8835,7 +8475,7 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.DataProducer = DataProducer; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./errors":50}],43:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./errors":49}],42:[function(require,module,exports){ "use strict"; /* global RTCRtpTransceiver */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { @@ -9230,7 +8870,7 @@ class Device { } exports.Device = Device; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./Transport":49,"./errors":50,"./handlers/Chrome55":51,"./handlers/Chrome67":52,"./handlers/Chrome70":53,"./handlers/Chrome74":54,"./handlers/Edge11":55,"./handlers/Firefox60":56,"./handlers/ReactNative":58,"./handlers/Safari11":59,"./handlers/Safari12":60,"./ortc":68,"./utils":71,"bowser":8}],44:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./Transport":48,"./errors":49,"./handlers/Chrome55":50,"./handlers/Chrome67":51,"./handlers/Chrome70":52,"./handlers/Chrome74":53,"./handlers/Edge11":54,"./handlers/Firefox60":55,"./handlers/ReactNative":57,"./handlers/Safari11":58,"./handlers/Safari12":59,"./ortc":67,"./utils":70,"bowser":8}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EnhancedEventEmitter = void 0; @@ -9302,7 +8942,7 @@ class EnhancedEventEmitter extends events_1.EventEmitter { } exports.EnhancedEventEmitter = EnhancedEventEmitter; -},{"./Logger":45,"events":30}],45:[function(require,module,exports){ +},{"./Logger":44,"events":29}],44:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -9341,7 +8981,7 @@ class Logger { } exports.Logger = Logger; -},{"debug":72}],46:[function(require,module,exports){ +},{"debug":71}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Producer = void 0; @@ -9619,7 +9259,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.Producer = Producer; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./errors":50}],47:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./errors":49}],46:[function(require,module,exports){ "use strict"; /** * The RTP capabilities define what mediasoup or an endpoint can receive at @@ -9627,11 +9267,11 @@ exports.Producer = Producer; */ Object.defineProperty(exports, "__esModule", { value: true }); -},{}],48:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -},{}],49:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -10315,7 +9955,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.Transport = Transport; -},{"./Consumer":40,"./DataConsumer":41,"./DataProducer":42,"./EnhancedEventEmitter":44,"./Logger":45,"./Producer":46,"./errors":50,"./ortc":68,"./utils":71,"awaitqueue":3}],50:[function(require,module,exports){ +},{"./Consumer":39,"./DataConsumer":40,"./DataProducer":41,"./EnhancedEventEmitter":43,"./Logger":44,"./Producer":45,"./errors":49,"./ortc":67,"./utils":70,"awaitqueue":3}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvalidStateError = exports.UnsupportedError = void 0; @@ -10356,7 +9996,7 @@ class InvalidStateError extends Error { } exports.InvalidStateError = InvalidStateError; -},{}],51:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -10877,7 +10517,7 @@ class Chrome55 extends HandlerInterface_1.HandlerInterface { } exports.Chrome55 = Chrome55; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],52:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],51:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -11445,7 +11085,7 @@ class Chrome67 extends HandlerInterface_1.HandlerInterface { } exports.Chrome67 = Chrome67; -},{"../Logger":45,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],53:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],52:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -12020,7 +11660,7 @@ class Chrome70 extends HandlerInterface_1.HandlerInterface { } exports.Chrome70 = Chrome70; -},{"../Logger":45,"../ortc":68,"../scalabilityModes":69,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],54:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../scalabilityModes":68,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],53:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -12609,7 +12249,7 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface { } exports.Chrome74 = Chrome74; -},{"../Logger":45,"../ortc":68,"../scalabilityModes":69,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],55:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../scalabilityModes":68,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],54:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -13032,7 +12672,7 @@ class Edge11 extends HandlerInterface_1.HandlerInterface { } exports.Edge11 = Edge11; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./ortc/edgeUtils":61}],56:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./ortc/edgeUtils":60}],55:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -13621,7 +13261,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface { } exports.Firefox60 = Firefox60; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],57:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HandlerInterface = void 0; @@ -13633,7 +13273,7 @@ class HandlerInterface extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.HandlerInterface = HandlerInterface; -},{"../EnhancedEventEmitter":44}],58:[function(require,module,exports){ +},{"../EnhancedEventEmitter":43}],57:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -14168,7 +13808,7 @@ class ReactNative extends HandlerInterface_1.HandlerInterface { } exports.ReactNative = ReactNative; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],59:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],58:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -14728,7 +14368,7 @@ class Safari11 extends HandlerInterface_1.HandlerInterface { } exports.Safari11 = Safari11; -},{"../Logger":45,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],60:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],59:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -15285,7 +14925,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface { } exports.Safari12 = Safari12; -},{"../Logger":45,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],61:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],60:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -15369,7 +15009,7 @@ function mangleRtpParameters(rtpParameters) { } exports.mangleRtpParameters = mangleRtpParameters; -},{"../../utils":71}],62:[function(require,module,exports){ +},{"../../utils":70}],61:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -15903,7 +15543,7 @@ function getCodecName(codec) { return mimeTypeMatch[2]; } -},{"../../utils":71}],63:[function(require,module,exports){ +},{"../../utils":70}],62:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -16184,7 +15824,7 @@ class RemoteSdp { } exports.RemoteSdp = RemoteSdp; -},{"../../Logger":45,"./MediaSection":62,"sdp-transform":80}],64:[function(require,module,exports){ +},{"../../Logger":44,"./MediaSection":61,"sdp-transform":79}],63:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -16380,7 +16020,7 @@ function applyCodecParameters({ offerRtpParameters, answerMediaObject }) { } exports.applyCodecParameters = applyCodecParameters; -},{"sdp-transform":80}],65:[function(require,module,exports){ +},{"sdp-transform":79}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLegacySimulcast = exports.getRtpEncodings = void 0; @@ -16526,7 +16166,7 @@ function addLegacySimulcast({ offerMediaObject, track, numStreams }) { } exports.addLegacySimulcast = addLegacySimulcast; -},{}],66:[function(require,module,exports){ +},{}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLegacySimulcast = exports.getRtpEncodings = void 0; @@ -16651,7 +16291,7 @@ function addLegacySimulcast({ offerMediaObject, numStreams }) { } exports.addLegacySimulcast = addLegacySimulcast; -},{}],67:[function(require,module,exports){ +},{}],66:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -16698,7 +16338,7 @@ exports.version = '3.6.54'; var scalabilityModes_1 = require("./scalabilityModes"); Object.defineProperty(exports, "parseScalabilityMode", { enumerable: true, get: function () { return scalabilityModes_1.parse; } }); -},{"./Device":43,"./scalabilityModes":69,"./types":70,"debug":72}],68:[function(require,module,exports){ +},{"./Device":42,"./scalabilityModes":68,"./types":69,"debug":71}],67:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -17545,7 +17185,7 @@ function reduceRtcpFeedback(codecA, codecB) { return reducedRtcpFeedback; } -},{"./utils":71,"h264-profile-level-id":31}],69:[function(require,module,exports){ +},{"./utils":70,"h264-profile-level-id":30}],68:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = void 0; @@ -17567,7 +17207,7 @@ function parse(scalabilityMode) { } exports.parse = parse; -},{}],70:[function(require,module,exports){ +},{}],69:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -17595,7 +17235,7 @@ __exportStar(require("./SctpParameters"), exports); __exportStar(require("./handlers/HandlerInterface"), exports); __exportStar(require("./errors"), exports); -},{"./Consumer":40,"./DataConsumer":41,"./DataProducer":42,"./Device":43,"./Producer":46,"./RtpParameters":47,"./SctpParameters":48,"./Transport":49,"./errors":50,"./handlers/HandlerInterface":57}],71:[function(require,module,exports){ +},{"./Consumer":39,"./DataConsumer":40,"./DataProducer":41,"./Device":42,"./Producer":45,"./RtpParameters":46,"./SctpParameters":47,"./Transport":48,"./errors":49,"./handlers/HandlerInterface":56}],70:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateRandomNumber = exports.clone = void 0; @@ -17616,13 +17256,13 @@ function generateRandomNumber() { } exports.generateRandomNumber = generateRandomNumber; -},{}],72:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./common":72,"_process":77,"dup":31}],72:[function(require,module,exports){ arguments[4][32][0].apply(exports,arguments) -},{"./common":73,"_process":78,"dup":32}],73:[function(require,module,exports){ +},{"dup":32,"ms":73}],73:[function(require,module,exports){ arguments[4][33][0].apply(exports,arguments) -},{"dup":33,"ms":74}],74:[function(require,module,exports){ -arguments[4][34][0].apply(exports,arguments) -},{"dup":34}],75:[function(require,module,exports){ +},{"dup":33}],74:[function(require,module,exports){ /** * Helpers. */ @@ -17776,87 +17416,116 @@ function plural(ms, n, name) { return Math.ceil(ms / n) + ' ' + name + 's'; } +},{}],75:[function(require,module,exports){ +/** + * Compiles a querystring + * Returns string representation of the object + * + * @param {Object} + * @api private + */ + +exports.encode = function (obj) { + var str = ''; + + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + if (str.length) str += '&'; + str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); + } + } + + return str; +}; + +/** + * Parses a simple querystring into an object + * + * @param {String} qs + * @api private + */ + +exports.decode = function(qs){ + var qry = {}; + var pairs = qs.split('&'); + for (var i = 0, l = pairs.length; i < l; i++) { + var pair = pairs[i].split('='); + qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + return qry; +}; + },{}],76:[function(require,module,exports){ -/** - * Compiles a querystring - * Returns string representation of the object - * - * @param {Object} - * @api private - */ - -exports.encode = function (obj) { - var str = ''; - - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - if (str.length) str += '&'; - str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); - } - } - - return str; -}; - -/** - * Parses a simple querystring into an object - * - * @param {String} qs - * @api private - */ - -exports.decode = function(qs){ - var qry = {}; - var pairs = qs.split('&'); - for (var i = 0, l = pairs.length; i < l; i++) { - var pair = pairs[i].split('='); - qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); - } - return qry; -}; +/** + * Parses an URI + * + * @author Steven Levithan (MIT license) + * @api private + */ + +var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; + +var parts = [ + 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' +]; + +module.exports = function parseuri(str) { + var src = str, + b = str.indexOf('['), + e = str.indexOf(']'); + + if (b != -1 && e != -1) { + str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + } + + var m = re.exec(str || ''), + uri = {}, + i = 14; + + while (i--) { + uri[parts[i]] = m[i] || ''; + } + + if (b != -1 && e != -1) { + uri.source = src; + uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); + uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); + uri.ipv6uri = true; + } + + uri.pathNames = pathNames(uri, uri['path']); + uri.queryKey = queryKey(uri, uri['query']); + + return uri; +}; + +function pathNames(obj, path) { + var regx = /\/{2,9}/g, + names = path.replace(regx, "/").split("/"); + + if (path.substr(0, 1) == '/' || path.length === 0) { + names.splice(0, 1); + } + if (path.substr(path.length - 1, 1) == '/') { + names.splice(names.length - 1, 1); + } + + return names; +} + +function queryKey(uri, query) { + var data = {}; + + query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { + if ($1) { + data[$1] = $2; + } + }); + + return data; +} },{}],77:[function(require,module,exports){ -/** - * Parses an URI - * - * @author Steven Levithan (MIT license) - * @api private - */ - -var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; - -var parts = [ - 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -]; - -module.exports = function parseuri(str) { - var src = str, - b = str.indexOf('['), - e = str.indexOf(']'); - - if (b != -1 && e != -1) { - str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); - } - - var m = re.exec(str || ''), - uri = {}, - i = 14; - - while (i--) { - uri[parts[i]] = m[i] || ''; - } - - if (b != -1 && e != -1) { - uri.source = src; - uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); - uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); - uri.ipv6uri = true; - } - - return uri; -}; - -},{}],78:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -18042,7 +17711,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],79:[function(require,module,exports){ +},{}],78:[function(require,module,exports){ var grammar = module.exports = { v: [{ name: 'version', @@ -18538,7 +18207,7 @@ Object.keys(grammar).forEach(function (key) { }); }); -},{}],80:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ var parser = require('./parser'); var writer = require('./writer'); @@ -18551,7 +18220,7 @@ exports.parseRemoteCandidates = parser.parseRemoteCandidates; exports.parseImageAttributes = parser.parseImageAttributes; exports.parseSimulcastStreamList = parser.parseSimulcastStreamList; -},{"./parser":81,"./writer":82}],81:[function(require,module,exports){ +},{"./parser":80,"./writer":81}],80:[function(require,module,exports){ var toIntIfInt = function (v) { return String(Number(v)) === v ? Number(v) : v; }; @@ -18677,7 +18346,7 @@ exports.parseSimulcastStreamList = function (str) { }); }; -},{"./grammar":79}],82:[function(require,module,exports){ +},{"./grammar":78}],81:[function(require,module,exports){ var grammar = require('./grammar'); // customized util.format - discards excess arguments and can void middle ones @@ -18793,7 +18462,7 @@ module.exports = function (session, opts) { return sdp.join('\r\n') + '\r\n'; }; -},{"./grammar":79}],83:[function(require,module,exports){ +},{"./grammar":78}],82:[function(require,module,exports){ /** * Module dependencies. @@ -18889,7 +18558,7 @@ exports.connect = lookup; exports.Manager = require('./manager'); exports.Socket = require('./socket'); -},{"./manager":84,"./socket":86,"./url":87,"debug":14,"socket.io-parser":89}],84:[function(require,module,exports){ +},{"./manager":83,"./socket":85,"./url":86,"debug":87,"socket.io-parser":90}],83:[function(require,module,exports){ /** * Module dependencies. @@ -19148,6 +18817,10 @@ Manager.prototype.connect = function (fn, opts) { var timeout = this._timeout; debug('connect attempt will timeout after %d', timeout); + if (timeout === 0) { + openSub.destroy(); // prevents a race condition with the 'open' event + } + // set timer var timer = setTimeout(function () { debug('connect attempt timed out after %d', timeout); @@ -19464,7 +19137,7 @@ Manager.prototype.onreconnect = function () { this.emitAll('reconnect', attempt); }; -},{"./on":85,"./socket":86,"backo2":4,"component-bind":11,"component-emitter":12,"debug":14,"engine.io-client":16,"indexof":38,"socket.io-parser":89}],85:[function(require,module,exports){ +},{"./on":84,"./socket":85,"backo2":4,"component-bind":11,"component-emitter":12,"debug":87,"engine.io-client":15,"indexof":37,"socket.io-parser":90}],84:[function(require,module,exports){ /** * Module exports. @@ -19490,7 +19163,7 @@ function on (obj, ev, fn) { }; } -},{}],86:[function(require,module,exports){ +},{}],85:[function(require,module,exports){ /** * Module dependencies. @@ -19503,6 +19176,7 @@ var on = require('./on'); var bind = require('component-bind'); var debug = require('debug')('socket.io-client:socket'); var parseqs = require('parseqs'); +var hasBin = require('has-binary2'); /** * Module exports. @@ -19555,6 +19229,7 @@ function Socket (io, nsp, opts) { this.sendBuffer = []; this.connected = false; this.disconnected = true; + this.flags = {}; if (opts && opts.query) { this.query = opts.query; } @@ -19595,7 +19270,7 @@ Socket.prototype.connect = function () { if (this.connected) return this; this.subEvents(); - this.io.open(); // ensure open + if (!this.io.reconnecting) this.io.open(); // ensure open if ('open' === this.io.readyState) this.onopen(); this.emit('connecting'); return this; @@ -19631,7 +19306,10 @@ Socket.prototype.emit = function (ev) { } var args = toArray(arguments); - var packet = { type: parser.EVENT, data: args }; + var packet = { + type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT, + data: args + }; packet.options = {}; packet.options.compress = !this.flags || false !== this.flags.compress; @@ -19649,7 +19327,7 @@ Socket.prototype.emit = function (ev) { this.sendBuffer.push(packet); } - delete this.flags; + this.flags = {}; return this; }; @@ -19710,7 +19388,10 @@ Socket.prototype.onclose = function (reason) { */ Socket.prototype.onpacket = function (packet) { - if (packet.nsp !== this.nsp) return; + var sameNamespace = packet.nsp === this.nsp; + var rootNamespaceError = packet.type === parser.ERROR && packet.nsp === '/'; + + if (!sameNamespace && !rootNamespaceError) return; switch (packet.type) { case parser.CONNECT: @@ -19783,7 +19464,7 @@ Socket.prototype.ack = function (id) { debug('sending ack %j', args); self.packet({ - type: parser.ACK, + type: hasBin(args) ? parser.BINARY_ACK : parser.ACK, id: id, data: args }); @@ -19817,8 +19498,8 @@ Socket.prototype.onack = function (packet) { Socket.prototype.onconnect = function () { this.connected = true; this.disconnected = false; - this.emit('connect'); this.emitBuffered(); + this.emit('connect'); }; /** @@ -19905,13 +19586,24 @@ Socket.prototype.disconnect = function () { */ Socket.prototype.compress = function (compress) { - this.flags = this.flags || {}; this.flags.compress = compress; return this; }; -},{"./on":85,"component-bind":11,"component-emitter":12,"debug":14,"parseqs":76,"socket.io-parser":89,"to-array":93}],87:[function(require,module,exports){ -(function (global){(function (){ +/** + * Sets the binary flag + * + * @param {Boolean} whether the emitted data contains binary + * @return {Socket} self + * @api public + */ + +Socket.prototype.binary = function (binary) { + this.flags.binary = binary; + return this; +}; + +},{"./on":84,"component-bind":11,"component-emitter":12,"debug":87,"has-binary2":34,"parseqs":75,"socket.io-parser":90,"to-array":92}],86:[function(require,module,exports){ /** * Module dependencies. @@ -19939,7 +19631,7 @@ function url (uri, loc) { var obj = uri; // default to window.location - loc = loc || global.location; + loc = loc || (typeof location !== 'undefined' && location); if (null == uri) uri = loc.protocol + '//' + loc.host; // relative path support @@ -19988,9 +19680,11 @@ function url (uri, loc) { return obj; } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"debug":14,"parseuri":77}],88:[function(require,module,exports){ -(function (global){(function (){ +},{"debug":87,"parseuri":76}],87:[function(require,module,exports){ +arguments[4][24][0].apply(exports,arguments) +},{"./debug":88,"_process":77,"dup":24}],88:[function(require,module,exports){ +arguments[4][25][0].apply(exports,arguments) +},{"dup":25,"ms":74}],89:[function(require,module,exports){ /*global Blob,File*/ /** @@ -20000,8 +19694,8 @@ function url (uri, loc) { var isArray = require('isarray'); var isBuf = require('./is-buffer'); var toString = Object.prototype.toString; -var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]'; -var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]'; +var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]'); +var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]'); /** * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. @@ -20133,8 +19827,7 @@ exports.removeBlobs = function(data, callback) { } }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./is-buffer":90,"isarray":39}],89:[function(require,module,exports){ +},{"./is-buffer":91,"isarray":38}],90:[function(require,module,exports){ /** * Module dependencies. @@ -20142,7 +19835,6 @@ exports.removeBlobs = function(data, callback) { var debug = require('debug')('socket.io-parser'); var Emitter = require('component-emitter'); -var hasBin = require('has-binary2'); var binary = require('./binary'); var isArray = require('isarray'); var isBuf = require('./is-buffer'); @@ -20251,6 +19943,8 @@ exports.Decoder = Decoder; function Encoder() {} +var ERROR_PACKET = exports.ERROR + '"encode error"'; + /** * Encode a packet as a single string if non-binary, or as a * buffer sequence, depending on packet type. @@ -20262,16 +19956,11 @@ function Encoder() {} */ Encoder.prototype.encode = function(obj, callback){ - if ((obj.type === exports.EVENT || obj.type === exports.ACK) && hasBin(obj.data)) { - obj.type = obj.type === exports.EVENT ? exports.BINARY_EVENT : exports.BINARY_ACK; - } - debug('encoding packet %j', obj); if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) { encodeAsBinary(obj, callback); - } - else { + } else { var encoding = encodeAsString(obj); callback([encoding]); } @@ -20308,13 +19997,26 @@ function encodeAsString(obj) { // json data if (null != obj.data) { - str += JSON.stringify(obj.data); + var payload = tryStringify(obj.data); + if (payload !== false) { + str += payload; + } else { + return ERROR_PACKET; + } } debug('encoded %j as %s', obj, str); return str; } +function tryStringify(str) { + try { + return JSON.stringify(str); + } catch(e){ + return false; + } +} + /** * Encode packet as 'buffer sequence' by removing blobs, and * deconstructing packet into object with placeholders and @@ -20357,7 +20059,7 @@ function Decoder() { Emitter(Decoder.prototype); /** - * Decodes an ecoded packet string into packet JSON. + * Decodes an encoded packet string into packet JSON. * * @param {String} obj - encoded packet * @return {Object} packet @@ -20378,8 +20080,7 @@ Decoder.prototype.add = function(obj) { } else { // non-binary full packet this.emit('decoded', packet); } - } - else if (isBuf(obj) || obj.base64) { // raw binary data + } else if (isBuf(obj) || obj.base64) { // raw binary data if (!this.reconstructor) { throw new Error('got binary data when not reconstructing a packet'); } else { @@ -20389,8 +20090,7 @@ Decoder.prototype.add = function(obj) { this.emit('decoded', packet); } } - } - else { + } else { throw new Error('Unknown type: ' + obj); } }; @@ -20416,11 +20116,9 @@ function decodeString(str) { // look up attachments if type binary if (exports.BINARY_EVENT === p.type || exports.BINARY_ACK === p.type) { - var buf = ''; - while (str.charAt(++i) !== '-') { - buf += str.charAt(i); - if (i == str.length) break; - } + var start = i + 1; + while (str.charAt(++i) !== '-' && i != str.length) {} + var buf = str.substring(start, i); if (buf != Number(buf) || str.charAt(i) !== '-') { throw new Error('Illegal attachments'); } @@ -20429,13 +20127,13 @@ function decodeString(str) { // look up namespace (if any) if ('/' === str.charAt(i + 1)) { - p.nsp = ''; + var start = i + 1; while (++i) { var c = str.charAt(i); if (',' === c) break; - p.nsp += c; if (i === str.length) break; } + p.nsp = str.substring(start, i); } else { p.nsp = '/'; } @@ -20443,17 +20141,16 @@ function decodeString(str) { // look up id var next = str.charAt(i + 1); if ('' !== next && Number(next) == next) { - p.id = ''; + var start = i + 1; while (++i) { var c = str.charAt(i); if (null == c || Number(c) != c) { --i; break; } - p.id += str.charAt(i); if (i === str.length) break; } - p.id = Number(p.id); + p.id = Number(str.substring(start, i + 1)); } // look up json data @@ -20544,11 +20241,18 @@ function error(msg) { }; } -},{"./binary":88,"./is-buffer":90,"component-emitter":12,"debug":91,"has-binary2":35,"isarray":39}],90:[function(require,module,exports){ -(function (global){(function (){ +},{"./binary":89,"./is-buffer":91,"component-emitter":12,"debug":87,"isarray":38}],91:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = isBuf; +var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function'; +var withNativeArrayBuffer = typeof ArrayBuffer === 'function'; + +var isView = function (obj) { + return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer); +}; + /** * Returns true if obj is a buffer or an arraybuffer. * @@ -20556,16 +20260,12 @@ module.exports = isBuf; */ function isBuf(obj) { - return (global.Buffer && global.Buffer.isBuffer(obj)) || - (global.ArrayBuffer && (obj instanceof ArrayBuffer || ArrayBuffer.isView(obj))); + return (withNativeBuffer && Buffer.isBuffer(obj)) || + (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))); } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],91:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"./debug":92,"_process":78,"dup":25}],92:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"dup":26,"ms":75}],93:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":10}],92:[function(require,module,exports){ module.exports = toArray function toArray(list, index) { @@ -20580,7 +20280,7 @@ function toArray(list, index) { return array } -},{}],94:[function(require,module,exports){ +},{}],93:[function(require,module,exports){ 'use strict'; var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('') @@ -20650,13 +20350,12 @@ yeast.encode = encode; yeast.decode = decode; module.exports = yeast; -},{}],95:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', - // mediasoupAddress: 'https://video.safemobile.org/mediasoup', - mediasoupAddress: 'http://localhost:3000/mediasoup', + mediasoupAddress: 'https://video.safemobile.org', } -},{}],96:[function(require,module,exports){ +},{}],95:[function(require,module,exports){ const io = require('socket.io-client') const mediasoupClient = require('mediasoup-client') const urlParams = new URLSearchParams(location.search); @@ -20671,6 +20370,8 @@ let callId = parseInt(urlParams.get('callId')) || null; const IS_PRODUCER = urlParams.get('producer') === 'true' ? true : false console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', callId, ' | IS_PRODUCER', IS_PRODUCER) +console.log('🟩 config', config) + let socket hub = io(config.hubAddress) @@ -20794,7 +20495,7 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: false, + audio: true, video: { width: { min: 640, @@ -21009,7 +20710,6 @@ const createRecvTransport = async () => { } const resetCallSettings = () => { - socket.emit('transportclose', { callId }) localVideo.srcObject = null remoteVideo.srcObject = null consumer = null @@ -21057,12 +20757,12 @@ const connectRecvTransport = async () => { const closeCall = () => { console.log('closeCall'); - + // Emit 'notify-end' to Hub so the consumer will know to close the video const notifyEnd = { - origin_asset_id: ASSET_ID, - dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), - type: 'notify-end', + origin_asset_id: ASSET_ID, + dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), + type: 'notify-end', video_call_id: callId } console.log('notifyEnd', notifyEnd) @@ -21072,11 +20772,11 @@ const closeCall = () => { const closeCallBtn = document.getElementById('btnCloseCall') closeCallBtn.setAttribute('disabled', '') - // Reset settings and send closeTransport to video server + // Reset settings resetCallSettings() } btnLocalVideo.addEventListener('click', getLocalStream) btnRecvSendTransport.addEventListener('click', goConnect) btnCloseCall.addEventListener('click', closeCall) -},{"./config":95,"mediasoup-client":67,"socket.io-client":83}]},{},[96]); +},{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]); -- 2.37.1 From b621b76e37418307f6d69ef68daa54d084b58806 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:27:56 +0200 Subject: [PATCH 006/121] Connect to mediasoup with timeout(fix when it appears offline) --- public/index.js | 64 +++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/public/index.js b/public/index.js index 60a48e1..86e0654 100644 --- a/public/index.js +++ b/public/index.js @@ -37,39 +37,41 @@ const connectToMediasoup = () => { } if (IS_PRODUCER === true) { - hub.on('connect', async () => { - console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, + setTimeout(() => { + hub.on('connect', async () => { + console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, + }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } }) - ) - - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; - - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } }) - }) + }, 2000); hub.on('connect_error', (error) => { console.log('connect_error', error); -- 2.37.1 From c7303416742c366b060e39332999ea0239442414 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:28:50 +0200 Subject: [PATCH 007/121] Update build --- public/bundle.js | 64 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 8bae239..defe606 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20395,39 +20395,41 @@ const connectToMediasoup = () => { } if (IS_PRODUCER === true) { - hub.on('connect', async () => { - console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, + setTimeout(() => { + hub.on('connect', async () => { + console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, + }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } }) - ) - - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; - - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } }) - }) + }, 2000); hub.on('connect_error', (error) => { console.log('connect_error', error); -- 2.37.1 From cdbfc7891d4e7841006fa08f27fa724aa9ccb341 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:30:25 +0200 Subject: [PATCH 008/121] Update build --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index defe606..931e4f2 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20397,7 +20397,7 @@ const connectToMediasoup = () => { if (IS_PRODUCER === true) { setTimeout(() => { hub.on('connect', async () => { - console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) connectToMediasoup() hub.emit( diff --git a/public/index.js b/public/index.js index 86e0654..bd8aa9a 100644 --- a/public/index.js +++ b/public/index.js @@ -39,7 +39,7 @@ const connectToMediasoup = () => { if (IS_PRODUCER === true) { setTimeout(() => { hub.on('connect', async () => { - console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) connectToMediasoup() hub.emit( -- 2.37.1 From bc2bf24a65e8515bd0856dab2ae9f48dfa1a80e6 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:32:47 +0200 Subject: [PATCH 009/121] Update build --- public/index.js | 69 +++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/public/index.js b/public/index.js index bd8aa9a..f3b6bfb 100644 --- a/public/index.js +++ b/public/index.js @@ -15,7 +15,10 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) let socket -hub = io(config.hubAddress) + +setTimeout(() => { + hub = io(config.hubAddress) +}, 2000); const connectToMediasoup = () => { @@ -37,41 +40,39 @@ const connectToMediasoup = () => { } if (IS_PRODUCER === true) { - setTimeout(() => { - hub.on('connect', async () => { - console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, - }) - ) - - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; - - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } + hub.on('connect', async () => { + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } }) - }, 2000); + }) hub.on('connect_error', (error) => { console.log('connect_error', error); -- 2.37.1 From 1d7c994036ccb52afa99a0a98837a72e1dc3d6b8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:33:06 +0200 Subject: [PATCH 010/121] Update build --- public/bundle.js | 69 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 931e4f2..b1ba321 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20373,7 +20373,10 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) let socket -hub = io(config.hubAddress) + +setTimeout(() => { + hub = io(config.hubAddress) +}, 2000); const connectToMediasoup = () => { @@ -20395,41 +20398,39 @@ const connectToMediasoup = () => { } if (IS_PRODUCER === true) { - setTimeout(() => { - hub.on('connect', async () => { - console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, - }) - ) - - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; - - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } + hub.on('connect', async () => { + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } }) - }, 2000); + }) hub.on('connect_error', (error) => { console.log('connect_error', error); -- 2.37.1 From 0d24604f2a9598e10599374e89296129cf909842 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:33:46 +0200 Subject: [PATCH 011/121] Update build --- public/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.js b/public/index.js index f3b6bfb..5ad8edf 100644 --- a/public/index.js +++ b/public/index.js @@ -14,7 +14,7 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) -let socket +let socket, hub setTimeout(() => { hub = io(config.hubAddress) -- 2.37.1 From 1a1fa9450ee9e2fb6ae2f86d7cdb95993701233b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:34:12 +0200 Subject: [PATCH 012/121] Update build --- public/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/bundle.js b/public/bundle.js index b1ba321..5695b58 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20372,7 +20372,7 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) -let socket +let socket, hub setTimeout(() => { hub = io(config.hubAddress) -- 2.37.1 From d593d6dc834d36f7f576a237b5849a17c5f6938c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:35:36 +0200 Subject: [PATCH 013/121] Update build --- public/bundle.js | 138 ++++++++++++++++++++++++----------------------- public/index.js | 138 ++++++++++++++++++++++++----------------------- 2 files changed, 140 insertions(+), 136 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 5695b58..c7c493c 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20376,76 +20376,78 @@ let socket, hub setTimeout(() => { hub = io(config.hubAddress) + + const connectToMediasoup = () => { + + socket = io(config.mediasoupAddress, { + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 5000, + reconnectionAttempts: Infinity + }) + + socket.on('connection-success', ({ _socketId, existsProducer }) => { + console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) + if (!IS_PRODUCER && existsProducer && consumer === undefined) { + goConnect() + // document.getElementById('btnRecvSendTransport').click(); + } + if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } + }) + } + + if (IS_PRODUCER === true) { + hub.on('connect', async () => { + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, + }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } + }) + }) + + hub.on('connect_error', (error) => { + console.log('connect_error', error); + }); + + hub.on('connection', () => { + console.log('connection') + }) + + hub.on('disconnect', () => { + console.log('disconnect') + }) + } else { + connectToMediasoup() + } + }, 2000); -const connectToMediasoup = () => { - - socket = io(config.mediasoupAddress, { - reconnection: true, - reconnectionDelay: 1000, - reconnectionDelayMax : 5000, - reconnectionAttempts: Infinity - }) - - socket.on('connection-success', ({ _socketId, existsProducer }) => { - console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) - if (!IS_PRODUCER && existsProducer && consumer === undefined) { - goConnect() - // document.getElementById('btnRecvSendTransport').click(); - } - if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } - }) -} - -if (IS_PRODUCER === true) { - hub.on('connect', async () => { - console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, - }) - ) - - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; - - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } - }) - }) - - hub.on('connect_error', (error) => { - console.log('connect_error', error); - }); - - hub.on('connection', () => { - console.log('connection') - }) - - hub.on('disconnect', () => { - console.log('disconnect') - }) -} else { - connectToMediasoup() -} let device let rtpCapabilities diff --git a/public/index.js b/public/index.js index 5ad8edf..716fa8a 100644 --- a/public/index.js +++ b/public/index.js @@ -18,76 +18,78 @@ let socket, hub setTimeout(() => { hub = io(config.hubAddress) + + const connectToMediasoup = () => { + + socket = io(config.mediasoupAddress, { + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 5000, + reconnectionAttempts: Infinity + }) + + socket.on('connection-success', ({ _socketId, existsProducer }) => { + console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) + if (!IS_PRODUCER && existsProducer && consumer === undefined) { + goConnect() + // document.getElementById('btnRecvSendTransport').click(); + } + if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } + }) + } + + if (IS_PRODUCER === true) { + hub.on('connect', async () => { + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, + }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } + }) + }) + + hub.on('connect_error', (error) => { + console.log('connect_error', error); + }); + + hub.on('connection', () => { + console.log('connection') + }) + + hub.on('disconnect', () => { + console.log('disconnect') + }) + } else { + connectToMediasoup() + } + }, 2000); -const connectToMediasoup = () => { - - socket = io(config.mediasoupAddress, { - reconnection: true, - reconnectionDelay: 1000, - reconnectionDelayMax : 5000, - reconnectionAttempts: Infinity - }) - - socket.on('connection-success', ({ _socketId, existsProducer }) => { - console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) - if (!IS_PRODUCER && existsProducer && consumer === undefined) { - goConnect() - // document.getElementById('btnRecvSendTransport').click(); - } - if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } - }) -} - -if (IS_PRODUCER === true) { - hub.on('connect', async () => { - console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, - }) - ) - - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; - - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } - }) - }) - - hub.on('connect_error', (error) => { - console.log('connect_error', error); - }); - - hub.on('connection', () => { - console.log('connection') - }) - - hub.on('disconnect', () => { - console.log('disconnect') - }) -} else { - connectToMediasoup() -} let device let rtpCapabilities -- 2.37.1 From 4ae02f70d6856c3c1c856fe0d5044494d2ab4513 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:54:22 +0200 Subject: [PATCH 014/121] Update build --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index c7c493c..08568de 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20609,7 +20609,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log(parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer diff --git a/public/index.js b/public/index.js index 716fa8a..cf61f7b 100644 --- a/public/index.js +++ b/public/index.js @@ -251,7 +251,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log(parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer -- 2.37.1 From d6bc4e51e5b198ad0196839d9903ebc426a6e809 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:11:00 +0200 Subject: [PATCH 015/121] Update build --- public/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.js b/public/index.js index cf61f7b..f498868 100644 --- a/public/index.js +++ b/public/index.js @@ -251,7 +251,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log('[produce] parameters', parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer -- 2.37.1 From c5c8bc5bb3819d40c13712da7495bfd9857404d3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:14:50 +0200 Subject: [PATCH 016/121] Update build --- public/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/index.js b/public/index.js index f498868..62c9b26 100644 --- a/public/index.js +++ b/public/index.js @@ -277,6 +277,9 @@ const createSendTransport = () => { } const connectSendTransport = async () => { + + console.log('[connectSendTransport] producerTransport', params); + // we now call produce() to instruct the producer transport // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -- 2.37.1 From a05f7cc987f995f2c5f8bf624bcdb85f5ebaccd3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:15:34 +0200 Subject: [PATCH 017/121] Update build --- public/bundle.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/bundle.js b/public/bundle.js index 08568de..5b65980 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20609,7 +20609,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log('[produce] parameters', parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer @@ -20635,6 +20635,9 @@ const createSendTransport = () => { } const connectSendTransport = async () => { + + console.log('[connectSendTransport] producerTransport', params); + // we now call produce() to instruct the producer transport // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -- 2.37.1 From 06bb275f0dbfc8e492bc62684eaf3f7936c783ca Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:18:48 +0200 Subject: [PATCH 018/121] Update build --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 5b65980..48994df 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20487,13 +20487,13 @@ let params = { } const streamSuccess = (stream) => { - console.log('[streamSuccess]'); localVideo.srcObject = stream const track = stream.getVideoTracks()[0] params = { track, ...params } + console.log('[streamSuccess] track', params); goConnect() } diff --git a/public/index.js b/public/index.js index 62c9b26..b621043 100644 --- a/public/index.js +++ b/public/index.js @@ -129,13 +129,13 @@ let params = { } const streamSuccess = (stream) => { - console.log('[streamSuccess]'); localVideo.srcObject = stream const track = stream.getVideoTracks()[0] params = { track, ...params } + console.log('[streamSuccess] track', params); goConnect() } -- 2.37.1 From 3838f774bf0a7828694692611ecb004732f6b221 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:33:38 +0200 Subject: [PATCH 019/121] Update build --- public/bundle.js | 12 ++++++------ public/index.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 48994df..08e7d51 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20488,12 +20488,12 @@ let params = { const streamSuccess = (stream) => { localVideo.srcObject = stream - const track = stream.getVideoTracks()[0] - params = { - track, - ...params - } - console.log('[streamSuccess] track', params); + // const track = stream.getVideoTracks()[0] + // params = { + // track, + // ...params + // } + // console.log('[streamSuccess] track', params); goConnect() } diff --git a/public/index.js b/public/index.js index b621043..d932558 100644 --- a/public/index.js +++ b/public/index.js @@ -130,12 +130,12 @@ let params = { const streamSuccess = (stream) => { localVideo.srcObject = stream - const track = stream.getVideoTracks()[0] - params = { - track, - ...params - } - console.log('[streamSuccess] track', params); + // const track = stream.getVideoTracks()[0] + // params = { + // track, + // ...params + // } + // console.log('[streamSuccess] track', params); goConnect() } -- 2.37.1 From 1084a808c7951eabcca0aa765c75988825d48e8d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:40:02 +0200 Subject: [PATCH 020/121] Update build --- public/bundle.js | 13 +++++++------ public/index.js | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 08e7d51..b936ede 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20488,12 +20488,13 @@ let params = { const streamSuccess = (stream) => { localVideo.srcObject = stream - // const track = stream.getVideoTracks()[0] - // params = { - // track, - // ...params - // } - // console.log('[streamSuccess] track', params); + console.log('stream', stream); + const track = stream.getVideoTracks()[0] + params = { + track, + ...params + } + console.log('[streamSuccess] track', params); goConnect() } diff --git a/public/index.js b/public/index.js index d932558..09242d4 100644 --- a/public/index.js +++ b/public/index.js @@ -130,12 +130,13 @@ let params = { const streamSuccess = (stream) => { localVideo.srcObject = stream - // const track = stream.getVideoTracks()[0] - // params = { - // track, - // ...params - // } - // console.log('[streamSuccess] track', params); + console.log('stream', stream); + const track = stream.getVideoTracks()[0] + params = { + track, + ...params + } + console.log('[streamSuccess] track', params); goConnect() } -- 2.37.1 From 8f96b8c98bac03b1dc519a1b98710280fca5e9f7 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:51:09 +0200 Subject: [PATCH 021/121] Update build --- public/bundle.js | 55 ++++++++++++++++++++++++++++++++++++------------ public/index.js | 55 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 82 insertions(+), 28 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index b936ede..cf9d44e 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20453,7 +20453,8 @@ let device let rtpCapabilities let producerTransport let consumerTransport -let producer +let producerVideo +let producerAudio let consumer let originAssetId // let originAssetName = 'Adi' @@ -20461,21 +20462,18 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -let params = { +let videoParams = { // mediasoup params encodings: [ { - rid: 'r0', maxBitrate: 100000, scalabilityMode: 'S1T3', }, { - rid: 'r1', maxBitrate: 300000, scalabilityMode: 'S1T3', }, { - rid: 'r2', maxBitrate: 900000, scalabilityMode: 'S1T3', }, @@ -20486,15 +20484,44 @@ let params = { } } +let audioParams = { + // mediasoup params + encodings: [ + { + maxBitrate: 100000, + scalabilityMode: 'S1T3', + }, + { + maxBitrate: 300000, + scalabilityMode: 'S1T3', + }, + { + maxBitrate: 900000, + scalabilityMode: 'S1T3', + }, + ], + codecOptions: { + opusStereo: true + } +} + const streamSuccess = (stream) => { localVideo.srcObject = stream console.log('stream', stream); - const track = stream.getVideoTracks()[0] - params = { - track, - ...params + const videoTrack = stream.getVideoTracks()[0] + const audioTrack = stream.getAudioTrack()[0] + + videoParams = { + track: videoTrack, + ...videoParams } - console.log('[streamSuccess] track', params); + + audioParams = { + track: audioTrack, + ...audioParams + } + + console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() } @@ -20643,14 +20670,14 @@ const connectSendTransport = async () => { // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - producer = await producerTransport.produce(params) + producerVideo = await producerTransport.produce(videoParams) - producer.on('trackended', () => { + producerVideo.on('trackended', () => { console.log('track ended') // close video track }) - producer.on('transportclose', () => { + producerVideo.on('transportclose', () => { console.log('transport ended') // close video track }) @@ -20722,7 +20749,7 @@ const resetCallSettings = () => { localVideo.srcObject = null remoteVideo.srcObject = null consumer = null - producer = null + producerVideo = null producerTransport = null consumerTransport = null device = undefined diff --git a/public/index.js b/public/index.js index 09242d4..ed494f6 100644 --- a/public/index.js +++ b/public/index.js @@ -95,7 +95,8 @@ let device let rtpCapabilities let producerTransport let consumerTransport -let producer +let producerVideo +let producerAudio let consumer let originAssetId // let originAssetName = 'Adi' @@ -103,21 +104,18 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -let params = { +let videoParams = { // mediasoup params encodings: [ { - rid: 'r0', maxBitrate: 100000, scalabilityMode: 'S1T3', }, { - rid: 'r1', maxBitrate: 300000, scalabilityMode: 'S1T3', }, { - rid: 'r2', maxBitrate: 900000, scalabilityMode: 'S1T3', }, @@ -128,15 +126,44 @@ let params = { } } +let audioParams = { + // mediasoup params + encodings: [ + { + maxBitrate: 100000, + scalabilityMode: 'S1T3', + }, + { + maxBitrate: 300000, + scalabilityMode: 'S1T3', + }, + { + maxBitrate: 900000, + scalabilityMode: 'S1T3', + }, + ], + codecOptions: { + opusStereo: true + } +} + const streamSuccess = (stream) => { localVideo.srcObject = stream console.log('stream', stream); - const track = stream.getVideoTracks()[0] - params = { - track, - ...params + const videoTrack = stream.getVideoTracks()[0] + const audioTrack = stream.getAudioTrack()[0] + + videoParams = { + track: videoTrack, + ...videoParams } - console.log('[streamSuccess] track', params); + + audioParams = { + track: audioTrack, + ...audioParams + } + + console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() } @@ -285,14 +312,14 @@ const connectSendTransport = async () => { // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - producer = await producerTransport.produce(params) + producerVideo = await producerTransport.produce(videoParams) - producer.on('trackended', () => { + producerVideo.on('trackended', () => { console.log('track ended') // close video track }) - producer.on('transportclose', () => { + producerVideo.on('transportclose', () => { console.log('transport ended') // close video track }) @@ -364,7 +391,7 @@ const resetCallSettings = () => { localVideo.srcObject = null remoteVideo.srcObject = null consumer = null - producer = null + producerVideo = null producerTransport = null consumerTransport = null device = undefined -- 2.37.1 From 7d677f4a34360da368c3f5acf95c2f014c32afd8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:52:11 +0200 Subject: [PATCH 022/121] Update build --- public/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.js b/public/index.js index ed494f6..eb0af83 100644 --- a/public/index.js +++ b/public/index.js @@ -151,7 +151,7 @@ const streamSuccess = (stream) => { localVideo.srcObject = stream console.log('stream', stream); const videoTrack = stream.getVideoTracks()[0] - const audioTrack = stream.getAudioTrack()[0] + const audioTrack = stream.getAudioTracks()[0] videoParams = { track: videoTrack, -- 2.37.1 From e9ff06054469b513825d504045b8039c4a2bc79c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:52:25 +0200 Subject: [PATCH 023/121] Update build --- public/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/bundle.js b/public/bundle.js index cf9d44e..8dee509 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20509,7 +20509,7 @@ const streamSuccess = (stream) => { localVideo.srcObject = stream console.log('stream', stream); const videoTrack = stream.getVideoTracks()[0] - const audioTrack = stream.getAudioTrack()[0] + const audioTrack = stream.getAudioTracks()[0] videoParams = { track: videoTrack, -- 2.37.1 From 4e4cd6f893732bcbe6315f2bd5294f2477982bbd Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:55:55 +0200 Subject: [PATCH 024/121] Update build --- public/bundle.js | 7 ++++--- public/index.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 8dee509..6e89fa9 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20600,6 +20600,7 @@ const getRtpCapabilities = () => { } const createSendTransport = () => { + console.log('[createSendTransport'); // see server's socket.on('createWebRtcTransport', sender?, ...) // this is a call from Producer, so sender = true socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => { @@ -20610,7 +20611,7 @@ const createSendTransport = () => { return } - console.log(params) + console.log('[createWebRtcTransport] params', params) // creates a new WebRTC Transport to send media // based on the server's producer transport params @@ -20664,7 +20665,7 @@ const createSendTransport = () => { const connectSendTransport = async () => { - console.log('[connectSendTransport] producerTransport', params); + console.log('[connectSendTransport] producerTransport'); // we now call produce() to instruct the producer transport // to send media to the Router @@ -20716,7 +20717,7 @@ const createRecvTransport = async () => { return } - console.log(params) + console.log('[createRecvTransport] params', params) // creates a new WebRTC Transport to receive media // based on server's consumer transport params diff --git a/public/index.js b/public/index.js index eb0af83..2703c87 100644 --- a/public/index.js +++ b/public/index.js @@ -242,6 +242,7 @@ const getRtpCapabilities = () => { } const createSendTransport = () => { + console.log('[createSendTransport'); // see server's socket.on('createWebRtcTransport', sender?, ...) // this is a call from Producer, so sender = true socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => { @@ -252,7 +253,7 @@ const createSendTransport = () => { return } - console.log(params) + console.log('[createWebRtcTransport] params', params) // creates a new WebRTC Transport to send media // based on the server's producer transport params @@ -306,7 +307,7 @@ const createSendTransport = () => { const connectSendTransport = async () => { - console.log('[connectSendTransport] producerTransport', params); + console.log('[connectSendTransport] producerTransport'); // we now call produce() to instruct the producer transport // to send media to the Router @@ -358,7 +359,7 @@ const createRecvTransport = async () => { return } - console.log(params) + console.log('[createRecvTransport] params', params) // creates a new WebRTC Transport to receive media // based on server's consumer transport params -- 2.37.1 From 544e9e59ab9ba5f6ceaa592963989fed6425b3dd Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:00:44 +0200 Subject: [PATCH 025/121] Update build --- public/bundle.js | 15 ++++++++++++++- public/index.js | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 6e89fa9..85296b2 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20638,7 +20638,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log('[produce] parameters', parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer @@ -20683,6 +20683,18 @@ const connectSendTransport = async () => { // close video track }) + producerAudio = await producerTransport.produce(audioParams) + + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + const answer = { origin_asset_id: ASSET_ID, dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), @@ -20751,6 +20763,7 @@ const resetCallSettings = () => { remoteVideo.srcObject = null consumer = null producerVideo = null + producerAudio = null producerTransport = null consumerTransport = null device = undefined diff --git a/public/index.js b/public/index.js index 2703c87..63074c6 100644 --- a/public/index.js +++ b/public/index.js @@ -280,7 +280,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log('[produce] parameters', parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer @@ -325,6 +325,18 @@ const connectSendTransport = async () => { // close video track }) + producerAudio = await producerTransport.produce(audioParams) + + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + const answer = { origin_asset_id: ASSET_ID, dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), @@ -393,6 +405,7 @@ const resetCallSettings = () => { remoteVideo.srcObject = null consumer = null producerVideo = null + producerAudio = null producerTransport = null consumerTransport = null device = undefined -- 2.37.1 From 27151a26d1b4d0a0c001ba96851b0560a7093c66 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:03:36 +0200 Subject: [PATCH 026/121] Update build --- public/bundle.js | 18 +++++++++--------- public/index.js | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 85296b2..63cda5a 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20683,17 +20683,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) + // producerAudio = await producerTransport.produce(audioParams) - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) const answer = { origin_asset_id: ASSET_ID, diff --git a/public/index.js b/public/index.js index 63074c6..3595a2b 100644 --- a/public/index.js +++ b/public/index.js @@ -325,17 +325,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) + // producerAudio = await producerTransport.produce(audioParams) - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From f20e1ad260516391d32c006803259a22f00e6842 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:04:43 +0200 Subject: [PATCH 027/121] Update build --- public/bundle.js | 6 ++++-- public/index.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 63cda5a..0cb30b6 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20672,7 +20672,8 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above producerVideo = await producerTransport.produce(videoParams) - + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { console.log('track ended') // close video track @@ -20683,7 +20684,8 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); // producerAudio.on('trackended', () => { // console.log('track ended') diff --git a/public/index.js b/public/index.js index 3595a2b..3f2dc63 100644 --- a/public/index.js +++ b/public/index.js @@ -314,7 +314,8 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above producerVideo = await producerTransport.produce(videoParams) - + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { console.log('track ended') // close video track @@ -325,7 +326,8 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); // producerAudio.on('trackended', () => { // console.log('track ended') -- 2.37.1 From d1ad8b4d3a082b905780b6c02d42823f8113b669 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:38:16 +0200 Subject: [PATCH 028/121] Update server --- app.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 702eb14..5707a3f 100644 --- a/app.js +++ b/app.js @@ -92,10 +92,21 @@ worker = createWorker(); // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts const mediaCodecs = [ { - kind: 'audio', - mimeType: 'audio/opus', + // kind: 'audio', + // mimeType: 'audio/opus', + // clockRate: 48000, + // channels: 2, clockRate: 48000, - channels: 2, + mimeType: "audio/opus", + parameters: { + minptime: 10, + useinbandfec: 1 + }, + payloadType: 111, + rtcpFeedback: [{ + parameter: "", + type: "transport-cc" + }] }, { kind: 'video', -- 2.37.1 From 127f17cd97696aa254ee2a6d878f4ca09300bfbd Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:42:55 +0200 Subject: [PATCH 029/121] Update server --- public/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/index.js b/public/index.js index 3f2dc63..9918b0c 100644 --- a/public/index.js +++ b/public/index.js @@ -315,7 +315,6 @@ const connectSendTransport = async () => { // this action will trigger the 'connect' and 'produce' events above producerVideo = await producerTransport.produce(videoParams) console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { console.log('track ended') // close video track @@ -326,9 +325,8 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); // producerAudio.on('trackended', () => { // console.log('track ended') // // close video track -- 2.37.1 From 233f49a99894cc4be78cf9dbaa06b8f0789c2d2f Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:43:30 +0200 Subject: [PATCH 030/121] Update server --- public/bundle.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 0cb30b6..50b402e 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20673,7 +20673,6 @@ const connectSendTransport = async () => { // this action will trigger the 'connect' and 'produce' events above producerVideo = await producerTransport.produce(videoParams) console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { console.log('track ended') // close video track @@ -20684,9 +20683,8 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); // producerAudio.on('trackended', () => { // console.log('track ended') // // close video track -- 2.37.1 From 0dfbd296a74db7b4e7eb8687d8a3be86f6f07737 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:44:22 +0200 Subject: [PATCH 031/121] Update server --- app.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index 5707a3f..8a72663 100644 --- a/app.js +++ b/app.js @@ -92,21 +92,21 @@ worker = createWorker(); // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts const mediaCodecs = [ { - // kind: 'audio', - // mimeType: 'audio/opus', - // clockRate: 48000, - // channels: 2, + kind: 'audio', + mimeType: 'audio/opus', clockRate: 48000, - mimeType: "audio/opus", - parameters: { - minptime: 10, - useinbandfec: 1 - }, - payloadType: 111, - rtcpFeedback: [{ - parameter: "", - type: "transport-cc" - }] + channels: 2, + // clockRate: 48000, + // mimeType: "audio/opus", + // parameters: { + // minptime: 10, + // useinbandfec: 1 + // }, + // payloadType: 111, + // rtcpFeedback: [{ + // parameter: "", + // type: "transport-cc" + // }] }, { kind: 'video', -- 2.37.1 From b63fb39fd4445026cf9a6b9cc64347f7a745bfc9 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:09:33 +0200 Subject: [PATCH 032/121] Update server --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 8a72663..ad2c555 100644 --- a/app.js +++ b/app.js @@ -94,9 +94,9 @@ const mediaCodecs = [ { kind: 'audio', mimeType: 'audio/opus', - clockRate: 48000, - channels: 2, // clockRate: 48000, + channels: 2, + clockRate: 48000, // mimeType: "audio/opus", // parameters: { // minptime: 10, -- 2.37.1 From a39e0eaa17386be5cbe3c81c8f2240222e316424 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:11:14 +0200 Subject: [PATCH 033/121] Update server --- app.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index ad2c555..88563c9 100644 --- a/app.js +++ b/app.js @@ -93,15 +93,15 @@ worker = createWorker(); const mediaCodecs = [ { kind: 'audio', - mimeType: 'audio/opus', + // mimeType: 'audio/opus', // clockRate: 48000, channels: 2, clockRate: 48000, - // mimeType: "audio/opus", - // parameters: { - // minptime: 10, - // useinbandfec: 1 - // }, + mimeType: "audio/opus", + parameters: { + minptime: 10, + useinbandfec: 1 + }, // payloadType: 111, // rtcpFeedback: [{ // parameter: "", -- 2.37.1 From 3cbd31b49c261bd66e4647c8661753c9011100ef Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:11:45 +0200 Subject: [PATCH 034/121] Update server --- public/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/index.js b/public/index.js index 9918b0c..d39db89 100644 --- a/public/index.js +++ b/public/index.js @@ -325,17 +325,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From d1063803b9ab41c30e1743716a4a5c65d7961b57 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:12:21 +0200 Subject: [PATCH 035/121] Update server --- public/bundle.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 50b402e..89e1668 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20683,17 +20683,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From 4dbb7ad5541c18bcd84162543c81f2a7d575a9a1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:12:55 +0200 Subject: [PATCH 036/121] Update server --- public/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/index.js b/public/index.js index d39db89..9918b0c 100644 --- a/public/index.js +++ b/public/index.js @@ -325,17 +325,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From fa42caeeb2ca9da1107c0b243df90059c68a2ca3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:14:01 +0200 Subject: [PATCH 037/121] Update server --- public/bundle.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 89e1668..50b402e 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20683,17 +20683,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From d18041caddbc4eb333e5e0a9c9dae29eb9fef2e1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:11:16 +0200 Subject: [PATCH 038/121] Update server --- public/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/index.js b/public/index.js index 9918b0c..d39db89 100644 --- a/public/index.js +++ b/public/index.js @@ -325,17 +325,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From dfe4630839327bcc1b31277dcfd9dd441f85e0c5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:11:26 +0200 Subject: [PATCH 039/121] Update server --- public/bundle.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 50b402e..89e1668 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20683,17 +20683,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From 0b3a45ae458e589d100de1de6ca14497f832e4d3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:13:56 +0200 Subject: [PATCH 040/121] Update server --- app.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 88563c9..e39c1dc 100644 --- a/app.js +++ b/app.js @@ -95,18 +95,17 @@ const mediaCodecs = [ kind: 'audio', // mimeType: 'audio/opus', // clockRate: 48000, - channels: 2, + // channels: 2, clockRate: 48000, mimeType: "audio/opus", parameters: { minptime: 10, useinbandfec: 1 }, - // payloadType: 111, - // rtcpFeedback: [{ - // parameter: "", - // type: "transport-cc" - // }] + rtcpFeedback: [{ + parameter: "", + type: "transport-cc" + }] }, { kind: 'video', -- 2.37.1 From f5b9067b7e1070d3271d9d784e17ba60b1f79063 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:21:26 +0200 Subject: [PATCH 041/121] Update server --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index e39c1dc..9e5f3f9 100644 --- a/app.js +++ b/app.js @@ -97,7 +97,7 @@ const mediaCodecs = [ // clockRate: 48000, // channels: 2, clockRate: 48000, - mimeType: "audio/opus", + mimeType: "audio/webm;codecs=opus", // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#supported_audio_codecs parameters: { minptime: 10, useinbandfec: 1 @@ -109,7 +109,7 @@ const mediaCodecs = [ }, { kind: 'video', - mimeType: 'video/VP8', + mimeType: 'video/VP8', // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#supported_video_codecs clockRate: 90000, parameters: { 'x-google-start-bitrate': 1000, -- 2.37.1 From 22656722e866477f5a8c1f892b9a6c0f5f82a312 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:22:00 +0200 Subject: [PATCH 042/121] Update server --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 9e5f3f9..3edb742 100644 --- a/app.js +++ b/app.js @@ -97,7 +97,7 @@ const mediaCodecs = [ // clockRate: 48000, // channels: 2, clockRate: 48000, - mimeType: "audio/webm;codecs=opus", // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#supported_audio_codecs + mimeType: "audio/opus", // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#supported_audio_codecs parameters: { minptime: 10, useinbandfec: 1 -- 2.37.1 From daa2c556e40ac5cc91f5ec6b9ce1078caea4e13e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:25:16 +0200 Subject: [PATCH 043/121] Update server --- app.js | 67 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/app.js b/app.js index 3edb742..2a92d39 100644 --- a/app.js +++ b/app.js @@ -90,31 +90,56 @@ worker = createWorker(); // https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#RtpCodecCapability // list of media codecs supported by mediasoup ... // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts -const mediaCodecs = [ +const mediaCodecs = [ { - kind: 'audio', - // mimeType: 'audio/opus', - // clockRate: 48000, - // channels: 2, - clockRate: 48000, - mimeType: "audio/opus", // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#supported_audio_codecs - parameters: { - minptime: 10, - useinbandfec: 1 - }, - rtcpFeedback: [{ - parameter: "", - type: "transport-cc" - }] + kind : 'audio', + mimeType : 'audio/opus', + clockRate : 48000, + channels : 2 }, { - kind: 'video', - mimeType: 'video/VP8', // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#supported_video_codecs - clockRate: 90000, - parameters: { - 'x-google-start-bitrate': 1000, - }, + kind : 'video', + mimeType : 'video/VP8', + clockRate : 90000, + parameters : + { + 'x-google-start-bitrate' : 1000 + } }, + { + kind : 'video', + mimeType : 'video/VP9', + clockRate : 90000, + parameters : + { + 'profile-id' : 2, + 'x-google-start-bitrate' : 1000 + } + }, + { + kind : 'video', + mimeType : 'video/h264', + clockRate : 90000, + parameters : + { + 'packetization-mode' : 1, + 'profile-level-id' : '4d0032', + 'level-asymmetry-allowed' : 1, + 'x-google-start-bitrate' : 1000 + } + }, + { + kind : 'video', + mimeType : 'video/h264', + clockRate : 90000, + parameters : + { + 'packetization-mode' : 1, + 'profile-level-id' : '42e01f', + 'level-asymmetry-allowed' : 1, + 'x-google-start-bitrate' : 1000 + } + } ]; const closeCall = (callId) => { -- 2.37.1 From 1a7b44807d44dfe4d5b91e4ba35acb71323c2814 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:32:24 +0200 Subject: [PATCH 044/121] Update server --- public/bundle.js | 21 ++++----------------- public/index.js | 21 ++++----------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 89e1668..f08cdfd 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20485,23 +20485,10 @@ let videoParams = { } let audioParams = { - // mediasoup params - encodings: [ - { - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, - ], - codecOptions: { - opusStereo: true + codecOptions : + { + opusStereo : true, + opusDtx : true } } diff --git a/public/index.js b/public/index.js index d39db89..2b40b61 100644 --- a/public/index.js +++ b/public/index.js @@ -127,23 +127,10 @@ let videoParams = { } let audioParams = { - // mediasoup params - encodings: [ - { - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, - ], - codecOptions: { - opusStereo: true + codecOptions : + { + opusStereo : true, + opusDtx : true } } -- 2.37.1 From 3c23c6791d440ad3a595e8215b112f2668d1a908 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:34:12 +0200 Subject: [PATCH 045/121] Update server --- public/bundle.js | 20 ++++++++++---------- public/index.js | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index f08cdfd..d70d17d 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20670,17 +20670,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) const answer = { origin_asset_id: ASSET_ID, diff --git a/public/index.js b/public/index.js index 2b40b61..0628d21 100644 --- a/public/index.js +++ b/public/index.js @@ -312,17 +312,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From a97ec241482cf2413118cb1c765e5e9f5565e4a8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:54:03 +0200 Subject: [PATCH 046/121] Update server --- public/bundle.js | 35 ++++++++++------------------------- public/index.js | 35 ++++++++++------------------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index d70d17d..0ed41ae 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20446,7 +20446,7 @@ setTimeout(() => { connectToMediasoup() } -}, 2000); +}, 1600); let device @@ -20457,28 +20457,18 @@ let producerVideo let producerAudio let consumer let originAssetId -// let originAssetName = 'Adi' -// let originAssetTypeName = 'linx' // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce let videoParams = { - // mediasoup params + codec : device.rtpCapabilities.codecs + .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), encodings: [ - { - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } ], - // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } @@ -20517,14 +20507,9 @@ const getLocalStream = () => { navigator.mediaDevices.getUserMedia({ audio: true, video: { - width: { - min: 640, - max: 1920, - }, - height: { - min: 400, - max: 1080, - } + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) .then(streamSuccess) diff --git a/public/index.js b/public/index.js index 0628d21..42e50e9 100644 --- a/public/index.js +++ b/public/index.js @@ -88,7 +88,7 @@ setTimeout(() => { connectToMediasoup() } -}, 2000); +}, 1600); let device @@ -99,28 +99,18 @@ let producerVideo let producerAudio let consumer let originAssetId -// let originAssetName = 'Adi' -// let originAssetTypeName = 'linx' // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce let videoParams = { - // mediasoup params + codec : device.rtpCapabilities.codecs + .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), encodings: [ - { - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } ], - // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } @@ -159,14 +149,9 @@ const getLocalStream = () => { navigator.mediaDevices.getUserMedia({ audio: true, video: { - width: { - min: 640, - max: 1920, - }, - height: { - min: 400, - max: 1080, - } + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) .then(streamSuccess) -- 2.37.1 From c63aee83a1e006ad27eeeeb875a15e12ba3bfa35 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 13:19:56 +0200 Subject: [PATCH 047/121] Update server --- public/bundle.js | 1 + public/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/public/bundle.js b/public/bundle.js index 0ed41ae..3534637 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20460,6 +20460,7 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce +console.log('device.rtpCapabilities.codecs', device.rtpCapabilities.codecs); let videoParams = { codec : device.rtpCapabilities.codecs .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), diff --git a/public/index.js b/public/index.js index 42e50e9..3da1002 100644 --- a/public/index.js +++ b/public/index.js @@ -102,6 +102,7 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce +console.log('device.rtpCapabilities.codecs', device.rtpCapabilities.codecs); let videoParams = { codec : device.rtpCapabilities.codecs .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), -- 2.37.1 From c089e91fbaedaf0db5b9fe79d5c90404ddd15bef Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 13:20:49 +0200 Subject: [PATCH 048/121] Update server --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 3534637..fce5079 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20460,7 +20460,7 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -console.log('device.rtpCapabilities.codecs', device.rtpCapabilities.codecs); +console.log('🟥 device', device); let videoParams = { codec : device.rtpCapabilities.codecs .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), diff --git a/public/index.js b/public/index.js index 3da1002..f4e8780 100644 --- a/public/index.js +++ b/public/index.js @@ -102,7 +102,7 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -console.log('device.rtpCapabilities.codecs', device.rtpCapabilities.codecs); +console.log('🟥 device', device); let videoParams = { codec : device.rtpCapabilities.codecs .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), -- 2.37.1 From b41b8f2d647a02a1ccc3bb2a56cfa532ab9b4d3e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 15:57:27 +0200 Subject: [PATCH 049/121] Update server --- public/bundle.js | 3 +-- public/index.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index fce5079..231b0cb 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20462,8 +20462,6 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce console.log('🟥 device', device); let videoParams = { - codec : device.rtpCapabilities.codecs - .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), encodings: [ { scaleResolutionDownBy: 4, maxBitrate: 500000 }, { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, @@ -20491,6 +20489,7 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, + codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), ...videoParams } diff --git a/public/index.js b/public/index.js index f4e8780..8093fc0 100644 --- a/public/index.js +++ b/public/index.js @@ -104,8 +104,6 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce console.log('🟥 device', device); let videoParams = { - codec : device.rtpCapabilities.codecs - .find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), encodings: [ { scaleResolutionDownBy: 4, maxBitrate: 500000 }, { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, @@ -133,6 +131,7 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, + codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), ...videoParams } -- 2.37.1 From c2dbef191893b3e70cb691763da3c7af35cf8cd6 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:00:54 +0200 Subject: [PATCH 050/121] Update server --- public/bundle.js | 3 +-- public/index.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 231b0cb..466e665 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20460,7 +20460,6 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -console.log('🟥 device', device); let videoParams = { encodings: [ { scaleResolutionDownBy: 4, maxBitrate: 500000 }, @@ -20505,7 +20504,7 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: true, + audio: false, video: { qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, vga : { width: { ideal: 640 }, height: { ideal: 480 } }, diff --git a/public/index.js b/public/index.js index 8093fc0..284dc30 100644 --- a/public/index.js +++ b/public/index.js @@ -102,7 +102,6 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -console.log('🟥 device', device); let videoParams = { encodings: [ { scaleResolutionDownBy: 4, maxBitrate: 500000 }, @@ -147,7 +146,7 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: true, + audio: false, video: { qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, vga : { width: { ideal: 640 }, height: { ideal: 480 } }, -- 2.37.1 From a3ae874f8e532e06fa8219da2ce97c755a68bb6f Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:01:51 +0200 Subject: [PATCH 051/121] Update server --- public/bundle.js | 19 ++++++++++++++++--- public/index.js | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 466e665..378405a 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20503,12 +20503,25 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); + // navigator.mediaDevices.getUserMedia({ + // audio: false, + // video: { + // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + // } + // }) navigator.mediaDevices.getUserMedia({ audio: false, video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + width: { + min: 640, + max: 1920, + }, + height: { + min: 400, + max: 1080, + } } }) .then(streamSuccess) diff --git a/public/index.js b/public/index.js index 284dc30..59fff99 100644 --- a/public/index.js +++ b/public/index.js @@ -145,12 +145,25 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); + // navigator.mediaDevices.getUserMedia({ + // audio: false, + // video: { + // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + // } + // }) navigator.mediaDevices.getUserMedia({ audio: false, video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + width: { + min: 640, + max: 1920, + }, + height: { + min: 400, + max: 1080, + } } }) .then(streamSuccess) -- 2.37.1 From d49b8e42ff9dc9c50055c3b608e97a99ec1df8b5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:03:13 +0200 Subject: [PATCH 052/121] Update server --- public/bundle.js | 29 +++++++++++++++++++++++++---- public/index.js | 29 +++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 378405a..2af8860 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20461,12 +20461,33 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce let videoParams = { + // encodings: [ + // { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + // { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + // { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + // { scalabilityMode: 'S3T3_KEY' } + // ], + // codecOptions: { + // videoGoogleStartBitrate: 1000 + // } encodings: [ - { scaleResolutionDownBy: 4, maxBitrate: 500000 }, - { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, - { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, - { scalabilityMode: 'S3T3_KEY' } + { + rid: 'r0', + maxBitrate: 100000, + scalabilityMode: 'S1T3', + }, + { + rid: 'r1', + maxBitrate: 300000, + scalabilityMode: 'S1T3', + }, + { + rid: 'r2', + maxBitrate: 900000, + scalabilityMode: 'S1T3', + }, ], + // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } diff --git a/public/index.js b/public/index.js index 59fff99..e9d712a 100644 --- a/public/index.js +++ b/public/index.js @@ -103,12 +103,33 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce let videoParams = { + // encodings: [ + // { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + // { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + // { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + // { scalabilityMode: 'S3T3_KEY' } + // ], + // codecOptions: { + // videoGoogleStartBitrate: 1000 + // } encodings: [ - { scaleResolutionDownBy: 4, maxBitrate: 500000 }, - { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, - { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, - { scalabilityMode: 'S3T3_KEY' } + { + rid: 'r0', + maxBitrate: 100000, + scalabilityMode: 'S1T3', + }, + { + rid: 'r1', + maxBitrate: 300000, + scalabilityMode: 'S1T3', + }, + { + rid: 'r2', + maxBitrate: 900000, + scalabilityMode: 'S1T3', + }, ], + // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } -- 2.37.1 From 2479f58e217cb9fb97fc0bd775fc7659b81e0a4a Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:09:26 +0200 Subject: [PATCH 053/121] Update server --- public/bundle.js | 6 ++++-- public/index.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 2af8860..5c9258a 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20502,6 +20502,7 @@ let audioParams = { } const streamSuccess = (stream) => { + console.log('[streamSuccess] device', device); localVideo.srcObject = stream console.log('stream', stream); const videoTrack = stream.getVideoTracks()[0] @@ -20565,7 +20566,7 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { - console.log('[createDevice]'); + console.log('[createDevice] 1 device', device); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -20576,7 +20577,8 @@ const createDevice = async () => { }) console.log('Device RTP Capabilities', device.rtpCapabilities) - + console.log('[createDevice] 2 device', device); + // once the device loads, create transport goCreateTransport() diff --git a/public/index.js b/public/index.js index e9d712a..1858d38 100644 --- a/public/index.js +++ b/public/index.js @@ -144,6 +144,7 @@ let audioParams = { } const streamSuccess = (stream) => { + console.log('[streamSuccess] device', device); localVideo.srcObject = stream console.log('stream', stream); const videoTrack = stream.getVideoTracks()[0] @@ -207,7 +208,7 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { - console.log('[createDevice]'); + console.log('[createDevice] 1 device', device); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -218,7 +219,8 @@ const createDevice = async () => { }) console.log('Device RTP Capabilities', device.rtpCapabilities) - + console.log('[createDevice] 2 device', device); + // once the device loads, create transport goCreateTransport() -- 2.37.1 From d386915ff2bc63242705a5acb9d10d27b543d8de Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:16:17 +0200 Subject: [PATCH 054/121] Update server --- app.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index 2a92d39..27e486d 100644 --- a/app.js +++ b/app.js @@ -91,21 +91,21 @@ worker = createWorker(); // list of media codecs supported by mediasoup ... // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts const mediaCodecs = [ - { - kind : 'audio', - mimeType : 'audio/opus', - clockRate : 48000, - channels : 2 - }, - { - kind : 'video', - mimeType : 'video/VP8', - clockRate : 90000, - parameters : - { - 'x-google-start-bitrate' : 1000 - } - }, + // { + // kind : 'audio', + // mimeType : 'audio/opus', + // clockRate : 48000, + // channels : 2 + // }, + // { + // kind : 'video', + // mimeType : 'video/VP8', + // clockRate : 90000, + // parameters : + // { + // 'x-google-start-bitrate' : 1000 + // } + // }, { kind : 'video', mimeType : 'video/VP9', -- 2.37.1 From e8bd6837cf7d13e604e3911e0b2bd8fc1d515c5f Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:21:48 +0200 Subject: [PATCH 055/121] Update server --- public/bundle.js | 3 ++- public/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 5c9258a..37d75fe 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20510,7 +20510,8 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, - codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + codec : 'video/vp9', ...videoParams } diff --git a/public/index.js b/public/index.js index 1858d38..1d6938a 100644 --- a/public/index.js +++ b/public/index.js @@ -152,7 +152,8 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, - codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + codec : 'video/vp9', ...videoParams } -- 2.37.1 From ba63fb20bf305ca05695a9c2ff223ac7b78ac1e8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:24:12 +0200 Subject: [PATCH 056/121] Update server --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 37d75fe..1dc9d39 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20511,7 +20511,7 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - codec : 'video/vp9', + // codec : 'video/vp9', ...videoParams } diff --git a/public/index.js b/public/index.js index 1d6938a..3b62b7f 100644 --- a/public/index.js +++ b/public/index.js @@ -153,7 +153,7 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - codec : 'video/vp9', + // codec : 'video/vp9', ...videoParams } -- 2.37.1 From fcbc28c801da59b741a5048b1dab9f9144ecaee2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:26:28 +0200 Subject: [PATCH 057/121] Update server --- public/bundle.js | 42 +++++++++++++++++++++++++----------------- public/index.js | 42 +++++++++++++++++++++++++----------------- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 1dc9d39..c9b610c 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20502,25 +20502,33 @@ let audioParams = { } const streamSuccess = (stream) => { - console.log('[streamSuccess] device', device); + // console.log('[streamSuccess] device', device); + // localVideo.srcObject = stream + // console.log('stream', stream); + // const videoTrack = stream.getVideoTracks()[0] + // const audioTrack = stream.getAudioTracks()[0] + + // videoParams = { + // track: videoTrack, + // // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // // codec : 'video/vp9', + // ...videoParams + // } + + // audioParams = { + // track: audioTrack, + // ...audioParams + // } + + // console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); + // goConnect() + console.log('[streamSuccess]'); localVideo.srcObject = stream - console.log('stream', stream); - const videoTrack = stream.getVideoTracks()[0] - const audioTrack = stream.getAudioTracks()[0] - - videoParams = { - track: videoTrack, - // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - // codec : 'video/vp9', - ...videoParams + const track = stream.getVideoTracks()[0] + params = { + track, + ...params } - - audioParams = { - track: audioTrack, - ...audioParams - } - - console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() } diff --git a/public/index.js b/public/index.js index 3b62b7f..9fd0206 100644 --- a/public/index.js +++ b/public/index.js @@ -144,25 +144,33 @@ let audioParams = { } const streamSuccess = (stream) => { - console.log('[streamSuccess] device', device); + // console.log('[streamSuccess] device', device); + // localVideo.srcObject = stream + // console.log('stream', stream); + // const videoTrack = stream.getVideoTracks()[0] + // const audioTrack = stream.getAudioTracks()[0] + + // videoParams = { + // track: videoTrack, + // // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // // codec : 'video/vp9', + // ...videoParams + // } + + // audioParams = { + // track: audioTrack, + // ...audioParams + // } + + // console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); + // goConnect() + console.log('[streamSuccess]'); localVideo.srcObject = stream - console.log('stream', stream); - const videoTrack = stream.getVideoTracks()[0] - const audioTrack = stream.getAudioTracks()[0] - - videoParams = { - track: videoTrack, - // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - // codec : 'video/vp9', - ...videoParams + const track = stream.getVideoTracks()[0] + params = { + track, + ...params } - - audioParams = { - track: audioTrack, - ...audioParams - } - - console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() } -- 2.37.1 From c758a9106cfb35a20ff26c3e69e18c26b6b7538c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:27:13 +0200 Subject: [PATCH 058/121] Update server --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index c9b610c..49c320a 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20527,7 +20527,7 @@ const streamSuccess = (stream) => { const track = stream.getVideoTracks()[0] params = { track, - ...params + ...videoParams } goConnect() } diff --git a/public/index.js b/public/index.js index 9fd0206..93aca3e 100644 --- a/public/index.js +++ b/public/index.js @@ -169,7 +169,7 @@ const streamSuccess = (stream) => { const track = stream.getVideoTracks()[0] params = { track, - ...params + ...videoParams } goConnect() } -- 2.37.1 From e5bcc6262b6225ba3781f05c395f8dde5e771638 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 17:11:09 +0200 Subject: [PATCH 059/121] Update server --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 49c320a..dcadca7 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20525,7 +20525,7 @@ const streamSuccess = (stream) => { console.log('[streamSuccess]'); localVideo.srcObject = stream const track = stream.getVideoTracks()[0] - params = { + videoParams = { track, ...videoParams } diff --git a/public/index.js b/public/index.js index 93aca3e..72275b4 100644 --- a/public/index.js +++ b/public/index.js @@ -167,7 +167,7 @@ const streamSuccess = (stream) => { console.log('[streamSuccess]'); localVideo.srcObject = stream const track = stream.getVideoTracks()[0] - params = { + videoParams = { track, ...videoParams } -- 2.37.1 From 9fbe01ae1d2e9c68b0cdf43ee2fcba75381d5367 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 17:19:55 +0200 Subject: [PATCH 060/121] Update server --- app.js | 74 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/app.js b/app.js index 27e486d..8b35161 100644 --- a/app.js +++ b/app.js @@ -106,40 +106,54 @@ const mediaCodecs = [ // 'x-google-start-bitrate' : 1000 // } // }, + // { + // kind : 'video', + // mimeType : 'video/VP9', + // clockRate : 90000, + // parameters : + // { + // 'profile-id' : 2, + // 'x-google-start-bitrate' : 1000 + // } + // }, + // { + // kind : 'video', + // mimeType : 'video/h264', + // clockRate : 90000, + // parameters : + // { + // 'packetization-mode' : 1, + // 'profile-level-id' : '4d0032', + // 'level-asymmetry-allowed' : 1, + // 'x-google-start-bitrate' : 1000 + // } + // }, + // { + // kind : 'video', + // mimeType : 'video/h264', + // clockRate : 90000, + // parameters : + // { + // 'packetization-mode' : 1, + // 'profile-level-id' : '42e01f', + // 'level-asymmetry-allowed' : 1, + // 'x-google-start-bitrate' : 1000 + // } + // } { - kind : 'video', - mimeType : 'video/VP9', - clockRate : 90000, - parameters : - { - 'profile-id' : 2, - 'x-google-start-bitrate' : 1000 - } + kind: 'audio', + mimeType: 'audio/opus', + clockRate: 48000, + channels: 2, }, { - kind : 'video', - mimeType : 'video/h264', - clockRate : 90000, - parameters : - { - 'packetization-mode' : 1, - 'profile-level-id' : '4d0032', - 'level-asymmetry-allowed' : 1, - 'x-google-start-bitrate' : 1000 - } + kind: 'video', + mimeType: 'video/VP8', + clockRate: 90000, + parameters: { + 'x-google-start-bitrate': 1000, + }, }, - { - kind : 'video', - mimeType : 'video/h264', - clockRate : 90000, - parameters : - { - 'packetization-mode' : 1, - 'profile-level-id' : '42e01f', - 'level-asymmetry-allowed' : 1, - 'x-google-start-bitrate' : 1000 - } - } ]; const closeCall = (callId) => { -- 2.37.1 From fa5a1a5ae720a774524b567879f951a3b3e1a72e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 17:56:18 +0200 Subject: [PATCH 061/121] Update server --- app.js | 120 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/app.js b/app.js index 8b35161..70fd522 100644 --- a/app.js +++ b/app.js @@ -91,70 +91,70 @@ worker = createWorker(); // list of media codecs supported by mediasoup ... // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts const mediaCodecs = [ - // { - // kind : 'audio', - // mimeType : 'audio/opus', - // clockRate : 48000, - // channels : 2 - // }, - // { - // kind : 'video', - // mimeType : 'video/VP8', - // clockRate : 90000, - // parameters : - // { - // 'x-google-start-bitrate' : 1000 - // } - // }, - // { - // kind : 'video', - // mimeType : 'video/VP9', - // clockRate : 90000, - // parameters : - // { - // 'profile-id' : 2, - // 'x-google-start-bitrate' : 1000 - // } - // }, - // { - // kind : 'video', - // mimeType : 'video/h264', - // clockRate : 90000, - // parameters : - // { - // 'packetization-mode' : 1, - // 'profile-level-id' : '4d0032', - // 'level-asymmetry-allowed' : 1, - // 'x-google-start-bitrate' : 1000 - // } - // }, - // { - // kind : 'video', - // mimeType : 'video/h264', - // clockRate : 90000, - // parameters : - // { - // 'packetization-mode' : 1, - // 'profile-level-id' : '42e01f', - // 'level-asymmetry-allowed' : 1, - // 'x-google-start-bitrate' : 1000 - // } - // } { - kind: 'audio', - mimeType: 'audio/opus', - clockRate: 48000, - channels: 2, + kind : 'audio', + mimeType : 'audio/opus', + clockRate : 48000, + channels : 2 }, { - kind: 'video', - mimeType: 'video/VP8', - clockRate: 90000, - parameters: { - 'x-google-start-bitrate': 1000, - }, + kind : 'video', + mimeType : 'video/VP8', + clockRate : 90000, + parameters : + { + 'x-google-start-bitrate' : 1000 + } }, -]; + { + kind : 'video', + mimeType : 'video/VP9', + clockRate : 90000, + parameters : + { + 'profile-id' : 2, + 'x-google-start-bitrate' : 1000 + } + }, + { + kind : 'video', + mimeType : 'video/h264', + clockRate : 90000, + parameters : + { + 'packetization-mode' : 1, + 'profile-level-id' : '4d0032', + 'level-asymmetry-allowed' : 1, + 'x-google-start-bitrate' : 1000 + } + }, + { + kind : 'video', + mimeType : 'video/h264', + clockRate : 90000, + parameters : + { + 'packetization-mode' : 1, + 'profile-level-id' : '42e01f', + 'level-asymmetry-allowed' : 1, + 'x-google-start-bitrate' : 1000 + } + } +// { +// kind: 'audio', +// mimeType: 'audio/opus', +// clockRate: 48000, +// channels: 2, +// }, +// { +// kind: 'video', +// mimeType: 'video/VP8', +// clockRate: 90000, +// parameters: { +// 'x-google-start-bitrate': 1000, +// }, +// }, +// ]; const closeCall = (callId) => { try { -- 2.37.1 From 458342c0d2bb27b2a60d06e02a12e8843e317e2a Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:32:45 +0200 Subject: [PATCH 062/121] Update server --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 70fd522..7c6b8c6 100644 --- a/app.js +++ b/app.js @@ -154,7 +154,7 @@ const mediaCodecs = [ // 'x-google-start-bitrate': 1000, // }, // }, -// ]; +]; const closeCall = (callId) => { try { -- 2.37.1 From aa7c2aea90e616d815a109dd8197735ad0ef4268 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:35:32 +0200 Subject: [PATCH 063/121] Update server --- public/bundle.js | 50 ++++++++++++++++++++++++------------------------ public/index.js | 50 ++++++++++++++++++++++++------------------------ 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index dcadca7..2bafe5e 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20461,36 +20461,36 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce let videoParams = { - // encodings: [ - // { scaleResolutionDownBy: 4, maxBitrate: 500000 }, - // { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, - // { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, - // { scalabilityMode: 'S3T3_KEY' } - // ], - // codecOptions: { - // videoGoogleStartBitrate: 1000 - // } encodings: [ - { - rid: 'r0', - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r1', - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r2', - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } ], - // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } + // encodings: [ + // { + // rid: 'r0', + // maxBitrate: 100000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r1', + // maxBitrate: 300000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r2', + // maxBitrate: 900000, + // scalabilityMode: 'S1T3', + // }, + // ], + // // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions + // codecOptions: { + // videoGoogleStartBitrate: 1000 + // } } let audioParams = { diff --git a/public/index.js b/public/index.js index 72275b4..43796e9 100644 --- a/public/index.js +++ b/public/index.js @@ -103,36 +103,36 @@ let originAssetId // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce let videoParams = { - // encodings: [ - // { scaleResolutionDownBy: 4, maxBitrate: 500000 }, - // { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, - // { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, - // { scalabilityMode: 'S3T3_KEY' } - // ], - // codecOptions: { - // videoGoogleStartBitrate: 1000 - // } encodings: [ - { - rid: 'r0', - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r1', - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r2', - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } ], - // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } + // encodings: [ + // { + // rid: 'r0', + // maxBitrate: 100000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r1', + // maxBitrate: 300000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r2', + // maxBitrate: 900000, + // scalabilityMode: 'S1T3', + // }, + // ], + // // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions + // codecOptions: { + // videoGoogleStartBitrate: 1000 + // } } let audioParams = { -- 2.37.1 From e65b7e0d7c4ab9655feffebbd8676cdd78c49608 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:36:21 +0200 Subject: [PATCH 064/121] Update server --- public/bundle.js | 32 ++++++++++++++++---------------- public/index.js | 32 ++++++++++++++++---------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 2bafe5e..25c5f77 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20534,27 +20534,27 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); - // navigator.mediaDevices.getUserMedia({ - // audio: false, - // video: { - // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - // } - // }) navigator.mediaDevices.getUserMedia({ audio: false, video: { - width: { - min: 640, - max: 1920, - }, - height: { - min: 400, - max: 1080, - } + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + // navigator.mediaDevices.getUserMedia({ + // audio: false, + // video: { + // width: { + // min: 640, + // max: 1920, + // }, + // height: { + // min: 400, + // max: 1080, + // } + // } + // }) .then(streamSuccess) .catch(error => { console.log(error.message) diff --git a/public/index.js b/public/index.js index 43796e9..c0326ec 100644 --- a/public/index.js +++ b/public/index.js @@ -176,27 +176,27 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); - // navigator.mediaDevices.getUserMedia({ - // audio: false, - // video: { - // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - // } - // }) navigator.mediaDevices.getUserMedia({ audio: false, video: { - width: { - min: 640, - max: 1920, - }, - height: { - min: 400, - max: 1080, - } + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + // navigator.mediaDevices.getUserMedia({ + // audio: false, + // video: { + // width: { + // min: 640, + // max: 1920, + // }, + // height: { + // min: 400, + // max: 1080, + // } + // } + // }) .then(streamSuccess) .catch(error => { console.log(error.message) -- 2.37.1 From 6c42814229d8f015cd9e5f6932e4f573f744aa8a Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:37:42 +0200 Subject: [PATCH 065/121] Update server --- public/bundle.js | 46 +++++++++++++++++++++++----------------------- public/index.js | 46 +++++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 25c5f77..c880e9d 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20502,34 +20502,34 @@ let audioParams = { } const streamSuccess = (stream) => { - // console.log('[streamSuccess] device', device); - // localVideo.srcObject = stream - // console.log('stream', stream); - // const videoTrack = stream.getVideoTracks()[0] - // const audioTrack = stream.getAudioTracks()[0] - - // videoParams = { - // track: videoTrack, - // // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - // // codec : 'video/vp9', - // ...videoParams - // } - - // audioParams = { - // track: audioTrack, - // ...audioParams - // } - - // console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); - // goConnect() - console.log('[streamSuccess]'); + console.log('[streamSuccess] device', device); localVideo.srcObject = stream - const track = stream.getVideoTracks()[0] + console.log('stream', stream); + const videoTrack = stream.getVideoTracks()[0] + const audioTrack = stream.getAudioTracks()[0] + videoParams = { - track, + track: videoTrack, + // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // codec : 'video/vp9', ...videoParams } + + audioParams = { + track: audioTrack, + ...audioParams + } + + console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() + // console.log('[streamSuccess]'); + // localVideo.srcObject = stream + // const track = stream.getVideoTracks()[0] + // videoParams = { + // track, + // ...videoParams + // } + // goConnect() } const getLocalStream = () => { diff --git a/public/index.js b/public/index.js index c0326ec..38d3dde 100644 --- a/public/index.js +++ b/public/index.js @@ -144,34 +144,34 @@ let audioParams = { } const streamSuccess = (stream) => { - // console.log('[streamSuccess] device', device); - // localVideo.srcObject = stream - // console.log('stream', stream); - // const videoTrack = stream.getVideoTracks()[0] - // const audioTrack = stream.getAudioTracks()[0] - - // videoParams = { - // track: videoTrack, - // // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - // // codec : 'video/vp9', - // ...videoParams - // } - - // audioParams = { - // track: audioTrack, - // ...audioParams - // } - - // console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); - // goConnect() - console.log('[streamSuccess]'); + console.log('[streamSuccess] device', device); localVideo.srcObject = stream - const track = stream.getVideoTracks()[0] + console.log('stream', stream); + const videoTrack = stream.getVideoTracks()[0] + const audioTrack = stream.getAudioTracks()[0] + videoParams = { - track, + track: videoTrack, + // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // codec : 'video/vp9', ...videoParams } + + audioParams = { + track: audioTrack, + ...audioParams + } + + console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() + // console.log('[streamSuccess]'); + // localVideo.srcObject = stream + // const track = stream.getVideoTracks()[0] + // videoParams = { + // track, + // ...videoParams + // } + // goConnect() } const getLocalStream = () => { -- 2.37.1 From 56b8e2ea745f483c15d3133a3bc00ff12465f2a2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:38:28 +0200 Subject: [PATCH 066/121] Update server --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index c880e9d..e279e99 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20535,7 +20535,7 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: false, + audio: true, video: { qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, vga : { width: { ideal: 640 }, height: { ideal: 480 } }, diff --git a/public/index.js b/public/index.js index 38d3dde..b0c7c5b 100644 --- a/public/index.js +++ b/public/index.js @@ -177,7 +177,7 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: false, + audio: true, video: { qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, vga : { width: { ideal: 640 }, height: { ideal: 480 } }, -- 2.37.1 From 2a86042c807b65812ab3cdb8e0f5215fb2f1f3f5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:41:24 +0200 Subject: [PATCH 067/121] Update server --- public/bundle.js | 20 ++++++++++---------- public/index.js | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index e279e99..6f4a9d3 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20699,17 +20699,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) const answer = { origin_asset_id: ASSET_ID, diff --git a/public/index.js b/public/index.js index b0c7c5b..2ab4597 100644 --- a/public/index.js +++ b/public/index.js @@ -341,17 +341,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From 8ef6c2abb099ecc72453fc57d028b66f89b53d09 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:43:33 +0200 Subject: [PATCH 068/121] Update server --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index fb0f078..71e0467 100644 --- a/public/index.html +++ b/public/index.html @@ -43,7 +43,7 @@
- +
-- 2.37.1 From 6e74083733c0a57f621cab39150f3b322d9d615d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:49:04 +0200 Subject: [PATCH 069/121] Update server --- app.js | 4 +++- public/bundle.js | 27 ++++++++++++++++----------- public/index.js | 27 ++++++++++++++++----------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 7c6b8c6..8217598 100644 --- a/app.js +++ b/app.js @@ -285,7 +285,9 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); - console.log('[transport-produce] | socket.id', socket.id, '| callId', callId); + console.log(`[transport-produce] kind: ${kind} | socket.id: ${socket.id} | callId: ${callId}`); + console.log('kind', kind); + console.log('rtpParameters', rtpParameters); videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({ kind, rtpParameters, diff --git a/public/bundle.js b/public/bundle.js index 6f4a9d3..3c020f0 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20687,17 +20687,6 @@ const connectSendTransport = async () => { // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - producerVideo = await producerTransport.produce(videoParams) - console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerVideo.on('transportclose', () => { - console.log('transport ended') - // close video track - }) producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); @@ -20711,6 +20700,22 @@ const connectSendTransport = async () => { // close video track }) + + + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerVideo.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + + + const answer = { origin_asset_id: ASSET_ID, dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), diff --git a/public/index.js b/public/index.js index 2ab4597..b2a99a0 100644 --- a/public/index.js +++ b/public/index.js @@ -329,17 +329,6 @@ const connectSendTransport = async () => { // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - producerVideo = await producerTransport.produce(videoParams) - console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerVideo.on('transportclose', () => { - console.log('transport ended') - // close video track - }) producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); @@ -353,6 +342,22 @@ const connectSendTransport = async () => { // close video track }) + + + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerVideo.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + + + const answer = { origin_asset_id: ASSET_ID, dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), -- 2.37.1 From 950298c4f6a63ea89e34bc78a0517fcc2d8b22df Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:21:22 +0200 Subject: [PATCH 070/121] Update server --- public/bundle.js | 24 +++++++++++++----------- public/index.js | 24 +++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 3c020f0..59cdd16 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20688,6 +20688,19 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerVideo.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + + producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); producerAudio.on('trackended', () => { @@ -20702,17 +20715,6 @@ const connectSendTransport = async () => { - producerVideo = await producerTransport.produce(videoParams) - console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerVideo.on('transportclose', () => { - console.log('transport ended') - // close video track - }) diff --git a/public/index.js b/public/index.js index b2a99a0..2996ae6 100644 --- a/public/index.js +++ b/public/index.js @@ -330,6 +330,19 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerVideo.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + + producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); producerAudio.on('trackended', () => { @@ -344,17 +357,6 @@ const connectSendTransport = async () => { - producerVideo = await producerTransport.produce(videoParams) - console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerVideo.on('transportclose', () => { - console.log('transport ended') - // close video track - }) -- 2.37.1 From f2c0794bf42e3cf7167cf2f19995236f9aad7968 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:22:56 +0200 Subject: [PATCH 071/121] Update server --- public/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/index.js b/public/index.js index 2996ae6..f383eae 100644 --- a/public/index.js +++ b/public/index.js @@ -343,17 +343,17 @@ const connectSendTransport = async () => { }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) -- 2.37.1 From 2a7bd422477eb8bd04783644e8a16db6cafd2e76 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:34:54 +0200 Subject: [PATCH 072/121] Update server --- public/bundle.js | 2 +- public/index.js | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 59cdd16..7a1148c 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20688,6 +20688,7 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + producerVideo = await producerTransport.produce(videoParams) console.log('producerVideo', producerVideo); producerVideo.on('trackended', () => { @@ -20700,7 +20701,6 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); producerAudio.on('trackended', () => { diff --git a/public/index.js b/public/index.js index f383eae..d1d4dd5 100644 --- a/public/index.js +++ b/public/index.js @@ -330,6 +330,7 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + producerVideo = await producerTransport.produce(videoParams) console.log('producerVideo', producerVideo); producerVideo.on('trackended', () => { @@ -342,18 +343,17 @@ const connectSendTransport = async () => { // close video track }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) - - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) -- 2.37.1 From 3e4c0a32bc1c06112655a7e03da80ce31e67b0aa Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:36:00 +0200 Subject: [PATCH 073/121] Update server --- public/bundle.js | 20 ++++++++++---------- public/index.js | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 7a1148c..7256e97 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20701,17 +20701,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) diff --git a/public/index.js b/public/index.js index d1d4dd5..4b46fc8 100644 --- a/public/index.js +++ b/public/index.js @@ -343,17 +343,17 @@ const connectSendTransport = async () => { // close video track }) - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) + // producerAudio = await producerTransport.produce(audioParams) + // console.log('producerAudio', producerAudio); + // producerAudio.on('trackended', () => { + // console.log('track ended') + // // close video track + // }) - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) + // producerAudio.on('transportclose', () => { + // console.log('transport ended') + // // close video track + // }) -- 2.37.1 From aad96b72f2d90598c3b452ae37718e74600652c1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:36:36 +0200 Subject: [PATCH 074/121] Update server --- public/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/index.js b/public/index.js index 4b46fc8..d1d4dd5 100644 --- a/public/index.js +++ b/public/index.js @@ -343,17 +343,17 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close video track + }) -- 2.37.1 From e59f134a68a9c3b3b961ad08a62501fd51657fac Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:37:44 +0200 Subject: [PATCH 075/121] Update server --- public/bundle.js | 21 +++++++++++---------- public/index.js | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 7256e97..99709c6 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20701,17 +20701,18 @@ const connectSendTransport = async () => { // close video track }) - // producerAudio = await producerTransport.produce(audioParams) - // console.log('producerAudio', producerAudio); - // producerAudio.on('trackended', () => { - // console.log('track ended') - // // close video track - // }) + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) - // producerAudio.on('transportclose', () => { - // console.log('transport ended') - // // close video track - // }) + producerAudio.on('transportclose', () => { + console.log('transport ended') + + // close video track + }) diff --git a/public/index.js b/public/index.js index d1d4dd5..8b046bb 100644 --- a/public/index.js +++ b/public/index.js @@ -352,6 +352,7 @@ const connectSendTransport = async () => { producerAudio.on('transportclose', () => { console.log('transport ended') + // close video track }) -- 2.37.1 From c6edb2947d5b21d41bf10887b1d389deb96f8741 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:46:00 +0200 Subject: [PATCH 076/121] Update server --- app.js | 3 +++ public/bundle.js | 5 +++-- public/index.js | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 8217598..973de2f 100644 --- a/app.js +++ b/app.js @@ -332,6 +332,8 @@ peers.on('connection', async socket => { */ socket.on('consume', async ({ rtpCapabilities }, callback) => { try { + console.log(`[consume] rtpCapabilities: ${rtpCapabilities}`); + const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); @@ -370,6 +372,7 @@ peers.on('connection', async socket => { rtpParameters: videoCalls[callId].consumer.rtpParameters, }; + console.log('[consume] params', params); // Send the parameters to the client callback({ params }); } else { diff --git a/public/bundle.js b/public/bundle.js index 99709c6..e3fbe0f 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20688,7 +20688,7 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - + console.log('videoParams', videoParams); producerVideo = await producerTransport.produce(videoParams) console.log('producerVideo', producerVideo); producerVideo.on('trackended', () => { @@ -20701,6 +20701,7 @@ const connectSendTransport = async () => { // close video track }) + console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); producerAudio.on('trackended', () => { @@ -20710,7 +20711,7 @@ const connectSendTransport = async () => { producerAudio.on('transportclose', () => { console.log('transport ended') - + // close video track }) diff --git a/public/index.js b/public/index.js index 8b046bb..fed244a 100644 --- a/public/index.js +++ b/public/index.js @@ -330,7 +330,7 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - + console.log('videoParams', videoParams); producerVideo = await producerTransport.produce(videoParams) console.log('producerVideo', producerVideo); producerVideo.on('trackended', () => { @@ -343,6 +343,7 @@ const connectSendTransport = async () => { // close video track }) + console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); producerAudio.on('trackended', () => { @@ -352,7 +353,7 @@ const connectSendTransport = async () => { producerAudio.on('transportclose', () => { console.log('transport ended') - + // close video track }) -- 2.37.1 From 22ead926b07628c639911dfe606a216c168d8cfe Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:57:26 +0200 Subject: [PATCH 077/121] Update server --- app.js | 6 ++++-- public/bundle.js | 36 ++++++++++++++++++------------------ public/index.js | 36 ++++++++++++++++++------------------ 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/app.js b/app.js index 973de2f..1faca04 100644 --- a/app.js +++ b/app.js @@ -91,6 +91,7 @@ worker = createWorker(); // list of media codecs supported by mediasoup ... // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts const mediaCodecs = [ + channels : 2, { kind : 'audio', mimeType : 'audio/opus', @@ -104,7 +105,8 @@ const mediaCodecs = [ parameters : { 'x-google-start-bitrate' : 1000 - } + }, + channels : 2 }, { kind : 'video', @@ -333,7 +335,7 @@ peers.on('connection', async socket => { socket.on('consume', async ({ rtpCapabilities }, callback) => { try { console.log(`[consume] rtpCapabilities: ${rtpCapabilities}`); - + const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); diff --git a/public/bundle.js b/public/bundle.js index e3fbe0f..c1e17dd 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20687,6 +20687,22 @@ const connectSendTransport = async () => { // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + + + console.log('audioParams', audioParams); + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + + // close video track + }) + console.log('videoParams', videoParams); producerVideo = await producerTransport.produce(videoParams) @@ -20694,28 +20710,12 @@ const connectSendTransport = async () => { producerVideo.on('trackended', () => { console.log('track ended') // close video track - }) + }) producerVideo.on('transportclose', () => { console.log('transport ended') // close video track - }) - - console.log('audioParams', audioParams); - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerAudio.on('transportclose', () => { - console.log('transport ended') - - // close video track - }) - - + }) diff --git a/public/index.js b/public/index.js index fed244a..dd984bc 100644 --- a/public/index.js +++ b/public/index.js @@ -329,6 +329,22 @@ const connectSendTransport = async () => { // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + + + console.log('audioParams', audioParams); + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + + // close video track + }) + console.log('videoParams', videoParams); producerVideo = await producerTransport.produce(videoParams) @@ -336,28 +352,12 @@ const connectSendTransport = async () => { producerVideo.on('trackended', () => { console.log('track ended') // close video track - }) + }) producerVideo.on('transportclose', () => { console.log('transport ended') // close video track - }) - - console.log('audioParams', audioParams); - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerAudio.on('transportclose', () => { - console.log('transport ended') - - // close video track - }) - - + }) -- 2.37.1 From 3561bb13a6dd75ed5d50541409224190a6e38bf0 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:59:04 +0200 Subject: [PATCH 078/121] Update server --- app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app.js b/app.js index 1faca04..49b06f8 100644 --- a/app.js +++ b/app.js @@ -91,7 +91,6 @@ worker = createWorker(); // list of media codecs supported by mediasoup ... // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts const mediaCodecs = [ - channels : 2, { kind : 'audio', mimeType : 'audio/opus', -- 2.37.1 From 1148532a9b90b53a6373f3b49fe5568c51259d0b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 17:01:26 +0200 Subject: [PATCH 079/121] Update server --- public/bundle.js | 25 +++++++++++++------------ public/index.js | 25 +++++++++++++------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index c1e17dd..e9f0f4c 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20688,6 +20688,19 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + console.log('videoParams', videoParams); + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerVideo.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) @@ -20704,18 +20717,6 @@ const connectSendTransport = async () => { }) - console.log('videoParams', videoParams); - producerVideo = await producerTransport.produce(videoParams) - console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerVideo.on('transportclose', () => { - console.log('transport ended') - // close video track - }) diff --git a/public/index.js b/public/index.js index dd984bc..36b6440 100644 --- a/public/index.js +++ b/public/index.js @@ -330,6 +330,19 @@ const connectSendTransport = async () => { // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above + console.log('videoParams', videoParams); + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerVideo.on('transportclose', () => { + console.log('transport ended') + // close video track + }) + console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) @@ -346,18 +359,6 @@ const connectSendTransport = async () => { }) - console.log('videoParams', videoParams); - producerVideo = await producerTransport.produce(videoParams) - console.log('producerVideo', producerVideo); - producerVideo.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerVideo.on('transportclose', () => { - console.log('transport ended') - // close video track - }) -- 2.37.1 From d94ea12a407596f92df28052b4936a14b4e08c7d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 17:08:54 +0200 Subject: [PATCH 080/121] Update server --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 49b06f8..a0333e9 100644 --- a/app.js +++ b/app.js @@ -333,7 +333,7 @@ peers.on('connection', async socket => { */ socket.on('consume', async ({ rtpCapabilities }, callback) => { try { - console.log(`[consume] rtpCapabilities: ${rtpCapabilities}`); + console.log(`[consume] rtpCapabilities: ${JSON.stringify(rtpCapabilities)}`); const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); -- 2.37.1 From 038bdb99bcbd6323ccf4868925b0239795935722 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 22:18:37 +0200 Subject: [PATCH 081/121] Update server --- app.js | 1 + public/bundle.js | 1 - public/index.js | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app.js b/app.js index a0333e9..264573a 100644 --- a/app.js +++ b/app.js @@ -448,6 +448,7 @@ const createWebRtcTransportLayer = async (callId, callback) => { dtlsParameters: transport.dtlsParameters, }; + console.log('[createWebRtcTransportLayer] callback params', params); // Send back to the client the params callback({ params }); diff --git a/public/bundle.js b/public/bundle.js index e9f0f4c..acc8999 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20701,7 +20701,6 @@ const connectSendTransport = async () => { // close video track }) - console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); diff --git a/public/index.js b/public/index.js index 36b6440..1b5f06d 100644 --- a/public/index.js +++ b/public/index.js @@ -343,7 +343,6 @@ const connectSendTransport = async () => { // close video track }) - console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); -- 2.37.1 From cd84c534ce7eb57858ca03ee5df8cf44570f1ebc Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 22:27:33 +0200 Subject: [PATCH 082/121] Update server --- public/bundle.js | 1 + public/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/public/bundle.js b/public/bundle.js index acc8999..4bf5e42 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20501,6 +20501,7 @@ let audioParams = { } } + const streamSuccess = (stream) => { console.log('[streamSuccess] device', device); localVideo.srcObject = stream diff --git a/public/index.js b/public/index.js index 1b5f06d..bf14996 100644 --- a/public/index.js +++ b/public/index.js @@ -143,6 +143,7 @@ let audioParams = { } } + const streamSuccess = (stream) => { console.log('[streamSuccess] device', device); localVideo.srcObject = stream -- 2.37.1 From 8444809910abe74a79fffa123d886864bd5361b0 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:06:02 +0200 Subject: [PATCH 083/121] Update server --- app.js | 140 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 101 insertions(+), 39 deletions(-) diff --git a/app.js b/app.js index 264573a..59a3772 100644 --- a/app.js +++ b/app.js @@ -160,8 +160,11 @@ const mediaCodecs = [ const closeCall = (callId) => { try { if (callId && videoCalls[callId]) { - videoCalls[callId].producer?.close(); - videoCalls[callId].consumer?.close(); + videoCalls[callId].producerVideo?.close(); + videoCalls[callId].producerAudio?.close(); + videoCalls[callId].consumerVideo?.close(); + videoCalls[callId].consumerAudio?.close(); + videoCalls[callId]?.consumerTransport?.close(); videoCalls[callId]?.producerTransport?.close(); videoCalls[callId]?.router?.close(); @@ -280,31 +283,54 @@ peers.on('connection', async socket => { - The event sent by the client (PRODUCER) after successfully connecting to producerTransport - For the router with the id callId, we make produce on producerTransport - Create the handler on producer at the 'transportclose' event - */ - socket.on('transport-produce', async ({ kind, rtpParameters, appData }, callback) => { - try { - const callId = socketDetails[socket.id]; - if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); + */ + socket.on('transport-produce', async ({ kind, rtpParameters, appData }, callback) => { + try { + const callId = socketDetails[socket.id]; + if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); + + console.log(`[transport-produce] kind: ${kind} | socket.id: ${socket.id} | callId: ${callId}`); + console.log('kind', kind); + console.log('rtpParameters', rtpParameters); - console.log(`[transport-produce] kind: ${kind} | socket.id: ${socket.id} | callId: ${callId}`); - console.log('kind', kind); - console.log('rtpParameters', rtpParameters); - videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({ - kind, - rtpParameters, - }); - console.log(`[transport-produce] Producer ID: ${videoCalls[callId].producer.id} | kind: ${videoCalls[callId].producer.kind}`); - - videoCalls[callId].producer.on('transportclose', () => { - const callId = socketDetails[socket.id]; - console.log('transport for this producer closed', callId) - closeCall(callId); - }); + if (kind === 'video') { + videoCalls[callId].producerVideo = await videoCalls[callId].producerTransport.produce({ + kind, + rtpParameters, + }); + - // Send back to the client the Producer's id - callback && callback({ - id: videoCalls[callId].producer.id - }); + console.log(`[transport-produce] Producer ID: ${videoCalls[callId].producerVideo.id} | kind: ${videoCalls[callId].producerVideo.kind}`); + + videoCalls[callId].producerVideo.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport for this producer closed', callId) + closeCall(callId); + }); + + // Send back to the client the Producer's id + callback && callback({ + id: videoCalls[callId].producerVideo.id + }); + } else if (kind === 'audio') { + videoCalls[callId].producerAudio = await videoCalls[callId].producerTransport.produce({ + kind, + rtpParameters, + }); + + console.log(`[transport-produce] Producer ID: ${videoCalls[callId].producerAudio.id} | kind: ${videoCalls[callId].producerAudio.kind}`); + + videoCalls[callId].producerAudio.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport for this producer closed', callId) + closeCall(callId); + }); + + // Send back to the client the Producer's id + callback && callback({ + id: videoCalls[callId].producerAudio.id + }); + } } catch (error) { console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); } @@ -339,43 +365,79 @@ peers.on('connection', async socket => { console.log('[consume] callId', callId); // Check if the router can consume the specified producer - if (videoCalls[callId].router.canConsume({ - producerId: videoCalls[callId].producer.id, - rtpCapabilities - })) { + if ( + videoCalls[callId].router.canConsume({ + producerId: videoCalls[callId].producerVideo.id, + rtpCapabilities + }) && + videoCalls[callId].router.canConsume({ + producerId: videoCalls[callId].producerAudio.id, + rtpCapabilities + }) + ) { console.log('[consume] Can consume', callId); // Transport can now consume and return a consumer - videoCalls[callId].consumer = await videoCalls[callId].consumerTransport.consume({ - producerId: videoCalls[callId].producer.id, + videoCalls[callId].consumerVideo = await videoCalls[callId].consumerTransport.consume({ + producerId: videoCalls[callId].producerVideo.id, rtpCapabilities, paused: true, }); // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose - videoCalls[callId].consumer.on('transportclose', () => { + videoCalls[callId].consumerVideo.on('transportclose', () => { const callId = socketDetails[socket.id]; console.log('transport close from consumer', callId); closeCall(callId); }); // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose - videoCalls[callId].consumer.on('producerclose', () => { + videoCalls[callId].consumerVideo.on('producerclose', () => { const callId = socketDetails[socket.id]; console.log('producer of consumer closed', callId); closeCall(callId); }); + videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ + producerId: videoCalls[callId].producerAudio.id, + rtpCapabilities, + paused: true, + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose + videoCalls[callId].consumerAudio.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport close from consumer', callId); + closeCall(callId); + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose + videoCalls[callId].consumerAudio.on('producerclose', () => { + const callId = socketDetails[socket.id]; + console.log('producer of consumer closed', callId); + closeCall(callId); + }); + + console.log('🟠 videoCalls[callId].consumerVideo', videoCalls[callId].consumerVideo); + console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); + // From the consumer extract the following params to send back to the Client - const params = { - id: videoCalls[callId].consumer.id, - producerId: videoCalls[callId].producer.id, - kind: videoCalls[callId].consumer.kind, - rtpParameters: videoCalls[callId].consumer.rtpParameters, + const videoParams = { + id: videoCalls[callId].consumerVideo.id, + producerId: videoCalls[callId].producerVideo.id, + kind: 'video', + rtpParameters: videoCalls[callId].consumerVideo.rtpParameters, + }; + + const audioParams = { + id: videoCalls[callId].consumerAudio.id, + producerId: videoCalls[callId].producerAudio.id, + kind: 'audio', + rtpParameters: videoCalls[callId].consumerAudio.rtpParameters, }; console.log('[consume] params', params); // Send the parameters to the client - callback({ params }); + callback({ videoParams, audioParams }); } else { console.log(`[canConsume] Can't consume | callId ${callId}`); callback(null); -- 2.37.1 From 56bdbca537efbe5c86142c549bf1e15310fb7444 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:09:18 +0200 Subject: [PATCH 084/121] Update server --- app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 59a3772..7e27ae9 100644 --- a/app.js +++ b/app.js @@ -435,7 +435,8 @@ peers.on('connection', async socket => { rtpParameters: videoCalls[callId].consumerAudio.rtpParameters, }; - console.log('[consume] params', params); + console.log('[consume] videoParams', videoParams); + console.log('[consume] audioParams', audioParams); // Send the parameters to the client callback({ videoParams, audioParams }); } else { -- 2.37.1 From 13694915294d0ad6ab90564499e667ed13c33b7e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:22:55 +0200 Subject: [PATCH 085/121] Update server --- public/bundle.js | 9 +++++---- public/index.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 4bf5e42..525c0c5 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20620,16 +20620,17 @@ const createSendTransport = () => { console.log('[createSendTransport'); // see server's socket.on('createWebRtcTransport', sender?, ...) // this is a call from Producer, so sender = true - socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => { + socket.emit('createWebRtcTransport', { sender: true, callId }, (value) => { + + console.log(`[createWebRtcTransport] value: ${value}`); + + const params = value; // The server sends back params needed // to create Send Transport on the client side if (params.error) { console.log(params.error) return } - - console.log('[createWebRtcTransport] params', params) - // creates a new WebRTC Transport to send media // based on the server's producer transport params // https://mediasoup.org/documentation/v3/mediasoup-client/api/#TransportOptions diff --git a/public/index.js b/public/index.js index bf14996..a6c66f7 100644 --- a/public/index.js +++ b/public/index.js @@ -262,16 +262,17 @@ const createSendTransport = () => { console.log('[createSendTransport'); // see server's socket.on('createWebRtcTransport', sender?, ...) // this is a call from Producer, so sender = true - socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => { + socket.emit('createWebRtcTransport', { sender: true, callId }, (value) => { + + console.log(`[createWebRtcTransport] value: ${value}`); + + const params = value; // The server sends back params needed // to create Send Transport on the client side if (params.error) { console.log(params.error) return } - - console.log('[createWebRtcTransport] params', params) - // creates a new WebRTC Transport to send media // based on the server's producer transport params // https://mediasoup.org/documentation/v3/mediasoup-client/api/#TransportOptions -- 2.37.1 From 21dffefa8c9c16737658e652aedc6b2ad392635e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:29:03 +0200 Subject: [PATCH 086/121] Update server --- public/bundle.js | 4 ++-- public/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 525c0c5..733c840 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20622,9 +20622,9 @@ const createSendTransport = () => { // this is a call from Producer, so sender = true socket.emit('createWebRtcTransport', { sender: true, callId }, (value) => { - console.log(`[createWebRtcTransport] value: ${value}`); + console.log(`[createWebRtcTransport] value: ${JSON.stringify(value)}`); - const params = value; + const params = value.params; // The server sends back params needed // to create Send Transport on the client side if (params.error) { diff --git a/public/index.js b/public/index.js index a6c66f7..b30af81 100644 --- a/public/index.js +++ b/public/index.js @@ -264,9 +264,9 @@ const createSendTransport = () => { // this is a call from Producer, so sender = true socket.emit('createWebRtcTransport', { sender: true, callId }, (value) => { - console.log(`[createWebRtcTransport] value: ${value}`); + console.log(`[createWebRtcTransport] value: ${JSON.stringify(value)}`); - const params = value; + const params = value.params; // The server sends back params needed // to create Send Transport on the client side if (params.error) { -- 2.37.1 From 3387a362a630904de6c5492f603d1661ead5f600 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:30:27 +0200 Subject: [PATCH 087/121] Update server --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 7e27ae9..37f3305 100644 --- a/app.js +++ b/app.js @@ -457,7 +457,7 @@ peers.on('connection', async socket => { try { const callId = socketDetails[socket.id]; console.log(`[consumer-resume] callId ${callId}`) - await videoCalls[callId].consumer.resume(); + await videoCalls[callId].consumerVideo.resume(); } catch (error) { console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); } -- 2.37.1 From c02a7c73807ba040503cd168d16f8648afffcd17 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:56:42 +0200 Subject: [PATCH 088/121] Update server --- app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app.js b/app.js index 37f3305..9968a62 100644 --- a/app.js +++ b/app.js @@ -458,6 +458,7 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log(`[consumer-resume] callId ${callId}`) await videoCalls[callId].consumerVideo.resume(); + await videoCalls[callId].consumerAudio.resume(); } catch (error) { console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); } -- 2.37.1 From c862224ead8ed98aba0368512938d31a64e3ecc2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 10:28:45 +0200 Subject: [PATCH 089/121] LH-265: Update client and server --- app.js | 215 +++++-- public/bundle.js | 1385 +++++++++++++++++++-------------------------- public/config.js | 3 +- public/index.html | 2 +- public/index.js | 311 ++++++---- 5 files changed, 945 insertions(+), 971 deletions(-) diff --git a/app.js b/app.js index 702eb14..37f3305 100644 --- a/app.js +++ b/app.js @@ -90,28 +90,81 @@ worker = createWorker(); // https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#RtpCodecCapability // list of media codecs supported by mediasoup ... // https://github.com/versatica/mediasoup/blob/v3/src/supportedRtpCapabilities.ts -const mediaCodecs = [ +const mediaCodecs = [ { - kind: 'audio', - mimeType: 'audio/opus', - clockRate: 48000, - channels: 2, + kind : 'audio', + mimeType : 'audio/opus', + clockRate : 48000, + channels : 2 }, { - kind: 'video', - mimeType: 'video/VP8', - clockRate: 90000, - parameters: { - 'x-google-start-bitrate': 1000, + kind : 'video', + mimeType : 'video/VP8', + clockRate : 90000, + parameters : + { + 'x-google-start-bitrate' : 1000 }, + channels : 2 }, + { + kind : 'video', + mimeType : 'video/VP9', + clockRate : 90000, + parameters : + { + 'profile-id' : 2, + 'x-google-start-bitrate' : 1000 + } + }, + { + kind : 'video', + mimeType : 'video/h264', + clockRate : 90000, + parameters : + { + 'packetization-mode' : 1, + 'profile-level-id' : '4d0032', + 'level-asymmetry-allowed' : 1, + 'x-google-start-bitrate' : 1000 + } + }, + { + kind : 'video', + mimeType : 'video/h264', + clockRate : 90000, + parameters : + { + 'packetization-mode' : 1, + 'profile-level-id' : '42e01f', + 'level-asymmetry-allowed' : 1, + 'x-google-start-bitrate' : 1000 + } + } +// { +// kind: 'audio', +// mimeType: 'audio/opus', +// clockRate: 48000, +// channels: 2, +// }, +// { +// kind: 'video', +// mimeType: 'video/VP8', +// clockRate: 90000, +// parameters: { +// 'x-google-start-bitrate': 1000, +// }, +// }, ]; const closeCall = (callId) => { try { if (callId && videoCalls[callId]) { - videoCalls[callId].producer?.close(); - videoCalls[callId].consumer?.close(); + videoCalls[callId].producerVideo?.close(); + videoCalls[callId].producerAudio?.close(); + videoCalls[callId].consumerVideo?.close(); + videoCalls[callId].consumerAudio?.close(); + videoCalls[callId]?.consumerTransport?.close(); videoCalls[callId]?.producerTransport?.close(); videoCalls[callId]?.router?.close(); @@ -230,29 +283,54 @@ peers.on('connection', async socket => { - The event sent by the client (PRODUCER) after successfully connecting to producerTransport - For the router with the id callId, we make produce on producerTransport - Create the handler on producer at the 'transportclose' event - */ - socket.on('transport-produce', async ({ kind, rtpParameters, appData }, callback) => { - try { - const callId = socketDetails[socket.id]; - if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); + */ + socket.on('transport-produce', async ({ kind, rtpParameters, appData }, callback) => { + try { + const callId = socketDetails[socket.id]; + if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); + + console.log(`[transport-produce] kind: ${kind} | socket.id: ${socket.id} | callId: ${callId}`); + console.log('kind', kind); + console.log('rtpParameters', rtpParameters); - console.log('[transport-produce] | socket.id', socket.id, '| callId', callId); - videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({ - kind, - rtpParameters, - }); - console.log(`[transport-produce] Producer ID: ${videoCalls[callId].producer.id} | kind: ${videoCalls[callId].producer.kind}`); - - videoCalls[callId].producer.on('transportclose', () => { - const callId = socketDetails[socket.id]; - console.log('transport for this producer closed', callId) - closeCall(callId); - }); + if (kind === 'video') { + videoCalls[callId].producerVideo = await videoCalls[callId].producerTransport.produce({ + kind, + rtpParameters, + }); + - // Send back to the client the Producer's id - callback && callback({ - id: videoCalls[callId].producer.id - }); + console.log(`[transport-produce] Producer ID: ${videoCalls[callId].producerVideo.id} | kind: ${videoCalls[callId].producerVideo.kind}`); + + videoCalls[callId].producerVideo.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport for this producer closed', callId) + closeCall(callId); + }); + + // Send back to the client the Producer's id + callback && callback({ + id: videoCalls[callId].producerVideo.id + }); + } else if (kind === 'audio') { + videoCalls[callId].producerAudio = await videoCalls[callId].producerTransport.produce({ + kind, + rtpParameters, + }); + + console.log(`[transport-produce] Producer ID: ${videoCalls[callId].producerAudio.id} | kind: ${videoCalls[callId].producerAudio.kind}`); + + videoCalls[callId].producerAudio.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport for this producer closed', callId) + closeCall(callId); + }); + + // Send back to the client the Producer's id + callback && callback({ + id: videoCalls[callId].producerAudio.id + }); + } } catch (error) { console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); } @@ -281,46 +359,86 @@ peers.on('connection', async socket => { */ socket.on('consume', async ({ rtpCapabilities }, callback) => { try { + console.log(`[consume] rtpCapabilities: ${JSON.stringify(rtpCapabilities)}`); + const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); // Check if the router can consume the specified producer - if (videoCalls[callId].router.canConsume({ - producerId: videoCalls[callId].producer.id, - rtpCapabilities - })) { + if ( + videoCalls[callId].router.canConsume({ + producerId: videoCalls[callId].producerVideo.id, + rtpCapabilities + }) && + videoCalls[callId].router.canConsume({ + producerId: videoCalls[callId].producerAudio.id, + rtpCapabilities + }) + ) { console.log('[consume] Can consume', callId); // Transport can now consume and return a consumer - videoCalls[callId].consumer = await videoCalls[callId].consumerTransport.consume({ - producerId: videoCalls[callId].producer.id, + videoCalls[callId].consumerVideo = await videoCalls[callId].consumerTransport.consume({ + producerId: videoCalls[callId].producerVideo.id, rtpCapabilities, paused: true, }); // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose - videoCalls[callId].consumer.on('transportclose', () => { + videoCalls[callId].consumerVideo.on('transportclose', () => { const callId = socketDetails[socket.id]; console.log('transport close from consumer', callId); closeCall(callId); }); // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose - videoCalls[callId].consumer.on('producerclose', () => { + videoCalls[callId].consumerVideo.on('producerclose', () => { const callId = socketDetails[socket.id]; console.log('producer of consumer closed', callId); closeCall(callId); }); + videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ + producerId: videoCalls[callId].producerAudio.id, + rtpCapabilities, + paused: true, + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose + videoCalls[callId].consumerAudio.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport close from consumer', callId); + closeCall(callId); + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose + videoCalls[callId].consumerAudio.on('producerclose', () => { + const callId = socketDetails[socket.id]; + console.log('producer of consumer closed', callId); + closeCall(callId); + }); + + console.log('🟠 videoCalls[callId].consumerVideo', videoCalls[callId].consumerVideo); + console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); + // From the consumer extract the following params to send back to the Client - const params = { - id: videoCalls[callId].consumer.id, - producerId: videoCalls[callId].producer.id, - kind: videoCalls[callId].consumer.kind, - rtpParameters: videoCalls[callId].consumer.rtpParameters, + const videoParams = { + id: videoCalls[callId].consumerVideo.id, + producerId: videoCalls[callId].producerVideo.id, + kind: 'video', + rtpParameters: videoCalls[callId].consumerVideo.rtpParameters, }; + const audioParams = { + id: videoCalls[callId].consumerAudio.id, + producerId: videoCalls[callId].producerAudio.id, + kind: 'audio', + rtpParameters: videoCalls[callId].consumerAudio.rtpParameters, + }; + + console.log('[consume] videoParams', videoParams); + console.log('[consume] audioParams', audioParams); // Send the parameters to the client - callback({ params }); + callback({ videoParams, audioParams }); } else { console.log(`[canConsume] Can't consume | callId ${callId}`); callback(null); @@ -339,7 +457,7 @@ peers.on('connection', async socket => { try { const callId = socketDetails[socket.id]; console.log(`[consumer-resume] callId ${callId}`) - await videoCalls[callId].consumer.resume(); + await videoCalls[callId].consumerVideo.resume(); } catch (error) { console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); } @@ -393,6 +511,7 @@ const createWebRtcTransportLayer = async (callId, callback) => { dtlsParameters: transport.dtlsParameters, }; + console.log('[createWebRtcTransportLayer] callback params', params); // Send back to the client the params callback({ params }); diff --git a/public/bundle.js b/public/bundle.js index 0b0166f..733c840 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -305,17 +305,9 @@ Backoff.prototype.setJitter = function(jitter){ * Copyright (c) 2012 Niklas von Hertzen * Licensed under the MIT license. */ -(function(){ +(function(chars){ "use strict"; - var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - // Use a lookup table to find the index. - var lookup = new Uint8Array(256); - for (var i = 0; i < chars.length; i++) { - lookup[chars.charCodeAt(i)] = i; - } - exports.encode = function(arraybuffer) { var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = ""; @@ -352,10 +344,10 @@ Backoff.prototype.setJitter = function(jitter){ bytes = new Uint8Array(arraybuffer); for (i = 0; i < len; i+=4) { - encoded1 = lookup[base64.charCodeAt(i)]; - encoded2 = lookup[base64.charCodeAt(i+1)]; - encoded3 = lookup[base64.charCodeAt(i+2)]; - encoded4 = lookup[base64.charCodeAt(i+3)]; + encoded1 = chars.indexOf(base64[i]); + encoded2 = chars.indexOf(base64[i+1]); + encoded3 = chars.indexOf(base64[i+2]); + encoded4 = chars.indexOf(base64[i+3]); bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); @@ -364,7 +356,7 @@ Backoff.prototype.setJitter = function(jitter){ return arraybuffer; }; -})(); +})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); },{}],6:[function(require,module,exports){ 'use strict' @@ -2405,7 +2397,7 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":6,"buffer":10,"ieee754":37}],11:[function(require,module,exports){ +},{"base64-js":6,"buffer":10,"ieee754":36}],11:[function(require,module,exports){ /** * Slice reference. */ @@ -2544,6 +2536,13 @@ Emitter.prototype.removeEventListener = function(event, fn){ break; } } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + return this; }; @@ -2557,9 +2556,14 @@ Emitter.prototype.removeEventListener = function(event, fn){ Emitter.prototype.emit = function(event){ this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) + + var args = new Array(arguments.length - 1) , callbacks = this._callbacks['$' + event]; + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) { @@ -2604,399 +2608,17 @@ module.exports = function(a, b){ a.prototype.constructor = a; }; },{}],14:[function(require,module,exports){ -(function (process){(function (){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; +module.exports = (function () { + if (typeof self !== 'undefined') { + return self; + } else if (typeof window !== 'undefined') { + return window; + } else { + return Function('return this')(); // eslint-disable-line no-new-func } +})(); - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } - - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - -}).call(this)}).call(this,require('_process')) -},{"./debug":15,"_process":78}],15:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - exports.names = []; - exports.skips = []; - - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":75}],16:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ module.exports = require('./socket'); @@ -3008,8 +2630,7 @@ module.exports = require('./socket'); */ module.exports.parser = require('engine.io-parser'); -},{"./socket":17,"engine.io-parser":27}],17:[function(require,module,exports){ -(function (global){(function (){ +},{"./socket":16,"engine.io-parser":26}],16:[function(require,module,exports){ /** * Module dependencies. */ @@ -3057,7 +2678,7 @@ function Socket (uri, opts) { } this.secure = null != opts.secure ? opts.secure - : (global.location && 'https:' === location.protocol); + : (typeof location !== 'undefined' && 'https:' === location.protocol); if (opts.hostname && !opts.port) { // if no port is specified manually, use the protocol default @@ -3066,8 +2687,8 @@ function Socket (uri, opts) { this.agent = opts.agent || false; this.hostname = opts.hostname || - (global.location ? location.hostname : 'localhost'); - this.port = opts.port || (global.location && location.port + (typeof location !== 'undefined' ? location.hostname : 'localhost'); + this.port = opts.port || (typeof location !== 'undefined' && location.port ? location.port : (this.secure ? 443 : 80)); this.query = opts.query || {}; @@ -3078,6 +2699,7 @@ function Socket (uri, opts) { this.jsonp = false !== opts.jsonp; this.forceBase64 = !!opts.forceBase64; this.enablesXDR = !!opts.enablesXDR; + this.withCredentials = false !== opts.withCredentials; this.timestampParam = opts.timestampParam || 't'; this.timestampRequests = opts.timestampRequests; this.transports = opts.transports || ['polling', 'websocket']; @@ -3097,18 +2719,20 @@ function Socket (uri, opts) { } // SSL options for Node.js client - this.pfx = opts.pfx || null; - this.key = opts.key || null; - this.passphrase = opts.passphrase || null; - this.cert = opts.cert || null; - this.ca = opts.ca || null; - this.ciphers = opts.ciphers || null; + this.pfx = opts.pfx || undefined; + this.key = opts.key || undefined; + this.passphrase = opts.passphrase || undefined; + this.cert = opts.cert || undefined; + this.ca = opts.ca || undefined; + this.ciphers = opts.ciphers || undefined; this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized; this.forceNode = !!opts.forceNode; - // other options for Node.js client - var freeGlobal = typeof global === 'object' && global; - if (freeGlobal.global === freeGlobal) { + // detect ReactNative environment + this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative'); + + // other options for Node.js or ReactNative client + if (typeof self === 'undefined' || this.isReactNative) { if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) { this.extraHeaders = opts.extraHeaders; } @@ -3193,6 +2817,7 @@ Socket.prototype.createTransport = function (name) { jsonp: options.jsonp || this.jsonp, forceBase64: options.forceBase64 || this.forceBase64, enablesXDR: options.enablesXDR || this.enablesXDR, + withCredentials: options.withCredentials || this.withCredentials, timestampRequests: options.timestampRequests || this.timestampRequests, timestampParam: options.timestampParam || this.timestampParam, policyPort: options.policyPort || this.policyPort, @@ -3208,7 +2833,8 @@ Socket.prototype.createTransport = function (name) { forceNode: options.forceNode || this.forceNode, localAddress: options.localAddress || this.localAddress, requestTimeout: options.requestTimeout || this.requestTimeout, - protocols: options.protocols || void (0) + protocols: options.protocols || void (0), + isReactNative: this.isReactNative }); return transport; @@ -3754,8 +3380,7 @@ Socket.prototype.filterUpgrades = function (upgrades) { return filteredUpgrades; }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./transport":18,"./transports/index":19,"component-emitter":12,"debug":25,"engine.io-parser":27,"indexof":38,"parseqs":76,"parseuri":77}],18:[function(require,module,exports){ +},{"./transport":17,"./transports/index":18,"component-emitter":12,"debug":24,"engine.io-parser":26,"indexof":37,"parseqs":75,"parseuri":76}],17:[function(require,module,exports){ /** * Module dependencies. */ @@ -3788,6 +3413,7 @@ function Transport (opts) { this.agent = opts.agent || false; this.socket = opts.socket; this.enablesXDR = opts.enablesXDR; + this.withCredentials = opts.withCredentials; // SSL options for Node.js client this.pfx = opts.pfx; @@ -3799,6 +3425,9 @@ function Transport (opts) { this.rejectUnauthorized = opts.rejectUnauthorized; this.forceNode = opts.forceNode; + // results of ReactNative environment detection + this.isReactNative = opts.isReactNative; + // other options for Node.js client this.extraHeaders = opts.extraHeaders; this.localAddress = opts.localAddress; @@ -3914,13 +3543,12 @@ Transport.prototype.onClose = function () { this.emit('close'); }; -},{"component-emitter":12,"engine.io-parser":27}],19:[function(require,module,exports){ -(function (global){(function (){ +},{"component-emitter":12,"engine.io-parser":26}],18:[function(require,module,exports){ /** * Module dependencies */ -var XMLHttpRequest = require('xmlhttprequest-ssl'); +var XMLHttpRequest = require('./xmlhttprequest'); var XHR = require('./polling-xhr'); var JSONP = require('./polling-jsonp'); var websocket = require('./websocket'); @@ -3945,7 +3573,7 @@ function polling (opts) { var xs = false; var jsonp = false !== opts.jsonp; - if (global.location) { + if (typeof location !== 'undefined') { var isSSL = 'https:' === location.protocol; var port = location.port; @@ -3970,16 +3598,14 @@ function polling (opts) { } } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polling-jsonp":20,"./polling-xhr":21,"./websocket":23,"xmlhttprequest-ssl":24}],20:[function(require,module,exports){ -(function (global){(function (){ - +},{"./polling-jsonp":19,"./polling-xhr":20,"./websocket":22,"./xmlhttprequest":23}],19:[function(require,module,exports){ /** * Module requirements. */ var Polling = require('./polling'); var inherit = require('component-inherit'); +var globalThis = require('../globalThis'); /** * Module exports. @@ -4022,8 +3648,7 @@ function JSONPPolling (opts) { // we do this here (lazily) to avoid unneeded global pollution if (!callbacks) { // we need to consider multiple engines in the same page - if (!global.___eio) global.___eio = []; - callbacks = global.___eio; + callbacks = globalThis.___eio = (globalThis.___eio || []); } // callback identifier @@ -4039,8 +3664,8 @@ function JSONPPolling (opts) { this.query.j = this.index; // prevent spurious errors from being emitted when the window is unloaded - if (global.document && global.addEventListener) { - global.addEventListener('beforeunload', function () { + if (typeof addEventListener === 'function') { + addEventListener('beforeunload', function () { if (self.script) self.script.onerror = empty; }, false); } @@ -4205,18 +3830,19 @@ JSONPPolling.prototype.doWrite = function (data, fn) { } }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polling":22,"component-inherit":13}],21:[function(require,module,exports){ -(function (global){(function (){ +},{"../globalThis":14,"./polling":21,"component-inherit":13}],20:[function(require,module,exports){ +/* global attachEvent */ + /** * Module requirements. */ -var XMLHttpRequest = require('xmlhttprequest-ssl'); +var XMLHttpRequest = require('./xmlhttprequest'); var Polling = require('./polling'); var Emitter = require('component-emitter'); var inherit = require('component-inherit'); var debug = require('debug')('engine.io-client:polling-xhr'); +var globalThis = require('../globalThis'); /** * Module exports. @@ -4243,7 +3869,7 @@ function XHR (opts) { this.requestTimeout = opts.requestTimeout; this.extraHeaders = opts.extraHeaders; - if (global.location) { + if (typeof location !== 'undefined') { var isSSL = 'https:' === location.protocol; var port = location.port; @@ -4252,7 +3878,7 @@ function XHR (opts) { port = isSSL ? 443 : 80; } - this.xd = opts.hostname !== global.location.hostname || + this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) || port !== opts.port; this.xs = opts.secure !== isSSL; } @@ -4285,6 +3911,7 @@ XHR.prototype.request = function (opts) { opts.agent = this.agent || false; opts.supportsBinary = this.supportsBinary; opts.enablesXDR = this.enablesXDR; + opts.withCredentials = this.withCredentials; // SSL options for Node.js client opts.pfx = this.pfx; @@ -4358,6 +3985,7 @@ function Request (opts) { this.isBinary = opts.isBinary; this.supportsBinary = opts.supportsBinary; this.enablesXDR = opts.enablesXDR; + this.withCredentials = opts.withCredentials; this.requestTimeout = opts.requestTimeout; // SSL options for Node.js client @@ -4432,7 +4060,7 @@ Request.prototype.create = function () { // ie6 check if ('withCredentials' in xhr) { - xhr.withCredentials = true; + xhr.withCredentials = this.withCredentials; } if (this.requestTimeout) { @@ -4451,7 +4079,7 @@ Request.prototype.create = function () { if (xhr.readyState === 2) { try { var contentType = xhr.getResponseHeader('Content-Type'); - if (self.supportsBinary && contentType === 'application/octet-stream') { + if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') { xhr.responseType = 'arraybuffer'; } } catch (e) {} @@ -4463,7 +4091,7 @@ Request.prototype.create = function () { // make sure the `error` event handler that's user-set // does not throw in the same tick and gets caught here setTimeout(function () { - self.onError(xhr.status); + self.onError(typeof xhr.status === 'number' ? xhr.status : 0); }, 0); } }; @@ -4481,7 +4109,7 @@ Request.prototype.create = function () { return; } - if (global.document) { + if (typeof document !== 'undefined') { this.index = Request.requestsCount++; Request.requests[this.index] = this; } @@ -4543,7 +4171,7 @@ Request.prototype.cleanup = function (fromError) { } catch (e) {} } - if (global.document) { + if (typeof document !== 'undefined') { delete Request.requests[this.index]; } @@ -4563,7 +4191,7 @@ Request.prototype.onLoad = function () { try { contentType = this.xhr.getResponseHeader('Content-Type'); } catch (e) {} - if (contentType === 'application/octet-stream') { + if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') { data = this.xhr.response || this.xhr.responseText; } else { data = this.xhr.responseText; @@ -4583,7 +4211,7 @@ Request.prototype.onLoad = function () { */ Request.prototype.hasXDR = function () { - return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR; + return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR; }; /** @@ -4605,11 +4233,12 @@ Request.prototype.abort = function () { Request.requestsCount = 0; Request.requests = {}; -if (global.document) { - if (global.attachEvent) { - global.attachEvent('onunload', unloadHandler); - } else if (global.addEventListener) { - global.addEventListener('beforeunload', unloadHandler, false); +if (typeof document !== 'undefined') { + if (typeof attachEvent === 'function') { + attachEvent('onunload', unloadHandler); + } else if (typeof addEventListener === 'function') { + var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload'; + addEventListener(terminationEvent, unloadHandler, false); } } @@ -4621,8 +4250,7 @@ function unloadHandler () { } } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./polling":22,"component-emitter":12,"component-inherit":13,"debug":25,"xmlhttprequest-ssl":24}],22:[function(require,module,exports){ +},{"../globalThis":14,"./polling":21,"./xmlhttprequest":23,"component-emitter":12,"component-inherit":13,"debug":24}],21:[function(require,module,exports){ /** * Module dependencies. */ @@ -4645,7 +4273,7 @@ module.exports = Polling; */ var hasXHR2 = (function () { - var XMLHttpRequest = require('xmlhttprequest-ssl'); + var XMLHttpRequest = require('./xmlhttprequest'); var xhr = new XMLHttpRequest({ xdomain: false }); return null != xhr.responseType; })(); @@ -4755,7 +4383,7 @@ Polling.prototype.onData = function (data) { debug('polling got data %s', data); var callback = function (packet, index, total) { // if its the first message we consider the transport open - if ('opening' === self.readyState) { + if ('opening' === self.readyState && packet.type === 'open') { self.onOpen(); } @@ -4869,8 +4497,8 @@ Polling.prototype.uri = function () { return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query; }; -},{"../transport":18,"component-inherit":13,"debug":25,"engine.io-parser":27,"parseqs":76,"xmlhttprequest-ssl":24,"yeast":94}],23:[function(require,module,exports){ -(function (global){(function (){ +},{"../transport":17,"./xmlhttprequest":23,"component-inherit":13,"debug":24,"engine.io-parser":26,"parseqs":75,"yeast":93}],22:[function(require,module,exports){ +(function (Buffer){(function (){ /** * Module dependencies. */ @@ -4881,8 +4509,15 @@ var parseqs = require('parseqs'); var inherit = require('component-inherit'); var yeast = require('yeast'); var debug = require('debug')('engine.io-client:websocket'); -var BrowserWebSocket = global.WebSocket || global.MozWebSocket; -var NodeWebSocket; + +var BrowserWebSocket, NodeWebSocket; + +if (typeof WebSocket !== 'undefined') { + BrowserWebSocket = WebSocket; +} else if (typeof self !== 'undefined') { + BrowserWebSocket = self.WebSocket || self.MozWebSocket; +} + if (typeof window === 'undefined') { try { NodeWebSocket = require('ws'); @@ -4895,10 +4530,7 @@ if (typeof window === 'undefined') { * interface exposed by `ws` for Node-like environment. */ -var WebSocket = BrowserWebSocket; -if (!WebSocket && typeof window === 'undefined') { - WebSocket = NodeWebSocket; -} +var WebSocketImpl = BrowserWebSocket || NodeWebSocket; /** * Module exports. @@ -4922,7 +4554,7 @@ function WS (opts) { this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode; this.protocols = opts.protocols; if (!this.usingBrowserWebSocket) { - WebSocket = NodeWebSocket; + WebSocketImpl = NodeWebSocket; } Transport.call(this, opts); } @@ -4961,19 +4593,23 @@ WS.prototype.doOpen = function () { var uri = this.uri(); var protocols = this.protocols; - var opts = { - agent: this.agent, - perMessageDeflate: this.perMessageDeflate - }; - // SSL options for Node.js client - opts.pfx = this.pfx; - opts.key = this.key; - opts.passphrase = this.passphrase; - opts.cert = this.cert; - opts.ca = this.ca; - opts.ciphers = this.ciphers; - opts.rejectUnauthorized = this.rejectUnauthorized; + var opts = {}; + + if (!this.isReactNative) { + opts.agent = this.agent; + opts.perMessageDeflate = this.perMessageDeflate; + + // SSL options for Node.js client + opts.pfx = this.pfx; + opts.key = this.key; + opts.passphrase = this.passphrase; + opts.cert = this.cert; + opts.ca = this.ca; + opts.ciphers = this.ciphers; + opts.rejectUnauthorized = this.rejectUnauthorized; + } + if (this.extraHeaders) { opts.headers = this.extraHeaders; } @@ -4982,7 +4618,12 @@ WS.prototype.doOpen = function () { } try { - this.ws = this.usingBrowserWebSocket ? (protocols ? new WebSocket(uri, protocols) : new WebSocket(uri)) : new WebSocket(uri, protocols, opts); + this.ws = + this.usingBrowserWebSocket && !this.isReactNative + ? protocols + ? new WebSocketImpl(uri, protocols) + : new WebSocketImpl(uri) + : new WebSocketImpl(uri, protocols, opts); } catch (err) { return this.emit('error', err); } @@ -5049,7 +4690,7 @@ WS.prototype.write = function (packets) { } if (self.perMessageDeflate) { - var len = 'string' === typeof data ? global.Buffer.byteLength(data) : data.length; + var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length; if (len < self.perMessageDeflate.threshold) { opts.compress = false; } @@ -5155,15 +4796,15 @@ WS.prototype.uri = function () { */ WS.prototype.check = function () { - return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name); + return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name); }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../transport":18,"component-inherit":13,"debug":25,"engine.io-parser":27,"parseqs":76,"ws":9,"yeast":94}],24:[function(require,module,exports){ -(function (global){(function (){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"../transport":17,"buffer":10,"component-inherit":13,"debug":24,"engine.io-parser":26,"parseqs":75,"ws":9,"yeast":93}],23:[function(require,module,exports){ // browser shim for xmlhttprequest module var hasCORS = require('has-cors'); +var globalThis = require('../globalThis'); module.exports = function (opts) { var xdomain = opts.xdomain; @@ -5194,13 +4835,12 @@ module.exports = function (opts) { if (!xdomain) { try { - return new global[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); + return new globalThis[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); } catch (e) { } } }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"has-cors":36}],25:[function(require,module,exports){ +},{"../globalThis":14,"has-cors":35}],24:[function(require,module,exports){ (function (process){(function (){ /** * This is the web browser implementation of `debug()`. @@ -5399,7 +5039,7 @@ function localstorage() { } }).call(this)}).call(this,require('_process')) -},{"./debug":26,"_process":78}],26:[function(require,module,exports){ +},{"./debug":25,"_process":77}],25:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -5626,7 +5266,7 @@ function coerce(val) { return val; } -},{"ms":75}],27:[function(require,module,exports){ +},{"ms":74}],26:[function(require,module,exports){ /** * Module dependencies. */ @@ -6233,7 +5873,7 @@ exports.decodePayloadAsBinary = function (data, binaryType, callback) { }); }; -},{"./keys":28,"./utf8":29,"after":1,"arraybuffer.slice":2,"base64-arraybuffer":5,"blob":7,"has-binary2":35}],28:[function(require,module,exports){ +},{"./keys":27,"./utf8":28,"after":1,"arraybuffer.slice":2,"base64-arraybuffer":5,"blob":7,"has-binary2":34}],27:[function(require,module,exports){ /** * Gets the keys for an object. @@ -6254,7 +5894,7 @@ module.exports = Object.keys || function keys (obj){ return arr; }; -},{}],29:[function(require,module,exports){ +},{}],28:[function(require,module,exports){ /*! https://mths.be/utf8js v2.1.2 by @mathias */ var stringFromCharCode = String.fromCharCode; @@ -6466,7 +6106,7 @@ module.exports = { decode: utf8decode }; -},{}],30:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -6965,7 +6605,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) { } } -},{}],31:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ const debug = require('debug')('h264-profile-level-id'); /* eslint-disable no-console */ @@ -7420,7 +7060,7 @@ function isLevelAsymmetryAllowed(params = {}) ); } -},{"debug":32}],32:[function(require,module,exports){ +},{"debug":31}],31:[function(require,module,exports){ (function (process){(function (){ /* eslint-env browser */ @@ -7693,7 +7333,7 @@ formatters.j = function (v) { }; }).call(this)}).call(this,require('_process')) -},{"./common":33,"_process":78}],33:[function(require,module,exports){ +},{"./common":32,"_process":77}],32:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -7969,7 +7609,7 @@ function setup(env) { module.exports = setup; -},{"ms":34}],34:[function(require,module,exports){ +},{"ms":33}],33:[function(require,module,exports){ /** * Helpers. */ @@ -8133,7 +7773,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],35:[function(require,module,exports){ +},{}],34:[function(require,module,exports){ (function (Buffer){(function (){ /* global Blob File */ @@ -8201,7 +7841,7 @@ function hasBinary (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":10,"isarray":39}],36:[function(require,module,exports){ +},{"buffer":10,"isarray":38}],35:[function(require,module,exports){ /** * Module exports. @@ -8220,7 +7860,7 @@ try { module.exports = false; } -},{}],37:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -8307,7 +7947,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],38:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ var indexOf = [].indexOf; @@ -8318,14 +7958,14 @@ module.exports = function(arr, obj){ } return -1; }; -},{}],39:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],40:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Consumer = void 0; @@ -8507,7 +8147,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.Consumer = Consumer; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./errors":50}],41:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./errors":49}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataConsumer = void 0; @@ -8663,7 +8303,7 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.DataConsumer = DataConsumer; -},{"./EnhancedEventEmitter":44,"./Logger":45}],42:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataProducer = void 0; @@ -8835,7 +8475,7 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.DataProducer = DataProducer; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./errors":50}],43:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./errors":49}],42:[function(require,module,exports){ "use strict"; /* global RTCRtpTransceiver */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { @@ -9230,7 +8870,7 @@ class Device { } exports.Device = Device; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./Transport":49,"./errors":50,"./handlers/Chrome55":51,"./handlers/Chrome67":52,"./handlers/Chrome70":53,"./handlers/Chrome74":54,"./handlers/Edge11":55,"./handlers/Firefox60":56,"./handlers/ReactNative":58,"./handlers/Safari11":59,"./handlers/Safari12":60,"./ortc":68,"./utils":71,"bowser":8}],44:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./Transport":48,"./errors":49,"./handlers/Chrome55":50,"./handlers/Chrome67":51,"./handlers/Chrome70":52,"./handlers/Chrome74":53,"./handlers/Edge11":54,"./handlers/Firefox60":55,"./handlers/ReactNative":57,"./handlers/Safari11":58,"./handlers/Safari12":59,"./ortc":67,"./utils":70,"bowser":8}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EnhancedEventEmitter = void 0; @@ -9302,7 +8942,7 @@ class EnhancedEventEmitter extends events_1.EventEmitter { } exports.EnhancedEventEmitter = EnhancedEventEmitter; -},{"./Logger":45,"events":30}],45:[function(require,module,exports){ +},{"./Logger":44,"events":29}],44:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -9341,7 +8981,7 @@ class Logger { } exports.Logger = Logger; -},{"debug":72}],46:[function(require,module,exports){ +},{"debug":71}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Producer = void 0; @@ -9619,7 +9259,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.Producer = Producer; -},{"./EnhancedEventEmitter":44,"./Logger":45,"./errors":50}],47:[function(require,module,exports){ +},{"./EnhancedEventEmitter":43,"./Logger":44,"./errors":49}],46:[function(require,module,exports){ "use strict"; /** * The RTP capabilities define what mediasoup or an endpoint can receive at @@ -9627,11 +9267,11 @@ exports.Producer = Producer; */ Object.defineProperty(exports, "__esModule", { value: true }); -},{}],48:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -},{}],49:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -10315,7 +9955,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.Transport = Transport; -},{"./Consumer":40,"./DataConsumer":41,"./DataProducer":42,"./EnhancedEventEmitter":44,"./Logger":45,"./Producer":46,"./errors":50,"./ortc":68,"./utils":71,"awaitqueue":3}],50:[function(require,module,exports){ +},{"./Consumer":39,"./DataConsumer":40,"./DataProducer":41,"./EnhancedEventEmitter":43,"./Logger":44,"./Producer":45,"./errors":49,"./ortc":67,"./utils":70,"awaitqueue":3}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvalidStateError = exports.UnsupportedError = void 0; @@ -10356,7 +9996,7 @@ class InvalidStateError extends Error { } exports.InvalidStateError = InvalidStateError; -},{}],51:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -10877,7 +10517,7 @@ class Chrome55 extends HandlerInterface_1.HandlerInterface { } exports.Chrome55 = Chrome55; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],52:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],51:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -11445,7 +11085,7 @@ class Chrome67 extends HandlerInterface_1.HandlerInterface { } exports.Chrome67 = Chrome67; -},{"../Logger":45,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],53:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],52:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -12020,7 +11660,7 @@ class Chrome70 extends HandlerInterface_1.HandlerInterface { } exports.Chrome70 = Chrome70; -},{"../Logger":45,"../ortc":68,"../scalabilityModes":69,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],54:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../scalabilityModes":68,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],53:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -12609,7 +12249,7 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface { } exports.Chrome74 = Chrome74; -},{"../Logger":45,"../ortc":68,"../scalabilityModes":69,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],55:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../scalabilityModes":68,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],54:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -13032,7 +12672,7 @@ class Edge11 extends HandlerInterface_1.HandlerInterface { } exports.Edge11 = Edge11; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./ortc/edgeUtils":61}],56:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./ortc/edgeUtils":60}],55:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -13621,7 +13261,7 @@ class Firefox60 extends HandlerInterface_1.HandlerInterface { } exports.Firefox60 = Firefox60; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],57:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HandlerInterface = void 0; @@ -13633,7 +13273,7 @@ class HandlerInterface extends EnhancedEventEmitter_1.EnhancedEventEmitter { } exports.HandlerInterface = HandlerInterface; -},{"../EnhancedEventEmitter":44}],58:[function(require,module,exports){ +},{"../EnhancedEventEmitter":43}],57:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -14168,7 +13808,7 @@ class ReactNative extends HandlerInterface_1.HandlerInterface { } exports.ReactNative = ReactNative; -},{"../Logger":45,"../errors":50,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],59:[function(require,module,exports){ +},{"../Logger":44,"../errors":49,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],58:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -14728,7 +14368,7 @@ class Safari11 extends HandlerInterface_1.HandlerInterface { } exports.Safari11 = Safari11; -},{"../Logger":45,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/planBUtils":65,"sdp-transform":80}],60:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/planBUtils":64,"sdp-transform":79}],59:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -15285,7 +14925,7 @@ class Safari12 extends HandlerInterface_1.HandlerInterface { } exports.Safari12 = Safari12; -},{"../Logger":45,"../ortc":68,"../utils":71,"./HandlerInterface":57,"./sdp/RemoteSdp":63,"./sdp/commonUtils":64,"./sdp/unifiedPlanUtils":66,"sdp-transform":80}],61:[function(require,module,exports){ +},{"../Logger":44,"../ortc":67,"../utils":70,"./HandlerInterface":56,"./sdp/RemoteSdp":62,"./sdp/commonUtils":63,"./sdp/unifiedPlanUtils":65,"sdp-transform":79}],60:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -15369,7 +15009,7 @@ function mangleRtpParameters(rtpParameters) { } exports.mangleRtpParameters = mangleRtpParameters; -},{"../../utils":71}],62:[function(require,module,exports){ +},{"../../utils":70}],61:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -15903,7 +15543,7 @@ function getCodecName(codec) { return mimeTypeMatch[2]; } -},{"../../utils":71}],63:[function(require,module,exports){ +},{"../../utils":70}],62:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -16184,7 +15824,7 @@ class RemoteSdp { } exports.RemoteSdp = RemoteSdp; -},{"../../Logger":45,"./MediaSection":62,"sdp-transform":80}],64:[function(require,module,exports){ +},{"../../Logger":44,"./MediaSection":61,"sdp-transform":79}],63:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -16380,7 +16020,7 @@ function applyCodecParameters({ offerRtpParameters, answerMediaObject }) { } exports.applyCodecParameters = applyCodecParameters; -},{"sdp-transform":80}],65:[function(require,module,exports){ +},{"sdp-transform":79}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLegacySimulcast = exports.getRtpEncodings = void 0; @@ -16526,7 +16166,7 @@ function addLegacySimulcast({ offerMediaObject, track, numStreams }) { } exports.addLegacySimulcast = addLegacySimulcast; -},{}],66:[function(require,module,exports){ +},{}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLegacySimulcast = exports.getRtpEncodings = void 0; @@ -16651,7 +16291,7 @@ function addLegacySimulcast({ offerMediaObject, numStreams }) { } exports.addLegacySimulcast = addLegacySimulcast; -},{}],67:[function(require,module,exports){ +},{}],66:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -16698,7 +16338,7 @@ exports.version = '3.6.54'; var scalabilityModes_1 = require("./scalabilityModes"); Object.defineProperty(exports, "parseScalabilityMode", { enumerable: true, get: function () { return scalabilityModes_1.parse; } }); -},{"./Device":43,"./scalabilityModes":69,"./types":70,"debug":72}],68:[function(require,module,exports){ +},{"./Device":42,"./scalabilityModes":68,"./types":69,"debug":71}],67:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -17545,7 +17185,7 @@ function reduceRtcpFeedback(codecA, codecB) { return reducedRtcpFeedback; } -},{"./utils":71,"h264-profile-level-id":31}],69:[function(require,module,exports){ +},{"./utils":70,"h264-profile-level-id":30}],68:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = void 0; @@ -17567,7 +17207,7 @@ function parse(scalabilityMode) { } exports.parse = parse; -},{}],70:[function(require,module,exports){ +},{}],69:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -17595,7 +17235,7 @@ __exportStar(require("./SctpParameters"), exports); __exportStar(require("./handlers/HandlerInterface"), exports); __exportStar(require("./errors"), exports); -},{"./Consumer":40,"./DataConsumer":41,"./DataProducer":42,"./Device":43,"./Producer":46,"./RtpParameters":47,"./SctpParameters":48,"./Transport":49,"./errors":50,"./handlers/HandlerInterface":57}],71:[function(require,module,exports){ +},{"./Consumer":39,"./DataConsumer":40,"./DataProducer":41,"./Device":42,"./Producer":45,"./RtpParameters":46,"./SctpParameters":47,"./Transport":48,"./errors":49,"./handlers/HandlerInterface":56}],70:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateRandomNumber = exports.clone = void 0; @@ -17616,13 +17256,13 @@ function generateRandomNumber() { } exports.generateRandomNumber = generateRandomNumber; -},{}],72:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./common":72,"_process":77,"dup":31}],72:[function(require,module,exports){ arguments[4][32][0].apply(exports,arguments) -},{"./common":73,"_process":78,"dup":32}],73:[function(require,module,exports){ +},{"dup":32,"ms":73}],73:[function(require,module,exports){ arguments[4][33][0].apply(exports,arguments) -},{"dup":33,"ms":74}],74:[function(require,module,exports){ -arguments[4][34][0].apply(exports,arguments) -},{"dup":34}],75:[function(require,module,exports){ +},{"dup":33}],74:[function(require,module,exports){ /** * Helpers. */ @@ -17776,87 +17416,116 @@ function plural(ms, n, name) { return Math.ceil(ms / n) + ' ' + name + 's'; } +},{}],75:[function(require,module,exports){ +/** + * Compiles a querystring + * Returns string representation of the object + * + * @param {Object} + * @api private + */ + +exports.encode = function (obj) { + var str = ''; + + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + if (str.length) str += '&'; + str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); + } + } + + return str; +}; + +/** + * Parses a simple querystring into an object + * + * @param {String} qs + * @api private + */ + +exports.decode = function(qs){ + var qry = {}; + var pairs = qs.split('&'); + for (var i = 0, l = pairs.length; i < l; i++) { + var pair = pairs[i].split('='); + qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + return qry; +}; + },{}],76:[function(require,module,exports){ -/** - * Compiles a querystring - * Returns string representation of the object - * - * @param {Object} - * @api private - */ - -exports.encode = function (obj) { - var str = ''; - - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - if (str.length) str += '&'; - str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); - } - } - - return str; -}; - -/** - * Parses a simple querystring into an object - * - * @param {String} qs - * @api private - */ - -exports.decode = function(qs){ - var qry = {}; - var pairs = qs.split('&'); - for (var i = 0, l = pairs.length; i < l; i++) { - var pair = pairs[i].split('='); - qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); - } - return qry; -}; +/** + * Parses an URI + * + * @author Steven Levithan (MIT license) + * @api private + */ + +var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; + +var parts = [ + 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' +]; + +module.exports = function parseuri(str) { + var src = str, + b = str.indexOf('['), + e = str.indexOf(']'); + + if (b != -1 && e != -1) { + str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + } + + var m = re.exec(str || ''), + uri = {}, + i = 14; + + while (i--) { + uri[parts[i]] = m[i] || ''; + } + + if (b != -1 && e != -1) { + uri.source = src; + uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); + uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); + uri.ipv6uri = true; + } + + uri.pathNames = pathNames(uri, uri['path']); + uri.queryKey = queryKey(uri, uri['query']); + + return uri; +}; + +function pathNames(obj, path) { + var regx = /\/{2,9}/g, + names = path.replace(regx, "/").split("/"); + + if (path.substr(0, 1) == '/' || path.length === 0) { + names.splice(0, 1); + } + if (path.substr(path.length - 1, 1) == '/') { + names.splice(names.length - 1, 1); + } + + return names; +} + +function queryKey(uri, query) { + var data = {}; + + query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { + if ($1) { + data[$1] = $2; + } + }); + + return data; +} },{}],77:[function(require,module,exports){ -/** - * Parses an URI - * - * @author Steven Levithan (MIT license) - * @api private - */ - -var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; - -var parts = [ - 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -]; - -module.exports = function parseuri(str) { - var src = str, - b = str.indexOf('['), - e = str.indexOf(']'); - - if (b != -1 && e != -1) { - str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); - } - - var m = re.exec(str || ''), - uri = {}, - i = 14; - - while (i--) { - uri[parts[i]] = m[i] || ''; - } - - if (b != -1 && e != -1) { - uri.source = src; - uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); - uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); - uri.ipv6uri = true; - } - - return uri; -}; - -},{}],78:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -18042,7 +17711,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],79:[function(require,module,exports){ +},{}],78:[function(require,module,exports){ var grammar = module.exports = { v: [{ name: 'version', @@ -18538,7 +18207,7 @@ Object.keys(grammar).forEach(function (key) { }); }); -},{}],80:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ var parser = require('./parser'); var writer = require('./writer'); @@ -18551,7 +18220,7 @@ exports.parseRemoteCandidates = parser.parseRemoteCandidates; exports.parseImageAttributes = parser.parseImageAttributes; exports.parseSimulcastStreamList = parser.parseSimulcastStreamList; -},{"./parser":81,"./writer":82}],81:[function(require,module,exports){ +},{"./parser":80,"./writer":81}],80:[function(require,module,exports){ var toIntIfInt = function (v) { return String(Number(v)) === v ? Number(v) : v; }; @@ -18677,7 +18346,7 @@ exports.parseSimulcastStreamList = function (str) { }); }; -},{"./grammar":79}],82:[function(require,module,exports){ +},{"./grammar":78}],81:[function(require,module,exports){ var grammar = require('./grammar'); // customized util.format - discards excess arguments and can void middle ones @@ -18793,7 +18462,7 @@ module.exports = function (session, opts) { return sdp.join('\r\n') + '\r\n'; }; -},{"./grammar":79}],83:[function(require,module,exports){ +},{"./grammar":78}],82:[function(require,module,exports){ /** * Module dependencies. @@ -18889,7 +18558,7 @@ exports.connect = lookup; exports.Manager = require('./manager'); exports.Socket = require('./socket'); -},{"./manager":84,"./socket":86,"./url":87,"debug":14,"socket.io-parser":89}],84:[function(require,module,exports){ +},{"./manager":83,"./socket":85,"./url":86,"debug":87,"socket.io-parser":90}],83:[function(require,module,exports){ /** * Module dependencies. @@ -19148,6 +18817,10 @@ Manager.prototype.connect = function (fn, opts) { var timeout = this._timeout; debug('connect attempt will timeout after %d', timeout); + if (timeout === 0) { + openSub.destroy(); // prevents a race condition with the 'open' event + } + // set timer var timer = setTimeout(function () { debug('connect attempt timed out after %d', timeout); @@ -19464,7 +19137,7 @@ Manager.prototype.onreconnect = function () { this.emitAll('reconnect', attempt); }; -},{"./on":85,"./socket":86,"backo2":4,"component-bind":11,"component-emitter":12,"debug":14,"engine.io-client":16,"indexof":38,"socket.io-parser":89}],85:[function(require,module,exports){ +},{"./on":84,"./socket":85,"backo2":4,"component-bind":11,"component-emitter":12,"debug":87,"engine.io-client":15,"indexof":37,"socket.io-parser":90}],84:[function(require,module,exports){ /** * Module exports. @@ -19490,7 +19163,7 @@ function on (obj, ev, fn) { }; } -},{}],86:[function(require,module,exports){ +},{}],85:[function(require,module,exports){ /** * Module dependencies. @@ -19503,6 +19176,7 @@ var on = require('./on'); var bind = require('component-bind'); var debug = require('debug')('socket.io-client:socket'); var parseqs = require('parseqs'); +var hasBin = require('has-binary2'); /** * Module exports. @@ -19555,6 +19229,7 @@ function Socket (io, nsp, opts) { this.sendBuffer = []; this.connected = false; this.disconnected = true; + this.flags = {}; if (opts && opts.query) { this.query = opts.query; } @@ -19595,7 +19270,7 @@ Socket.prototype.connect = function () { if (this.connected) return this; this.subEvents(); - this.io.open(); // ensure open + if (!this.io.reconnecting) this.io.open(); // ensure open if ('open' === this.io.readyState) this.onopen(); this.emit('connecting'); return this; @@ -19631,7 +19306,10 @@ Socket.prototype.emit = function (ev) { } var args = toArray(arguments); - var packet = { type: parser.EVENT, data: args }; + var packet = { + type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT, + data: args + }; packet.options = {}; packet.options.compress = !this.flags || false !== this.flags.compress; @@ -19649,7 +19327,7 @@ Socket.prototype.emit = function (ev) { this.sendBuffer.push(packet); } - delete this.flags; + this.flags = {}; return this; }; @@ -19710,7 +19388,10 @@ Socket.prototype.onclose = function (reason) { */ Socket.prototype.onpacket = function (packet) { - if (packet.nsp !== this.nsp) return; + var sameNamespace = packet.nsp === this.nsp; + var rootNamespaceError = packet.type === parser.ERROR && packet.nsp === '/'; + + if (!sameNamespace && !rootNamespaceError) return; switch (packet.type) { case parser.CONNECT: @@ -19783,7 +19464,7 @@ Socket.prototype.ack = function (id) { debug('sending ack %j', args); self.packet({ - type: parser.ACK, + type: hasBin(args) ? parser.BINARY_ACK : parser.ACK, id: id, data: args }); @@ -19817,8 +19498,8 @@ Socket.prototype.onack = function (packet) { Socket.prototype.onconnect = function () { this.connected = true; this.disconnected = false; - this.emit('connect'); this.emitBuffered(); + this.emit('connect'); }; /** @@ -19905,13 +19586,24 @@ Socket.prototype.disconnect = function () { */ Socket.prototype.compress = function (compress) { - this.flags = this.flags || {}; this.flags.compress = compress; return this; }; -},{"./on":85,"component-bind":11,"component-emitter":12,"debug":14,"parseqs":76,"socket.io-parser":89,"to-array":93}],87:[function(require,module,exports){ -(function (global){(function (){ +/** + * Sets the binary flag + * + * @param {Boolean} whether the emitted data contains binary + * @return {Socket} self + * @api public + */ + +Socket.prototype.binary = function (binary) { + this.flags.binary = binary; + return this; +}; + +},{"./on":84,"component-bind":11,"component-emitter":12,"debug":87,"has-binary2":34,"parseqs":75,"socket.io-parser":90,"to-array":92}],86:[function(require,module,exports){ /** * Module dependencies. @@ -19939,7 +19631,7 @@ function url (uri, loc) { var obj = uri; // default to window.location - loc = loc || global.location; + loc = loc || (typeof location !== 'undefined' && location); if (null == uri) uri = loc.protocol + '//' + loc.host; // relative path support @@ -19988,9 +19680,11 @@ function url (uri, loc) { return obj; } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"debug":14,"parseuri":77}],88:[function(require,module,exports){ -(function (global){(function (){ +},{"debug":87,"parseuri":76}],87:[function(require,module,exports){ +arguments[4][24][0].apply(exports,arguments) +},{"./debug":88,"_process":77,"dup":24}],88:[function(require,module,exports){ +arguments[4][25][0].apply(exports,arguments) +},{"dup":25,"ms":74}],89:[function(require,module,exports){ /*global Blob,File*/ /** @@ -20000,8 +19694,8 @@ function url (uri, loc) { var isArray = require('isarray'); var isBuf = require('./is-buffer'); var toString = Object.prototype.toString; -var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]'; -var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]'; +var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]'); +var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]'); /** * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. @@ -20133,8 +19827,7 @@ exports.removeBlobs = function(data, callback) { } }; -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./is-buffer":90,"isarray":39}],89:[function(require,module,exports){ +},{"./is-buffer":91,"isarray":38}],90:[function(require,module,exports){ /** * Module dependencies. @@ -20142,7 +19835,6 @@ exports.removeBlobs = function(data, callback) { var debug = require('debug')('socket.io-parser'); var Emitter = require('component-emitter'); -var hasBin = require('has-binary2'); var binary = require('./binary'); var isArray = require('isarray'); var isBuf = require('./is-buffer'); @@ -20251,6 +19943,8 @@ exports.Decoder = Decoder; function Encoder() {} +var ERROR_PACKET = exports.ERROR + '"encode error"'; + /** * Encode a packet as a single string if non-binary, or as a * buffer sequence, depending on packet type. @@ -20262,16 +19956,11 @@ function Encoder() {} */ Encoder.prototype.encode = function(obj, callback){ - if ((obj.type === exports.EVENT || obj.type === exports.ACK) && hasBin(obj.data)) { - obj.type = obj.type === exports.EVENT ? exports.BINARY_EVENT : exports.BINARY_ACK; - } - debug('encoding packet %j', obj); if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) { encodeAsBinary(obj, callback); - } - else { + } else { var encoding = encodeAsString(obj); callback([encoding]); } @@ -20308,13 +19997,26 @@ function encodeAsString(obj) { // json data if (null != obj.data) { - str += JSON.stringify(obj.data); + var payload = tryStringify(obj.data); + if (payload !== false) { + str += payload; + } else { + return ERROR_PACKET; + } } debug('encoded %j as %s', obj, str); return str; } +function tryStringify(str) { + try { + return JSON.stringify(str); + } catch(e){ + return false; + } +} + /** * Encode packet as 'buffer sequence' by removing blobs, and * deconstructing packet into object with placeholders and @@ -20357,7 +20059,7 @@ function Decoder() { Emitter(Decoder.prototype); /** - * Decodes an ecoded packet string into packet JSON. + * Decodes an encoded packet string into packet JSON. * * @param {String} obj - encoded packet * @return {Object} packet @@ -20378,8 +20080,7 @@ Decoder.prototype.add = function(obj) { } else { // non-binary full packet this.emit('decoded', packet); } - } - else if (isBuf(obj) || obj.base64) { // raw binary data + } else if (isBuf(obj) || obj.base64) { // raw binary data if (!this.reconstructor) { throw new Error('got binary data when not reconstructing a packet'); } else { @@ -20389,8 +20090,7 @@ Decoder.prototype.add = function(obj) { this.emit('decoded', packet); } } - } - else { + } else { throw new Error('Unknown type: ' + obj); } }; @@ -20416,11 +20116,9 @@ function decodeString(str) { // look up attachments if type binary if (exports.BINARY_EVENT === p.type || exports.BINARY_ACK === p.type) { - var buf = ''; - while (str.charAt(++i) !== '-') { - buf += str.charAt(i); - if (i == str.length) break; - } + var start = i + 1; + while (str.charAt(++i) !== '-' && i != str.length) {} + var buf = str.substring(start, i); if (buf != Number(buf) || str.charAt(i) !== '-') { throw new Error('Illegal attachments'); } @@ -20429,13 +20127,13 @@ function decodeString(str) { // look up namespace (if any) if ('/' === str.charAt(i + 1)) { - p.nsp = ''; + var start = i + 1; while (++i) { var c = str.charAt(i); if (',' === c) break; - p.nsp += c; if (i === str.length) break; } + p.nsp = str.substring(start, i); } else { p.nsp = '/'; } @@ -20443,17 +20141,16 @@ function decodeString(str) { // look up id var next = str.charAt(i + 1); if ('' !== next && Number(next) == next) { - p.id = ''; + var start = i + 1; while (++i) { var c = str.charAt(i); if (null == c || Number(c) != c) { --i; break; } - p.id += str.charAt(i); if (i === str.length) break; } - p.id = Number(p.id); + p.id = Number(str.substring(start, i + 1)); } // look up json data @@ -20544,11 +20241,18 @@ function error(msg) { }; } -},{"./binary":88,"./is-buffer":90,"component-emitter":12,"debug":91,"has-binary2":35,"isarray":39}],90:[function(require,module,exports){ -(function (global){(function (){ +},{"./binary":89,"./is-buffer":91,"component-emitter":12,"debug":87,"isarray":38}],91:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = isBuf; +var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function'; +var withNativeArrayBuffer = typeof ArrayBuffer === 'function'; + +var isView = function (obj) { + return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer); +}; + /** * Returns true if obj is a buffer or an arraybuffer. * @@ -20556,16 +20260,12 @@ module.exports = isBuf; */ function isBuf(obj) { - return (global.Buffer && global.Buffer.isBuffer(obj)) || - (global.ArrayBuffer && (obj instanceof ArrayBuffer || ArrayBuffer.isView(obj))); + return (withNativeBuffer && Buffer.isBuffer(obj)) || + (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))); } -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],91:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"./debug":92,"_process":78,"dup":25}],92:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"dup":26,"ms":75}],93:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":10}],92:[function(require,module,exports){ module.exports = toArray function toArray(list, index) { @@ -20580,7 +20280,7 @@ function toArray(list, index) { return array } -},{}],94:[function(require,module,exports){ +},{}],93:[function(require,module,exports){ 'use strict'; var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('') @@ -20650,13 +20350,12 @@ yeast.encode = encode; yeast.decode = decode; module.exports = yeast; -},{}],95:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', - // mediasoupAddress: 'https://video.safemobile.org/mediasoup', - mediasoupAddress: 'http://localhost:3000/mediasoup', + mediasoupAddress: 'https://video.safemobile.org', } -},{}],96:[function(require,module,exports){ +},{}],95:[function(require,module,exports){ const io = require('socket.io-client') const mediasoupClient = require('mediasoup-client') const urlParams = new URLSearchParams(location.search); @@ -20671,141 +20370,192 @@ let callId = parseInt(urlParams.get('callId')) || null; const IS_PRODUCER = urlParams.get('producer') === 'true' ? true : false console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', callId, ' | IS_PRODUCER', IS_PRODUCER) -let socket -hub = io(config.hubAddress) +console.log('🟩 config', config) -const connectToMediasoup = () => { +let socket, hub - socket = io(config.mediasoupAddress, { - reconnection: true, - reconnectionDelay: 1000, - reconnectionDelayMax : 5000, - reconnectionAttempts: Infinity - }) - - socket.on('connection-success', ({ _socketId, existsProducer }) => { - console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) - if (!IS_PRODUCER && existsProducer && consumer === undefined) { - goConnect() - // document.getElementById('btnRecvSendTransport').click(); - } - if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } - }) -} - -if (IS_PRODUCER === true) { - hub.on('connect', async () => { - console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, - }) - ) +setTimeout(() => { + hub = io(config.hubAddress) - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; + const connectToMediasoup = () => { - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } + socket = io(config.mediasoupAddress, { + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 5000, + reconnectionAttempts: Infinity }) - }) + + socket.on('connection-success', ({ _socketId, existsProducer }) => { + console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) + if (!IS_PRODUCER && existsProducer && consumer === undefined) { + goConnect() + // document.getElementById('btnRecvSendTransport').click(); + } + if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } + }) + } + + if (IS_PRODUCER === true) { + hub.on('connect', async () => { + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, + }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } + }) + }) + + hub.on('connect_error', (error) => { + console.log('connect_error', error); + }); + + hub.on('connection', () => { + console.log('connection') + }) + + hub.on('disconnect', () => { + console.log('disconnect') + }) + } else { + connectToMediasoup() + } + +}, 1600); - hub.on('connect_error', (error) => { - console.log('connect_error', error); - }); - - hub.on('connection', () => { - console.log('connection') - }) - - hub.on('disconnect', () => { - console.log('disconnect') - }) -} else { - connectToMediasoup() -} let device let rtpCapabilities let producerTransport let consumerTransport -let producer +let producerVideo +let producerAudio let consumer let originAssetId -// let originAssetName = 'Adi' -// let originAssetTypeName = 'linx' // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -let params = { - // mediasoup params +let videoParams = { encodings: [ - { - rid: 'r0', - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r1', - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r2', - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } ], - // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } + // encodings: [ + // { + // rid: 'r0', + // maxBitrate: 100000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r1', + // maxBitrate: 300000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r2', + // maxBitrate: 900000, + // scalabilityMode: 'S1T3', + // }, + // ], + // // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions + // codecOptions: { + // videoGoogleStartBitrate: 1000 + // } } -const streamSuccess = (stream) => { - console.log('[streamSuccess]'); - localVideo.srcObject = stream - const track = stream.getVideoTracks()[0] - params = { - track, - ...params +let audioParams = { + codecOptions : + { + opusStereo : true, + opusDtx : true } +} + + +const streamSuccess = (stream) => { + console.log('[streamSuccess] device', device); + localVideo.srcObject = stream + console.log('stream', stream); + const videoTrack = stream.getVideoTracks()[0] + const audioTrack = stream.getAudioTracks()[0] + + videoParams = { + track: videoTrack, + // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // codec : 'video/vp9', + ...videoParams + } + + audioParams = { + track: audioTrack, + ...audioParams + } + + console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() + // console.log('[streamSuccess]'); + // localVideo.srcObject = stream + // const track = stream.getVideoTracks()[0] + // videoParams = { + // track, + // ...videoParams + // } + // goConnect() } const getLocalStream = () => { console.log('[getLocalStream]'); navigator.mediaDevices.getUserMedia({ - audio: false, + audio: true, video: { - width: { - min: 640, - max: 1920, - }, - height: { - min: 400, - max: 1080, - } + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + // navigator.mediaDevices.getUserMedia({ + // audio: false, + // video: { + // width: { + // min: 640, + // max: 1920, + // }, + // height: { + // min: 400, + // max: 1080, + // } + // } + // }) .then(streamSuccess) .catch(error => { console.log(error.message) @@ -20826,7 +20576,7 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { - console.log('[createDevice]'); + console.log('[createDevice] 1 device', device); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -20837,7 +20587,8 @@ const createDevice = async () => { }) console.log('Device RTP Capabilities', device.rtpCapabilities) - + console.log('[createDevice] 2 device', device); + // once the device loads, create transport goCreateTransport() @@ -20866,18 +20617,20 @@ const getRtpCapabilities = () => { } const createSendTransport = () => { + console.log('[createSendTransport'); // see server's socket.on('createWebRtcTransport', sender?, ...) // this is a call from Producer, so sender = true - socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => { + socket.emit('createWebRtcTransport', { sender: true, callId }, (value) => { + + console.log(`[createWebRtcTransport] value: ${JSON.stringify(value)}`); + + const params = value.params; // The server sends back params needed // to create Send Transport on the client side if (params.error) { console.log(params.error) return } - - console.log(params) - // creates a new WebRTC Transport to send media // based on the server's producer transport params // https://mediasoup.org/documentation/v3/mediasoup-client/api/#TransportOptions @@ -20903,7 +20656,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log(parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer @@ -20929,21 +20682,45 @@ const createSendTransport = () => { } const connectSendTransport = async () => { + + console.log('[connectSendTransport] producerTransport'); + // we now call produce() to instruct the producer transport // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - producer = await producerTransport.produce(params) - - producer.on('trackended', () => { + + console.log('videoParams', videoParams); + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { console.log('track ended') // close video track - }) + }) - producer.on('transportclose', () => { + producerVideo.on('transportclose', () => { console.log('transport ended') // close video track - }) + }) + + console.log('audioParams', audioParams); + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + + // close video track + }) + + + + + const answer = { origin_asset_id: ASSET_ID, @@ -20979,7 +20756,7 @@ const createRecvTransport = async () => { return } - console.log(params) + console.log('[createRecvTransport] params', params) // creates a new WebRTC Transport to receive media // based on server's consumer transport params @@ -21009,11 +20786,11 @@ const createRecvTransport = async () => { } const resetCallSettings = () => { - socket.emit('transportclose', { callId }) localVideo.srcObject = null remoteVideo.srcObject = null consumer = null - producer = null + producerVideo = null + producerAudio = null producerTransport = null consumerTransport = null device = undefined @@ -21057,12 +20834,12 @@ const connectRecvTransport = async () => { const closeCall = () => { console.log('closeCall'); - + // Emit 'notify-end' to Hub so the consumer will know to close the video const notifyEnd = { - origin_asset_id: ASSET_ID, - dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), - type: 'notify-end', + origin_asset_id: ASSET_ID, + dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')), + type: 'notify-end', video_call_id: callId } console.log('notifyEnd', notifyEnd) @@ -21072,11 +20849,11 @@ const closeCall = () => { const closeCallBtn = document.getElementById('btnCloseCall') closeCallBtn.setAttribute('disabled', '') - // Reset settings and send closeTransport to video server + // Reset settings resetCallSettings() } btnLocalVideo.addEventListener('click', getLocalStream) btnRecvSendTransport.addEventListener('click', goConnect) btnCloseCall.addEventListener('click', closeCall) -},{"./config":95,"mediasoup-client":67,"socket.io-client":83}]},{},[96]); +},{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]); diff --git a/public/config.js b/public/config.js index d12c148..fa3612f 100644 --- a/public/config.js +++ b/public/config.js @@ -1,5 +1,4 @@ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', - mediasoupAddress: 'https://video.safemobile.org/mediasoup', - // mediasoupAddress: 'http://localhost:3000/mediasoup', + mediasoupAddress: 'https://video.safemobile.org', } \ No newline at end of file diff --git a/public/index.html b/public/index.html index fb0f078..71e0467 100644 --- a/public/index.html +++ b/public/index.html @@ -43,7 +43,7 @@
- +
diff --git a/public/index.js b/public/index.js index 5c3d177..b30af81 100644 --- a/public/index.js +++ b/public/index.js @@ -12,124 +12,167 @@ let callId = parseInt(urlParams.get('callId')) || null; const IS_PRODUCER = urlParams.get('producer') === 'true' ? true : false console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', callId, ' | IS_PRODUCER', IS_PRODUCER) -let socket -hub = io(config.hubAddress) +console.log('🟩 config', config) -const connectToMediasoup = () => { +let socket, hub - socket = io(config.mediasoupAddress, { - reconnection: true, - reconnectionDelay: 1000, - reconnectionDelayMax : 5000, - reconnectionAttempts: Infinity - }) - - socket.on('connection-success', ({ _socketId, existsProducer }) => { - console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) - if (!IS_PRODUCER && existsProducer && consumer === undefined) { - goConnect() - // document.getElementById('btnRecvSendTransport').click(); - } - if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } - }) -} - -if (IS_PRODUCER === true) { - hub.on('connect', async () => { - console.log(`[HUB] ${config.hubAddress} | connected: ${hub.connected}`) - connectToMediasoup() - - hub.emit( - 'ars', - JSON.stringify({ - ars: true, - asset_id: ASSET_ID, - account_id: ACCOUNT_ID, - }) - ) +setTimeout(() => { + hub = io(config.hubAddress) - hub.on('video', (data) => { - const parsedData = JSON.parse(data); - - if (parsedData.type === 'notify-request') { - console.log('video', parsedData) - originAssetId = parsedData.origin_asset_id; - // originAssetName = parsedData.origin_asset_name; - // originAssetTypeName = parsedData.origin_asset_type_name; - callId = parsedData.video_call_id; + const connectToMediasoup = () => { - console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - getLocalStream() - } - - if (parsedData.type === 'notify-end') { - console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); - resetCallSettings() - } + socket = io(config.mediasoupAddress, { + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 5000, + reconnectionAttempts: Infinity }) - }) + + socket.on('connection-success', ({ _socketId, existsProducer }) => { + console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) + if (!IS_PRODUCER && existsProducer && consumer === undefined) { + goConnect() + // document.getElementById('btnRecvSendTransport').click(); + } + if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } + }) + } + + if (IS_PRODUCER === true) { + hub.on('connect', async () => { + console.log(`[HUB]! ${config.hubAddress} | connected: ${hub.connected}`) + connectToMediasoup() + + hub.emit( + 'ars', + JSON.stringify({ + ars: true, + asset_id: ASSET_ID, + account_id: ACCOUNT_ID, + }) + ) + + hub.on('video', (data) => { + const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { + console.log('video', parsedData) + originAssetId = parsedData.origin_asset_id; + // originAssetName = parsedData.origin_asset_name; + // originAssetTypeName = parsedData.origin_asset_type_name; + callId = parsedData.video_call_id; + + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + getLocalStream() + } + + if (parsedData.type === 'notify-end') { + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + resetCallSettings() + } + }) + }) + + hub.on('connect_error', (error) => { + console.log('connect_error', error); + }); + + hub.on('connection', () => { + console.log('connection') + }) + + hub.on('disconnect', () => { + console.log('disconnect') + }) + } else { + connectToMediasoup() + } + +}, 1600); - hub.on('connect_error', (error) => { - console.log('connect_error', error); - }); - - hub.on('connection', () => { - console.log('connection') - }) - - hub.on('disconnect', () => { - console.log('disconnect') - }) -} else { - connectToMediasoup() -} let device let rtpCapabilities let producerTransport let consumerTransport -let producer +let producerVideo +let producerAudio let consumer let originAssetId -// let originAssetName = 'Adi' -// let originAssetTypeName = 'linx' // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -let params = { - // mediasoup params +let videoParams = { encodings: [ - { - rid: 'r0', - maxBitrate: 100000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r1', - maxBitrate: 300000, - scalabilityMode: 'S1T3', - }, - { - rid: 'r2', - maxBitrate: 900000, - scalabilityMode: 'S1T3', - }, + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } ], - // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions codecOptions: { videoGoogleStartBitrate: 1000 } + // encodings: [ + // { + // rid: 'r0', + // maxBitrate: 100000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r1', + // maxBitrate: 300000, + // scalabilityMode: 'S1T3', + // }, + // { + // rid: 'r2', + // maxBitrate: 900000, + // scalabilityMode: 'S1T3', + // }, + // ], + // // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions + // codecOptions: { + // videoGoogleStartBitrate: 1000 + // } } -const streamSuccess = (stream) => { - console.log('[streamSuccess]'); - localVideo.srcObject = stream - const track = stream.getVideoTracks()[0] - params = { - track, - ...params +let audioParams = { + codecOptions : + { + opusStereo : true, + opusDtx : true } +} + + +const streamSuccess = (stream) => { + console.log('[streamSuccess] device', device); + localVideo.srcObject = stream + console.log('stream', stream); + const videoTrack = stream.getVideoTracks()[0] + const audioTrack = stream.getAudioTracks()[0] + + videoParams = { + track: videoTrack, + // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), + // codec : 'video/vp9', + ...videoParams + } + + audioParams = { + track: audioTrack, + ...audioParams + } + + console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() + // console.log('[streamSuccess]'); + // localVideo.srcObject = stream + // const track = stream.getVideoTracks()[0] + // videoParams = { + // track, + // ...videoParams + // } + // goConnect() } const getLocalStream = () => { @@ -137,16 +180,24 @@ const getLocalStream = () => { navigator.mediaDevices.getUserMedia({ audio: true, video: { - width: { - min: 640, - max: 1920, - }, - height: { - min: 400, - max: 1080, - } + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + // navigator.mediaDevices.getUserMedia({ + // audio: false, + // video: { + // width: { + // min: 640, + // max: 1920, + // }, + // height: { + // min: 400, + // max: 1080, + // } + // } + // }) .then(streamSuccess) .catch(error => { console.log(error.message) @@ -167,7 +218,7 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { - console.log('[createDevice]'); + console.log('[createDevice] 1 device', device); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -178,7 +229,8 @@ const createDevice = async () => { }) console.log('Device RTP Capabilities', device.rtpCapabilities) - + console.log('[createDevice] 2 device', device); + // once the device loads, create transport goCreateTransport() @@ -207,18 +259,20 @@ const getRtpCapabilities = () => { } const createSendTransport = () => { + console.log('[createSendTransport'); // see server's socket.on('createWebRtcTransport', sender?, ...) // this is a call from Producer, so sender = true - socket.emit('createWebRtcTransport', { sender: true, callId }, ({ params }) => { + socket.emit('createWebRtcTransport', { sender: true, callId }, (value) => { + + console.log(`[createWebRtcTransport] value: ${JSON.stringify(value)}`); + + const params = value.params; // The server sends back params needed // to create Send Transport on the client side if (params.error) { console.log(params.error) return } - - console.log(params) - // creates a new WebRTC Transport to send media // based on the server's producer transport params // https://mediasoup.org/documentation/v3/mediasoup-client/api/#TransportOptions @@ -244,7 +298,7 @@ const createSendTransport = () => { }) producerTransport.on('produce', async (parameters, callback, errback) => { - console.log(parameters) + console.log('[produce] parameters', parameters) try { // tell the server to create a Producer @@ -270,21 +324,45 @@ const createSendTransport = () => { } const connectSendTransport = async () => { + + console.log('[connectSendTransport] producerTransport'); + // we now call produce() to instruct the producer transport // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - producer = await producerTransport.produce(params) - - producer.on('trackended', () => { + + console.log('videoParams', videoParams); + producerVideo = await producerTransport.produce(videoParams) + console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { console.log('track ended') // close video track - }) + }) - producer.on('transportclose', () => { + producerVideo.on('transportclose', () => { console.log('transport ended') // close video track - }) + }) + + console.log('audioParams', audioParams); + producerAudio = await producerTransport.produce(audioParams) + console.log('producerAudio', producerAudio); + producerAudio.on('trackended', () => { + console.log('track ended') + // close video track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + + // close video track + }) + + + + + const answer = { origin_asset_id: ASSET_ID, @@ -320,7 +398,7 @@ const createRecvTransport = async () => { return } - console.log(params) + console.log('[createRecvTransport] params', params) // creates a new WebRTC Transport to receive media // based on server's consumer transport params @@ -353,7 +431,8 @@ const resetCallSettings = () => { localVideo.srcObject = null remoteVideo.srcObject = null consumer = null - producer = null + producerVideo = null + producerAudio = null producerTransport = null consumerTransport = null device = undefined -- 2.37.1 From adbcf6c2bc85abf971321a88f25c590cfbdf6c21 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:56:42 +0200 Subject: [PATCH 090/121] Update server --- app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app.js b/app.js index 37f3305..9968a62 100644 --- a/app.js +++ b/app.js @@ -458,6 +458,7 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log(`[consumer-resume] callId ${callId}`) await videoCalls[callId].consumerVideo.resume(); + await videoCalls[callId].consumerAudio.resume(); } catch (error) { console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); } -- 2.37.1 From 3605ca04686e0f947cdd703f9dadadbd2c24a637 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Mon, 28 Nov 2022 23:40:08 +0200 Subject: [PATCH 091/121] Update server --- public/index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/public/index.js b/public/index.js index b30af81..ccf1fe2 100644 --- a/public/index.js +++ b/public/index.js @@ -185,6 +185,26 @@ const getLocalStream = () => { hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + + navigator.permissions.query( + // { name: 'camera' } + { name: 'microphone' } + // { name: 'geolocation' } + // { name: 'notifications' } + // { name: 'midi', sysex: false } + // { name: 'midi', sysex: true } + // { name: 'push', userVisibleOnly: true } + // { name: 'push' } // without userVisibleOnly isn't supported in chrome M45, yet + ).then(function(permissionStatus){ + + console.log('navigator.permissions', permissionStatus.state); // granted, denied, prompt + + permissionStatus.onchange = function(){ + console.log("Permission changed to " + this.state); + } + + }) + // navigator.mediaDevices.getUserMedia({ // audio: false, // video: { @@ -495,6 +515,7 @@ const closeCall = () => { resetCallSettings() } + btnLocalVideo.addEventListener('click', getLocalStream) btnRecvSendTransport.addEventListener('click', goConnect) btnCloseCall.addEventListener('click', closeCall) \ No newline at end of file -- 2.37.1 From c92dff9bfe9f34299f40a8aea2a02c782ecec843 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Mon, 28 Nov 2022 23:40:56 +0200 Subject: [PATCH 092/121] Update server --- public/bundle.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/public/bundle.js b/public/bundle.js index 733c840..e55a76e 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20543,6 +20543,26 @@ const getLocalStream = () => { hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + + navigator.permissions.query( + // { name: 'camera' } + { name: 'microphone' } + // { name: 'geolocation' } + // { name: 'notifications' } + // { name: 'midi', sysex: false } + // { name: 'midi', sysex: true } + // { name: 'push', userVisibleOnly: true } + // { name: 'push' } // without userVisibleOnly isn't supported in chrome M45, yet + ).then(function(permissionStatus){ + + console.log('navigator.permissions', permissionStatus.state); // granted, denied, prompt + + permissionStatus.onchange = function(){ + console.log("Permission changed to " + this.state); + } + + }) + // navigator.mediaDevices.getUserMedia({ // audio: false, // video: { @@ -20853,6 +20873,7 @@ const closeCall = () => { resetCallSettings() } + btnLocalVideo.addEventListener('click', getLocalStream) btnRecvSendTransport.addEventListener('click', goConnect) btnCloseCall.addEventListener('click', closeCall) -- 2.37.1 From 67042185c4b0cd5dc742770d6772e967875fbe14 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 01:59:53 +0200 Subject: [PATCH 093/121] Update server --- public/bundle.js | 23 +++++------------------ public/index.js | 23 +++++------------------ 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index e55a76e..335f81d 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20543,6 +20543,10 @@ const getLocalStream = () => { hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) navigator.permissions.query( // { name: 'camera' } @@ -20555,7 +20559,7 @@ const getLocalStream = () => { // { name: 'push' } // without userVisibleOnly isn't supported in chrome M45, yet ).then(function(permissionStatus){ - console.log('navigator.permissions', permissionStatus.state); // granted, denied, prompt + console.log(permissionStatus.state); // granted, denied, prompt permissionStatus.onchange = function(){ console.log("Permission changed to " + this.state); @@ -20563,23 +20567,6 @@ const getLocalStream = () => { }) - // navigator.mediaDevices.getUserMedia({ - // audio: false, - // video: { - // width: { - // min: 640, - // max: 1920, - // }, - // height: { - // min: 400, - // max: 1080, - // } - // } - // }) - .then(streamSuccess) - .catch(error => { - console.log(error.message) - }) } const goConnect = () => { diff --git a/public/index.js b/public/index.js index ccf1fe2..bf3f6fe 100644 --- a/public/index.js +++ b/public/index.js @@ -185,6 +185,10 @@ const getLocalStream = () => { hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) navigator.permissions.query( // { name: 'camera' } @@ -197,7 +201,7 @@ const getLocalStream = () => { // { name: 'push' } // without userVisibleOnly isn't supported in chrome M45, yet ).then(function(permissionStatus){ - console.log('navigator.permissions', permissionStatus.state); // granted, denied, prompt + console.log(permissionStatus.state); // granted, denied, prompt permissionStatus.onchange = function(){ console.log("Permission changed to " + this.state); @@ -205,23 +209,6 @@ const getLocalStream = () => { }) - // navigator.mediaDevices.getUserMedia({ - // audio: false, - // video: { - // width: { - // min: 640, - // max: 1920, - // }, - // height: { - // min: 400, - // max: 1080, - // } - // } - // }) - .then(streamSuccess) - .catch(error => { - console.log(error.message) - }) } const goConnect = () => { -- 2.37.1 From 3bc15fdef119c4d3859ff14e5b50d457a41e3d47 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:09:37 +0200 Subject: [PATCH 094/121] Update server --- public/bundle.js | 27 +++++++++++++++------------ public/index.js | 27 +++++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 335f81d..5ef5243 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20372,7 +20372,8 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) -let socket, hub +let socket, hub, having +let doIHaveAudio = false setTimeout(() => { hub = io(config.hubAddress) @@ -20549,20 +20550,22 @@ const getLocalStream = () => { }) navigator.permissions.query( - // { name: 'camera' } { name: 'microphone' } - // { name: 'geolocation' } - // { name: 'notifications' } - // { name: 'midi', sysex: false } - // { name: 'midi', sysex: true } - // { name: 'push', userVisibleOnly: true } - // { name: 'push' } // without userVisibleOnly isn't supported in chrome M45, yet - ).then(function(permissionStatus){ + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - console.log(permissionStatus.state); // granted, denied, prompt + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } - permissionStatus.onchange = function(){ - console.log("Permission changed to " + this.state); + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'grated') { + doIHaveAudio = true; + } } }) diff --git a/public/index.js b/public/index.js index bf3f6fe..679cf0d 100644 --- a/public/index.js +++ b/public/index.js @@ -14,7 +14,8 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) -let socket, hub +let socket, hub, having +let doIHaveAudio = false setTimeout(() => { hub = io(config.hubAddress) @@ -191,20 +192,22 @@ const getLocalStream = () => { }) navigator.permissions.query( - // { name: 'camera' } { name: 'microphone' } - // { name: 'geolocation' } - // { name: 'notifications' } - // { name: 'midi', sysex: false } - // { name: 'midi', sysex: true } - // { name: 'push', userVisibleOnly: true } - // { name: 'push' } // without userVisibleOnly isn't supported in chrome M45, yet - ).then(function(permissionStatus){ + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - console.log(permissionStatus.state); // granted, denied, prompt + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } - permissionStatus.onchange = function(){ - console.log("Permission changed to " + this.state); + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'grated') { + doIHaveAudio = true; + } } }) -- 2.37.1 From e085d22e89eab8f9ad1a7b79c58e494405bf1af4 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:16:44 +0200 Subject: [PATCH 095/121] Update server --- app.js | 37 +++++++++--------- public/bundle.js | 97 +++++++++++++++++------------------------------- public/index.js | 97 +++++++++++++++++------------------------------- 3 files changed, 89 insertions(+), 142 deletions(-) diff --git a/app.js b/app.js index 9968a62..6c125dc 100644 --- a/app.js +++ b/app.js @@ -397,29 +397,30 @@ peers.on('connection', async socket => { closeCall(callId); }); - videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ - producerId: videoCalls[callId].producerAudio.id, - rtpCapabilities, - paused: true, - }); - // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose - videoCalls[callId].consumerAudio.on('transportclose', () => { - const callId = socketDetails[socket.id]; - console.log('transport close from consumer', callId); - closeCall(callId); - }); + // videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ + // producerId: videoCalls[callId].producerAudio.id, + // rtpCapabilities, + // paused: true, + // }); - // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose - videoCalls[callId].consumerAudio.on('producerclose', () => { - const callId = socketDetails[socket.id]; - console.log('producer of consumer closed', callId); - closeCall(callId); - }); + // // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose + // videoCalls[callId].consumerAudio.on('transportclose', () => { + // const callId = socketDetails[socket.id]; + // console.log('transport close from consumer', callId); + // closeCall(callId); + // }); + + // // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose + // videoCalls[callId].consumerAudio.on('producerclose', () => { + // const callId = socketDetails[socket.id]; + // console.log('producer of consumer closed', callId); + // closeCall(callId); + // }); - console.log('🟠 videoCalls[callId].consumerVideo', videoCalls[callId].consumerVideo); console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); + // From the consumer extract the following params to send back to the Client const videoParams = { id: videoCalls[callId].consumerVideo.id, diff --git a/public/bundle.js b/public/bundle.js index 5ef5243..5b6974c 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20372,8 +20372,38 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) -let socket, hub, having +let socket, hub let doIHaveAudio = false +let device +let rtpCapabilities +let producerTransport +let consumerTransport +let producerVideo +let producerAudio +let consumer +let originAssetId + +// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions +// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce +let videoParams = { + encodings: [ + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } + ], + codecOptions: { + videoGoogleStartBitrate: 1000 + } +} + +let audioParams = { + codecOptions : + { + opusStereo : true, + opusDtx : true + } +} setTimeout(() => { hub = io(config.hubAddress) @@ -20449,60 +20479,6 @@ setTimeout(() => { }, 1600); - -let device -let rtpCapabilities -let producerTransport -let consumerTransport -let producerVideo -let producerAudio -let consumer -let originAssetId - -// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions -// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -let videoParams = { - encodings: [ - { scaleResolutionDownBy: 4, maxBitrate: 500000 }, - { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, - { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, - { scalabilityMode: 'S3T3_KEY' } - ], - codecOptions: { - videoGoogleStartBitrate: 1000 - } - // encodings: [ - // { - // rid: 'r0', - // maxBitrate: 100000, - // scalabilityMode: 'S1T3', - // }, - // { - // rid: 'r1', - // maxBitrate: 300000, - // scalabilityMode: 'S1T3', - // }, - // { - // rid: 'r2', - // maxBitrate: 900000, - // scalabilityMode: 'S1T3', - // }, - // ], - // // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions - // codecOptions: { - // videoGoogleStartBitrate: 1000 - // } -} - -let audioParams = { - codecOptions : - { - opusStereo : true, - opusDtx : true - } -} - - const streamSuccess = (stream) => { console.log('[streamSuccess] device', device); localVideo.srcObject = stream @@ -20552,7 +20528,7 @@ const getLocalStream = () => { navigator.permissions.query( { name: 'microphone' } ).then(function(permissionStatus) { - + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt // If he has entered before, the saved access is already saved @@ -20713,6 +20689,8 @@ const connectSendTransport = async () => { // close video track }) + // Video is mandatory, but audio may not be included + if (doIHaveAudio) { console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); @@ -20723,14 +20701,9 @@ const connectSendTransport = async () => { producerAudio.on('transportclose', () => { console.log('transport ended') - // close video track }) - - - - - + } const answer = { origin_asset_id: ASSET_ID, diff --git a/public/index.js b/public/index.js index 679cf0d..cf685e3 100644 --- a/public/index.js +++ b/public/index.js @@ -14,8 +14,38 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) -let socket, hub, having +let socket, hub let doIHaveAudio = false +let device +let rtpCapabilities +let producerTransport +let consumerTransport +let producerVideo +let producerAudio +let consumer +let originAssetId + +// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions +// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce +let videoParams = { + encodings: [ + { scaleResolutionDownBy: 4, maxBitrate: 500000 }, + { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, + { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, + { scalabilityMode: 'S3T3_KEY' } + ], + codecOptions: { + videoGoogleStartBitrate: 1000 + } +} + +let audioParams = { + codecOptions : + { + opusStereo : true, + opusDtx : true + } +} setTimeout(() => { hub = io(config.hubAddress) @@ -91,60 +121,6 @@ setTimeout(() => { }, 1600); - -let device -let rtpCapabilities -let producerTransport -let consumerTransport -let producerVideo -let producerAudio -let consumer -let originAssetId - -// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions -// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce -let videoParams = { - encodings: [ - { scaleResolutionDownBy: 4, maxBitrate: 500000 }, - { scaleResolutionDownBy: 2, maxBitrate: 1000000 }, - { scaleResolutionDownBy: 1, maxBitrate: 5000000 }, - { scalabilityMode: 'S3T3_KEY' } - ], - codecOptions: { - videoGoogleStartBitrate: 1000 - } - // encodings: [ - // { - // rid: 'r0', - // maxBitrate: 100000, - // scalabilityMode: 'S1T3', - // }, - // { - // rid: 'r1', - // maxBitrate: 300000, - // scalabilityMode: 'S1T3', - // }, - // { - // rid: 'r2', - // maxBitrate: 900000, - // scalabilityMode: 'S1T3', - // }, - // ], - // // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions - // codecOptions: { - // videoGoogleStartBitrate: 1000 - // } -} - -let audioParams = { - codecOptions : - { - opusStereo : true, - opusDtx : true - } -} - - const streamSuccess = (stream) => { console.log('[streamSuccess] device', device); localVideo.srcObject = stream @@ -194,7 +170,7 @@ const getLocalStream = () => { navigator.permissions.query( { name: 'microphone' } ).then(function(permissionStatus) { - + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt // If he has entered before, the saved access is already saved @@ -355,6 +331,8 @@ const connectSendTransport = async () => { // close video track }) + // Video is mandatory, but audio may not be included + if (doIHaveAudio) { console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); @@ -365,14 +343,9 @@ const connectSendTransport = async () => { producerAudio.on('transportclose', () => { console.log('transport ended') - // close video track }) - - - - - + } const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From 984b2b892e3f73985fe7c36a9eea39465213d005 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:20:05 +0200 Subject: [PATCH 096/121] Update server --- app.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 6c125dc..a800147 100644 --- a/app.js +++ b/app.js @@ -364,6 +364,8 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); + console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); + // Check if the router can consume the specified producer if ( videoCalls[callId].router.canConsume({ @@ -418,9 +420,6 @@ peers.on('connection', async socket => { // closeCall(callId); // }); - console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); - - // From the consumer extract the following params to send back to the Client const videoParams = { id: videoCalls[callId].consumerVideo.id, -- 2.37.1 From 38b95d52467acf56d8c6ff3d2b706e87a9766a83 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:21:29 +0200 Subject: [PATCH 097/121] Update server --- app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index a800147..8c11bdc 100644 --- a/app.js +++ b/app.js @@ -364,7 +364,7 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); - console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); + console.log('🟠 videoCalls[callId].producerAudio', videoCalls[callId].producerAudio); // Check if the router can consume the specified producer if ( @@ -419,6 +419,7 @@ peers.on('connection', async socket => { // console.log('producer of consumer closed', callId); // closeCall(callId); // }); + console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); // From the consumer extract the following params to send back to the Client const videoParams = { -- 2.37.1 From 46d3499e3d02fa6afa1b91bf3855221f33ba294e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:34:48 +0200 Subject: [PATCH 098/121] Update server --- app.js | 142 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/app.js b/app.js index 8c11bdc..62f0844 100644 --- a/app.js +++ b/app.js @@ -366,79 +366,22 @@ peers.on('connection', async socket => { console.log('🟠 videoCalls[callId].producerAudio', videoCalls[callId].producerAudio); - // Check if the router can consume the specified producer - if ( - videoCalls[callId].router.canConsume({ - producerId: videoCalls[callId].producerVideo.id, - rtpCapabilities - }) && - videoCalls[callId].router.canConsume({ - producerId: videoCalls[callId].producerAudio.id, - rtpCapabilities - }) - ) { - console.log('[consume] Can consume', callId); - // Transport can now consume and return a consumer - videoCalls[callId].consumerVideo = await videoCalls[callId].consumerTransport.consume({ - producerId: videoCalls[callId].producerVideo.id, - rtpCapabilities, - paused: true, - }); + const canConsumeVideo = videoCalls[callId].producerVideo && videoCalls[callId].router.canConsume({ + producerId: videoCalls[callId].producerVideo.id, + rtpCapabilities + }) - // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose - videoCalls[callId].consumerVideo.on('transportclose', () => { - const callId = socketDetails[socket.id]; - console.log('transport close from consumer', callId); - closeCall(callId); - }); + const canConsumeAudio = videoCalls[callId].producerAudio && videoCalls[callId].router.canConsume({ + producerId: videoCalls[callId].producerAudio.id, + rtpCapabilities + }) - // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose - videoCalls[callId].consumerVideo.on('producerclose', () => { - const callId = socketDetails[socket.id]; - console.log('producer of consumer closed', callId); - closeCall(callId); - }); - - - // videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ - // producerId: videoCalls[callId].producerAudio.id, - // rtpCapabilities, - // paused: true, - // }); - - // // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose - // videoCalls[callId].consumerAudio.on('transportclose', () => { - // const callId = socketDetails[socket.id]; - // console.log('transport close from consumer', callId); - // closeCall(callId); - // }); - - // // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose - // videoCalls[callId].consumerAudio.on('producerclose', () => { - // const callId = socketDetails[socket.id]; - // console.log('producer of consumer closed', callId); - // closeCall(callId); - // }); - console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio); - - // From the consumer extract the following params to send back to the Client - const videoParams = { - id: videoCalls[callId].consumerVideo.id, - producerId: videoCalls[callId].producerVideo.id, - kind: 'video', - rtpParameters: videoCalls[callId].consumerVideo.rtpParameters, - }; - - const audioParams = { - id: videoCalls[callId].consumerAudio.id, - producerId: videoCalls[callId].producerAudio.id, - kind: 'audio', - rtpParameters: videoCalls[callId].consumerAudio.rtpParameters, - }; - - console.log('[consume] videoParams', videoParams); - console.log('[consume] audioParams', audioParams); - // Send the parameters to the client + if (canConsumeVideo && !canConsumeAudio) { + const videoParams = consumeVideo() + callback({ videoParams, audioParams: null }); + } if (canConsumeVideo && canConsumeAudio) { + const videoParams = consumeVideo() + const audioParams = consumeAudio() callback({ videoParams, audioParams }); } else { console.log(`[canConsume] Can't consume | callId ${callId}`); @@ -466,6 +409,63 @@ peers.on('connection', async socket => { }); }); +const consumeVideo = async () => { + videoCalls[callId].consumerVideo = await videoCalls[callId].consumerTransport.consume({ + producerId: videoCalls[callId].producerVideo.id, + rtpCapabilities, + paused: true, + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose + videoCalls[callId].consumerVideo.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport close from consumer', callId); + closeCall(callId); + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose + videoCalls[callId].consumerVideo.on('producerclose', () => { + const callId = socketDetails[socket.id]; + console.log('producer of consumer closed', callId); + closeCall(callId); + }); + + return { + id: videoCalls[callId].consumerVideo.id, + producerId: videoCalls[callId].producerVideo.id, + kind: 'video', + rtpParameters: videoCalls[callId].consumerVideo.rtpParameters, + } +} + +const consumeAudio = async () => { + videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ + producerId: videoCalls[callId].producerAudio.id, + rtpCapabilities, + paused: true, + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose + videoCalls[callId].consumerAudio.on('transportclose', () => { + const callId = socketDetails[socket.id]; + console.log('transport close from consumer', callId); + closeCall(callId); + }); + + // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose + videoCalls[callId].consumerAudio.on('producerclose', () => { + const callId = socketDetails[socket.id]; + console.log('producer of consumer closed', callId); + closeCall(callId); + }); + return { + id: videoCalls[callId].consumerAudio.id, + producerId: videoCalls[callId].producerAudio.id, + kind: 'audio', + rtpParameters: videoCalls[callId].consumerAudio.rtpParameters, + } +} + /* - Called from at event 'createWebRtcTransport' and assigned to the consumer or producer transport - It will return parameters, these are required for the client to create the RecvTransport -- 2.37.1 From a3b083fe248c883809577190a81d1f791516a1e8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:37:55 +0200 Subject: [PATCH 099/121] Update server --- app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 62f0844..fc1e6b5 100644 --- a/app.js +++ b/app.js @@ -377,11 +377,11 @@ peers.on('connection', async socket => { }) if (canConsumeVideo && !canConsumeAudio) { - const videoParams = consumeVideo() + const videoParams = consumeVideo(callId) callback({ videoParams, audioParams: null }); } if (canConsumeVideo && canConsumeAudio) { - const videoParams = consumeVideo() - const audioParams = consumeAudio() + const videoParams = consumeVideo(callId) + const audioParams = consumeAudio(callId) callback({ videoParams, audioParams }); } else { console.log(`[canConsume] Can't consume | callId ${callId}`); @@ -409,7 +409,7 @@ peers.on('connection', async socket => { }); }); -const consumeVideo = async () => { +const consumeVideo = async (callId) => { videoCalls[callId].consumerVideo = await videoCalls[callId].consumerTransport.consume({ producerId: videoCalls[callId].producerVideo.id, rtpCapabilities, @@ -438,7 +438,7 @@ const consumeVideo = async () => { } } -const consumeAudio = async () => { +const consumeAudio = async (callId) => { videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ producerId: videoCalls[callId].producerAudio.id, rtpCapabilities, -- 2.37.1 From 5169d0d49fc5af7ec5196bb38e43b39a29c21e6b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:39:11 +0200 Subject: [PATCH 100/121] Update server --- app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index fc1e6b5..3e84214 100644 --- a/app.js +++ b/app.js @@ -377,11 +377,11 @@ peers.on('connection', async socket => { }) if (canConsumeVideo && !canConsumeAudio) { - const videoParams = consumeVideo(callId) + const videoParams = consumeVideo(callId, rtpCapabilities) callback({ videoParams, audioParams: null }); } if (canConsumeVideo && canConsumeAudio) { - const videoParams = consumeVideo(callId) - const audioParams = consumeAudio(callId) + const videoParams = consumeVideo(callId, rtpCapabilities) + const audioParams = consumeAudio(callId, rtpCapabilities) callback({ videoParams, audioParams }); } else { console.log(`[canConsume] Can't consume | callId ${callId}`); @@ -409,7 +409,7 @@ peers.on('connection', async socket => { }); }); -const consumeVideo = async (callId) => { +const consumeVideo = async (callId, rtpCapabilities) => { videoCalls[callId].consumerVideo = await videoCalls[callId].consumerTransport.consume({ producerId: videoCalls[callId].producerVideo.id, rtpCapabilities, @@ -438,7 +438,7 @@ const consumeVideo = async (callId) => { } } -const consumeAudio = async (callId) => { +const consumeAudio = async (callId, rtpCapabilities) => { videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({ producerId: videoCalls[callId].producerAudio.id, rtpCapabilities, -- 2.37.1 From 359c7c784ef402a8bfc772774344147cc7d6f99d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:40:25 +0200 Subject: [PATCH 101/121] Update server --- app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 3e84214..31d835b 100644 --- a/app.js +++ b/app.js @@ -364,8 +364,6 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); - console.log('🟠 videoCalls[callId].producerAudio', videoCalls[callId].producerAudio); - const canConsumeVideo = videoCalls[callId].producerVideo && videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerVideo.id, rtpCapabilities @@ -376,6 +374,9 @@ peers.on('connection', async socket => { rtpCapabilities }) + console.log('[consume] canConsumeVideo', canConsumeVideo); + console.log('[consume] canConsumeAudio', canConsumeAudio); + if (canConsumeVideo && !canConsumeAudio) { const videoParams = consumeVideo(callId, rtpCapabilities) callback({ videoParams, audioParams: null }); -- 2.37.1 From 753b476462b593df9b7d6768d54e9349bdf00e95 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:42:13 +0200 Subject: [PATCH 102/121] Update server --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 31d835b..a586bc1 100644 --- a/app.js +++ b/app.js @@ -364,12 +364,12 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); - const canConsumeVideo = videoCalls[callId].producerVideo && videoCalls[callId].router.canConsume({ + const canConsumeVideo = videoCalls[callId]?.producerVideo && videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerVideo.id, rtpCapabilities }) - const canConsumeAudio = videoCalls[callId].producerAudio && videoCalls[callId].router.canConsume({ + const canConsumeAudio = videoCalls[callId]?.producerAudio && videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerAudio.id, rtpCapabilities }) -- 2.37.1 From d047cdf7d121f78e66a5f85c7d5920cb3f980810 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:44:01 +0200 Subject: [PATCH 103/121] Update server --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index a586bc1..f684f20 100644 --- a/app.js +++ b/app.js @@ -364,12 +364,12 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); - const canConsumeVideo = videoCalls[callId]?.producerVideo && videoCalls[callId].router.canConsume({ + const canConsumeVideo = videoCalls[callId].producerVideo && !!videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerVideo.id, rtpCapabilities }) - const canConsumeAudio = videoCalls[callId]?.producerAudio && videoCalls[callId].router.canConsume({ + const canConsumeAudio = videoCalls[callId].producerAudio && !!videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerAudio.id, rtpCapabilities }) -- 2.37.1 From 85110b7f5c90a0650b7a6558f726deb95582c872 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:44:40 +0200 Subject: [PATCH 104/121] Update server --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index f684f20..07a62eb 100644 --- a/app.js +++ b/app.js @@ -364,12 +364,12 @@ peers.on('connection', async socket => { const callId = socketDetails[socket.id]; console.log('[consume] callId', callId); - const canConsumeVideo = videoCalls[callId].producerVideo && !!videoCalls[callId].router.canConsume({ + const canConsumeVideo = !!videoCalls[callId].producerVideo && !!videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerVideo.id, rtpCapabilities }) - const canConsumeAudio = videoCalls[callId].producerAudio && !!videoCalls[callId].router.canConsume({ + const canConsumeAudio = !!videoCalls[callId].producerAudio && !!videoCalls[callId].router.canConsume({ producerId: videoCalls[callId].producerAudio.id, rtpCapabilities }) -- 2.37.1 From 9feaebf8a7ab34a30b134e6755293c16cc52e9d2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 02:46:12 +0200 Subject: [PATCH 105/121] Update server --- app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 07a62eb..bd4f5bb 100644 --- a/app.js +++ b/app.js @@ -378,14 +378,16 @@ peers.on('connection', async socket => { console.log('[consume] canConsumeAudio', canConsumeAudio); if (canConsumeVideo && !canConsumeAudio) { + console.log('1'); const videoParams = consumeVideo(callId, rtpCapabilities) callback({ videoParams, audioParams: null }); - } if (canConsumeVideo && canConsumeAudio) { + } else if (canConsumeVideo && canConsumeAudio) { + console.log('2'); const videoParams = consumeVideo(callId, rtpCapabilities) const audioParams = consumeAudio(callId, rtpCapabilities) callback({ videoParams, audioParams }); } else { - console.log(`[canConsume] Can't consume | callId ${callId}`); + console.log(`[consume] Can't consume | callId ${callId}`); callback(null); } } catch (error) { -- 2.37.1 From ae7a8ed9cebc9175df6b7a57f37de742a4c48821 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:16:15 +0200 Subject: [PATCH 106/121] Update server --- app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app.js b/app.js index bd4f5bb..dff83d3 100644 --- a/app.js +++ b/app.js @@ -380,6 +380,7 @@ peers.on('connection', async socket => { if (canConsumeVideo && !canConsumeAudio) { console.log('1'); const videoParams = consumeVideo(callId, rtpCapabilities) + console.log('videoParams', videoParams); callback({ videoParams, audioParams: null }); } else if (canConsumeVideo && canConsumeAudio) { console.log('2'); -- 2.37.1 From 0bdc6fac3afc9419978bc2421c8ae3d4907ef31c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:17:28 +0200 Subject: [PATCH 107/121] Update server --- app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index dff83d3..8b33249 100644 --- a/app.js +++ b/app.js @@ -379,13 +379,13 @@ peers.on('connection', async socket => { if (canConsumeVideo && !canConsumeAudio) { console.log('1'); - const videoParams = consumeVideo(callId, rtpCapabilities) + const videoParams = await consumeVideo(callId, rtpCapabilities) console.log('videoParams', videoParams); callback({ videoParams, audioParams: null }); } else if (canConsumeVideo && canConsumeAudio) { console.log('2'); - const videoParams = consumeVideo(callId, rtpCapabilities) - const audioParams = consumeAudio(callId, rtpCapabilities) + const videoParams = await consumeVideo(callId, rtpCapabilities) + const audioParams = await consumeAudio(callId, rtpCapabilities) callback({ videoParams, audioParams }); } else { console.log(`[consume] Can't consume | callId ${callId}`); -- 2.37.1 From 39efdd12b7c1aea914ac9183bfce8dba18c7c388 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:41:00 +0200 Subject: [PATCH 108/121] Update server --- public/bundle.js | 5 +++-- public/index.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 5b6974c..82efd94 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20689,8 +20689,9 @@ const connectSendTransport = async () => { // close video track }) + console.log('doIHaveAudio', doIHaveAudio); // Video is mandatory, but audio may not be included - if (doIHaveAudio) { + // if (doIHaveAudio) { console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); @@ -20703,7 +20704,7 @@ const connectSendTransport = async () => { console.log('transport ended') // close video track }) - } + // } const answer = { origin_asset_id: ASSET_ID, diff --git a/public/index.js b/public/index.js index cf685e3..f345b9c 100644 --- a/public/index.js +++ b/public/index.js @@ -331,8 +331,9 @@ const connectSendTransport = async () => { // close video track }) + console.log('doIHaveAudio', doIHaveAudio); // Video is mandatory, but audio may not be included - if (doIHaveAudio) { + // if (doIHaveAudio) { console.log('audioParams', audioParams); producerAudio = await producerTransport.produce(audioParams) console.log('producerAudio', producerAudio); @@ -345,7 +346,7 @@ const connectSendTransport = async () => { console.log('transport ended') // close video track }) - } + // } const answer = { origin_asset_id: ASSET_ID, -- 2.37.1 From 7a2d02dcda85d8a06b36f4c35ab9cff008296899 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:44:02 +0200 Subject: [PATCH 109/121] Update server --- public/bundle.js | 2 +- public/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 82efd94..f7b901a 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20539,7 +20539,7 @@ const getLocalStream = () => { // If it is the first time client enter and give permission permissionStatus.onchange = function() { console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'grated') { + if (this.state === 'granted') { doIHaveAudio = true; } } diff --git a/public/index.js b/public/index.js index f345b9c..03f3f82 100644 --- a/public/index.js +++ b/public/index.js @@ -181,7 +181,7 @@ const getLocalStream = () => { // If it is the first time client enter and give permission permissionStatus.onchange = function() { console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'grated') { + if (this.state === 'granted') { doIHaveAudio = true; } } -- 2.37.1 From 9111c4e245481601d1e95f650eae44ffed756227 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:50:45 +0200 Subject: [PATCH 110/121] Update server --- public/bundle.js | 46 +++++++++++++++++++++++----------------------- public/index.js | 46 +++++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index f7b901a..2f9f879 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20520,32 +20520,32 @@ const getLocalStream = () => { hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) - .then(streamSuccess) + .then((streamSuccess) => { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { + doIHaveAudio = true; + } + } + + }) + return streamSuccess + }) .catch(error => { console.log(error.message) }) - - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; - } - } - - }) - } const goConnect = () => { diff --git a/public/index.js b/public/index.js index 03f3f82..0026d00 100644 --- a/public/index.js +++ b/public/index.js @@ -162,32 +162,32 @@ const getLocalStream = () => { hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } }) - .then(streamSuccess) + .then((streamSuccess) => { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { + doIHaveAudio = true; + } + } + + }) + return streamSuccess + }) .catch(error => { console.log(error.message) }) - - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; - } - } - - }) - } const goConnect = () => { -- 2.37.1 From ac8c651a9d784093b9d54089bb71b214b8327c0b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:52:15 +0200 Subject: [PATCH 111/121] Update server --- public/bundle.js | 40 ++++++++++++++++++++++------------------ public/index.js | 40 ++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 2f9f879..9081ae1 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20521,26 +20521,30 @@ const getLocalStream = () => { } }) .then((streamSuccess) => { - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { + try { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { doIHaveAudio = true; } - } - - }) + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { + doIHaveAudio = true; + } + } + + }) + } catch (error) { + console.log('eeeeee', error); + } return streamSuccess }) .catch(error => { diff --git a/public/index.js b/public/index.js index 0026d00..f2c84de 100644 --- a/public/index.js +++ b/public/index.js @@ -163,26 +163,30 @@ const getLocalStream = () => { } }) .then((streamSuccess) => { - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { + try { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { doIHaveAudio = true; } - } - - }) + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { + doIHaveAudio = true; + } + } + + }) + } catch (error) { + console.log('eeeeee', error); + } return streamSuccess }) .catch(error => { -- 2.37.1 From df0cb81a8e7253465606a3a57750d5aa0395da33 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:55:34 +0200 Subject: [PATCH 112/121] Update server --- public/bundle.js | 52 ++++++++++++++++++++++++++---------------------- public/index.js | 52 ++++++++++++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 9081ae1..569367b 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20512,6 +20512,33 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); + + try { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { + doIHaveAudio = true; + } + } + + }) + } catch (error) { + console.log('eeeeee', error); + } + + navigator.mediaDevices.getUserMedia({ audio: true, video: { @@ -20521,30 +20548,7 @@ const getLocalStream = () => { } }) .then((streamSuccess) => { - try { - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; - } - } - - }) - } catch (error) { - console.log('eeeeee', error); - } + return streamSuccess }) .catch(error => { diff --git a/public/index.js b/public/index.js index f2c84de..b38eb63 100644 --- a/public/index.js +++ b/public/index.js @@ -154,6 +154,33 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); + + try { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { + doIHaveAudio = true; + } + } + + }) + } catch (error) { + console.log('eeeeee', error); + } + + navigator.mediaDevices.getUserMedia({ audio: true, video: { @@ -163,30 +190,7 @@ const getLocalStream = () => { } }) .then((streamSuccess) => { - try { - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; - } - } - - }) - } catch (error) { - console.log('eeeeee', error); - } + return streamSuccess }) .catch(error => { -- 2.37.1 From a21451e46d0175c6f43ca5a63bcac6fcf9dec754 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 03:59:42 +0200 Subject: [PATCH 113/121] Update server --- public/bundle.js | 81 +++++++++++++++++++++++++++--------------------- public/index.js | 81 +++++++++++++++++++++++++++--------------------- 2 files changed, 92 insertions(+), 70 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 569367b..2093202 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20513,47 +20513,58 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); - try { - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { doIHaveAudio = true; } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; + navigator.mediaDevices.getUserMedia({ + audio: true, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } - } - - }) - } catch (error) { - console.log('eeeeee', error); - } + }) + .then((streamSuccess) => { + + return streamSuccess + }) + .catch(error => { + console.log(error.message) + }) + } + + }) - navigator.mediaDevices.getUserMedia({ - audio: true, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then((streamSuccess) => { + // navigator.mediaDevices.getUserMedia({ + // audio: true, + // video: { + // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + // } + // }) + // .then((streamSuccess) => { - return streamSuccess - }) - .catch(error => { - console.log(error.message) - }) + // return streamSuccess + // }) + // .catch(error => { + // console.log(error.message) + // }) } const goConnect = () => { diff --git a/public/index.js b/public/index.js index b38eb63..f746b01 100644 --- a/public/index.js +++ b/public/index.js @@ -155,47 +155,58 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); - try { - navigator.permissions.query( - { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { + navigator.permissions.query( + { name: 'microphone' } + ).then(function(permissionStatus) { + + console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } + + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange', this.state); + if (this.state === 'granted') { doIHaveAudio = true; } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; + navigator.mediaDevices.getUserMedia({ + audio: true, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } } - } - - }) - } catch (error) { - console.log('eeeeee', error); - } + }) + .then((streamSuccess) => { + + return streamSuccess + }) + .catch(error => { + console.log(error.message) + }) + } + + }) - navigator.mediaDevices.getUserMedia({ - audio: true, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then((streamSuccess) => { + // navigator.mediaDevices.getUserMedia({ + // audio: true, + // video: { + // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + // } + // }) + // .then((streamSuccess) => { - return streamSuccess - }) - .catch(error => { - console.log(error.message) - }) + // return streamSuccess + // }) + // .catch(error => { + // console.log(error.message) + // }) } const goConnect = () => { -- 2.37.1 From d17b035526d06dbdd999fd1c05cb84fce66acd13 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 04:03:06 +0200 Subject: [PATCH 114/121] Update server --- public/bundle.js | 53 ++++++++++++++++++++++++++++++++++-------------- public/index.js | 53 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 76 insertions(+), 30 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 2093202..95c783d 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20529,22 +20529,45 @@ const getLocalStream = () => { console.log('🟨 [PERMISSION] onchange', this.state); if (this.state === 'granted') { doIHaveAudio = true; + navigator.mediaDevices.getUserMedia({ + audio: true, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + } + }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) + } else if (this.state === 'denied') { + doIHaveAudio = false; + navigator.mediaDevices.getUserMedia({ + audio: false, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + } + }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) } - navigator.mediaDevices.getUserMedia({ - audio: true, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then((streamSuccess) => { - - return streamSuccess - }) - .catch(error => { - console.log(error.message) - }) + // navigator.mediaDevices.getUserMedia({ + // audio: true, + // video: { + // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + // } + // }) + // .then(streamSuccess) + // .catch(error => { + // console.log(error.message) + // }) } }) diff --git a/public/index.js b/public/index.js index f746b01..bf5664f 100644 --- a/public/index.js +++ b/public/index.js @@ -171,22 +171,45 @@ const getLocalStream = () => { console.log('🟨 [PERMISSION] onchange', this.state); if (this.state === 'granted') { doIHaveAudio = true; + navigator.mediaDevices.getUserMedia({ + audio: true, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + } + }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) + } else if (this.state === 'denied') { + doIHaveAudio = false; + navigator.mediaDevices.getUserMedia({ + audio: false, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + } + }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) } - navigator.mediaDevices.getUserMedia({ - audio: true, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then((streamSuccess) => { - - return streamSuccess - }) - .catch(error => { - console.log(error.message) - }) + // navigator.mediaDevices.getUserMedia({ + // audio: true, + // video: { + // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + // } + // }) + // .then(streamSuccess) + // .catch(error => { + // console.log(error.message) + // }) } }) -- 2.37.1 From 7634a18465c46a89a21568a0a3f7305818c967e2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 10:22:02 +0200 Subject: [PATCH 115/121] Update server --- public/bundle.js | 1 + public/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/public/bundle.js b/public/bundle.js index 95c783d..afd5beb 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20543,6 +20543,7 @@ const getLocalStream = () => { }) } else if (this.state === 'denied') { doIHaveAudio = false; + console.log('Getting user permission'); navigator.mediaDevices.getUserMedia({ audio: false, video: { diff --git a/public/index.js b/public/index.js index bf5664f..ad405de 100644 --- a/public/index.js +++ b/public/index.js @@ -185,6 +185,7 @@ const getLocalStream = () => { }) } else if (this.state === 'denied') { doIHaveAudio = false; + console.log('Getting user permission'); navigator.mediaDevices.getUserMedia({ audio: false, video: { -- 2.37.1 From e22093d97e080e28b558dd206b0cbc893fba4bb8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 10:27:55 +0200 Subject: [PATCH 116/121] Update server --- public/bundle.js | 3 ++- public/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index afd5beb..771346c 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20524,6 +20524,7 @@ const getLocalStream = () => { doIHaveAudio = true; } + // 🟨 [PERMISSION] onchange denied // If it is the first time client enter and give permission permissionStatus.onchange = function() { console.log('🟨 [PERMISSION] onchange', this.state); @@ -20541,7 +20542,7 @@ const getLocalStream = () => { .catch(error => { console.log(error.message) }) - } else if (this.state === 'denied') { + } else /*if (this.state === 'denied') */ { doIHaveAudio = false; console.log('Getting user permission'); navigator.mediaDevices.getUserMedia({ diff --git a/public/index.js b/public/index.js index ad405de..2b78f2b 100644 --- a/public/index.js +++ b/public/index.js @@ -166,6 +166,7 @@ const getLocalStream = () => { doIHaveAudio = true; } + // 🟨 [PERMISSION] onchange denied // If it is the first time client enter and give permission permissionStatus.onchange = function() { console.log('🟨 [PERMISSION] onchange', this.state); @@ -183,7 +184,7 @@ const getLocalStream = () => { .catch(error => { console.log(error.message) }) - } else if (this.state === 'denied') { + } else /*if (this.state === 'denied') */ { doIHaveAudio = false; console.log('Getting user permission'); navigator.mediaDevices.getUserMedia({ -- 2.37.1 From 742d67f2e3380e0abc96da43fc671a1904b205e6 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 11:08:12 +0200 Subject: [PATCH 117/121] Update server --- public/index.js | 91 +++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 68 deletions(-) diff --git a/public/index.js b/public/index.js index 2b78f2b..76e467b 100644 --- a/public/index.js +++ b/public/index.js @@ -154,84 +154,40 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); + navigator.mediaDevices.getUserMedia({ + audio: true, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + } + }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) navigator.permissions.query( { name: 'microphone' } ).then(function(permissionStatus) { - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + console.log('🟨 [PERMISSION] onchange1', permissionStatus.state); // granted, denied, prompt - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } - // 🟨 [PERMISSION] onchange denied - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; - navigator.mediaDevices.getUserMedia({ - audio: true, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then(streamSuccess) - .catch(error => { - console.log(error.message) - }) - } else /*if (this.state === 'denied') */ { - doIHaveAudio = false; - console.log('Getting user permission'); - navigator.mediaDevices.getUserMedia({ - audio: false, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then(streamSuccess) - .catch(error => { - console.log(error.message) - }) - } - // navigator.mediaDevices.getUserMedia({ - // audio: true, - // video: { - // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - // } - // }) - // .then(streamSuccess) - // .catch(error => { - // console.log(error.message) - // }) + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange2', this.state); + if (this.state === 'grated') { + // doIHaveAudio = true; } + } }) - - // navigator.mediaDevices.getUserMedia({ - // audio: true, - // video: { - // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - // } - // }) - // .then((streamSuccess) => { - - // return streamSuccess - // }) - // .catch(error => { - // console.log(error.message) - // }) } const goConnect = () => { @@ -375,7 +331,6 @@ const connectSendTransport = async () => { // close video track }) - console.log('doIHaveAudio', doIHaveAudio); // Video is mandatory, but audio may not be included // if (doIHaveAudio) { console.log('audioParams', audioParams); -- 2.37.1 From fc745a58790d3f152ed535ba2c62c7574f08a643 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 11:09:10 +0200 Subject: [PATCH 118/121] Update server --- public/bundle.js | 91 ++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 68 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 771346c..88677a4 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20512,84 +20512,40 @@ const streamSuccess = (stream) => { const getLocalStream = () => { console.log('[getLocalStream]'); + navigator.mediaDevices.getUserMedia({ + audio: true, + video: { + qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, + vga : { width: { ideal: 640 }, height: { ideal: 480 } }, + hd : { width: { ideal: 1280 }, height: { ideal: 720 } } + } + }) + .then(streamSuccess) + .catch(error => { + console.log(error.message) + }) navigator.permissions.query( { name: 'microphone' } ).then(function(permissionStatus) { - console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt + console.log('🟨 [PERMISSION] onchange1', permissionStatus.state); // granted, denied, prompt - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } + // If he has entered before, the saved access is already saved + if (permissionStatus === 'grated') { + doIHaveAudio = true; + } - // 🟨 [PERMISSION] onchange denied - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange', this.state); - if (this.state === 'granted') { - doIHaveAudio = true; - navigator.mediaDevices.getUserMedia({ - audio: true, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then(streamSuccess) - .catch(error => { - console.log(error.message) - }) - } else /*if (this.state === 'denied') */ { - doIHaveAudio = false; - console.log('Getting user permission'); - navigator.mediaDevices.getUserMedia({ - audio: false, - video: { - qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - } - }) - .then(streamSuccess) - .catch(error => { - console.log(error.message) - }) - } - // navigator.mediaDevices.getUserMedia({ - // audio: true, - // video: { - // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - // } - // }) - // .then(streamSuccess) - // .catch(error => { - // console.log(error.message) - // }) + // If it is the first time client enter and give permission + permissionStatus.onchange = function() { + console.log('🟨 [PERMISSION] onchange2', this.state); + if (this.state === 'grated') { + // doIHaveAudio = true; } + } }) - - // navigator.mediaDevices.getUserMedia({ - // audio: true, - // video: { - // qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, - // vga : { width: { ideal: 640 }, height: { ideal: 480 } }, - // hd : { width: { ideal: 1280 }, height: { ideal: 720 } } - // } - // }) - // .then((streamSuccess) => { - - // return streamSuccess - // }) - // .catch(error => { - // console.log(error.message) - // }) } const goConnect = () => { @@ -20733,7 +20689,6 @@ const connectSendTransport = async () => { // close video track }) - console.log('doIHaveAudio', doIHaveAudio); // Video is mandatory, but audio may not be included // if (doIHaveAudio) { console.log('audioParams', audioParams); -- 2.37.1 From 4bb23def42fdccc04e51d30ea58c707797e7de57 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 11:32:03 +0200 Subject: [PATCH 119/121] Update server --- public/bundle.js | 69 ++++++++++++++++++++---------------------------- public/index.js | 69 ++++++++++++++++++++---------------------------- 2 files changed, 56 insertions(+), 82 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 88677a4..d1e6c30 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20527,23 +20527,9 @@ const getLocalStream = () => { navigator.permissions.query( { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange1', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange2', this.state); - if (this.state === 'grated') { - // doIHaveAudio = true; - } - } - + ).then((permissionStatus) =>{ + console.log('🟨 [PERMISSION] permissionStatus', permissionStatus); // granted, denied, prompt + // It will block the code from execution and display "Permission denied" if we don't have microphone permissions }) } @@ -20645,7 +20631,7 @@ const createSendTransport = () => { console.log('[produce] parameters', parameters) try { - // tell the server to create a Producer + // Tell the server to create a Producer // with the following parameters and produce // and expect back a server side producer id // see server's socket.on('transport-produce', ...) @@ -20671,14 +20657,16 @@ const connectSendTransport = async () => { console.log('[connectSendTransport] producerTransport'); - // we now call produce() to instruct the producer transport + // We now call produce() to instruct the producer transport // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - console.log('videoParams', videoParams); + // Produce video producerVideo = await producerTransport.produce(videoParams) + console.log('videoParams', videoParams); console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { console.log('track ended') // close video track @@ -20689,21 +20677,20 @@ const connectSendTransport = async () => { // close video track }) - // Video is mandatory, but audio may not be included - // if (doIHaveAudio) { - console.log('audioParams', audioParams); - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) - // } + // Produce audio + producerAudio = await producerTransport.produce(audioParams) + console.log('audioParams', audioParams); + console.log('producerAudio', producerAudio); + + producerAudio.on('trackended', () => { + console.log('track ended') + // close audio track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close audio track + }) const answer = { origin_asset_id: ASSET_ID, @@ -20713,7 +20700,7 @@ const connectSendTransport = async () => { origin_asset_type_name: ASSET_TYPE, origin_asset_name: ASSET_NAME, video_call_id: callId, - answer: 'accepted', // answer: 'rejected' + answer: 'accepted', // answer: accepted/rejected }; console.log('SEND answer', answer); @@ -20729,7 +20716,7 @@ const connectSendTransport = async () => { const createRecvTransport = async () => { console.log('createRecvTransport'); - // see server's socket.on('consume', sender?, ...) + // See server's socket.on('consume', sender?, ...) // this is a call from Consumer, so sender = false await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => { // The server sends back params needed @@ -20741,13 +20728,13 @@ const createRecvTransport = async () => { console.log('[createRecvTransport] params', params) - // creates a new WebRTC Transport to receive media + // Creates a new WebRTC Transport to receive media // based on server's consumer transport params // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport consumerTransport = device.createRecvTransport(params) // https://mediasoup.org/documentation/v3/communication-between-client-and-server/#producing-media - // this event is raised when a first call to transport.produce() is made + // This event is raised when a first call to transport.produce() is made // see connectRecvTransport() below consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { try { @@ -20781,7 +20768,7 @@ const resetCallSettings = () => { const connectRecvTransport = async () => { console.log('connectRecvTransport'); - // for consumer, we need to tell the server first + // For consumer, we need to tell the server first // to create a consumer based on the rtpCapabilities and consume // if the router can consume, it will send back a set of params as below await socket.emit('consume', { @@ -20793,7 +20780,7 @@ const connectRecvTransport = async () => { return } - // then consume with the local consumer transport + // Then consume with the local consumer transport // which creates a consumer consumer = await consumerTransport.consume({ id: params.id, diff --git a/public/index.js b/public/index.js index 76e467b..de7e529 100644 --- a/public/index.js +++ b/public/index.js @@ -169,23 +169,9 @@ const getLocalStream = () => { navigator.permissions.query( { name: 'microphone' } - ).then(function(permissionStatus) { - - console.log('🟨 [PERMISSION] onchange1', permissionStatus.state); // granted, denied, prompt - - // If he has entered before, the saved access is already saved - if (permissionStatus === 'grated') { - doIHaveAudio = true; - } - - // If it is the first time client enter and give permission - permissionStatus.onchange = function() { - console.log('🟨 [PERMISSION] onchange2', this.state); - if (this.state === 'grated') { - // doIHaveAudio = true; - } - } - + ).then((permissionStatus) =>{ + console.log('🟨 [PERMISSION] permissionStatus', permissionStatus); // granted, denied, prompt + // It will block the code from execution and display "Permission denied" if we don't have microphone permissions }) } @@ -287,7 +273,7 @@ const createSendTransport = () => { console.log('[produce] parameters', parameters) try { - // tell the server to create a Producer + // Tell the server to create a Producer // with the following parameters and produce // and expect back a server side producer id // see server's socket.on('transport-produce', ...) @@ -313,14 +299,16 @@ const connectSendTransport = async () => { console.log('[connectSendTransport] producerTransport'); - // we now call produce() to instruct the producer transport + // We now call produce() to instruct the producer transport // to send media to the Router // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce // this action will trigger the 'connect' and 'produce' events above - console.log('videoParams', videoParams); + // Produce video producerVideo = await producerTransport.produce(videoParams) + console.log('videoParams', videoParams); console.log('producerVideo', producerVideo); + producerVideo.on('trackended', () => { console.log('track ended') // close video track @@ -331,21 +319,20 @@ const connectSendTransport = async () => { // close video track }) - // Video is mandatory, but audio may not be included - // if (doIHaveAudio) { - console.log('audioParams', audioParams); - producerAudio = await producerTransport.produce(audioParams) - console.log('producerAudio', producerAudio); - producerAudio.on('trackended', () => { - console.log('track ended') - // close video track - }) - - producerAudio.on('transportclose', () => { - console.log('transport ended') - // close video track - }) - // } + // Produce audio + producerAudio = await producerTransport.produce(audioParams) + console.log('audioParams', audioParams); + console.log('producerAudio', producerAudio); + + producerAudio.on('trackended', () => { + console.log('track ended') + // close audio track + }) + + producerAudio.on('transportclose', () => { + console.log('transport ended') + // close audio track + }) const answer = { origin_asset_id: ASSET_ID, @@ -355,7 +342,7 @@ const connectSendTransport = async () => { origin_asset_type_name: ASSET_TYPE, origin_asset_name: ASSET_NAME, video_call_id: callId, - answer: 'accepted', // answer: 'rejected' + answer: 'accepted', // answer: accepted/rejected }; console.log('SEND answer', answer); @@ -371,7 +358,7 @@ const connectSendTransport = async () => { const createRecvTransport = async () => { console.log('createRecvTransport'); - // see server's socket.on('consume', sender?, ...) + // See server's socket.on('consume', sender?, ...) // this is a call from Consumer, so sender = false await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => { // The server sends back params needed @@ -383,13 +370,13 @@ const createRecvTransport = async () => { console.log('[createRecvTransport] params', params) - // creates a new WebRTC Transport to receive media + // Creates a new WebRTC Transport to receive media // based on server's consumer transport params // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport consumerTransport = device.createRecvTransport(params) // https://mediasoup.org/documentation/v3/communication-between-client-and-server/#producing-media - // this event is raised when a first call to transport.produce() is made + // This event is raised when a first call to transport.produce() is made // see connectRecvTransport() below consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { try { @@ -423,7 +410,7 @@ const resetCallSettings = () => { const connectRecvTransport = async () => { console.log('connectRecvTransport'); - // for consumer, we need to tell the server first + // For consumer, we need to tell the server first // to create a consumer based on the rtpCapabilities and consume // if the router can consume, it will send back a set of params as below await socket.emit('consume', { @@ -435,7 +422,7 @@ const connectRecvTransport = async () => { return } - // then consume with the local consumer transport + // Then consume with the local consumer transport // which creates a consumer consumer = await consumerTransport.consume({ id: params.id, -- 2.37.1 From 6cc14cdf30d3ec712cb6817250c6f20d43ed0b22 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 13:27:12 +0200 Subject: [PATCH 120/121] LH-265: Update documentation and README.md --- README.md | 9 ++++++--- public/index.js | 14 +------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 55ecd20..4b412f6 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,20 @@ 2. Run the `npm start:prod` command to start the server in production mode. (To connect to the terminal, use `pm2 log video-server`) ---- + +### Web client - The server will start by default on port 3000, and the ssl certificates will have to be configured - The web client can be accessed using the /sfu path -ex: http://localhost:3000/sfu/?assetId=1&&accountId=1&producer=true&assetName=Adi&assetType=linx +ex: https://HOST/sfu/?assetId=1&&accountId=1&producer=true&dest_asset_id=75&assetName=Adi assetId = asset id of the unit on which you are doing the test accountId = account id of the unit on which you are doing the test producer = it will always be true because you are the producer (it's possible to put false, but then you have to have another client with producer true) assetName = asset name of the unit on which you are doing the test -assetType = asset type of the unit on which you are doing the test +dest_asset_id= the addressee with whom the call is made +- To make a call using this client, you need a microphone and permission to use it +- For any changes related to the client, the command `npm run watch' will have to be used to generate the bundle.js used by the web client ### Demo project The demo project used initially and then modified for our needs `https://github.com/jamalag/mediasoup2` diff --git a/public/index.js b/public/index.js index de7e529..86b9d90 100644 --- a/public/index.js +++ b/public/index.js @@ -15,7 +15,6 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) let socket, hub -let doIHaveAudio = false let device let rtpCapabilities let producerTransport @@ -130,8 +129,6 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, - // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - // codec : 'video/vp9', ...videoParams } @@ -142,14 +139,6 @@ const streamSuccess = (stream) => { console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() - // console.log('[streamSuccess]'); - // localVideo.srcObject = stream - // const track = stream.getVideoTracks()[0] - // videoParams = { - // track, - // ...videoParams - // } - // goConnect() } const getLocalStream = () => { @@ -190,7 +179,6 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { - console.log('[createDevice] 1 device', device); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -201,7 +189,7 @@ const createDevice = async () => { }) console.log('Device RTP Capabilities', device.rtpCapabilities) - console.log('[createDevice] 2 device', device); + console.log('[createDevice] device', device); // once the device loads, create transport goCreateTransport() -- 2.37.1 From c823f7578cd59ce91b546bed350a91973c05af6c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 29 Nov 2022 13:27:33 +0200 Subject: [PATCH 121/121] LH-265: Update client --- public/bundle.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index d1e6c30..82ddb74 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20373,7 +20373,6 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId', console.log('🟩 config', config) let socket, hub -let doIHaveAudio = false let device let rtpCapabilities let producerTransport @@ -20488,8 +20487,6 @@ const streamSuccess = (stream) => { videoParams = { track: videoTrack, - // codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'), - // codec : 'video/vp9', ...videoParams } @@ -20500,14 +20497,6 @@ const streamSuccess = (stream) => { console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams); goConnect() - // console.log('[streamSuccess]'); - // localVideo.srcObject = stream - // const track = stream.getVideoTracks()[0] - // videoParams = { - // track, - // ...videoParams - // } - // goConnect() } const getLocalStream = () => { @@ -20548,7 +20537,6 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { - console.log('[createDevice] 1 device', device); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -20559,7 +20547,7 @@ const createDevice = async () => { }) console.log('Device RTP Capabilities', device.rtpCapabilities) - console.log('[createDevice] 2 device', device); + console.log('[createDevice] device', device); // once the device loads, create transport goCreateTransport() -- 2.37.1