From 8860423e21a063c51f0f768e8e7a639d74c5d1ac Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 10:28:45 +0200 Subject: [PATCH 01/85] 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) From 39ad9cad274e3f6a978436cbf553f5741bdab4d5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:10:05 +0200 Subject: [PATCH 02/85] 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]); From b621b76e37418307f6d69ef68daa54d084b58806 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:27:56 +0200 Subject: [PATCH 03/85] 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); From c7303416742c366b060e39332999ea0239442414 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:28:50 +0200 Subject: [PATCH 04/85] 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); From cdbfc7891d4e7841006fa08f27fa724aa9ccb341 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:30:25 +0200 Subject: [PATCH 05/85] 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( From bc2bf24a65e8515bd0856dab2ae9f48dfa1a80e6 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:32:47 +0200 Subject: [PATCH 06/85] 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); From 1d7c994036ccb52afa99a0a98837a72e1dc3d6b8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:33:06 +0200 Subject: [PATCH 07/85] 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); From 0d24604f2a9598e10599374e89296129cf909842 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:33:46 +0200 Subject: [PATCH 08/85] 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) From 1a1fa9450ee9e2fb6ae2f86d7cdb95993701233b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:34:12 +0200 Subject: [PATCH 09/85] 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) From d593d6dc834d36f7f576a237b5849a17c5f6938c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:35:36 +0200 Subject: [PATCH 10/85] 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 From 4ae02f70d6856c3c1c856fe0d5044494d2ab4513 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 18:54:22 +0200 Subject: [PATCH 11/85] 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 From d6bc4e51e5b198ad0196839d9903ebc426a6e809 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:11:00 +0200 Subject: [PATCH 12/85] 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 From c5c8bc5bb3819d40c13712da7495bfd9857404d3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:14:50 +0200 Subject: [PATCH 13/85] 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 From a05f7cc987f995f2c5f8bf624bcdb85f5ebaccd3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:15:34 +0200 Subject: [PATCH 14/85] 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 From 06bb275f0dbfc8e492bc62684eaf3f7936c783ca Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:18:48 +0200 Subject: [PATCH 15/85] 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() } From 3838f774bf0a7828694692611ecb004732f6b221 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:33:38 +0200 Subject: [PATCH 16/85] 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() } From 1084a808c7951eabcca0aa765c75988825d48e8d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:40:02 +0200 Subject: [PATCH 17/85] 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() } From 8f96b8c98bac03b1dc519a1b98710280fca5e9f7 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:51:09 +0200 Subject: [PATCH 18/85] 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 From 7d677f4a34360da368c3f5acf95c2f014c32afd8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:52:11 +0200 Subject: [PATCH 19/85] 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, From e9ff06054469b513825d504045b8039c4a2bc79c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:52:25 +0200 Subject: [PATCH 20/85] 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, From 4e4cd6f893732bcbe6315f2bd5294f2477982bbd Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 19:55:55 +0200 Subject: [PATCH 21/85] 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 From 544e9e59ab9ba5f6ceaa592963989fed6425b3dd Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:00:44 +0200 Subject: [PATCH 22/85] 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 From 27151a26d1b4d0a0c001ba96851b0560a7093c66 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:03:36 +0200 Subject: [PATCH 23/85] 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, From f20e1ad260516391d32c006803259a22f00e6842 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:04:43 +0200 Subject: [PATCH 24/85] 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') From d1ad8b4d3a082b905780b6c02d42823f8113b669 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:38:16 +0200 Subject: [PATCH 25/85] 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', From 127f17cd97696aa254ee2a6d878f4ca09300bfbd Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:42:55 +0200 Subject: [PATCH 26/85] 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 From 233f49a99894cc4be78cf9dbaa06b8f0789c2d2f Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:43:30 +0200 Subject: [PATCH 27/85] 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 From 0dfbd296a74db7b4e7eb8687d8a3be86f6f07737 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 20:44:22 +0200 Subject: [PATCH 28/85] 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', From b63fb39fd4445026cf9a6b9cc64347f7a745bfc9 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:09:33 +0200 Subject: [PATCH 29/85] 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, From a39e0eaa17386be5cbe3c81c8f2240222e316424 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:11:14 +0200 Subject: [PATCH 30/85] 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: "", From 3cbd31b49c261bd66e4647c8661753c9011100ef Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:11:45 +0200 Subject: [PATCH 31/85] 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, From d1063803b9ab41c30e1743716a4a5c65d7961b57 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:12:21 +0200 Subject: [PATCH 32/85] 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, From 4dbb7ad5541c18bcd84162543c81f2a7d575a9a1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:12:55 +0200 Subject: [PATCH 33/85] 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, From fa42caeeb2ca9da1107c0b243df90059c68a2ca3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 22 Nov 2022 23:14:01 +0200 Subject: [PATCH 34/85] 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, From d18041caddbc4eb333e5e0a9c9dae29eb9fef2e1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:11:16 +0200 Subject: [PATCH 35/85] 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, From dfe4630839327bcc1b31277dcfd9dd441f85e0c5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:11:26 +0200 Subject: [PATCH 36/85] 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, From 0b3a45ae458e589d100de1de6ca14497f832e4d3 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:13:56 +0200 Subject: [PATCH 37/85] 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', From f5b9067b7e1070d3271d9d784e17ba60b1f79063 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:21:26 +0200 Subject: [PATCH 38/85] 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, From 22656722e866477f5a8c1f892b9a6c0f5f82a312 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:22:00 +0200 Subject: [PATCH 39/85] 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 From daa2c556e40ac5cc91f5ec6b9ce1078caea4e13e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:25:16 +0200 Subject: [PATCH 40/85] 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) => { From 1a7b44807d44dfe4d5b91e4ba35acb71323c2814 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:32:24 +0200 Subject: [PATCH 41/85] 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 } } From 3c23c6791d440ad3a595e8215b112f2668d1a908 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:34:12 +0200 Subject: [PATCH 42/85] 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, From a97ec241482cf2413118cb1c765e5e9f5565e4a8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 00:54:03 +0200 Subject: [PATCH 43/85] 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) From c63aee83a1e006ad27eeeeb875a15e12ba3bfa35 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 13:19:56 +0200 Subject: [PATCH 44/85] 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'), From c089e91fbaedaf0db5b9fe79d5c90404ddd15bef Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 13:20:49 +0200 Subject: [PATCH 45/85] 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'), From b41b8f2d647a02a1ccc3bb2a56cfa532ab9b4d3e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 15:57:27 +0200 Subject: [PATCH 46/85] 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 } From c2dbef191893b3e70cb691763da3c7af35cf8cd6 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:00:54 +0200 Subject: [PATCH 47/85] 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 } }, From a3ae874f8e532e06fa8219da2ce97c755a68bb6f Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:01:51 +0200 Subject: [PATCH 48/85] 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) From d49b8e42ff9dc9c50055c3b608e97a99ec1df8b5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:03:13 +0200 Subject: [PATCH 49/85] 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 } From 2479f58e217cb9fb97fc0bd775fc7659b81e0a4a Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:09:26 +0200 Subject: [PATCH 50/85] 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() From d386915ff2bc63242705a5acb9d10d27b543d8de Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:16:17 +0200 Subject: [PATCH 51/85] 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', From e8bd6837cf7d13e604e3911e0b2bd8fc1d515c5f Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:21:48 +0200 Subject: [PATCH 52/85] 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 } From ba63fb20bf305ca05695a9c2ff223ac7b78ac1e8 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:24:12 +0200 Subject: [PATCH 53/85] 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 } From fcbc28c801da59b741a5048b1dab9f9144ecaee2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:26:28 +0200 Subject: [PATCH 54/85] 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() } From c758a9106cfb35a20ff26c3e69e18c26b6b7538c Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 16:27:13 +0200 Subject: [PATCH 55/85] 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() } From e5bcc6262b6225ba3781f05c395f8dde5e771638 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 17:11:09 +0200 Subject: [PATCH 56/85] 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 } From 9fbe01ae1d2e9c68b0cdf43ee2fcba75381d5367 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 17:19:55 +0200 Subject: [PATCH 57/85] 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) => { From fa5a1a5ae720a774524b567879f951a3b3e1a72e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 23 Nov 2022 17:56:18 +0200 Subject: [PATCH 58/85] 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 { From 458342c0d2bb27b2a60d06e02a12e8843e317e2a Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:32:45 +0200 Subject: [PATCH 59/85] 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 { From aa7c2aea90e616d815a109dd8197735ad0ef4268 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:35:32 +0200 Subject: [PATCH 60/85] 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 = { From e65b7e0d7c4ab9655feffebbd8676cdd78c49608 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:36:21 +0200 Subject: [PATCH 61/85] 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) From 6c42814229d8f015cd9e5f6932e4f573f744aa8a Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:37:42 +0200 Subject: [PATCH 62/85] 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 = () => { From 56b8e2ea745f483c15d3133a3bc00ff12465f2a2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:38:28 +0200 Subject: [PATCH 63/85] 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 } }, From 2a86042c807b65812ab3cdb8e0f5215fb2f1f3f5 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:41:24 +0200 Subject: [PATCH 64/85] 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, From 8ef6c2abb099ecc72453fc57d028b66f89b53d09 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:43:33 +0200 Subject: [PATCH 65/85] 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 @@
- +
From 6e74083733c0a57f621cab39150f3b322d9d615d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 13:49:04 +0200 Subject: [PATCH 66/85] 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')), From 950298c4f6a63ea89e34bc78a0517fcc2d8b22df Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:21:22 +0200 Subject: [PATCH 67/85] 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 - }) From f2c0794bf42e3cf7167cf2f19995236f9aad7968 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:22:56 +0200 Subject: [PATCH 68/85] 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 + // }) From 2a7bd422477eb8bd04783644e8a16db6cafd2e76 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:34:54 +0200 Subject: [PATCH 69/85] 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 + }) From 3e4c0a32bc1c06112655a7e03da80ce31e67b0aa Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:36:00 +0200 Subject: [PATCH 70/85] 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 + // }) From aad96b72f2d90598c3b452ae37718e74600652c1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:36:36 +0200 Subject: [PATCH 71/85] 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 + }) From e59f134a68a9c3b3b961ad08a62501fd51657fac Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:37:44 +0200 Subject: [PATCH 72/85] 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 }) From c6edb2947d5b21d41bf10887b1d389deb96f8741 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:46:00 +0200 Subject: [PATCH 73/85] 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 }) From 22ead926b07628c639911dfe606a216c168d8cfe Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:57:26 +0200 Subject: [PATCH 74/85] 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 - }) - - + }) From 3561bb13a6dd75ed5d50541409224190a6e38bf0 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 16:59:04 +0200 Subject: [PATCH 75/85] 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', From 1148532a9b90b53a6373f3b49fe5568c51259d0b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 17:01:26 +0200 Subject: [PATCH 76/85] 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 - }) From d94ea12a407596f92df28052b4936a14b4e08c7d Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 17:08:54 +0200 Subject: [PATCH 77/85] 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); From 038bdb99bcbd6323ccf4868925b0239795935722 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 22:18:37 +0200 Subject: [PATCH 78/85] 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); From cd84c534ce7eb57858ca03ee5df8cf44570f1ebc Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 22:27:33 +0200 Subject: [PATCH 79/85] 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 From 8444809910abe74a79fffa123d886864bd5361b0 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:06:02 +0200 Subject: [PATCH 80/85] 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); From 56bdbca537efbe5c86142c549bf1e15310fb7444 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:09:18 +0200 Subject: [PATCH 81/85] 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 { From 13694915294d0ad6ab90564499e667ed13c33b7e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:22:55 +0200 Subject: [PATCH 82/85] 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 From 21dffefa8c9c16737658e652aedc6b2ad392635e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:29:03 +0200 Subject: [PATCH 83/85] 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) { From 3387a362a630904de6c5492f603d1661ead5f600 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:30:27 +0200 Subject: [PATCH 84/85] 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}`); } From c02a7c73807ba040503cd168d16f8648afffcd17 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Thu, 24 Nov 2022 23:56:42 +0200 Subject: [PATCH 85/85] 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}`); }