From ef01424b36ef3cfb0e4c4f8521bfe3caee89c4de Mon Sep 17 00:00:00 2001 From: DmitriyB Date: Thu, 2 Feb 2023 15:35:14 +0500 Subject: [PATCH] updated ui --- pixel-streaming-webrtc/.gitignore | 123 ++ pixel-streaming-webrtc/README.md | 3 + pixel-streaming-webrtc/WebServers/.gitignore | 5 + pixel-streaming-webrtc/WebServers/LICENSE.md | 7 + .../WebServers/Matchmaker/config.json | 6 + .../WebServers/Matchmaker/matchmaker.js | 295 ++++ .../WebServers/Matchmaker/modules/config.js | 49 + .../WebServers/Matchmaker/modules/logging.js | 108 ++ .../WebServers/Matchmaker/package-lock.json | 1491 +++++++++++++++++ .../WebServers/Matchmaker/package.json | 11 + .../platform_scripts/bash/common_utils.sh | 57 + .../Matchmaker/platform_scripts/bash/run.sh | 25 + .../Matchmaker/platform_scripts/bash/setup.sh | 114 ++ .../Matchmaker/platform_scripts/cmd/run.bat | 25 + .../Matchmaker/platform_scripts/cmd/setup.bat | 17 + .../platform_scripts/cmd/setup_node.bat | 35 + pixel-streaming-webrtc/WebServers/README.md | 45 + .../WebServers/SFU/.dockerignore | 1 + .../WebServers/SFU/config.js | 108 ++ .../SFU/mediasoup-sdp-bridge/LICENSE | 15 + .../SFU/mediasoup-sdp-bridge/README.md | 182 ++ .../lib/BrowserRtpCapabilities.js | 1182 +++++++++++++ .../SFU/mediasoup-sdp-bridge/lib/SdpUtils.js | 89 + .../SFU/mediasoup-sdp-bridge/lib/index.js | 198 +++ .../SFU/mediasoup-sdp-bridge/package.json | 27 + .../WebServers/SFU/package-lock.json | 371 ++++ .../WebServers/SFU/package.json | 23 + .../SFU/platform_scripts/bash/Dockerfile | 25 + .../SFU/platform_scripts/bash/common_utils.sh | 80 + .../SFU/platform_scripts/bash/docker-build.sh | 9 + .../SFU/platform_scripts/bash/docker-start.sh | 8 + .../SFU/platform_scripts/bash/docker-stop.sh | 12 + .../SFU/platform_scripts/bash/run_cloud.sh | 27 + .../SFU/platform_scripts/bash/run_local.sh | 27 + .../SFU/platform_scripts/bash/setup.sh | 114 ++ .../SFU/platform_scripts/cmd/run_cloud.bat | 19 + .../SFU/platform_scripts/cmd/run_local.bat | 25 + .../SFU/platform_scripts/cmd/setup.bat | 17 + .../SFU/platform_scripts/cmd/setup_node.bat | 35 + .../WebServers/SFU/sfu_server.js | 321 ++++ .../WebServers/SignallingWebServer | 1 + .../WebServers/get_ps_servers.bat | 110 ++ .../WebServers/get_ps_servers.sh | 93 + 43 files changed, 5535 insertions(+) create mode 100644 pixel-streaming-webrtc/.gitignore create mode 100644 pixel-streaming-webrtc/README.md create mode 100644 pixel-streaming-webrtc/WebServers/.gitignore create mode 100644 pixel-streaming-webrtc/WebServers/LICENSE.md create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/config.json create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/matchmaker.js create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/modules/config.js create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/modules/logging.js create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/package-lock.json create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/package.json create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/common_utils.sh create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/run.sh create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/setup.sh create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/run.bat create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup.bat create mode 100644 pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup_node.bat create mode 100644 pixel-streaming-webrtc/WebServers/README.md create mode 100644 pixel-streaming-webrtc/WebServers/SFU/.dockerignore create mode 100644 pixel-streaming-webrtc/WebServers/SFU/config.js create mode 100644 pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/LICENSE create mode 100644 pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/README.md create mode 100644 pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/BrowserRtpCapabilities.js create mode 100644 pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/SdpUtils.js create mode 100644 pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/index.js create mode 100644 pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/package.json create mode 100644 pixel-streaming-webrtc/WebServers/SFU/package-lock.json create mode 100644 pixel-streaming-webrtc/WebServers/SFU/package.json create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/Dockerfile create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/common_utils.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-build.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-start.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-stop.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_cloud.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_local.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/setup.sh create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_cloud.bat create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_local.bat create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup.bat create mode 100644 pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup_node.bat create mode 100644 pixel-streaming-webrtc/WebServers/SFU/sfu_server.js create mode 160000 pixel-streaming-webrtc/WebServers/SignallingWebServer create mode 100644 pixel-streaming-webrtc/WebServers/get_ps_servers.bat create mode 100644 pixel-streaming-webrtc/WebServers/get_ps_servers.sh diff --git a/pixel-streaming-webrtc/.gitignore b/pixel-streaming-webrtc/.gitignore new file mode 100644 index 0000000..23c3196 --- /dev/null +++ b/pixel-streaming-webrtc/.gitignore @@ -0,0 +1,123 @@ +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +logs/ +node_modules/ +**/platform_scripts/cmd/*/ +**/platform_scripts/bash/*/ +node.zip \ No newline at end of file diff --git a/pixel-streaming-webrtc/README.md b/pixel-streaming-webrtc/README.md new file mode 100644 index 0000000..e634d0c --- /dev/null +++ b/pixel-streaming-webrtc/README.md @@ -0,0 +1,3 @@ +# pixel-streaming-webrtc + +pixel streaming webrtc server \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/.gitignore b/pixel-streaming-webrtc/WebServers/.gitignore new file mode 100644 index 0000000..81a34ed --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/.gitignore @@ -0,0 +1,5 @@ +logs/ +node_modules/ +**/platform_scripts/cmd/*/ +**/platform_scripts/bash/*/ +node.zip \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/LICENSE.md b/pixel-streaming-webrtc/WebServers/LICENSE.md new file mode 100644 index 0000000..688fa9e --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2004-2022, Epic Games, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/config.json b/pixel-streaming-webrtc/WebServers/Matchmaker/config.json new file mode 100644 index 0000000..9ee3c27 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/config.json @@ -0,0 +1,6 @@ +{ + "HttpPort": 90, + "UseHTTPS": false, + "MatchmakerPort": 9999, + "LogToFile": true +} \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/matchmaker.js b/pixel-streaming-webrtc/WebServers/Matchmaker/matchmaker.js new file mode 100644 index 0000000..a1afca6 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/matchmaker.js @@ -0,0 +1,295 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +var enableRedirectionLinks = true; +var enableRESTAPI = true; + +const defaultConfig = { + // The port clients connect to the matchmaking service over HTTP + HttpPort: 80, + UseHTTPS: false, + // The matchmaking port the signaling service connects to the matchmaker + MatchmakerPort: 9999, + + // Log to file + LogToFile: true +}; + +// Similar to the Signaling Server (SS) code, load in a config.json file for the MM parameters +const argv = require('yargs').argv; + +var configFile = (typeof argv.configFile != 'undefined') ? argv.configFile.toString() : 'config.json'; +console.log(`configFile ${configFile}`); +const config = require('./modules/config.js').init(configFile, defaultConfig); +console.log("Config: " + JSON.stringify(config, null, '\t')); + +const express = require('express'); +var cors = require('cors'); +const app = express(); +const http = require('http').Server(app); +const fs = require('fs'); +const path = require('path'); +const logging = require('./modules/logging.js'); +logging.RegisterConsoleLogger(); + +if (config.LogToFile) { + logging.RegisterFileLogger('./logs'); +} + +// A list of all the Cirrus server which are connected to the Matchmaker. +var cirrusServers = new Map(); + +// +// Parse command line. +// + +if (typeof argv.HttpPort != 'undefined') { + config.HttpPort = argv.HttpPort; +} +if (typeof argv.MatchmakerPort != 'undefined') { + config.MatchmakerPort = argv.MatchmakerPort; +} + +http.listen(config.HttpPort, () => { + console.log('HTTP listening on *:' + config.HttpPort); +}); + + +if (config.UseHTTPS) { + //HTTPS certificate details + const options = { + key: fs.readFileSync(path.join(__dirname, './certificates/client-key.pem')), + cert: fs.readFileSync(path.join(__dirname, './certificates/client-cert.pem')) + }; + + var https = require('https').Server(options, app); + + //Setup http -> https redirect + console.log('Redirecting http->https'); + app.use(function (req, res, next) { + if (!req.secure) { + if (req.get('Host')) { + var hostAddressParts = req.get('Host').split(':'); + var hostAddress = hostAddressParts[0]; + if (httpsPort != 443) { + hostAddress = `${hostAddress}:${httpsPort}`; + } + return res.redirect(['https://', hostAddress, req.originalUrl].join('')); + } else { + console.error(`unable to get host name from header. Requestor ${req.ip}, url path: '${req.originalUrl}', available headers ${JSON.stringify(req.headers)}`); + return res.status(400).send('Bad Request'); + } + } + next(); + }); + + https.listen(443, function () { + console.log('Https listening on 443'); + }); +} + +// No servers are available so send some simple JavaScript to the client to make +// it retry after a short period of time. +function sendRetryResponse(res) { + res.send(`All ${cirrusServers.size} Cirrus servers are in use. Retrying in 3 seconds. + `); +} + +// Get a Cirrus server if there is one available which has no clients connected. +function getAvailableCirrusServer() { + for (cirrusServer of cirrusServers.values()) { + if (cirrusServer.numConnectedClients === 0 && cirrusServer.ready === true) { + + // Check if we had at least 10 seconds since the last redirect, avoiding the + // chance of redirecting 2+ users to the same SS before they click Play. + // In other words, give the user 10 seconds to click play button the claim the server. + if( cirrusServer.hasOwnProperty('lastRedirect')) { + if( ((Date.now() - cirrusServer.lastRedirect) / 1000) < 10 ) + continue; + } + cirrusServer.lastRedirect = Date.now(); + + return cirrusServer; + } + } + + console.log('WARNING: No empty Cirrus servers are available'); + return undefined; +} + +if(enableRESTAPI) { + // Handle REST signalling server only request. + app.options('/signallingserver', cors()) + app.get('/signallingserver', cors(), (req, res) => { + cirrusServer = getAvailableCirrusServer(); + if (cirrusServer != undefined) { + res.json({ signallingServer: `${cirrusServer.address}:${cirrusServer.port}`}); + console.log(`Returning ${cirrusServer.address}:${cirrusServer.port}`); + } else { + res.json({ signallingServer: '', error: 'No signalling servers available'}); + } + }); +} + +if(enableRedirectionLinks) { + // Handle standard URL. + app.get('/', (req, res) => { + cirrusServer = getAvailableCirrusServer(); + if (cirrusServer != undefined) { + res.redirect(`http://${cirrusServer.address}:${cirrusServer.port}/`); + //console.log(req); + console.log(`Redirect to ${cirrusServer.address}:${cirrusServer.port}`); + } else { + sendRetryResponse(res); + } + }); + + // Handle URL with custom HTML. + app.get('/custom_html/:htmlFilename', (req, res) => { + cirrusServer = getAvailableCirrusServer(); + if (cirrusServer != undefined) { + res.redirect(`http://${cirrusServer.address}:${cirrusServer.port}/custom_html/${req.params.htmlFilename}`); + console.log(`Redirect to ${cirrusServer.address}:${cirrusServer.port}`); + } else { + sendRetryResponse(res); + } + }); +} + +// +// Connection to Cirrus. +// + +const net = require('net'); + +function disconnect(connection) { + console.log(`Ending connection to remote address ${connection.remoteAddress}`); + connection.end(); +} + +const matchmaker = net.createServer((connection) => { + connection.on('data', (data) => { + try { + message = JSON.parse(data); + + if(message) + console.log(`Message TYPE: ${message.type}`); + } catch(e) { + console.log(`ERROR (${e.toString()}): Failed to parse Cirrus information from data: ${data.toString()}`); + disconnect(connection); + return; + } + if (message.type === 'connect') { + // A Cirrus server connects to this Matchmaker server. + cirrusServer = { + address: message.address, + port: message.port, + numConnectedClients: 0, + lastPingReceived: Date.now() + }; + cirrusServer.ready = message.ready === true; + + // Handles disconnects between MM and SS to not add dupes with numConnectedClients = 0 and redirect users to same SS + // Check if player is connected and doing a reconnect. message.playerConnected is a new variable sent from the SS to + // help track whether or not a player is already connected when a 'connect' message is sent (i.e., reconnect). + if(message.playerConnected == true) { + cirrusServer.numConnectedClients = 1; + } + + // Find if we already have a ciruss server address connected to (possibly a reconnect happening) + let server = [...cirrusServers.entries()].find(([key, val]) => val.address === cirrusServer.address && val.port === cirrusServer.port); + + // if a duplicate server with the same address isn't found -- add it to the map as an available server to send users to. + if (!server || server.size <= 0) { + console.log(`Adding connection for ${cirrusServer.address.split(".")[0]} with playerConnected: ${message.playerConnected}`) + cirrusServers.set(connection, cirrusServer); + } else { + console.log(`RECONNECT: cirrus server address ${cirrusServer.address.split(".")[0]} already found--replacing. playerConnected: ${message.playerConnected}`) + var foundServer = cirrusServers.get(server[0]); + + // Make sure to retain the numConnectedClients from the last one before the reconnect to MM + if (foundServer) { + cirrusServers.set(connection, cirrusServer); + console.log(`Replacing server with original with numConn: ${cirrusServer.numConnectedClients}`); + cirrusServers.delete(server[0]); + } else { + cirrusServers.set(connection, cirrusServer); + console.log("Connection not found in Map() -- adding a new one"); + } + } + } else if (message.type === 'streamerConnected') { + // The stream connects to a Cirrus server and so is ready to be used + cirrusServer = cirrusServers.get(connection); + if(cirrusServer) { + cirrusServer.ready = true; + console.log(`Cirrus server ${cirrusServer.address}:${cirrusServer.port} ready for use`); + } else { + disconnect(connection); + } + } else if (message.type === 'streamerDisconnected') { + // The stream connects to a Cirrus server and so is ready to be used + cirrusServer = cirrusServers.get(connection); + if(cirrusServer) { + cirrusServer.ready = false; + console.log(`Cirrus server ${cirrusServer.address}:${cirrusServer.port} no longer ready for use`); + } else { + disconnect(connection); + } + } else if (message.type === 'clientConnected') { + // A client connects to a Cirrus server. + cirrusServer = cirrusServers.get(connection); + if(cirrusServer) { + cirrusServer.numConnectedClients++; + console.log(`Client connected to Cirrus server ${cirrusServer.address}:${cirrusServer.port}`); + } else { + disconnect(connection); + } + } else if (message.type === 'clientDisconnected') { + // A client disconnects from a Cirrus server. + cirrusServer = cirrusServers.get(connection); + if(cirrusServer) { + cirrusServer.numConnectedClients--; + console.log(`Client disconnected from Cirrus server ${cirrusServer.address}:${cirrusServer.port}`); + if(cirrusServer.numConnectedClients === 0) { + // this make this server immediately available for a new client + cirrusServer.lastRedirect = 0; + } + } else { + disconnect(connection); + } + } else if (message.type === 'ping') { + cirrusServer = cirrusServers.get(connection); + if(cirrusServer) { + cirrusServer.lastPingReceived = Date.now(); + } else { + disconnect(connection); + } + } else { + console.log('ERROR: Unknown data: ' + JSON.stringify(message)); + disconnect(connection); + } + }); + + // A Cirrus server disconnects from this Matchmaker server. + connection.on('error', () => { + cirrusServer = cirrusServers.get(connection); + if(cirrusServer) { + cirrusServers.delete(connection); + console.log(`Cirrus server ${cirrusServer.address}:${cirrusServer.port} disconnected from Matchmaker`); + } else { + console.log(`Disconnected machine that wasn't a registered cirrus server, remote address: ${connection.remoteAddress}`); + } + }); +}); + +matchmaker.listen(config.MatchmakerPort, () => { + console.log('Matchmaker listening on *:' + config.MatchmakerPort); +}); diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/modules/config.js b/pixel-streaming-webrtc/WebServers/Matchmaker/modules/config.js new file mode 100644 index 0000000..b599f03 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/modules/config.js @@ -0,0 +1,49 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +//-- Provides configuration information from file and combines it with default values and command line arguments --// +//-- Hierachy of values: Default Values < Config File < Command Line arguments --// + +const fs = require('fs'); +const path = require('path'); +const argv = require('yargs').argv; + +function initConfig(configFile, defaultConfig){ + defaultConfig = defaultConfig || {}; + + // Using object spread syntax: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals + let config = {...defaultConfig}; + try{ + let configData = fs.readFileSync(configFile, 'UTF8'); + fileConfig = JSON.parse(configData); + config = {...config, ...fileConfig} + // Update config file with any additional defaults (does not override existing values if default has changed) + fs.writeFileSync(configFile, JSON.stringify(config, null, '\t'), 'UTF8'); + } catch(err) { + if (err.code === 'ENOENT') { + console.log("No config file found, writing defaults to log file " + configFile); + fs.writeFileSync(configFile, JSON.stringify(config, null, '\t'), 'UTF8'); + } else if (err instanceof SyntaxError) { + console.log(`ERROR: Invalid JSON in ${configFile}, ignoring file config, ${err}`) + } else { + console.log(`ERROR: ${err}`); + } + } + + try{ + //Make a copy of the command line args and remove the unneccessary ones + //The _ value is an array of any elements without a key + let commandLineConfig = {...argv} + delete commandLineConfig._; + delete commandLineConfig.help; + delete commandLineConfig.version; + delete commandLineConfig['$0']; + config = {...config, ...commandLineConfig} + } catch(err) { + console.log(`ERROR: ${err}`); + } + return config; +} + +module.exports = { + init: initConfig +} \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/modules/logging.js b/pixel-streaming-webrtc/WebServers/Matchmaker/modules/logging.js new file mode 100644 index 0000000..9482c58 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/modules/logging.js @@ -0,0 +1,108 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +const fs = require('fs'); +const { Console } = require('console'); + +var loggers=[]; +var logFunctions=[]; +var logColorFunctions=[]; + +console.log = function(msg, ...args) { + logFunctions.forEach((logFunction) => { + logFunction(msg, ...args); + }); +} + +console.logColor = function(color, msg, ...args) { + logColorFunctions.forEach((logColorFunction) => { + logColorFunction(color, msg, ...args); + }); +} + +const AllAttributesOff = '\x1b[0m'; +const BoldOn = '\x1b[1m'; +const Black = '\x1b[30m'; +const Red = '\x1b[31m'; +const Green = '\x1b[32m'; +const Yellow = '\x1b[33m'; +const Blue = '\x1b[34m'; +const Magenta = '\x1b[35m'; +const Cyan = '\x1b[36m'; +const White = '\x1b[37m'; + +/** + * Pad the start of the given number with zeros so it takes up the number of digits. + * e.g. zeroPad(5, 3) = '005' and zeroPad(23, 2) = '23'. + */ +function zeroPad(number, digits) { + let string = number.toString(); + while (string.length < digits) { + string = '0' + string; + } + return string; +} + +/** + * Create a string of the form 'YEAR.MONTH.DATE.HOURS.MINUTES.SECONDS'. + */ +function dateTimeToString() { + let date = new Date(); + return `${date.getFullYear()}.${zeroPad(date.getMonth(), 2)}.${zeroPad(date.getDate(), 2)}.${zeroPad(date.getHours(), 2)}.${zeroPad(date.getMinutes(), 2)}.${zeroPad(date.getSeconds(), 2)}`; +} + +/** + * Create a string of the form 'HOURS.MINUTES.SECONDS.MILLISECONDS'. + */ +function timeToString() { + let date = new Date(); + return `${zeroPad(date.getHours(), 2)}:${zeroPad(date.getMinutes(), 2)}:${zeroPad(date.getSeconds(), 2)}.${zeroPad(date.getMilliseconds(), 3)}`; +} + +function RegisterFileLogger(path) { + if(path == null) + path = './'; + + if (!fs.existsSync(path)) + fs.mkdirSync(path); + + var output = fs.createWriteStream(`./logs/${dateTimeToString()}.log`); + var fileLogger = new Console(output); + logFunctions.push(function(msg, ...args) { + fileLogger.log(`${timeToString()} ${msg}`, ...args); + }); + + logColorFunctions.push(function(color, msg, ...args) { + fileLogger.log(`${timeToString()} ${msg}`, ...args); + }); + loggers.push(fileLogger); +} + +function RegisterConsoleLogger() { + var consoleLogger = new Console(process.stdout, process.stderr) + logFunctions.push(function(msg, ...args) { + consoleLogger.log(`${timeToString()} ${msg}`, ...args); + }); + + logColorFunctions.push(function(color, msg, ...args) { + consoleLogger.log(`${BoldOn}${color}${timeToString()} ${msg}${AllAttributesOff}`, ...args); + }); + loggers.push(consoleLogger); +} + +module.exports = { + //Functions + RegisterFileLogger, + RegisterConsoleLogger, + + //Variables + AllAttributesOff, + BoldOn, + Black, + Red, + Green, + Yellow, + Blue, + Magenta, + Cyan, + White +} \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/package-lock.json b/pixel-streaming-webrtc/WebServers/Matchmaker/package-lock.json new file mode 100644 index 0000000..8fd9de7 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/package-lock.json @@ -0,0 +1,1491 @@ +{ + "name": "cirrus-matchmaker", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "cirrus-matchmaker", + "version": "0.0.1", + "dependencies": { + "cors": "^2.8.5", + "express": "^4.16.2", + "socket.io": "4.4.1", + "yargs": "17.3.1" + } + }, + "node_modules/@socket.io/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ==", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/@types/component-emitter": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.11.tgz", + "integrity": "sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ==" + }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "node_modules/@types/cors": { + "version": "2.8.12", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", + "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==" + }, + "node_modules/@types/node": { + "version": "17.0.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.18.tgz", + "integrity": "sha512-eKj4f/BsN/qcculZiRSujogjvp5O/k4lOW5m35NopjZM/QwLOR075a8pJW5hD+Rtdm2DaCVPENS6KtSQnUD6BA==" + }, + "node_modules/accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "dependencies": { + "mime-types": "~2.1.18", + "negotiator": "0.6.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "node_modules/base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", + "engines": { + "node": "^4.5.0 || >= 5.9" + } + }, + "node_modules/body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "dependencies": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.1", + "http-errors": "~1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "~2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "~1.6.15" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" + }, + "node_modules/content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/engine.io": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.2.tgz", + "integrity": "sha512-v/7eGHxPvO2AWsksyx2PUsQvBafuvqs0jJJQ0FdmJG1b9qIvgSbqDRGwNhfk2XHaTTbTXiC4quRE8Q9nRjsrQQ==", + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.4.1", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.0.0", + "ws": "~8.2.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/engine.io-parser": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.3.tgz", + "integrity": "sha512-BtQxwF27XUNnSafQLvDi0dQ8s3i6VgzSoQMJacpIcGNrlUdfHSKbgm3jmjCVvQluGzqwujQMPAoMai3oYSTurg==", + "dependencies": { + "@socket.io/base64-arraybuffer": "~1.0.2" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/engine.io/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "dependencies": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.3", + "qs": "6.5.1", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/express/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/express/node_modules/safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "node_modules/finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "node_modules/ipaddr.js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", + "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "bin": { + "mime": "cli.js" + } + }, + "node_modules/mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "dependencies": { + "mime-db": "~1.33.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "node_modules/proxy-addr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", + "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", + "dependencies": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.6.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "dependencies": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/raw-body/node_modules/depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body/node_modules/http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "dependencies": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": ">= 1.3.1 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body/node_modules/setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "dependencies": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "node_modules/socket.io": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.4.1.tgz", + "integrity": "sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==", + "dependencies": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "debug": "~4.3.2", + "engine.io": "~6.1.0", + "socket.io-adapter": "~2.3.3", + "socket.io-parser": "~4.0.4" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/socket.io-adapter": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.3.3.tgz", + "integrity": "sha512-Qd/iwn3VskrpNO60BeRyCyr8ZWw9CPZyitW4AQwmRZ8zCiyDiL+znRnWX6tDHXnWn1sJrM1+b6Mn6wEDJJ4aYQ==" + }, + "node_modules/socket.io-parser": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.5.tgz", + "integrity": "sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig==", + "dependencies": { + "@types/component-emitter": "^1.2.10", + "component-emitter": "~1.3.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/ws": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", + "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.3.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.1.tgz", + "integrity": "sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-z9kApYUOCwoeZ78rfRYYWdiU/iNL6mwwYlkkZfJoyMR1xps+NEBX5X7XmRpxkZHhXJ6+Ey00IwKxBBSW9FIjyA==", + "engines": { + "node": ">=12" + } + } + }, + "dependencies": { + "@socket.io/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ==" + }, + "@types/component-emitter": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.11.tgz", + "integrity": "sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ==" + }, + "@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "@types/cors": { + "version": "2.8.12", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", + "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==" + }, + "@types/node": { + "version": "17.0.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.18.tgz", + "integrity": "sha512-eKj4f/BsN/qcculZiRSujogjvp5O/k4lOW5m35NopjZM/QwLOR075a8pJW5hD+Rtdm2DaCVPENS6KtSQnUD6BA==" + }, + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "~2.1.18", + "negotiator": "0.6.1" + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==" + }, + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.1", + "http-errors": "~1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "~2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "~1.6.15" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "requires": { + "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "engine.io": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.2.tgz", + "integrity": "sha512-v/7eGHxPvO2AWsksyx2PUsQvBafuvqs0jJJQ0FdmJG1b9qIvgSbqDRGwNhfk2XHaTTbTXiC4quRE8Q9nRjsrQQ==", + "requires": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.4.1", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.0.0", + "ws": "~8.2.3" + }, + "dependencies": { + "cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" + } + } + }, + "engine.io-parser": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.3.tgz", + "integrity": "sha512-BtQxwF27XUNnSafQLvDi0dQ8s3i6VgzSoQMJacpIcGNrlUdfHSKbgm3jmjCVvQluGzqwujQMPAoMai3oYSTurg==", + "requires": { + "@socket.io/base64-arraybuffer": "~1.0.2" + } + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.3", + "qs": "6.5.1", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + } + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", + "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + }, + "mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "requires": { + "mime-db": "~1.33.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", + "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.6.0" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": ">= 1.3.1 < 2" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "socket.io": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.4.1.tgz", + "integrity": "sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==", + "requires": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "debug": "~4.3.2", + "engine.io": "~6.1.0", + "socket.io-adapter": "~2.3.3", + "socket.io-parser": "~4.0.4" + } + }, + "socket.io-adapter": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.3.3.tgz", + "integrity": "sha512-Qd/iwn3VskrpNO60BeRyCyr8ZWw9CPZyitW4AQwmRZ8zCiyDiL+znRnWX6tDHXnWn1sJrM1+b6Mn6wEDJJ4aYQ==" + }, + "socket.io-parser": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.5.tgz", + "integrity": "sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig==", + "requires": { + "@types/component-emitter": "^1.2.10", + "component-emitter": "~1.3.0", + "debug": "~4.3.1" + } + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "ws": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", + "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", + "requires": {} + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yargs": { + "version": "17.3.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.1.tgz", + "integrity": "sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==", + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.0.0" + } + }, + "yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-z9kApYUOCwoeZ78rfRYYWdiU/iNL6mwwYlkkZfJoyMR1xps+NEBX5X7XmRpxkZHhXJ6+Ey00IwKxBBSW9FIjyA==" + } + } +} diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/package.json b/pixel-streaming-webrtc/WebServers/Matchmaker/package.json new file mode 100644 index 0000000..df7d59f --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/package.json @@ -0,0 +1,11 @@ +{ + "name": "cirrus-matchmaker", + "version": "0.0.1", + "description": "Cirrus servers connect to the Matchmaker which redirects a browser to the next available Cirrus server", + "dependencies": { + "cors": "^2.8.5", + "express": "^4.16.2", + "socket.io": "4.4.1", + "yargs": "17.3.1" + } +} diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/common_utils.sh b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/common_utils.sh new file mode 100644 index 0000000..402d44f --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/common_utils.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +function log_msg() { #message + if [ ! -z $VERBOSE ]; then + echo $1 + fi +} + +function print_usage() { + echo " + Usage: + ${0} [--help] [--publicip ] [--turn ] [--stun ] [cirrus options...] + Where: + --help will print this message and stop this script. + --debug will run all scripts with --inspect + --nosudo will run all scripts without \`sudo\` command useful for when run in containers. + --verbose will enable additional logging + --package-manager specify an alternative package manager to apt-get + " + exit 1 +} + +function use_args() { + while(($#)) ; do + case "$1" in + --debug ) IS_DEBUG=1; shift;; + --nosudo ) NO_SUDO=1; shift;; + --verbose ) VERBOSE=1; shift;; + --help ) print_usage;; + * ) echo "Unknown command"; shift;; + esac + done +} + +function call_setup_sh() { + bash "setup.sh" +} + +function start_process() { + if [ ! -z $NO_SUDO ]; then + log_msg "running with sudo removed" + eval $(echo "$@" | sed 's/sudo//g') + else + eval $@ + fi +} + +function get_version() { + local version=$1 + + if command -v $version; then + version=$($@) + fi + + echo $version | sed -E 's/[^0-9.]//g' +} diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/run.sh b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/run.sh new file mode 100644 index 0000000..180e552 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. +BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +pushd "${BASH_LOCATION}" > /dev/null + +source common_utils.sh + +use_args "$@" +call_setup_sh + +process="${BASH_LOCATION}/node/bin/node matchmaker.js" + +pushd ../.. > /dev/null + +echo "" +echo "Starting Matchmaker use ctrl-c to exit" +echo "-----------------------------------------" +echo "" + +start_process $process + +popd > /dev/null # ../.. + +popd > /dev/null # BASH_SOURCE \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/setup.sh b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/setup.sh new file mode 100644 index 0000000..3e947f5 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/bash/setup.sh @@ -0,0 +1,114 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. +BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +pushd "${BASH_LOCATION}" > /dev/null + +source common_utils.sh + +use_args $@ +# Azure specific fix to allow installing NodeJS from NodeSource +if test -f "/etc/apt/sources.list.d/azure-cli.list"; then + sudo touch /etc/apt/sources.list.d/nodesource.list + sudo touch /usr/share/keyrings/nodesource.gpg + sudo chmod 644 /etc/apt/sources.list.d/nodesource.list + sudo chmod 644 /usr/share/keyrings/nodesource.gpg + sudo chmod 644 /etc/apt/sources.list.d/azure-cli.list +fi + +function check_version() { #current_version #min_version + #check if same string + if [ -z "$2" ] || [ "$1" = "$2" ]; then + return 0 + fi + + local i current minimum + + IFS="." read -r -a current <<< $1 + IFS="." read -r -a minimum <<< $2 + + # fill empty fields in current with zeros + for ((i=${#current[@]}; i<${#minimum[@]}; i++)) + do + current[i]=0 + done + + for ((i=0; i<${#current[@]}; i++)) + do + if [[ -z ${minimum[i]} ]]; then + # fill empty fields in minimum with zeros + minimum[i]=0 + fi + + if ((10#${current[i]} > 10#${minimum[i]})); then + return 1 + fi + + if ((10#${current[i]} < 10#${minimum[i]})); then + return 2 + fi + done + + # if got this far string is the same once we added missing 0 + return 0 +} + +function check_and_install() { #dep_name #get_version_string #version_min #install_command + local is_installed=0 + + log_msg "Checking for required $1 install" + + local current=$(echo $2 | sed -E 's/[^0-9.]//g') + local minimum=$(echo $3 | sed -E 's/[^0-9.]//g') + + if [ $# -ne 4 ]; then + log_msg "check_and_install expects 4 args (dep_name get_version_string version_min install_command) got $#" + return -1 + fi + + if [ ! -z $current ]; then + log_msg "Current version: $current checking >= $minimum" + check_version "$current" "$minimum" + if [ "$?" -lt 2 ]; then + log_msg "$1 is installed." + return 0 + else + log_msg "Required install of $1 not found installing" + fi + fi + + if [ $is_installed -ne 1 ]; then + echo "$1 installation not found installing..." + + start_process $4 + + if [ $? -ge 1 ]; then + echo "Installation of $1 failed try running `export VERBOSE=1` then run this script again for more details" + exit 1 + fi + + fi +} + +echo "Checking Matchmaker dependencies..." + +# navigate to Matchmaker root +pushd ../.. > /dev/null + +node_version="" +if [[ -f "${BASH_LOCATION}/node/bin/node" ]]; then + node_version=$("${BASH_LOCATION}/node/bin/node" --version) +fi +check_and_install "node" "$node_version" "v16.4.2" "curl https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.gz --output node.tar.xz + && tar -xf node.tar.xz + && rm node.tar.xz + && mv node-v*-linux-x64 \"${BASH_LOCATION}/node\"" + +PATH="${BASH_LOCATION}/node/bin:$PATH" +"${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js" install + +popd > /dev/null # Matchmaker + +popd > /dev/null # BASH_SOURCE + +echo "All Matchmaker dependencies up to date." \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/run.bat b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/run.bat new file mode 100644 index 0000000..b94075e --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/run.bat @@ -0,0 +1,25 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script directory as working directory. +pushd "%~dp0" + +title Matchmaker + +@Rem Run setup to ensure we have node and matchmaker installed. +call setup.bat + +@Rem Move to matchmaker.js directory. +pushd ..\.. + +@Rem Run node server and pass any argument along. +platform_scripts\cmd\node\node.exe matchmaker %* + +@Rem Pop matchmaker.js directory. +popd + +@Rem Pop script directory. +popd + +pause \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup.bat b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup.bat new file mode 100644 index 0000000..6653bd5 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup.bat @@ -0,0 +1,17 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script location as working directory for commands. +pushd "%~dp0" + +@Rem Ensure we have NodeJs available for calling. +call setup_node.bat + +@Rem Move to matchmaker.js directory and install its package.json +pushd %~dp0\..\..\ +call platform_scripts\cmd\node\npm install --no-save +popd + +@Rem Pop working directory +popd diff --git a/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup_node.bat b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup_node.bat new file mode 100644 index 0000000..cc079e5 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/Matchmaker/platform_scripts/cmd/setup_node.bat @@ -0,0 +1,35 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script location as working directory for commands. +pushd "%~dp0" + +@Rem Name and version of node that we are downloading +SET NodeVersion=v16.4.2 +SET NodeName=node-%NodeVersion%-win-x64 + +@Rem Look for a node directory next to this script +if exist node\ ( + echo Node directory found...skipping install. +) else ( + echo Node directory not found...beginning NodeJS download for Windows. + + @Rem Download nodejs and follow redirects. + curl -L -o ./node.zip "https://nodejs.org/dist/%NodeVersion%/%NodeName%.zip" + + @Rem Unarchive the .zip + tar -xf node.zip + + @Rem Rename the extracted, versioned, directory that contains the NodeJS binaries to simply "node". + ren "%NodeName%\" "node" + + @Rem Delete the downloaded node.zip + del node.zip +) + +@Rem Print node version +echo Node version: & node\node.exe -v + +@Rem Pop working directory +popd \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/README.md b/pixel-streaming-webrtc/WebServers/README.md new file mode 100644 index 0000000..cc701d4 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/README.md @@ -0,0 +1,45 @@ +# The new home for the Pixel Streaming servers! +The Pixel Streaming servers and web frontend that was in `Samples/PixelStreaming/WebServers` is now here. + +## Goals + +The goals of this repository are to: + +- Increase the release cadence for the Pixel Streaming servers (to mitigate browser breaking changes sooner). +- Encourage easier contribution of these components by Unreal Engine licensees. +- Facilitate a more standard web release mechanism (e.g. NPM packages or similar... coming soon). +- Grant a permissive license to distribute and modify this code wherever you see fit (MIT licensed). + +## Repository contents + +Reference implementations for the various pieces needed to support a PixelStreaming application: +- SignallingWebServer (Cirrus) +- SFU (Selective Forwarding Unit) +- Matchmaker + +## Container images + +The following container images are built from this repository: + +- [ghcr.io/epicgames/pixel-streaming-signalling-server](https://github.com/orgs/EpicGames/packages/container/package/pixel-streaming-signalling-server) (since Unreal Engine 5.1) + +## Versions + +We maintain versions of the servers and frontend that are compatible with existing and in-development version of Unreal Engine. + +:warning: **There are breaking changes between UE versions - so make sure you get the right version**. :warning: + +We maintain the following in branches right now: + +[Master](https://github.com/EpicGames/PixelStreamingInfrastructure/tree/master) (This is our dev branch.) + +[UE5.1](https://github.com/EpicGames/PixelStreamingInfrastructure/tree/UE5.1) + +[UE5.0](https://github.com/EpicGames/PixelStreamingInfrastructure/tree/UE5.0) + +[UE4.27](https://github.com/EpicGames/PixelStreamingInfrastructure/tree/UE4.27) + +[UE4.26](https://github.com/EpicGames/PixelStreamingInfrastructure/tree/UE4.26) + +## Legal +Ā© 2004-2022, Epic Games, Inc. Unreal and its logo are Epic’s trademarks or registered trademarks in the US and elsewhere. diff --git a/pixel-streaming-webrtc/WebServers/SFU/.dockerignore b/pixel-streaming-webrtc/WebServers/SFU/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/pixel-streaming-webrtc/WebServers/SFU/config.js b/pixel-streaming-webrtc/WebServers/SFU/config.js new file mode 100644 index 0000000..1387c88 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/config.js @@ -0,0 +1,108 @@ +// Parse passed arguments +let passedPublicIP = null; +for(let arg of process.argv){ + if(arg && arg.startsWith("--PublicIP=")){ + let splitArr = arg.split("="); + if(splitArr.length == 2){ + passedPublicIP = splitArr[1]; + console.log("--PublicIP=" + passedPublicIP); + } + } +} + +const config = { + signallingURL: "ws://localhost:8889", + + mediasoup: { + worker: { + rtcMinPort: 40000, + rtcMaxPort: 49999, + logLevel: "debug", + logTags: [ + "info", + "ice", + "dtls", + "rtp", + "srtp", + "rtcp", + "sctp" + // 'rtx', + // 'bwe', + // 'score', + // 'simulcast', + // 'svc' + ], + }, + router: { + mediaCodecs: [ + { + kind: "audio", + mimeType: "audio/opus", + clockRate: 48000, + channels: 2, + }, + { + kind: 'video', + mimeType: 'video/VP8', + clockRate: 90000, + parameters: { + "packetization-mode": 1, + "profile-level-id": "42e01f", + "level-asymmetry-allowed": 1 + } + }, + { + kind: "video", + mimeType: "video/h264", + clockRate: 90000, + parameters: { + "packetization-mode": 1, + "profile-level-id": "42e01f", + "level-asymmetry-allowed": 1 + }, + }, + + ], + }, + + // here you must specify ip addresses to listen on + // some browsers have issues with connecting to ICE on + // localhost so you might have to specify a proper + // private or public ip here. + webRtcTransport: { + listenIps: passedPublicIP != null ? [{ ip: "0.0.0.0", announcedIp: passedPublicIP}] : getLocalListenIps(), + // 100 megabits + initialAvailableOutgoingBitrate: 100_000_000, + }, + }, +} + +function getLocalListenIps() { + const listenIps = [] + if (typeof window === 'undefined') { + const os = require('os') + const networkInterfaces = os.networkInterfaces() + const ips = [] + if (networkInterfaces) { + for (const [key, addresses] of Object.entries(networkInterfaces)) { + addresses.forEach(address => { + if (address.family === 'IPv4') { + listenIps.push({ ip: address.address, announcedIp: null }) + } + /* ignore link-local and other special ipv6 addresses. + * https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml + */ + else if (address.family === 'IPv6' && address.address[0] !== 'f') { + listenIps.push({ ip: address.address, announcedIp: null }) + } + }) + } + } + } + if (listenIps.length === 0) { + listenIps.push({ ip: '127.0.0.1', announcedIp: null }) + } + return listenIps +} + +module.exports = config; diff --git a/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/LICENSE b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/LICENSE new file mode 100644 index 0000000..706f43b --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright Ā© 2020, IƱaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/README.md b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/README.md new file mode 100644 index 0000000..bcf8257 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/README.md @@ -0,0 +1,182 @@ +# mediasoup-sdp-bridge v3 + +[![][npm-shield-mediasoup-sdp-bridge]][npm-mediasoup-sdp-bridge] +[![][travis-ci-shield-mediasoup-sdp-bridge]][travis-ci-mediasoup-sdp-bridge] + +Node.js library to allow integration of SDP based clients with [mediasoup][mediasoup-website]. + + +## Website and Documentation + +* [mediasoup.org][mediasoup-website] + + +## Support Forum + +* [mediasoup.discourse.group][mediasoup-discourse] + + +## Use-Case Design Proposal + +This section contains a use-case that can serve as usage example to guide design of the internal implementation. + +Within the Node.js server app running mediasoup: + + +### mediasoup receiving media from a remote SDP endpoint + +```typescript +import * as SdpBridge from "mediasoup-sdp-bridge"; +import Signaling from "./my-signaling"; // Our own signaling stuff. + +const transport: Transport = ... // A mediasoup WebRtcTransport or PlainTransport. + +// Create an SdpEndpoint to handle SDP negotiation with the remote endpoint. +const sdpEndpoint = await SdpBridge.createSdpEndpoint({ + transport: transport, +}); + +// Upon receipt of an SDP Offer from the remote endpoint, apply it. +Signaling.on("sdp-offer", async (sdpOffer: string) => { + // For each media section in the SDP Offer, SdpEndpoint creates a new Producer + // on top of the Transport that was provided. + const producers: Producer[] = await sdpEndpoint.processOffer(sdpOffer); + + // Generate an SDP Answer and reply to the remote endpoint with it. + const sdpAnswer: string = sdpEndpoint.createAnswer(); + + await Signaling.sendAnswer(sdpAnswer); +}); +``` + + +### mediasoup sending media to a remote SDP endpoint + +```typescript +import * as SdpBridge from "mediasoup-sdp-bridge"; +import Signaling from "./my-signaling"; // Our own signaling stuff. + +const transport: Transport = ... // A mediasoup WebRtcTransport or PlainTransport. + +// Create an SdpEndpoint to send media to the remote endpoint. +const sdpEndpoint = await createSdpEndpoint({ + transport: transport, +}); + +// Listen for the "negotiationneeded" event, to send an SDP Offer to the remote +// endpoint. This event is emitted when transport.consume() is called, or when +// a Producer being consumed is closed or paused/resumed. +sdpEndpoint.on("negotiationneeded", () => { + // For each Consumer present in the Transport that was provided, + // SdpEndpoint creates a new media section in the SDP Offer. + const sdpOffer: string = sdpEndpoint.createOffer(); + + // Send the SDP Offer to the remote endpoint. + await Signaling.sendOffer(sdpOffer); +}); + +// Upon receipt of an SDP Answer from the remote endpoint, apply it. +Signaling.on("sdp-answer", async (sdpAnswer: string) => { + await sdpEndpoint.processAnswer(sdpAnswer); +}); + +// Generate remote endpoint's RTP capabilities based on a remote SDP or based +// on handmade capabilities. +const endpointRtpCapabilities = SdpBridge.generateRtpCapabilities( + router.rtpCapabilities, + remoteSdp +); +// or: +const endpointRtpCapabilities = SdpBridge.generateRtpCapabilities( + router.rtpCapabilities, + handmadeRtpCapabilities +); + +// If there were mediasoup Producers already created in the Router, or if a new +// one is created, and we want to consume them in the remote endpoint, tell the +// Transport to consume them. transport.consume() method will trigger the +// "negotiationneeded" event, handled above. +// +// NOTE: By calling consume() method in parallel (without waiting for the +// previous one to complete) we ensure that the "negotiationneeded" event will +// just be emitted once upon completion of all consume() calls, so a single +// SDP Offer/Answer roundtrip will be needed. +transport + .consume({ + producerId: producer1.id, + rtpCapabilities: endpointRtpCapabilities, + }) + .catch((error) => console.error("transport.consume() failed:", error)); + +transport + .consume({ + producerId: producer2.id, + rtpCapabilities: endpointRtpCapabilities, + }) + .catch((error) => console.error("transport.consume() failed:", error)); +``` + + +## Implementation Notes + +### Design limitations + +The initial Use-Case Design Proposal lacks an important detail: it uses an `endpointRtpCapabilities` object, which represents the WebRTC and RTP capabilities of the remote endpoint that will receive media from mediasoup. This *RtpCapabilities* object is assumed to be written either by hand, or obtained from a previous SDP message that somehow might have been obtained from the remote endpoint. It is only *after* having these *RtpCapabilities*, that the SDP Offer/Answer process starts. + +All this, however, goes backwards with the normal flow of the SDP Offer/Answer model. **The remote capabilities should be obtained from the SDP Offer/Answer exchange itself**, not as an unspecified out-of-band mechanism. In theory, how the mediasoup application learns about remote capabilities should come from one of these sources: + +1. An SDP Offer (with *recvonly* or *sendrecv* direction) from a remote endpoint that wants to receive media. + +2. An SDP Answer (with *recvonly* or *sendrecv* direction) from a remote endpoint, in response to an SDP Offer (with *sendonly* or *sendrecv* direction) that the application had previously sent. + +However, in practice both of these options conflict with the current design proposal: + +* (1) is not being considered for now. mediasoup is designed around the assumption that the participant sending media should always be the one starting the connection; thus, the endpoint that will send media is also the one sending the SDP Offer. + +* (2) is the ideal but *it's not possible* with the current design, because the remote capabilities must be already known by the time `sdpEndpoint.createOffer()` is called. + +(Note: Additionally, the *sendrecv* direction is also not considered for now. Both the local application or the remote endpoints are be assumed to be either *sendonly* or *recvonly*.) + + +### Current implementation + +The implementation found in this repo is enough to cover basic usage, but is not complete by any means. Also, it tries to work around the limitations described above, using alternatives that are far from ideal. + +Some notes: + +* Receiving media is the part that works best. It suffices to call `SdpEndpoint.processOffer()`, and this will return one Producer for each media section found in the SDP Offer. + +* Sending media, on the other hand, suffers from the limitation described in (2) above. To work around this, the class `BrowserRtpCapabilities` contains predefined capabilities objects for some of the most common web browsers. These can be used by the application to provide `transport.consume()` with something to work with. + + The obvious drawback to this solution is that the objects in `BrowserRtpCapabilities` must be kept up to date from time to time, in order to accurately represent the actual capabilities of web browsers. To help with this task, there is a handy tool that can be found in the [tools/browser-rtpcapabilities](./tools/browser-rtpcapabilities/) subdirectory. + +* SDP renegotiation is not implemented. The local endpoint cannot make an SDP Re-Offer when the state of the Producers or Consumers changes. + +* There are minor improvements to be done in the implementation. + + - Right now the SdpEndpoint class exports an `SdpEndpoint.addConsumer()` method, which the application uses to provide all Consumers that are created from the corresponding Transport. However, chances are that this is unnecessary: the Transport class already provides an observer event `Transport.observer.on("newconsumer")`, which could be used by the SdpEndpoint to be notified of all new Consumers in its Transport, saving the application the need to provide them explicitly with `addConsumer()`. + + - Some unexpected errors are not handled gracefully, and instead a "BUG" error is logged before the application is forced to exit. These should probably be replaced by a `throw new Error(...)`. + + - Some debug messages are simply commented out to avoid causing too much noise. A proper logging library should be used to allow setting different levels and hiding the less interesting ones. + + - The code hasn't been linted. The default linter rules were left as per the initial commit, but haven't been used yet. For now, the code has just been formatted with the default rules from *Prettier.js*. + + +## Contributors + +* IƱaki Baz Castillo [[website](https://inakibaz.me)|[github](https://github.com/ibc/)] +* Juan Navarro [[github](https://github.com/j1elo)] + + +## License + +[ISC](./LICENSE) + + +[mediasoup-website]: https://mediasoup.org +[mediasoup-discourse]: https://mediasoup.discourse.group +[npm-shield-mediasoup-sdp-bridge]: https://img.shields.io/npm/v/mediasoup-sdp-bridge.svg +[npm-mediasoup-sdp-bridge]: https://npmjs.org/package/mediasoup-sdp-bridge +[travis-ci-shield-mediasoup-sdp-bridge]: https://travis-ci.com/versatica/mediasoup-sdp-bridge.svg?branch=master +[travis-ci-mediasoup-sdp-bridge]: https://travis-ci.com/versatica/mediasoup-sdp-bridge diff --git a/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/BrowserRtpCapabilities.js b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/BrowserRtpCapabilities.js new file mode 100644 index 0000000..efd1a70 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/BrowserRtpCapabilities.js @@ -0,0 +1,1182 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.safari = exports.chrome = exports.firefox = void 0; +exports.firefox = { + codecs: [ + { + kind: "audio", + mimeType: "audio/opus", + preferredPayloadType: 109, + clockRate: 48000, + channels: 2, + parameters: { + maxplaybackrate: 48000, + stereo: 1, + useinbandfec: 1, + }, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/G722", + preferredPayloadType: 9, + clockRate: 8000, + channels: 1, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/PCMU", + preferredPayloadType: 0, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/PCMA", + preferredPayloadType: 8, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 101, + clockRate: 8000, + channels: 1, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/VP8", + preferredPayloadType: 120, + clockRate: 90000, + parameters: { + "max-fs": 12288, + "max-fr": 60, + }, + rtcpFeedback: [ + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 124, + clockRate: 90000, + parameters: { + apt: 120, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/VP9", + preferredPayloadType: 121, + clockRate: 90000, + parameters: { + "max-fs": 12288, + "max-fr": 60, + }, + rtcpFeedback: [ + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 125, + clockRate: 90000, + parameters: { + apt: 121, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 126, + clockRate: 90000, + parameters: { + "profile-level-id": "42e01f", + "level-asymmetry-allowed": 1, + "packetization-mode": 1, + }, + rtcpFeedback: [ + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 127, + clockRate: 90000, + parameters: { + apt: 126, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 97, + clockRate: 90000, + parameters: { + "profile-level-id": "42e01f", + "level-asymmetry-allowed": 1, + }, + rtcpFeedback: [ + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 98, + clockRate: 90000, + parameters: { + apt: 97, + }, + rtcpFeedback: [], + }, + ], + headerExtensions: [ + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:ssrc-audio-level", + preferredId: 1, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:mid", + preferredId: 3, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:mid", + preferredId: 3, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + preferredId: 4, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:toffset", + preferredId: 5, + }, + { + kind: "video", + uri: "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + preferredId: 7, + }, + ], +}; +exports.chrome = { + codecs: [ + { + kind: "audio", + mimeType: "audio/opus", + preferredPayloadType: 111, + clockRate: 48000, + channels: 2, + parameters: { + minptime: 10, + useinbandfec: 1, + }, + rtcpFeedback: [ + { + type: "transport-cc", + }, + ], + }, + { + kind: "audio", + mimeType: "audio/ISAC", + preferredPayloadType: 103, + clockRate: 16000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/ISAC", + preferredPayloadType: 104, + clockRate: 32000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/G722", + preferredPayloadType: 9, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/PCMU", + preferredPayloadType: 0, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/PCMA", + preferredPayloadType: 8, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/CN", + preferredPayloadType: 106, + clockRate: 32000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/CN", + preferredPayloadType: 105, + clockRate: 16000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/CN", + preferredPayloadType: 13, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 110, + clockRate: 48000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 112, + clockRate: 32000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 113, + clockRate: 16000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 126, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/VP8", + preferredPayloadType: 96, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 97, + clockRate: 90000, + parameters: { + apt: 96, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/VP9", + preferredPayloadType: 98, + clockRate: 90000, + parameters: { + "profile-id": 0, + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 99, + clockRate: 90000, + parameters: { + apt: 98, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/VP9", + preferredPayloadType: 100, + clockRate: 90000, + parameters: { + "profile-id": 2, + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 101, + clockRate: 90000, + parameters: { + apt: 100, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 102, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 1, + "profile-level-id": "42001f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 121, + clockRate: 90000, + parameters: { + apt: 102, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 127, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 0, + "profile-level-id": "42001f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 120, + clockRate: 90000, + parameters: { + apt: 127, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 125, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 1, + "profile-level-id": "42e01f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 107, + clockRate: 90000, + parameters: { + apt: 125, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 108, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 0, + "profile-level-id": "42e01f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 109, + clockRate: 90000, + parameters: { + apt: 108, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/AV1X", + preferredPayloadType: 35, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 36, + clockRate: 90000, + parameters: { + apt: 35, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/red", + preferredPayloadType: 124, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 119, + clockRate: 90000, + parameters: { + apt: 124, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/ulpfec", + preferredPayloadType: 123, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [], + }, + ], + headerExtensions: [ + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:ssrc-audio-level", + preferredId: 1, + }, + { + kind: "audio", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + preferredId: 2, + }, + { + kind: "audio", + uri: "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + preferredId: 3, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:mid", + preferredId: 4, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", + preferredId: 5, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id", + preferredId: 6, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:toffset", + preferredId: 14, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + preferredId: 2, + }, + { + kind: "video", + uri: "urn:3gpp:video-orientation", + preferredId: 13, + }, + { + kind: "video", + uri: "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + preferredId: 3, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay", + preferredId: 12, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type", + preferredId: 11, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/video-timing", + preferredId: 7, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/color-space", + preferredId: 8, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:mid", + preferredId: 4, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", + preferredId: 5, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id", + preferredId: 6, + }, + ], +}; +exports.safari = { + codecs: [ + { + kind: "audio", + mimeType: "audio/opus", + preferredPayloadType: 111, + clockRate: 48000, + channels: 2, + parameters: { + minptime: 10, + useinbandfec: 1, + }, + rtcpFeedback: [ + { + type: "transport-cc", + }, + ], + }, + { + kind: "audio", + mimeType: "audio/ISAC", + preferredPayloadType: 103, + clockRate: 16000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/G722", + preferredPayloadType: 9, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/PCMU", + preferredPayloadType: 0, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/PCMA", + preferredPayloadType: 8, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/CN", + preferredPayloadType: 105, + clockRate: 16000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/CN", + preferredPayloadType: 13, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 110, + clockRate: 48000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 113, + clockRate: 16000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "audio", + mimeType: "audio/telephone-event", + preferredPayloadType: 126, + clockRate: 8000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 96, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 1, + "profile-level-id": "640c1f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 97, + clockRate: 90000, + parameters: { + apt: 96, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 98, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 1, + "profile-level-id": "42e01f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 99, + clockRate: 90000, + parameters: { + apt: 98, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 100, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 0, + "profile-level-id": "640c1f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 101, + clockRate: 90000, + parameters: { + apt: 100, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/H264", + preferredPayloadType: 102, + clockRate: 90000, + parameters: { + "level-asymmetry-allowed": 1, + "packetization-mode": 0, + "profile-level-id": "42e01f", + }, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 127, + clockRate: 90000, + parameters: { + apt: 102, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/VP8", + preferredPayloadType: 104, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [ + { + type: "goog-remb", + }, + { + type: "transport-cc", + }, + { + type: "ccm", + parameter: "fir", + }, + { + type: "nack", + }, + { + type: "nack", + parameter: "pli", + }, + ], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 125, + clockRate: 90000, + parameters: { + apt: 104, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/red", + preferredPayloadType: 106, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/rtx", + preferredPayloadType: 107, + clockRate: 90000, + parameters: { + apt: 106, + }, + rtcpFeedback: [], + }, + { + kind: "video", + mimeType: "video/ulpfec", + preferredPayloadType: 108, + clockRate: 90000, + parameters: {}, + rtcpFeedback: [], + }, + ], + headerExtensions: [ + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:ssrc-audio-level", + preferredId: 1, + }, + { + kind: "audio", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + preferredId: 2, + }, + { + kind: "audio", + uri: "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + preferredId: 3, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:mid", + preferredId: 4, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", + preferredId: 5, + }, + { + kind: "audio", + uri: "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id", + preferredId: 6, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:toffset", + preferredId: 14, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", + preferredId: 2, + }, + { + kind: "video", + uri: "urn:3gpp:video-orientation", + preferredId: 13, + }, + { + kind: "video", + uri: "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", + preferredId: 3, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay", + preferredId: 12, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type", + preferredId: 11, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/video-timing", + preferredId: 7, + }, + { + kind: "video", + uri: "http://www.webrtc.org/experiments/rtp-hdrext/color-space", + preferredId: 8, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:mid", + preferredId: 4, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", + preferredId: 5, + }, + { + kind: "video", + uri: "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id", + preferredId: 6, + }, + ], +}; +//# sourceMappingURL=BrowserRtpCapabilities.js.map \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/SdpUtils.js b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/SdpUtils.js new file mode 100644 index 0000000..a1feb6f --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/SdpUtils.js @@ -0,0 +1,89 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sdpToSendRtpParameters = exports.sdpToRecvRtpCapabilities = void 0; +const MsRtpUtils = __importStar(require("mediasoup-client/lib/handlers/sdp/unifiedPlanUtils")); +const MsSdpUtils = __importStar(require("mediasoup-client/lib/handlers/sdp/commonUtils")); +const MsOrtc = __importStar(require("mediasoup-client/lib/ortc")); +require("util").inspect.defaultOptions.depth = null; +function sdpToRecvRtpCapabilities(sdpObject, localCaps) { + const caps = MsSdpUtils.extractRtpCapabilities({ + sdpObject, + }); + try { + MsOrtc.validateRtpCapabilities(caps); + } + catch (err) { + console.error("FIXME BUG:", err); + process.exit(1); + } + const extendedCaps = MsOrtc.getExtendedRtpCapabilities(caps, localCaps); + const recvCaps = MsOrtc.getRecvRtpCapabilities(extendedCaps); + { + } + return recvCaps; +} +exports.sdpToRecvRtpCapabilities = sdpToRecvRtpCapabilities; +function sdpToSendRtpParameters(sdpObject, sdpMediaObj, localCaps, kind) { + var _a; + const caps = MsSdpUtils.extractRtpCapabilities({ + sdpObject, + }); + try { + MsOrtc.validateRtpCapabilities(caps); + } + catch (err) { + console.error("FIXME BUG:", err); + process.exit(1); + } + const extendedCaps = MsOrtc.getExtendedRtpCapabilities(caps, localCaps); + const sendParams = MsOrtc.getSendingRemoteRtpParameters(kind, extendedCaps); + // const sdpMediaObj = (sdpObject.media || []).find((m) => m.type === kind) || + // {}; + if ("mid" in sdpMediaObj) { + sendParams.mid = String(sdpMediaObj.mid); + } + else { + sendParams.mid = kind === "audio" ? "0" : "1"; + } + if ("rids" in sdpMediaObj) { + for (const mediaRid of sdpMediaObj.rids) { + (_a = sendParams.encodings) === null || _a === void 0 ? void 0 : _a.push({ rid: mediaRid.id }); + } + } + else { + // sendParams.encodings = MsRtpUtils.getRtpEncodings({ + // sdpObject, + // kind, + // }); + sendParams.encodings = MsRtpUtils.getRtpEncodings({ offerMediaObject: sdpMediaObj }); + } + sendParams.rtcp = { + cname: MsSdpUtils.getCname({ offerMediaObject: sdpMediaObj }), + reducedSize: "rtcpRsize" in sdpMediaObj && sdpMediaObj.rtcpRsize, + mux: "rtcpMux" in sdpMediaObj && sdpMediaObj.rtcpMux, + }; + { + } + return sendParams; +} +exports.sdpToSendRtpParameters = sdpToSendRtpParameters; +//# sourceMappingURL=SdpUtils.js.map \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/index.js b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/index.js new file mode 100644 index 0000000..2725e69 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/lib/index.js @@ -0,0 +1,198 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.generateRtpCapabilities2 = exports.generateRtpCapabilities1 = exports.generateRtpCapabilities0 = exports.createSdpEndpoint = exports.SdpEndpoint = void 0; +const MsSdpUtils = __importStar(require("mediasoup-client/lib/handlers/sdp/commonUtils")); +const RemoteSdp_1 = require("mediasoup-client/lib/handlers/sdp/RemoteSdp"); +const SdpTransform = __importStar(require("sdp-transform")); +const uuid_1 = require("uuid"); +const BrowserRtpCapabilities = __importStar(require("./BrowserRtpCapabilities")); +const SdpUtils = __importStar(require("./SdpUtils")); +const MediaSection_1 = require("mediasoup-client/lib/handlers/sdp/MediaSection"); +require("util").inspect.defaultOptions.depth = null; +class SdpEndpoint { + constructor(webRtcTransport, localCaps) { + this.producers = []; + this.producerMedias = []; + this.consumers = []; + this.webRtcTransport = webRtcTransport; + this.transport = webRtcTransport; + this.localCaps = localCaps; + this.sctpMedia = null; + this.consumeData = false; + } + async processOffer(sdpOffer) { + if (this.remoteSdp) { + console.error("[SdpEndpoint.processOffer] ERROR: A remote description was already set"); + return []; + } + this.remoteSdp = sdpOffer; + const remoteSdpObj = SdpTransform.parse(sdpOffer); + await this.webRtcTransport.connect({ + dtlsParameters: MsSdpUtils.extractDtlsParameters({ + sdpObject: remoteSdpObj, + }), + }); + for (const media of remoteSdpObj.media) { + if (media.type == "application") { + this.sctpMedia = media; + console.log("[SdpEndpoint.processOffer] SCTP association received"); + } + else { + if (!("rtp" in media)) { + continue; + } + if (!("direction" in media)) { + continue; + } + if (media.direction !== "sendonly") { + continue; + } + const sendParams = SdpUtils.sdpToSendRtpParameters(remoteSdpObj, media, this.localCaps, media.type); + let producer; + try { + producer = await this.transport.produce({ + kind: media.type, + rtpParameters: sendParams, + paused: false, + }); + } + catch (err) { + console.error("FIXME BUG:", err); + process.exit(1); + } + this.producers.push(producer); + this.producerMedias.push(media); + console.log("[SdpEndpoint.processOffer] mediasoup Producer created, kind: %s, type: %s, paused: %s", producer.kind, producer.type, producer.paused); + } + } + return this.producers; + } + createAnswer() { + if (this.localSdp) { + console.error("[SdpEndpoint.createAnswer] ERROR: A local description was already set"); + return ""; + } + const sdpBuilder = new RemoteSdp_1.RemoteSdp({ + iceParameters: this.webRtcTransport.iceParameters, + iceCandidates: this.webRtcTransport.iceCandidates, + dtlsParameters: this.webRtcTransport.dtlsParameters, + sctpParameters: this.webRtcTransport.sctpParameters, + planB: false, + }); + console.log("[SdpEndpoint.createAnswer] Make 'recvonly' SDP Answer"); + for (let i = 0; i < this.producers.length; i++) { + const sdpMediaObj = this.producerMedias[i]; + const recvParams = this.producers[i].rtpParameters; + sdpBuilder.send({ + offerMediaObject: sdpMediaObj, + reuseMid: undefined, + offerRtpParameters: recvParams, + answerRtpParameters: recvParams, + codecOptions: undefined, + extmapAllowMixed: false, + }); + } + if (this.sctpMedia != null) { + sdpBuilder.sendSctpAssociation({offerMediaObject: this.sctpMedia}); + } + this.localSdp = sdpBuilder.getSdp(); + return this.localSdp; + } + addConsumer(consumer) { + this.consumers.push(consumer); + } + addConsumeData() { + this.consumeData = true; + } + createOffer() { + var _a; + if (this.localSdp) { + console.error("[SdpEndpoint.createOffer] ERROR: A local description was already set"); + return ""; + } + const sdpBuilder = new RemoteSdp_1.RemoteSdp({ + iceParameters: this.webRtcTransport.iceParameters, + iceCandidates: this.webRtcTransport.iceCandidates, + dtlsParameters: this.webRtcTransport.dtlsParameters, + sctpParameters: this.webRtcTransport.sctpParameters, + planB: false, + }); + const sendMsid = uuid_1.v4().substr(0, 8); + console.log("[SdpEndpoint.createOffer] Make 'sendonly' SDP Offer"); + for (let i = 0; i < this.consumers.length; i++) { + const mid = (_a = this.consumers[i].rtpParameters.mid) !== null && _a !== void 0 ? _a : "nomid"; + const kind = this.consumers[i].kind; + const sendParams = this.consumers[i].rtpParameters; + sdpBuilder.receive({ + mid, + kind, + offerRtpParameters: sendParams, + streamId: sendMsid, + trackId: `${sendMsid}-${kind}`, + }); + } + if (this.consumeData) { + sdpBuilder.receiveSctpAssociation(); + } + this.localSdp = sdpBuilder.getSdp(); + return this.localSdp; + } + async processAnswer(sdpAnswer) { + if (this.remoteSdp) { + console.error("[SdpEndpoint.processAnswer] ERROR: A remote description was already set"); + return; + } + this.remoteSdp = sdpAnswer; + const remoteSdpObj = SdpTransform.parse(sdpAnswer); + await this.webRtcTransport.connect({ + dtlsParameters: MsSdpUtils.extractDtlsParameters({ + sdpObject: remoteSdpObj, + }), + }); + { + } + } +} +exports.SdpEndpoint = SdpEndpoint; +function createSdpEndpoint(webRtcTransport, localCaps) { + return new SdpEndpoint(webRtcTransport, localCaps); +} +exports.createSdpEndpoint = createSdpEndpoint; +function generateRtpCapabilities0() { + return BrowserRtpCapabilities.chrome; +} +exports.generateRtpCapabilities0 = generateRtpCapabilities0; +function generateRtpCapabilities1(localCaps, remoteSdp) { + console.error("[SdpEndpoint.generateRtpCapabilities1] BUG: Not implemented"); + process.exit(1); + let caps; + return caps; +} +exports.generateRtpCapabilities1 = generateRtpCapabilities1; +function generateRtpCapabilities2(localCaps, remoteCaps) { + console.error("[SdpEndpoint.generateRtpCapabilities2] BUG: Not implemented"); + process.exit(1); + let caps; + return caps; +} +exports.generateRtpCapabilities2 = generateRtpCapabilities2; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/package.json b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/package.json new file mode 100644 index 0000000..f862047 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/mediasoup-sdp-bridge/package.json @@ -0,0 +1,27 @@ +{ + "name": "mediasoup-sdp-bridge", + "version": "3.6.5", + "description": "Node.js library to allow integration of SDP based clients with mediasoup", + "contributors": [ + "IƱaki Baz Castillo (https://inakibaz.me)", + "Juan Navarro (https://github.com/j1elo)" + ], + "homepage": "https://mediasoup.org", + "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/versatica/mediasoup-sdp-bridge.git" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mediasoup" + }, + "main": "lib/index.js", + "types": "lib/index.d.ts", + "engines": { + "node": ">=10" + }, + "dependencies": { + "mediasoup-client": "^3.6.41" + } +} diff --git a/pixel-streaming-webrtc/WebServers/SFU/package-lock.json b/pixel-streaming-webrtc/WebServers/SFU/package-lock.json new file mode 100644 index 0000000..8f97c8a --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/package-lock.json @@ -0,0 +1,371 @@ +{ + "name": "pixelstreaming-sfu", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "pixelstreaming-sfu", + "version": "1.0.0", + "dependencies": { + "mediasoup_prebuilt": "^3.8.4", + "mediasoup-sdp-bridge": "file:mediasoup-sdp-bridge", + "ws": "^7.1.2" + } + }, + "mediasoup-sdp-bridge": { + "version": "3.6.5", + "license": "ISC", + "dependencies": { + "mediasoup-client": "^3.6.41" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mediasoup" + } + }, + "node_modules/@types/debug": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", + "integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", + "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==" + }, + "node_modules/@types/ms": { + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", + "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" + }, + "node_modules/@types/node": { + "version": "16.11.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz", + "integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==" + }, + "node_modules/awaitqueue": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/awaitqueue/-/awaitqueue-2.3.3.tgz", + "integrity": "sha512-RbzQg6VtPUtyErm55iuQLTrBJ2uihy5BKBOEkyBwv67xm5Fn2o/j+Bz+a5BmfSoe2oZ5dcz9Z3fExS8pL+LLhw==", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/bowser": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz", + "integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==" + }, + "node_modules/debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fake-mediastreamtrack": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/fake-mediastreamtrack/-/fake-mediastreamtrack-1.1.6.tgz", + "integrity": "sha512-lcoO5oPsW57istAsnjvQxNjBEahi18OdUhWfmEewwfPfzNZnji5OXuodQM+VnUPi/1HnQRJ6gBUjbt1TNXrkjQ==", + "dependencies": { + "event-target-shim": "^5.0.1", + "uuid": "^8.1.0" + } + }, + "node_modules/h264-profile-level-id": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/h264-profile-level-id/-/h264-profile-level-id-1.0.1.tgz", + "integrity": "sha512-D3Rln/jKNjKDW5ZTJTK3niSoOGE+pFqPvRHHVgQN3G7umcn/zWGPUo8Q8VpDj16x3hKz++zVviRNRmXu5cpN+Q==", + "dependencies": { + "debug": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/mediasoup_prebuilt": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/mediasoup_prebuilt/-/mediasoup_prebuilt-3.8.4.tgz", + "integrity": "sha512-IdPcuT3YTJXNFYAY4JuIy8sZ88qagKPg2dR8d4USR5csTvC+qOq9wAIywO+u2lxLjePHJH+Y8UBM3kKfyU6Uug==", + "dependencies": { + "@types/node": "^16.9.1", + "awaitqueue": "^2.3.3", + "debug": "^4.3.2", + "h264-profile-level-id": "^1.0.1", + "netstring": "^0.3.0", + "random-number": "^0.0.9", + "supports-color": "^9.0.2", + "uuid": "^8.3.2" + } + }, + "node_modules/mediasoup-client": { + "version": "3.6.46", + "resolved": "https://registry.npmjs.org/mediasoup-client/-/mediasoup-client-3.6.46.tgz", + "integrity": "sha512-Dv8RxCa1cjSPrKWGf1mnypU5TiQCnrOIy4JpZwwjRQzEtCukCfV1zQabij6BigrtkI+l22ui3fl67Mmm4I0XCA==", + "dependencies": { + "@types/debug": "^4.1.7", + "@types/events": "^3.0.0", + "awaitqueue": "^2.3.3", + "bowser": "^2.11.0", + "debug": "^4.3.2", + "events": "^3.3.0", + "fake-mediastreamtrack": "^1.1.6", + "h264-profile-level-id": "^1.0.1", + "sdp-transform": "^2.14.1", + "supports-color": "^9.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mediasoup" + } + }, + "node_modules/mediasoup-sdp-bridge": { + "resolved": "mediasoup-sdp-bridge", + "link": true + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/netstring": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/netstring/-/netstring-0.3.0.tgz", + "integrity": "sha1-ho3FsgxY0/cwVTHUk2jqqr0ZtxI=", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/random-number": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/random-number/-/random-number-0.0.9.tgz", + "integrity": "sha512-ipG3kRCREi/YQpi2A5QGcvDz1KemohovWmH6qGfboVyyGdR2t/7zQz0vFxrfxpbHQgPPdtVlUDaks3aikD1Ljw==" + }, + "node_modules/sdp-transform": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.14.1.tgz", + "integrity": "sha512-RjZyX3nVwJyCuTo5tGPx+PZWkDMCg7oOLpSlhjDdZfwUoNqG1mM8nyj31IGHyaPWXhjbP7cdK3qZ2bmkJ1GzRw==", + "bin": { + "sdp-verify": "checker.js" + } + }, + "node_modules/supports-color": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.1.0.tgz", + "integrity": "sha512-lOCGOTmBSN54zKAoPWhHkjoqVQ0MqgzPE5iirtoSixhr0ZieR/6l7WZ32V53cvy9+1qghFnIk7k52p991lKd6g==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/ws": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", + "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + }, + "dependencies": { + "@types/debug": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", + "integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==", + "requires": { + "@types/ms": "*" + } + }, + "@types/events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", + "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==" + }, + "@types/ms": { + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", + "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" + }, + "@types/node": { + "version": "16.11.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz", + "integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==" + }, + "awaitqueue": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/awaitqueue/-/awaitqueue-2.3.3.tgz", + "integrity": "sha512-RbzQg6VtPUtyErm55iuQLTrBJ2uihy5BKBOEkyBwv67xm5Fn2o/j+Bz+a5BmfSoe2oZ5dcz9Z3fExS8pL+LLhw==" + }, + "bowser": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz", + "integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==" + }, + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "requires": { + "ms": "2.1.2" + } + }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, + "events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==" + }, + "fake-mediastreamtrack": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/fake-mediastreamtrack/-/fake-mediastreamtrack-1.1.6.tgz", + "integrity": "sha512-lcoO5oPsW57istAsnjvQxNjBEahi18OdUhWfmEewwfPfzNZnji5OXuodQM+VnUPi/1HnQRJ6gBUjbt1TNXrkjQ==", + "requires": { + "event-target-shim": "^5.0.1", + "uuid": "^8.1.0" + } + }, + "h264-profile-level-id": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/h264-profile-level-id/-/h264-profile-level-id-1.0.1.tgz", + "integrity": "sha512-D3Rln/jKNjKDW5ZTJTK3niSoOGE+pFqPvRHHVgQN3G7umcn/zWGPUo8Q8VpDj16x3hKz++zVviRNRmXu5cpN+Q==", + "requires": { + "debug": "^4.1.1" + } + }, + "mediasoup_prebuilt": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/mediasoup_prebuilt/-/mediasoup_prebuilt-3.8.4.tgz", + "integrity": "sha512-IdPcuT3YTJXNFYAY4JuIy8sZ88qagKPg2dR8d4USR5csTvC+qOq9wAIywO+u2lxLjePHJH+Y8UBM3kKfyU6Uug==", + "requires": { + "@types/node": "^16.9.1", + "awaitqueue": "^2.3.3", + "debug": "^4.3.2", + "h264-profile-level-id": "^1.0.1", + "netstring": "^0.3.0", + "random-number": "^0.0.9", + "supports-color": "^9.0.2", + "uuid": "^8.3.2" + } + }, + "mediasoup-client": { + "version": "3.6.46", + "resolved": "https://registry.npmjs.org/mediasoup-client/-/mediasoup-client-3.6.46.tgz", + "integrity": "sha512-Dv8RxCa1cjSPrKWGf1mnypU5TiQCnrOIy4JpZwwjRQzEtCukCfV1zQabij6BigrtkI+l22ui3fl67Mmm4I0XCA==", + "requires": { + "@types/debug": "^4.1.7", + "@types/events": "^3.0.0", + "awaitqueue": "^2.3.3", + "bowser": "^2.11.0", + "debug": "^4.3.2", + "events": "^3.3.0", + "fake-mediastreamtrack": "^1.1.6", + "h264-profile-level-id": "^1.0.1", + "sdp-transform": "^2.14.1", + "supports-color": "^9.1.0" + } + }, + "mediasoup-sdp-bridge": { + "version": "file:mediasoup-sdp-bridge", + "requires": { + "mediasoup-client": "^3.6.41" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "netstring": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/netstring/-/netstring-0.3.0.tgz", + "integrity": "sha1-ho3FsgxY0/cwVTHUk2jqqr0ZtxI=" + }, + "random-number": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/random-number/-/random-number-0.0.9.tgz", + "integrity": "sha512-ipG3kRCREi/YQpi2A5QGcvDz1KemohovWmH6qGfboVyyGdR2t/7zQz0vFxrfxpbHQgPPdtVlUDaks3aikD1Ljw==" + }, + "sdp-transform": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.14.1.tgz", + "integrity": "sha512-RjZyX3nVwJyCuTo5tGPx+PZWkDMCg7oOLpSlhjDdZfwUoNqG1mM8nyj31IGHyaPWXhjbP7cdK3qZ2bmkJ1GzRw==" + }, + "supports-color": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.1.0.tgz", + "integrity": "sha512-lOCGOTmBSN54zKAoPWhHkjoqVQ0MqgzPE5iirtoSixhr0ZieR/6l7WZ32V53cvy9+1qghFnIk7k52p991lKd6g==" + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, + "ws": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", + "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", + "requires": {} + } + } +} diff --git a/pixel-streaming-webrtc/WebServers/SFU/package.json b/pixel-streaming-webrtc/WebServers/SFU/package.json new file mode 100644 index 0000000..754e985 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/package.json @@ -0,0 +1,23 @@ +{ + "name": "pixelstreaming-sfu", + "version": "1.0.0", + "description": "Reference implementation for a PixelStreaming SFU", + "scripts": { + "start-local": "run-script-os --", + "start-local:windows": ".\\platform_scripts\\cmd\\run.bat", + "start-local:default": "./platform_scripts/bash/run_local.sh", + "start-cloud": "run-script-os --", + "start-cloud:windows": ".\\platform_scripts\\cmd\\run_cloud.bat", + "start-cloud:default": "./platform_scripts/bash/run_cloud.sh", + "start": "run-script-os", + "start:windows": "platform_scripts\\cmd\\node\\node.exe sfu_server.js", + "start:default": "if [ `id -u` -eq 0 ]\nthen\n export process=\"./platform_scripts/bash/node/bin/node sfu_server.js\"\nelse\n export process=\"sudo ./platform_scripts/bash/node/bin/node sfu_server.js\"\nfi\n$process " + + }, + "dependencies": { + "mediasoup-sdp-bridge": "file:mediasoup-sdp-bridge", + "ws": "^7.1.2", + "mediasoup_prebuilt": "^3.8.4", + "run-script-os": "^1.1.6" + } +} diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/Dockerfile b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/Dockerfile new file mode 100644 index 0000000..7987117 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/Dockerfile @@ -0,0 +1,25 @@ +# Copyright Epic Games, Inc. All Rights Reserved. + +FROM node:latest + +# Make sure Mediasoup requirements are met +RUN apt -y update +RUN apt -y install python3-pip + +# Copy the Selective Forwarding Unit (SFU) to the Docker build context +COPY . /opt/SFU + +# Install the dependencies for the mediasoup server +WORKDIR /opt/SFU +RUN npm update +RUN npm install . + +# Expose TCP port 80 for player WebSocket connections and web server HTTP access +EXPOSE 40000-49999 + +# Expose TCP port 8888 for streamer WebSocket connections +EXPOSE 8889 + +# Set the signalling server as the container's entrypoint +ENTRYPOINT ["/usr/local/bin/node", "/opt/SFU/sfu_server.js"] + diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/common_utils.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/common_utils.sh new file mode 100644 index 0000000..3dcdb1f --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/common_utils.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +function log_msg() { #message + if [ ! -z $VERBOSE ]; then + echo $1 + fi +} + +function print_usage() { + echo " + Usage: + ${0} [--help] [--publicip ] [sfu options...] + Where: + --help will print this message and stop this script. + --debug will run all scripts with --inspect + --nosudo will run all scripts without \`sudo\` command useful for when run in containers. + --verbose will enable additional logging + --package-manager specify an alternative package manager to apt-get + --publicip is used to define public ip address (using default port) for turn server, syntax: --publicip ; it is used for + default value: Retrieved from 'curl https://api.ipify.org' or if unsuccessful then set to 127.0.0.1. It is the IP address of the SFU + Other options: stored and passed to the SFU. All parameters printed once the script values are set. + " + exit 1 +} + +function print_parameters() { + echo "" + echo "${0} is running with the following parameters:" + echo "--------------------------------------" + echo "Public IP address : ${publicip}" + echo "SFU command line arguments: ${sfucmd}" + echo "" +} + +function set_start_default_values() { + # publicip and sfucmd are always needed + publicip=$(curl -s https://api.ipify.org) + if [[ -z $publicip ]]; then + publicip="127.0.0.1" + fi + + sfucmd="" +} + +function use_args() { + while(($#)) ; do + case "$1" in + --debug ) IS_DEBUG=1; shift;; + --nosudo ) NO_SUDO=1; shift;; + --verbose ) VERBOSE=1; shift;; + --publicip ) publicip="$2"; shift 2;; + --help ) print_usage;; + * ) echo "Unknown command, adding to SFU command line: $1"; sfucmd+=" $1"; shift;; + esac + done +} + +function call_setup_sh() { + bash "setup.sh" +} + +function start_process() { + if [ ! -z $NO_SUDO ]; then + log_msg "running with sudo removed" + eval $(echo "$@" | sed 's/sudo//g') + else + eval $@ + fi +} + +function get_version() { + local version=$1 + + if command -v $version; then + version=$($@) + fi + + echo $version | sed -E 's/[^0-9.]//g' +} diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-build.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-build.sh new file mode 100644 index 0000000..546a6bd --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-build.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +# Build docker image for the Selective Forwarding Unit (SFU) + +# When run from SFU/platform_scripts/bash, this uses the SFU directory +# as the build context so the SFU files can be successfully copied into the container image +docker build -t 'mediasoup_sfu:latest' -f ./Dockerfile ../.. + diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-start.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-start.sh new file mode 100644 index 0000000..4eda05e --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-start.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +# Start docker container by name using host networking +docker run --name sfu_latest --network host --rm mediasoup_sfu + +# Interactive start example +#docker run --name sfu_latest --network host --rm -it --entrypoint /bin/bash mediasoup_sfu diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-stop.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-stop.sh new file mode 100644 index 0000000..637eb27 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/docker-stop.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +# Stop the docker container +PSID=$(docker ps -a -q --filter="name=sfu_latest") +if [ -z "$PSID" ]; then + echo "Docker SFU is not running, no stopping will be done" + exit 1; +fi +echo "Stopping Mediasoup SFU server ..." +docker stop sfu_latest + diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_cloud.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_cloud.sh new file mode 100644 index 0000000..ee24da7 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_cloud.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. +BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +pushd "${BASH_LOCATION}" > /dev/null + +source common_utils.sh + +set_start_default_values # No server specific defaults +use_args "$@" +call_setup_sh +print_parameters + +process="${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js run start:default --" +arguments="--PublicIP=${publicip}" + +# Add arguments passed to script to arguments for executable +arguments+=" ${sfucmd}" + +pushd ../.. > /dev/null + +echo "Running: $process $arguments" +PATH="${BASH_LOCATION}/node/bin:$PATH" +start_process $process $arguments +popd + +popd diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_local.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_local.sh new file mode 100644 index 0000000..feb26e0 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/run_local.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. +BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +pushd "${BASH_LOCATION}" > /dev/null + +source common_utils.sh + +set_start_default_values # No server specific defaults +use_args "$@" +call_setup_sh + +process="${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js run start:default --" + +pushd ../.. > /dev/null + +echo "" +echo "Starting (S)elective (F)orwarding (U)nit use ctrl-c to exit" +echo "-----------------------------------------" +echo "" + +PATH="${BASH_LOCATION}/node/bin:$PATH" +start_process $process + +popd > /dev/null # ../.. + +popd > /dev/null # BASH_SOURCE \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/setup.sh b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/setup.sh new file mode 100644 index 0000000..06346ac --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/bash/setup.sh @@ -0,0 +1,114 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. +BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +pushd "${BASH_LOCATION}" > /dev/null + +source common_utils.sh + +use_args $@ +# Azure specific fix to allow installing NodeJS from NodeSource +if test -f "/etc/apt/sources.list.d/azure-cli.list"; then + sudo touch /etc/apt/sources.list.d/nodesource.list + sudo touch /usr/share/keyrings/nodesource.gpg + sudo chmod 644 /etc/apt/sources.list.d/nodesource.list + sudo chmod 644 /usr/share/keyrings/nodesource.gpg + sudo chmod 644 /etc/apt/sources.list.d/azure-cli.list +fi + +function check_version() { #current_version #min_version + #check if same string + if [ -z "$2" ] || [ "$1" = "$2" ]; then + return 0 + fi + + local i current minimum + + IFS="." read -r -a current <<< $1 + IFS="." read -r -a minimum <<< $2 + + # fill empty fields in current with zeros + for ((i=${#current[@]}; i<${#minimum[@]}; i++)) + do + current[i]=0 + done + + for ((i=0; i<${#current[@]}; i++)) + do + if [[ -z ${minimum[i]} ]]; then + # fill empty fields in minimum with zeros + minimum[i]=0 + fi + + if ((10#${current[i]} > 10#${minimum[i]})); then + return 1 + fi + + if ((10#${current[i]} < 10#${minimum[i]})); then + return 2 + fi + done + + # if got this far string is the same once we added missing 0 + return 0 +} + +function check_and_install() { #dep_name #get_version_string #version_min #install_command + local is_installed=0 + + log_msg "Checking for required $1 install" + + local current=$(echo $2 | sed -E 's/[^0-9.]//g') + local minimum=$(echo $3 | sed -E 's/[^0-9.]//g') + + if [ $# -ne 4 ]; then + log_msg "check_and_install expects 4 args (dep_name get_version_string version_min install_command) got $#" + return -1 + fi + + if [ ! -z $current ]; then + log_msg "Current version: $current checking >= $minimum" + check_version "$current" "$minimum" + if [ "$?" -lt 2 ]; then + log_msg "$1 is installed." + return 0 + else + log_msg "Required install of $1 not found installing" + fi + fi + + if [ $is_installed -ne 1 ]; then + echo "$1 installation not found installing..." + + start_process $4 + + if [ $? -ge 1 ]; then + echo "Installation of $1 failed try running `export VERBOSE=1` then run this script again for more details" + exit 1 + fi + + fi +} + +echo "Checking Pixel Streaming SFU dependencies." + +# navigate to SFU root +pushd ../.. > /dev/null + +node_version="" +if [[ -f "${BASH_LOCATION}/node/bin/node" ]]; then + node_version=$("${BASH_LOCATION}/node/bin/node" --version) +fi +check_and_install "node" "$node_version" "v16.4.2" "curl https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.gz --output node.tar.xz + && tar -xf node.tar.xz + && rm node.tar.xz + && mv node-v*-linux-x64 \"${BASH_LOCATION}/node\"" + +PATH="${BASH_LOCATION}/node/bin:$PATH" +"${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js" install + +popd > /dev/null # SFU + +popd > /dev/null # BASH_SOURCE + +echo "All Pixel Streaming SFU dependencies up to date." \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_cloud.bat b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_cloud.bat new file mode 100644 index 0000000..6834f75 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_cloud.bat @@ -0,0 +1,19 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script directory as working directory. +pushd "%~dp0" + +title SFU + +@Rem Get our public IP if we are running this SFU on the cloud we will need this. +FOR /F "tokens=*" %%g IN ('curl -L -S -s https://api.ipify.org') do (SET PUBLICIP=%%g) + +@Rem Call out run.bat and pass in the Public IP we grabbed earlier. +call run_local.bat --PublicIP=%PUBLICIP% + +@Rem Pop script directory. +popd + +pause \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_local.bat b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_local.bat new file mode 100644 index 0000000..b182fb1 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/run_local.bat @@ -0,0 +1,25 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script directory as working directory. +pushd "%~dp0" + +title SFU + +@Rem Run setup to ensure we have node and mediasoup installed. +call setup.bat + +@Rem Move to sfu_server.js directory. +pushd ..\.. + +@Rem Run node server and pass any argument along. +platform_scripts\cmd\node\node.exe sfu_server %* + +@Rem Pop sfu_server directory. +popd + +@Rem Pop script directory. +popd + +pause \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup.bat b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup.bat new file mode 100644 index 0000000..29468f3 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup.bat @@ -0,0 +1,17 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script location as working directory for commands. +pushd "%~dp0" + +@Rem Ensure we have NodeJs available for calling. +call setup_node.bat + +@Rem Move to sfu_server.js directory and install its package.json +pushd %~dp0\..\..\ +call platform_scripts\cmd\node\npm install --no-save +popd + +@Rem Pop working directory +popd \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup_node.bat b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup_node.bat new file mode 100644 index 0000000..cc079e5 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/platform_scripts/cmd/setup_node.bat @@ -0,0 +1,35 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script location as working directory for commands. +pushd "%~dp0" + +@Rem Name and version of node that we are downloading +SET NodeVersion=v16.4.2 +SET NodeName=node-%NodeVersion%-win-x64 + +@Rem Look for a node directory next to this script +if exist node\ ( + echo Node directory found...skipping install. +) else ( + echo Node directory not found...beginning NodeJS download for Windows. + + @Rem Download nodejs and follow redirects. + curl -L -o ./node.zip "https://nodejs.org/dist/%NodeVersion%/%NodeName%.zip" + + @Rem Unarchive the .zip + tar -xf node.zip + + @Rem Rename the extracted, versioned, directory that contains the NodeJS binaries to simply "node". + ren "%NodeName%\" "node" + + @Rem Delete the downloaded node.zip + del node.zip +) + +@Rem Print node version +echo Node version: & node\node.exe -v + +@Rem Pop working directory +popd \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/SFU/sfu_server.js b/pixel-streaming-webrtc/WebServers/SFU/sfu_server.js new file mode 100644 index 0000000..20b6557 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SFU/sfu_server.js @@ -0,0 +1,321 @@ +const config = require('./config'); +const WebSocket = require('ws'); +const mediasoup = require('mediasoup_prebuilt'); +const mediasoupSdp = require('mediasoup-sdp-bridge'); + +let signalServer = null; +let mediasoupRouter; +let streamer = null; +let peers = new Map(); + +function connectSignalling(server) { + console.log("Connecting to Signalling Server at %s", server); + signalServer = new WebSocket(server); + signalServer.addEventListener("open", _ => { console.log(`Connected to signalling server`); }); + signalServer.addEventListener("error", result => { console.log(`Error: ${result.message}`); }); + signalServer.addEventListener("message", result => onSignallingMessage(result.data)); + signalServer.addEventListener("close", result => { + console.log(`Disconnected from signalling server: ${result.code} ${result.reason}`); + console.log("Attempting reconnect to signalling server..."); + setTimeout(()=> { + connectSignalling(server); + }, 2000); + }); +} + +async function onStreamerOffer(sdp) { + console.log("Got offer from streamer"); + + if (streamer != null) { + signalServer.close(1013 /* Try again later */, 'Producer is already connected'); + return; + } + + const transport = await createWebRtcTransport("Streamer"); + const sdpEndpoint = mediasoupSdp.createSdpEndpoint(transport, mediasoupRouter.rtpCapabilities); + const producers = await sdpEndpoint.processOffer(sdp); + const sdpAnswer = sdpEndpoint.createAnswer(); + const answer = { type: "answer", sdp: sdpAnswer }; + + console.log("Sending answer to streamer."); + signalServer.send(JSON.stringify(answer)); + streamer = { transport: transport, producers: producers }; +} + +function getNextStreamerSCTPId() { + if(!streamer){ + throw new TypeError('Cannot generate an SCTP stream id - streamer was null.'); + } + if (!streamer.transport || !streamer.transport.sctpParameters || typeof streamer.transport.sctpParameters.MIS !== 'number') { + throw new TypeError('Streamer was not setup with the following require properties: streamer.transport.sctpParameters.MIS'); + } + const numStreams = streamer.transport.sctpParameters.MIS; + if (!streamer.dataStreamIds){ + streamer.dataStreamIds = Buffer.alloc(numStreams, 0); + } + if (!streamer.nextDataStreamId) { + streamer.nextDataStreamId = 0; + } + + let sctpStreamId; + for (let idx = streamer.nextDataStreamId; idx < streamer.dataStreamIds.length; ++idx) { + sctpStreamId = idx % streamer.dataStreamIds.length; + if (!streamer.dataStreamIds[sctpStreamId]) { + streamer.nextDataStreamId = sctpStreamId + 1; + return sctpStreamId; + } + } + console.error("No available SCTP ids, they are all allocated."); + return -1; +} + +function onStreamerDisconnected() { + console.log("Streamer disconnected"); + disconnectAllPeers(); + + if (streamer != null) { + for (const mediaProducer of streamer.producers) { + mediaProducer.close(); + } + streamer.transport.close(); + streamer = null; + } +} + +async function onPeerConnected(peerId) { + console.log("Player %s joined", peerId); + + if (streamer == null) { + console.log("No streamer connected, ignoring player."); + return; + } + + const transport = await createWebRtcTransport("Peer " + peerId); + const sdpEndpoint = mediasoupSdp.createSdpEndpoint( transport, mediasoupRouter.rtpCapabilities ); + sdpEndpoint.addConsumeData(); // adds the sctp 'application' section to the offer + + // media consumers + let consumers = []; + try { + for (const mediaProducer of streamer.producers) { + const consumer = await transport.consume({ producerId: mediaProducer.id, rtpCapabilities: mediasoupRouter.rtpCapabilities }); + consumer.observer.on("layerschange", function() { console.log("layer changed!", consumer.currentLayers); }); + sdpEndpoint.addConsumer(consumer); + consumers.push(consumer); + } + } catch(err) { + console.error("transport.consume() failed:", err); + return; + } + + const offerSignal = { + type: "offer", + playerId: peerId, + sdp: sdpEndpoint.createOffer(), + sfu: true // indicate we're offering from sfu + }; + + // send offer to peer + signalServer.send(JSON.stringify(offerSignal)); + + const newPeer = { + id: peerId, + transport: transport, + sdpEndpoint: sdpEndpoint, + consumers: consumers + }; + + // add the new peer + peers.set(peerId, newPeer); +} + +async function setupPeerDataChannels(peerId) { + const peer = peers.get(peerId); + if (!peer) { + console.error(`Could not send browser any datachannels for peer=${peerId} because peer was not found.`); + return; + } + + const nextStreamerSCTPStreamId = getNextStreamerSCTPId(); + const nextPeerSCTPStreamId = getNextStreamerSCTPId(); + + console.log(`Attempting streamer SCTP id=${nextStreamerSCTPStreamId}`); + + // streamer data producer (produces data for the peer) + peer.streamerDataProducer = await streamer.transport.produceData({label: 'send-datachannel', sctpStreamParameters: {streamId: nextStreamerSCTPStreamId, ordered: true}}); + + console.log(`Attempting peer SCTP id=${nextPeerSCTPStreamId}`); + + // peer data producer (produces data for the streamer) + peer.peerDataProducer = await peer.transport.produceData({label: 'send-datachannel', sctpStreamParameters: {streamId: nextPeerSCTPStreamId, ordered: true}}); + + // peer data consumer (consumes streamer data) + peer.peerDataConsumer = await peer.transport.consumeData({ dataProducerId: peer.streamerDataProducer.id }); + + // streamer data consumer (consumes peer data) + peer.streamerDataConsumer = await streamer.transport.consumeData({ dataProducerId: peer.peerDataProducer.id }); + + const peerSignal = { + type: 'peerDataChannels', + playerId: peerId, + sendStreamId: peer.peerDataProducer.sctpStreamParameters.streamId, + recvStreamId: peer.peerDataConsumer.sctpStreamParameters.streamId + }; + + // Send browser a message with a send/recv data channel SCTP stream id + signalServer.send(JSON.stringify(peerSignal)); + +} + +async function setupStreamerDataChannelsForPeer(peerId) { + + const peer = peers.get(peerId); + if (!peer) { + console.error(`Could not send streamer any datachannels for peer=${peerId} because peer was not found.`); + return; + } + + if(!peer.streamerDataProducer || !peer.streamerDataConsumer){ + console.error(`There was no streamer data producer/consumer setup for peer=${peerId}. Did you make sure to send "dataChannelRequest" first?`); + return; + } + + const streamerSignal = { + type: "streamerDataChannels", + playerId: peerId, + sendStreamId: peer.streamerDataProducer.sctpStreamParameters.streamId, + recvStreamId: peer.streamerDataConsumer.sctpStreamParameters.streamId + }; + + // send streamer a message with a send/recv data channel SCTP stream id + signalServer.send(JSON.stringify(streamerSignal)); +} + +async function onPeerAnswer(peerId, sdp) { + console.log("Got answer from player %s", peerId); + + const consumer = peers.get(peerId); + if (!consumer){ + console.error(`Unable to find player ${peerId}`); + } + else{ + consumer.sdpEndpoint.processAnswer(sdp); + } +} + +function onPeerDisconnected(peerId) { + console.log("Player %s disconnected", peerId); + const peer = peers.get(peerId); + if (peer != null) { + for (consumer of peer.consumers) { + consumer.close(); + } + if (peer.peerDataConsumer) { + peer.peerDataConsumer.close(); + peer.peerDataProducer.close(); + } + if(peer.streamerDataConsumer){ + // Set the streamer sctp id we generated back to zero indicating it can be reused. + if(streamer && streamer.dataStreamIds){ + const allocatedStreamId = peer.streamerDataProducer.sctpStreamParameters.streamId; + const allocatedPeerStreamId = peer.peerDataProducer.sctpStreamParameters.streamId; + streamer.dataStreamIds[allocatedStreamId] = 0; + streamer.dataStreamIds[allocatedPeerStreamId] = 0; + } + peer.streamerDataConsumer.close(); + peer.streamerDataProducer.close(); + } + peer.transport.close(); + } + peers.delete(peerId); +} + +function disconnectAllPeers() { + console.log("Disconnected all players"); + for (const [peerId, peer] of peers) { + onPeerDisconnected(peerId); + } +} + +async function onSignallingMessage(message) { + //console.log(`Got MSG: ${message}`); + const msg = JSON.parse(message); + + if (msg.type == 'offer') { + onStreamerOffer(msg.sdp); + } + else if (msg.type == 'answer') { + onPeerAnswer(msg.playerId, msg.sdp); + } + else if (msg.type == 'playerConnected') { + onPeerConnected(msg.playerId); + } + else if (msg.type == 'playerDisconnected') { + onPeerDisconnected(msg.playerId); + } + else if (msg.type == 'streamerDisconnected') { + onStreamerDisconnected(); + } + else if (msg.type == 'dataChannelRequest') { + setupPeerDataChannels(msg.playerId); + } + else if (msg.type == 'peerDataChannelsReady') { + setupStreamerDataChannelsForPeer(msg.playerId); + } + // todo a new message type for force layer switch (for debugging) + // see: https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-setPreferredLayers + // preferredLayers for debugging to select a particular simulcast layer, looks like { spatialLayer: 2, temporalLayer: 0 } +} + +async function startMediasoup() { + let worker = await mediasoup.createWorker({ + logLevel: config.mediasoup.worker.logLevel, + logTags: config.mediasoup.worker.logTags, + rtcMinPort: config.mediasoup.worker.rtcMinPort, + rtcMaxPort: config.mediasoup.worker.rtcMaxPort, + }); + + worker.on('died', () => { + console.error('mediasoup worker died (this should never happen)'); + process.exit(1); + }); + + const mediaCodecs = config.mediasoup.router.mediaCodecs; + const mediasoupRouter = await worker.createRouter({ mediaCodecs }); + + return mediasoupRouter; +} + +async function createWebRtcTransport(identifier) { + const { + listenIps, + initialAvailableOutgoingBitrate + } = config.mediasoup.webRtcTransport; + + const transport = await mediasoupRouter.createWebRtcTransport({ + listenIps: listenIps, + enableUdp: true, + enableTcp: false, + preferUdp: true, + enableSctp: true, // datachannels + initialAvailableOutgoingBitrate: initialAvailableOutgoingBitrate + }); + + transport.on("icestatechange", (iceState) => { console.log("%s ICE state changed to %s", identifier, iceState); }); + transport.on("iceselectedtuplechange", (iceTuple) => { console.log("%s ICE selected tuple %s", identifier, JSON.stringify(iceTuple)); }); + transport.on("sctpstatechange", (sctpState) => { console.log("%s SCTP state changed to %s", identifier, sctpState); }); + + return transport; +} + +async function main() { + console.log('Starting Mediasoup...'); + console.log("Config = "); + console.log(config); + + mediasoupRouter = await startMediasoup(); + + connectSignalling(config.signallingURL); +} + +main(); diff --git a/pixel-streaming-webrtc/WebServers/SignallingWebServer b/pixel-streaming-webrtc/WebServers/SignallingWebServer new file mode 160000 index 0000000..5d19a49 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/SignallingWebServer @@ -0,0 +1 @@ +Subproject commit 5d19a497ad1705359daa663db92b96365e07ac75 diff --git a/pixel-streaming-webrtc/WebServers/get_ps_servers.bat b/pixel-streaming-webrtc/WebServers/get_ps_servers.bat new file mode 100644 index 0000000..d816f11 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/get_ps_servers.bat @@ -0,0 +1,110 @@ +@Rem Copyright Epic Games, Inc. All Rights Reserved. + +@echo off + +@Rem Set script location as working directory for commands. +pushd "%~dp0" + +:arg_loop_start +SET ARG=%1 +if DEFINED ARG ( + if "%ARG%"=="/h" ( + goto print_help + ) + if "%ARG%"=="/v" ( + SET UEVersion=%2 + SHIFT + ) + if "%ARG%"=="/b" ( + SET PSInfraTagOrBranch=%2 + SET IsTag=0 + SHIFT + ) + if "%ARG%"=="/t" ( + SET PSInfraTagOrBranch=%2 + SET IsTag=1 + SHIFT + ) + SHIFT + goto arg_loop_start +) + +@Rem Name and version of ps-infra that we are downloading +SET PSInfraOrg=EpicGames +SET PSInfraRepo=PixelStreamingInfrastructure + +@Rem If a UE version is supplied set the right branch or tag to fetch for that version of UE +if DEFINED UEVersion ( + if "%UEVersion%"=="4.26" ( + SET PSInfraTagOrBranch=UE4.26 + SET IsTag=0 + ) + if "%UEVersion%"=="4.27" ( + SET PSInfraTagOrBranch=UE4.27 + SET IsTag=0 + ) + if "%UEVersion%"=="5.0" ( + SET PSInfraTagOrBranch=UE5.0 + SET IsTag=0 + ) +) + +@Rem If no arguments select a specific version, fetch the appropriate default +if NOT DEFINED PSInfraTagOrBranch ( + SET PSInfraTagOrBranch=master + SET IsTag=0 +) + +@Rem Whether the named reference is a tag or a branch affects the URL we fetch it on +if %IsTag%==1 ( + SET RefType=tags +) else ( + SET RefType=heads +) + +@Rem Look for a SignallingWebServer directory next to this script +if exist SignallingWebServer\ ( + echo SignallingWebServer directory found...skipping install. +) else ( + echo SignallingWebServer directory not found...beginning ps-infra download. + + @Rem Download ps-infra and follow redirects. + curl -L https://github.com/%PSInfraOrg%/%PSInfraRepo%/archive/refs/%RefType%/%PSInfraTagOrBranch%.zip > ps-infra.zip + + @Rem Unarchive the .zip + tar -xmf ps-infra.zip || echo bad archive, contents: && type ps-infra.zip && exit 0 + + @Rem Rename the extracted, versioned, directory + for /d %%i in ("PixelStreamingInfrastructure-*") do ( + for /d %%j in ("%%i/*") do ( + echo "%%i\%%j" + move "%%i\%%j" . + ) + for %%j in ("%%i/*") do ( + echo "%%i\%%j" + move "%%i\%%j" . + ) + + echo "%%i" + rmdir /s /q "%%i" + ) + + @Rem Delete the downloaded zip + del ps-infra.zip +) + +exit 0 + +:print_help +echo. +echo Tool for fetching PixelStreaming Infrastructure. If no flags are set specifying a version to fetch, +echo the recommended version will be chosen as a default. +echo. +echo Usage: +echo %~n0%~x0 [^/h] [^/v ^] [^/b ^] [^/t ^] +echo Where: +echo /v Specify a version of Unreal Engine to download the recommended release for +echo /b Specify a specific branch for the tool to download from repo +echo /t Specify a specific tag for the tool to download from repo +echo /h Display this help message +exit 1 \ No newline at end of file diff --git a/pixel-streaming-webrtc/WebServers/get_ps_servers.sh b/pixel-streaming-webrtc/WebServers/get_ps_servers.sh new file mode 100644 index 0000000..a402611 --- /dev/null +++ b/pixel-streaming-webrtc/WebServers/get_ps_servers.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +pushd "${BASH_LOCATION}" > /dev/null + +print_help() { + echo " + Tool for fetching PixelStreaming Infrastructure. If no flags are set specifying a version to fetch, + the recommended version will be chosen as a default. + + Usage: + ${0} [-h] [-v ] [-b ] [-t ] + Where: + -v Specify a version of Unreal Engine to download the recommended + release for + -b Specify a specific branch for the tool to download from repo + -t Specify a specific tag for the tool to download from repo + -h Display this help message +" + exit 1 +} + +while(($#)) ; do + case "$1" in + -h ) print_help;; + -v ) UEVersion="$2"; shift 2;; + -b ) PSInfraTagOrBranch="$2"; IsTag=0; shift 2;; + -t ) PSInfraTagOrBranch="$2"; IsTag=1; shift 2;; + * ) echo "Unknown command: $1"; shift;; + esac + done + +# Name and version of ps-infra that we are downloading +PSInfraOrg=EpicGames +PSInfraRepo=PixelStreamingInfrastructure + +# If a UE version is supplied set the right branch or tag to fetch for that version of UE +if [ ! -z "$UEVersion" ] +then + if [ "$UEVersion" = "4.26" ] + then + PSInfraTagOrBranch=UE4.26 + IsTag=0 + fi + if [ "$UEVersion" = "4.27" ] + then + PSInfraTagOrBranch=UE4.27 + IsTag=0 + fi + if [ "$UEVersion" = "5.0" ] + then + PSInfraTagOrBranch=UE5.0 + IsTag=0 + fi +fi + +# If no arguments select a specific version, fetch the appropriate default +if [ -z "$PSInfraTagOrBranch" ] +then + PSInfraTagOrBranch=master + IsTag=0 +fi + +# Whether the named reference is a tag or a branch affects the URL we fetch it on +if [ "$IsTag" -eq 1 ] +then + RefType=tags +else + RefType=heads +fi + +# Look for a SignallingWebServer directory next to this script +if [ -d SignallingWebServer ] +then + echo "SignallingWebServer directory found...skipping install." +else + echo "SignallingWebServer directory not found...beginning ps-infra download." + + # Download ps-infra and follow redirects. + curl -L https://github.com/$PSInfraOrg/$PSInfraRepo/archive/refs/$RefType/$PSInfraTagOrBranch.tar.gz > ps-infra.tar.gz + + # Unarchive the .tar + tar -xmf ps-infra.tar.gz || $(echo "bad archive, contents:" && head --lines=20 ps-infra.tar.gz && exit 0) + + # Move the server folders into the current directory (WebServers) and delete the original directory + mv PixelStreamingInfrastructure-*/* . + rm -rf PixelStreamingInfrastructure-* + + # Delete the downloaded tar + rm ps-infra.tar.gz +fi \ No newline at end of file