diff --git a/.gitattributes b/.gitattributes index 1ef325f1b111266a6b26e0196871bd78baa8c2f3..9d66823b0e6ba56d21e73da2f23bd6d69b6edce0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -57,3 +57,23 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text # Video files - compressed *.mp4 filter=lfs diff=lfs merge=lfs -text *.webm filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/House.exe filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/House/Binaries/Win64/House.exe filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/OpenXR/win64/openxr_loader.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/DbgHelp/dbghelp.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/NVaftermath/Win64/GFSDK_Aftermath_Lib.x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/ApexFrameworkPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/GeForceNOW/Win64/GfnRuntimeSdk.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_ClothingPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CookingPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/NvClothPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CommonPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_LegacyPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3PROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PxPvdSDKPROFILE_x64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/Windows/XAudio2_9/x64/xaudio2_9redist.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Binaries/ThirdParty/Vorbis/Win64/VS2015/libvorbis_64.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/House/Binaries/Win64/tbb12.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/Engine/Extras/Redist/en-us/UE4PrereqSetup_x64.exe filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/House/Binaries/Win64/OpenImageDenoise.dll filter=lfs diff=lfs merge=lfs -text +WindowsNoEditor/House/Content/Paks/House-WindowsNoEditor.pak filter=lfs diff=lfs merge=lfs -text diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/DbgHelp/dbghelp.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/DbgHelp/dbghelp.dll new file mode 100644 index 0000000000000000000000000000000000000000..18c857fed83a2b398bbcad11bb14e1752edcc22d --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/DbgHelp/dbghelp.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a02133854ff9f06c3b23a70f8c2a4814b2ed4eef613244b485e3737259ddf9e +size 1868736 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/GeForceNOW/Win64/GfnRuntimeSdk.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/GeForceNOW/Win64/GfnRuntimeSdk.dll new file mode 100644 index 0000000000000000000000000000000000000000..d6dea8886646972fc1a7c576904d91124c0545fe --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/GeForceNOW/Win64/GfnRuntimeSdk.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e741479b13faab35b34a60bd9e8b09791ea57d260a9336b44916e73ba2246d30 +size 3212640 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/NVaftermath/Win64/GFSDK_Aftermath_Lib.x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/NVaftermath/Win64/GFSDK_Aftermath_Lib.x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..5de114c9a131ec7b25c5da1bee7ecad44a6879c0 --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/NVIDIA/NVaftermath/Win64/GFSDK_Aftermath_Lib.x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:516e14af41a91fe960363728965f354aecc06bcdfaef6bcb45dd3537ede09195 +size 1425920 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/OpenXR/win64/openxr_loader.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/OpenXR/win64/openxr_loader.dll new file mode 100644 index 0000000000000000000000000000000000000000..5c28afef5498e10f7606c7747ebaa2dc85e5896c --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/OpenXR/win64/openxr_loader.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ae94572256dfd6d7e992a4474797d8cfe14cf3c030b2040a5b91a7d7bdfd8d8 +size 622592 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_ClothingPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_ClothingPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..7c4cd924ebba6323f6cc631ad42c7ca6ddf06331 --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_ClothingPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d0bf48f8e20b2876a0924fe23128fed4bfbe7c6263d0b98ede45bedd7486b41 +size 1575936 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_LegacyPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_LegacyPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..77681dfc662cf8a8c28a527e95c90eb94fd73ecb --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/APEX_LegacyPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9841fd409a788d0a8cb38c8e5ce06a5b7192d43a465ccbe0a6714fccdde67b79 +size 4198400 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/ApexFrameworkPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/ApexFrameworkPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..b299e9943b0e580f769d6255072fe6b6aa5be32a --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/ApexFrameworkPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:243e4b82d84f6abfc400aaa8c2cc4fc93f36e670c016bc673f18569eb04d47ec +size 1382400 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/NvClothPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/NvClothPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..fa6e063bc745b633537dad88e1206d05d901ebcb --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/NvClothPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e62523756094e9a7f83e2b752bd4452401978bb85e180e2efd9a7d8e1c93c851 +size 264704 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CommonPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CommonPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..4bf07e90580ae02cec1dd000c6a256c2250f0f24 --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CommonPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d0de2d0d5952857acc0234cba8e515cb79ce23569967f0b604ebc2ea70cbd15 +size 2033152 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CookingPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CookingPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..e498c17ed77e5bf06510f97971ac4c5306500d57 --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3CookingPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47e6124c9afa2f16ace856f415ee958fcb53109317e7b0191722bdc9c6626507 +size 244736 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3PROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3PROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..b8447648a4bec9b56196ec835fcec20de382dd20 --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PhysX3PROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b69d19c37c2a08b0aa61cf16595dec31935dafa1023cf27a4457cad2b5bc0a1e +size 3141120 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PxPvdSDKPROFILE_x64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PxPvdSDKPROFILE_x64.dll new file mode 100644 index 0000000000000000000000000000000000000000..e9b50ab4f98a39c47c482eadbe5c6eef89e50e1e --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/PhysX3/Win64/VS2015/PxPvdSDKPROFILE_x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a64d533c7486a346470e119111ef98bbe2a38b0d42d22f9c80ee7aec85cb53e3 +size 267776 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/Vorbis/Win64/VS2015/libvorbis_64.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/Vorbis/Win64/VS2015/libvorbis_64.dll new file mode 100644 index 0000000000000000000000000000000000000000..bbe93010e2a63922c0ecaae05d7ff0141873051f --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/Vorbis/Win64/VS2015/libvorbis_64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f66dcb5837e9b59c499277fd272b862043356aa9145802cf0a63e00a1bcca59 +size 1714176 diff --git a/WindowsNoEditor/Engine/Binaries/ThirdParty/Windows/XAudio2_9/x64/xaudio2_9redist.dll b/WindowsNoEditor/Engine/Binaries/ThirdParty/Windows/XAudio2_9/x64/xaudio2_9redist.dll new file mode 100644 index 0000000000000000000000000000000000000000..b0d76cd95815b1e01b8f189ef143e67f8b56cc9d --- /dev/null +++ b/WindowsNoEditor/Engine/Binaries/ThirdParty/Windows/XAudio2_9/x64/xaudio2_9redist.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e01f400baa09694cacfd2cfbff0d721c17b56785d2d6e29b6fdd117f70ccc1e +size 847440 diff --git a/WindowsNoEditor/Engine/Extras/Redist/en-us/UE4PrereqSetup_x64.exe b/WindowsNoEditor/Engine/Extras/Redist/en-us/UE4PrereqSetup_x64.exe new file mode 100644 index 0000000000000000000000000000000000000000..900a5dd1ebdadc2571cd62ba433bdfbc6579ef0b --- /dev/null +++ b/WindowsNoEditor/Engine/Extras/Redist/en-us/UE4PrereqSetup_x64.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:145f4e4d11e76a2612db5ffbfae8f9ab8e4385ff7660802ffd2f473c9dcb2a0d +size 41033784 diff --git a/WindowsNoEditor/House.exe b/WindowsNoEditor/House.exe new file mode 100644 index 0000000000000000000000000000000000000000..fc78ca72e229764d73dc838f9ac099aecebb7d61 --- /dev/null +++ b/WindowsNoEditor/House.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b42fa622dbe0dd1d81aa99e3f7d33365ee6ef989840fcfb62f12d3d5648cb52 +size 144896 diff --git a/WindowsNoEditor/House/Binaries/Win64/House.exe b/WindowsNoEditor/House/Binaries/Win64/House.exe new file mode 100644 index 0000000000000000000000000000000000000000..ad6b4aeed3505e5551050f0c835beda98359cc79 --- /dev/null +++ b/WindowsNoEditor/House/Binaries/Win64/House.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e4920b7414dd4a2f31dee537b85c8839506ec70f432fde21617656f5c90f753 +size 175959040 diff --git a/WindowsNoEditor/House/Binaries/Win64/OpenImageDenoise.dll b/WindowsNoEditor/House/Binaries/Win64/OpenImageDenoise.dll new file mode 100644 index 0000000000000000000000000000000000000000..ba1de5bfdc8e182b7d53a7c08847f319e2a918ec --- /dev/null +++ b/WindowsNoEditor/House/Binaries/Win64/OpenImageDenoise.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11213c268e6c67262d48e7351e1f6c196acbb91a9a1cf059d4d758c34368f08a +size 49771408 diff --git a/WindowsNoEditor/House/Binaries/Win64/tbb12.dll b/WindowsNoEditor/House/Binaries/Win64/tbb12.dll new file mode 100644 index 0000000000000000000000000000000000000000..c287cd28765c07879ec0c83babbcd01ec7731378 --- /dev/null +++ b/WindowsNoEditor/House/Binaries/Win64/tbb12.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:061f3b283b3e5b24c5ac45772ee19e2f4b24cdacb3ff8ae4f815fe62836e5a45 +size 383856 diff --git a/WindowsNoEditor/House/Content/Paks/House-WindowsNoEditor.pak b/WindowsNoEditor/House/Content/Paks/House-WindowsNoEditor.pak new file mode 100644 index 0000000000000000000000000000000000000000..13c7059450020af9c46470c1e894fa29342f2236 --- /dev/null +++ b/WindowsNoEditor/House/Content/Paks/House-WindowsNoEditor.pak @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27f3233dbe1025edc6a8af527f42a3b8f4ea1fef8b1eea97b5422ede051be595 +size 2128940159 diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/Play.png b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/Play.png new file mode 100644 index 0000000000000000000000000000000000000000..95c1d517da17f1d9572b067f6e4e59b4a451fb74 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/Play.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d6ca52841830d9321b7c776ad9faffef74e0884d8dc3a8777a497d85be60f15 +size 4882 diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-16x16.png b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..5789a5ea0217060746b64928ef8b8b895af2b898 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-16x16.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e4a1cbe7789046a083d7ca1e261a989b93e344dcedcb5af201d4ecff0d7208d +size 959 diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-32x32.png b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..ae61aa919b9bab277b974e68361c817491d412a4 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-32x32.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdd9a45c02c61017a0fc71ba6b4f7db890a8435718edece567076a52d0e7eaf8 +size 2240 diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-96x96.png b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-96x96.png new file mode 100644 index 0000000000000000000000000000000000000000..488b511d879456c0ff7c5b944490222ab9d714ba --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon-96x96.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f51f3fb508f0d0361b722345974969576daef2c7d3db8f97c4ca8e1ff1a1775 +size 5649 diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon.ico b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..0b46e9800a59b31765d3a9495229dcd169394924 Binary files /dev/null and b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/images/favicon.ico differ diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/index.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fb838e4103b74814fa877852d92f91f3b0734f9e --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/index.js @@ -0,0 +1,2 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +exports.users = require('./users'); diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/store_password.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/store_password.js new file mode 100644 index 0000000000000000000000000000000000000000..7b540ed89f69d6c0204318d703a094d4cdb8f69c --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/store_password.js @@ -0,0 +1,80 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +// +// Usage: npm run store_password -- --username --password +// or from ./modules/authentication/db dir: node store_password.js --username --password +// +// --usersFile is an optional parameter that can be used to specify a different location for the users database file +// use this if running the command from a different working dir. The default location is './users.json' +// e.g. If running from the SignallingWebServer dir use: --usersFile ./modules/authentication/db/users.json + +const argv = require('yargs').argv; +const fs = require('fs'); +const bcrypt = require('bcryptjs'); + +var username, password; +var usersFile = './users.json' + +const STORE_PLAINTEXT_PASSWORD = false; + +try { + if(typeof argv.username != 'undefined'){ + username = argv.username.toString(); + } + + if(typeof argv.password != 'undefined'){ + password = argv.password; + } + + if(typeof argv.usersFile != 'undefined'){ + usersFile = argv.usersFile; + } +} catch (e) { + console.error(e); + process.exit(2); +} + +if(username && password){ + let existingAccounts = []; + if (fs.existsSync(usersFile)) { + console.log(`File '${usersFile}' exists, reading file`) + var content = fs.readFileSync(usersFile, 'utf8'); + try{ + existingAccounts = JSON.parse(content); + } + catch(e){ + console.error(`Existing file '${usersFile}', has invalid JSON: ${e}`); + } + } + + var existingUser = existingAccounts.find( u => u.username == username) + if(existingUser){ + console.log(`User '${username}', already exists, updating password`) + existingUser.passwordHash = generatePasswordHash(password) + if(STORE_PLAINTEXT_PASSWORD) + existingUser.password = password; + else if (existingUser.password) + delete existingUser.password; + + } else { + console.log(`Adding new user '${username}'`) + let newUser = { + id: existingAccounts.length + 1, + username: username, + passwordHash: generatePasswordHash(password) + } + if(STORE_PLAINTEXT_PASSWORD) + newUser.password = password; + + existingAccounts.push(newUser); + } + + console.log(`Writing updated users to '${usersFile}'`); + var newContent = JSON.stringify(existingAccounts); + fs.writeFileSync(usersFile, newContent); +} else { + console.log(`Please pass in both username (${username}) and password (${password}) please`); +} + +function generatePasswordHash(pass){ + return bcrypt.hashSync(pass, 12) +} \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/users.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/users.js new file mode 100644 index 0000000000000000000000000000000000000000..be7b003efe0c6058370d69680543ccd0cc9fde3a --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/db/users.js @@ -0,0 +1,35 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +const fs = require('fs'); +const path = require('path'); + +// Read in users from file +let records = []; +let usersFile = path.join(__dirname, './users.json'); +if (fs.existsSync(usersFile)) { + console.log(`Reading users from '${usersFile}'`) + var content = fs.readFileSync(usersFile, 'utf8'); + try { + records = JSON.parse(content); + } catch(e) { + console.log(`ERROR: Failed to parse users from file '${usersFile}'`) + } +} + +exports.findById = function(id, cb) { + var idx = id - 1; + if (records[idx]) { + cb(null, records[idx]); + } else { + cb(new Error('User ' + id + ' does not exist')); + } +} + +exports.findByUsername = function(username, cb) { + for (var i = 0, len = records.length; i < len; i++) { + var record = records[i]; + if (record.username === username) { + return cb(null, record); + } + } + return cb(null, null); +} diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/index.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/index.js new file mode 100644 index 0000000000000000000000000000000000000000..55893001545b1f64e000fec0cfcffecdfc3413b5 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/index.js @@ -0,0 +1,4 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +module.exports = { + init: require('./init') +} \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/init.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/init.js new file mode 100644 index 0000000000000000000000000000000000000000..e75c2874acb8bb0486a19800dd4febe8b14ab438 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/authentication/init.js @@ -0,0 +1,109 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +// Adapted from +// * https://blog.risingstack.com/node-hero-node-js-authentication-passport-js/ +// * https://github.com/RisingStack/nodehero-authentication/tree/master/app +// * https://github.com/passport/express-4.x-local-example + + +const passport = require('passport'); +const session = require('express-session'); +const bcrypt = require('bcryptjs'); +const LocalStrategy = require('passport-local').Strategy; +const path = require('path'); +const fs = require('fs'); +var db = require('./db'); + +function initPassport (app) { + + // Generate session secret if it doesn't already exist and save it to file for use next time + let config = {}; + let configPath = path.join(__dirname, './config.json'); + if (fs.existsSync(configPath)) { + let content = fs.readFileSync(configPath, 'utf8'); + try { + config = JSON.parse(content); + } catch (e) { + console.log(`Error with config file '${configPath}': ${e}`); + } + } + + if(!config.sessionSecret){ + config.sessionSecret = bcrypt.genSaltSync(12); + let content = JSON.stringify(config); + fs.writeFileSync(configPath, content); + } + + // Setup session id settings + app.use(session({ + secret: config.sessionSecret, + resave: false, + saveUninitialized: false, + cookie: { + secure: true, + maxAge: 24 * 60 * 60 * 1000 /* 1 day */ + //maxAge: 5 * 1000 /* 5 seconds */ + } + })); + + app.use(passport.initialize()); + app.use(passport.session()); + + passport.serializeUser(function(user, cb) { + cb(null, user.id); + }); + + passport.deserializeUser(function(id, cb) { + db.users.findById(id, function (err, user) { + if (err) { return cb(err); } + cb(null, user); + }); + }); + + console.log('Setting up auth'); + passport.use(new LocalStrategy( + (username, password, callback) => { + db.users.findByUsername(username, (err, user) => { + if (err) { + console.log(`Unable to login '${username}', error ${err}`); + return callback(err); + } + + // User not found + if (!user) { + console.log(`User '${username}' not found`); + return callback(null, false); + } + + // Always use hashed passwords and fixed time comparison + bcrypt.compare(password, user.passwordHash, (err, isValid) => { + if (err) { + console.log(`Error comparing password for user '${username}': ${err}`); + return callback(err); + } + if (!isValid) { + console.log(`Password incorrect for user '${username}'`) + return callback(null, false); + } + + console.log(`User '${username}' logged in`); + return callback(null, user); + }); + }) + } + )); + + passport.authenticationMiddleware = function authenticationMiddleware (redirectUrl) { + return function (req, res, next) { + if (req.isAuthenticated()) { + return next(); + } + + // Set redirectTo property so that user can be redirected back there after logging in + //console.log(`Original request path '${req.originalUrl}'`); + req.session.redirectTo = req.originalUrl; + res.redirect(redirectUrl); + } + } +} + +module.exports = initPassport; \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/config.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/config.js new file mode 100644 index 0000000000000000000000000000000000000000..d1a04fa5713b2b4b5565b1553e9edfff706b44b3 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/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/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/httpsClient.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/httpsClient.js new file mode 100644 index 0000000000000000000000000000000000000000..c12f52e0716eaf644211bb69f670dcc40509ca35 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/httpsClient.js @@ -0,0 +1,95 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +var querystring = require('querystring') +const https = require('https'); +const assert = require('assert'); + +function cleanUrl(aUrl){ + let url = aUrl; + if(url.startsWith("https://")) + url = url.substring("https://".length); + + return url +} + +function createOptions(requestType, url){ + let index = url.indexOf('/'); + + let urlParts = url.split('/', 2) + + return { + hostname: (index === -1) ? url.substring(0) : url.substring(0, index), + port: 443, + path: (index === -1) ? '' : url.substring(index), + method: requestType, + timeout: 30000, + }; +} + +function makeHttpsCall(options, aCallback, aError){ + //console.log(JSON.stringify(options)); + const req = https.request(options, function(response){ + let data = ''; + + //console.log('statusCode:', response.statusCode); + //console.log('headers:', response.headers); + + // A chunk of data has been received. + response.on('data', (chunk) => { + data += chunk; + }); + + // The whole response has been received. Print out the result. + response.on('end', () => { + if(typeof aCallback != "undefined") + aCallback(response, data); + }); + }); + + req.on('timeout', function () { + console.log("Request timed out. " + (options.timeout / 1000) + " seconds expired"); + + // Source: https://github.com/nodejs/node/blob/master/test/parallel/test-http-client-timeout-option.js#L27 + req.destroy(); + }); + + req.on("error", (err) => { + if(typeof aError != "undefined") { + aError(err); + } else { + console.log("Error: " + err.message); + } + }); + + return req; +} + +module.exports = class HttpClient { + get(aUrl, aCallback, aError) { + let url = cleanUrl(aUrl); + + let options = createOptions('GET', url); + + const req = makeHttpsCall(options, aCallback, aError); + + req.end(); + } + + post(aUrl, body, aCallback, aError) { + let url = cleanUrl(aUrl); + + let options = createOptions('POST', url); + + let postBody = querystring.stringify(body); + + //Add extra options for POST request type + options.headers = { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Length': postBody.length + }; + + const req = makeHttpsCall(options, aCallback, aError); + + req.write(postBody); + req.end(); + } +} \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/logging.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/modules/logging.js new file mode 100644 index 0000000000000000000000000000000000000000..6bdbe4220de2d85d9918465a8354afe5e308efb1 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/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/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/package-lock.json b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..d61e70cfe69e7898f9e7dc034c121058114933d4 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/package-lock.json @@ -0,0 +1,1753 @@ +{ + "name": "cirrus-webserver", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "cirrus-webserver", + "version": "0.0.1", + "dependencies": { + "bcryptjs": "^2.4.3", + "express": "^4.16.2", + "express-session": "^1.15.6", + "helmet": "^3.21.3", + "passport": "^0.4.0", + "passport-local": "^1.0.0", + "ws": "^7.1.2", + "y18n": "^5.0.5", + "yargs": "^15.3.0" + } + }, + "node_modules/accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", + "dependencies": { + "mime-types": "~2.1.16", + "negotiator": "0.6.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "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" + } + }, + "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/async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "node_modules/bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=" + }, + "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/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/body-parser/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/bowser": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.9.0.tgz", + "integrity": "sha512-2ld76tuLBNFekRgmJfT2+3j5MIrP6bFict8WAIT3beq+srz1gcKNAdNKMqHqauQt63NmAa88HfP1/Ypa9Er3HA==" + }, + "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/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelize": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz", + "integrity": "sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs=" + }, + "node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.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/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-security-policy-builder": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-security-policy-builder/-/content-security-policy-builder-2.1.0.tgz", + "integrity": "sha512-/MtLWhJVvJNkA9dVLAp6fg9LxD2gfI6R2Fi1hPmfjYXSahJJzcfvoeDOxSyp4NvxMuwWv3WMssE9o31DoULHrQ==", + "engines": { + "node": ">=4.0.0" + } + }, + "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/crc": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", + "integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms=" + }, + "node_modules/dasherize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz", + "integrity": "sha1-bYCcnNDPe7iVLYD8hPoT1H3bEwg=" + }, + "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/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "engines": { + "node": ">=0.10.0" + } + }, + "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/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "node_modules/dont-sniff-mimetype": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.1.0.tgz", + "integrity": "sha512-ZjI4zqTaxveH2/tTlzS1wFp+7ncxNZaIEWYg3lzZRHkKf5zPT/MnEG6WL0BhHMJUabkh8GeU5NL5j+rEUCb7Ug==", + "engines": { + "node": ">=4.0.0" + } + }, + "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.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", + "engines": { + "node": ">= 0.8" + } + }, + "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.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", + "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", + "dependencies": { + "accepts": "~1.3.4", + "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.1", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.0", + "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.2", + "qs": "6.5.1", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.1", + "serve-static": "1.13.1", + "setprototypeof": "1.1.0", + "statuses": "~1.3.1", + "type-is": "~1.6.15", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/express-session": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.15.6.tgz", + "integrity": "sha512-r0nrHTCYtAMrFwZ0kBzZEXa1vtPVrw0dKvGSrKP4dahwBQ1BJpF2/y1Pp4sCD/0kvxV4zZeclyvfmw0B4RMJQA==", + "dependencies": { + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "crc": "3.4.4", + "debug": "2.6.9", + "depd": "~1.1.1", + "on-headers": "~1.0.1", + "parseurl": "~1.3.2", + "uid-safe": "~2.1.5", + "utils-merge": "1.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/express/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/feature-policy": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/feature-policy/-/feature-policy-0.3.0.tgz", + "integrity": "sha512-ZtijOTFN7TzCujt1fnNhfWPFPSHeZkesff9AXZj+UEjYBynWNUIYpC87Ve4wHzyexQsImicLu7WsC2LHq7/xrQ==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/finalhandler": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.3.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "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/helmet": { + "version": "3.23.3", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-3.23.3.tgz", + "integrity": "sha512-U3MeYdzPJQhtvqAVBPntVgAvNSOJyagwZwyKsFdyRa8TV3pOKVFljalPOCxbw5Wwf2kncGhmP0qHjyazIdNdSA==", + "dependencies": { + "depd": "2.0.0", + "dont-sniff-mimetype": "1.1.0", + "feature-policy": "0.3.0", + "helmet-crossdomain": "0.4.0", + "helmet-csp": "2.10.0", + "hide-powered-by": "1.1.0", + "hpkp": "2.0.0", + "hsts": "2.2.0", + "nocache": "2.1.0", + "referrer-policy": "1.2.0", + "x-xss-protection": "1.3.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/helmet-crossdomain": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/helmet-crossdomain/-/helmet-crossdomain-0.4.0.tgz", + "integrity": "sha512-AB4DTykRw3HCOxovD1nPR16hllrVImeFp5VBV9/twj66lJ2nU75DP8FPL0/Jp4jj79JhTfG+pFI2MD02kWJ+fA==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/helmet-csp": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/helmet-csp/-/helmet-csp-2.10.0.tgz", + "integrity": "sha512-Rz953ZNEFk8sT2XvewXkYN0Ho4GEZdjAZy4stjiEQV3eN7GDxg1QKmYggH7otDyIA7uGA6XnUMVSgeJwbR5X+w==", + "dependencies": { + "bowser": "2.9.0", + "camelize": "1.0.0", + "content-security-policy-builder": "2.1.0", + "dasherize": "2.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/helmet/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/hide-powered-by": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.1.0.tgz", + "integrity": "sha512-Io1zA2yOA1YJslkr+AJlWSf2yWFkKjvkcL9Ni1XSUqnGLr/qRQe2UI3Cn/J9MsJht7yEVCe0SscY1HgVMujbgg==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/hpkp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hpkp/-/hpkp-2.0.0.tgz", + "integrity": "sha1-EOFCJk52IVpdMMROxD3mTe5tFnI=" + }, + "node_modules/hsts": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hsts/-/hsts-2.2.0.tgz", + "integrity": "sha512-ToaTnQ2TbJkochoVcdXYm4HOCliNozlviNsg+X2XQLQvZNI/kCHR9rZxVYpJB3UPcHz80PgxRyWQ7PdU1r+VBQ==", + "dependencies": { + "depd": "2.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/hsts/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "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/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.5.2", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", + "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=", + "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/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dependencies": { + "p-locate": "^4.1.0" + }, + "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.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "dependencies": { + "mime-db": "~1.30.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/nocache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz", + "integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==", + "engines": { + "node": ">=4.0.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/on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "engines": { + "node": ">=6" + } + }, + "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/passport": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.4.0.tgz", + "integrity": "sha1-xQlWkTR71a07XhgCOMORTRbwWBE=", + "dependencies": { + "passport-strategy": "1.x.x", + "pause": "0.0.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/passport-local": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", + "integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=", + "dependencies": { + "passport-strategy": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=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/pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=" + }, + "node_modules/proxy-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", + "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", + "dependencies": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.5.2" + }, + "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/random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", + "engines": { + "node": ">= 0.8" + } + }, + "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/referrer-policy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/referrer-policy/-/referrer-policy-1.2.0.tgz", + "integrity": "sha512-LgQJIuS6nAy1Jd88DCQRemyE3mS+ispwlqMk3b0yjZ257fI1v9c+/p6SD5gP5FGyXUIgrNOAfmyioHwZtYv2VA==", + "engines": { + "node": ">=4.0.0" + } + }, + "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/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, + "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/send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "dependencies": { + "debug": "2.6.9", + "depd": "~1.1.1", + "destroy": "~1.0.4", + "encodeurl": "~1.0.1", + "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.3.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/serve-static": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", + "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", + "dependencies": { + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "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/statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.15" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "dependencies": { + "random-bytes": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "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/which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ws": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz", + "integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==", + "dependencies": { + "async-limiter": "^1.0.0" + } + }, + "node_modules/x-xss-protection": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/x-xss-protection/-/x-xss-protection-1.3.0.tgz", + "integrity": "sha512-kpyBI9TlVipZO4diReZMAHWtS0MMa/7Kgx8hwG/EuZLiA6sg4Ah/4TRdASHhRRN3boobzcYgFRUFSgHRge6Qhg==", + "engines": { + "node": ">=4.0.0" + } + }, + "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": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==" + } + }, + "dependencies": { + "accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", + "requires": { + "mime-types": "~2.1.16", + "negotiator": "0.6.1" + } + }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "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=" + }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=" + }, + "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" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + } + } + }, + "bowser": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.9.0.tgz", + "integrity": "sha512-2ld76tuLBNFekRgmJfT2+3j5MIrP6bFict8WAIT3beq+srz1gcKNAdNKMqHqauQt63NmAa88HfP1/Ypa9Er3HA==" + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, + "camelize": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz", + "integrity": "sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs=" + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.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==" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-security-policy-builder": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-security-policy-builder/-/content-security-policy-builder-2.1.0.tgz", + "integrity": "sha512-/MtLWhJVvJNkA9dVLAp6fg9LxD2gfI6R2Fi1hPmfjYXSahJJzcfvoeDOxSyp4NvxMuwWv3WMssE9o31DoULHrQ==" + }, + "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=" + }, + "crc": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", + "integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms=" + }, + "dasherize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz", + "integrity": "sha1-bYCcnNDPe7iVLYD8hPoT1H3bEwg=" + }, + "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" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "dont-sniff-mimetype": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.1.0.tgz", + "integrity": "sha512-ZjI4zqTaxveH2/tTlzS1wFp+7ncxNZaIEWYg3lzZRHkKf5zPT/MnEG6WL0BhHMJUabkh8GeU5NL5j+rEUCb7Ug==" + }, + "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.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" + }, + "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.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", + "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", + "requires": { + "accepts": "~1.3.4", + "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.1", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.0", + "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.2", + "qs": "6.5.1", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.1", + "serve-static": "1.13.1", + "setprototypeof": "1.1.0", + "statuses": "~1.3.1", + "type-is": "~1.6.15", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + } + } + }, + "express-session": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.15.6.tgz", + "integrity": "sha512-r0nrHTCYtAMrFwZ0kBzZEXa1vtPVrw0dKvGSrKP4dahwBQ1BJpF2/y1Pp4sCD/0kvxV4zZeclyvfmw0B4RMJQA==", + "requires": { + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "crc": "3.4.4", + "debug": "2.6.9", + "depd": "~1.1.1", + "on-headers": "~1.0.1", + "parseurl": "~1.3.2", + "uid-safe": "~2.1.5", + "utils-merge": "1.0.1" + } + }, + "feature-policy": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/feature-policy/-/feature-policy-0.3.0.tgz", + "integrity": "sha512-ZtijOTFN7TzCujt1fnNhfWPFPSHeZkesff9AXZj+UEjYBynWNUIYpC87Ve4wHzyexQsImicLu7WsC2LHq7/xrQ==" + }, + "finalhandler": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.3.1", + "unpipe": "~1.0.0" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.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==" + }, + "helmet": { + "version": "3.23.3", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-3.23.3.tgz", + "integrity": "sha512-U3MeYdzPJQhtvqAVBPntVgAvNSOJyagwZwyKsFdyRa8TV3pOKVFljalPOCxbw5Wwf2kncGhmP0qHjyazIdNdSA==", + "requires": { + "depd": "2.0.0", + "dont-sniff-mimetype": "1.1.0", + "feature-policy": "0.3.0", + "helmet-crossdomain": "0.4.0", + "helmet-csp": "2.10.0", + "hide-powered-by": "1.1.0", + "hpkp": "2.0.0", + "hsts": "2.2.0", + "nocache": "2.1.0", + "referrer-policy": "1.2.0", + "x-xss-protection": "1.3.0" + }, + "dependencies": { + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + } + } + }, + "helmet-crossdomain": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/helmet-crossdomain/-/helmet-crossdomain-0.4.0.tgz", + "integrity": "sha512-AB4DTykRw3HCOxovD1nPR16hllrVImeFp5VBV9/twj66lJ2nU75DP8FPL0/Jp4jj79JhTfG+pFI2MD02kWJ+fA==" + }, + "helmet-csp": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/helmet-csp/-/helmet-csp-2.10.0.tgz", + "integrity": "sha512-Rz953ZNEFk8sT2XvewXkYN0Ho4GEZdjAZy4stjiEQV3eN7GDxg1QKmYggH7otDyIA7uGA6XnUMVSgeJwbR5X+w==", + "requires": { + "bowser": "2.9.0", + "camelize": "1.0.0", + "content-security-policy-builder": "2.1.0", + "dasherize": "2.0.0" + } + }, + "hide-powered-by": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.1.0.tgz", + "integrity": "sha512-Io1zA2yOA1YJslkr+AJlWSf2yWFkKjvkcL9Ni1XSUqnGLr/qRQe2UI3Cn/J9MsJht7yEVCe0SscY1HgVMujbgg==" + }, + "hpkp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hpkp/-/hpkp-2.0.0.tgz", + "integrity": "sha1-EOFCJk52IVpdMMROxD3mTe5tFnI=" + }, + "hsts": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hsts/-/hsts-2.2.0.tgz", + "integrity": "sha512-ToaTnQ2TbJkochoVcdXYm4HOCliNozlviNsg+X2XQLQvZNI/kCHR9rZxVYpJB3UPcHz80PgxRyWQ7PdU1r+VBQ==", + "requires": { + "depd": "2.0.0" + }, + "dependencies": { + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + } + } + }, + "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" + } + }, + "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.5.2", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", + "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" + }, + "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==" + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "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.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "requires": { + "mime-db": "~1.30.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=" + }, + "nocache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz", + "integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==" + }, + "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" + } + }, + "on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=" + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "passport": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.4.0.tgz", + "integrity": "sha1-xQlWkTR71a07XhgCOMORTRbwWBE=", + "requires": { + "passport-strategy": "1.x.x", + "pause": "0.0.1" + } + }, + "passport-local": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", + "integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=", + "requires": { + "passport-strategy": "1.x.x" + } + }, + "passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=" + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "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=" + }, + "pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=" + }, + "proxy-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", + "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.5.2" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=" + }, + "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" + } + }, + "referrer-policy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/referrer-policy/-/referrer-policy-1.2.0.tgz", + "integrity": "sha512-LgQJIuS6nAy1Jd88DCQRemyE3mS+ispwlqMk3b0yjZ257fI1v9c+/p6SD5gP5FGyXUIgrNOAfmyioHwZtYv2VA==" + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.1", + "destroy": "~1.0.4", + "encodeurl": "~1.0.1", + "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.3.1" + } + }, + "serve-static": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", + "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", + "requires": { + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.1" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.15" + } + }, + "uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "requires": { + "random-bytes": "~1.0.0" + } + }, + "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=" + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "ws": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz", + "integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==", + "requires": { + "async-limiter": "^1.0.0" + } + }, + "x-xss-protection": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/x-xss-protection/-/x-xss-protection-1.3.0.tgz", + "integrity": "sha512-kpyBI9TlVipZO4diReZMAHWtS0MMa/7Kgx8hwG/EuZLiA6sg4Ah/4TRdASHhRRN3boobzcYgFRUFSgHRge6Qhg==" + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "dependencies": { + "y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==" + } + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } +} diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/package.json b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/package.json new file mode 100644 index 0000000000000000000000000000000000000000..28c8af9a822db1949e4f9851e4a71b43a7c59034 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/package.json @@ -0,0 +1,20 @@ +{ + "name": "cirrus-webserver", + "version": "0.0.1", + "description": "cirrus web server", + "scripts": { + "store_password": "node ./modules/authentication/db/store_password.js --usersFile=./modules/authentication/db/users.json", + "start": "npm install && node cirrus.js" + }, + "dependencies": { + "bcryptjs": "^2.4.3", + "express": "^4.16.2", + "express-session": "^1.15.6", + "helmet": "^3.21.3", + "passport": "^0.4.0", + "passport-local": "^1.0.0", + "ws": "^7.1.2", + "y18n": "^5.0.5", + "yargs": "^15.3.0" + } +} diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/README.txt b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..4efa2e400793dfbf7509e0540d43985c66a5711c --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/README.txt @@ -0,0 +1,13 @@ +How to use files in this directory: +- Make sure that all of your dependencies are installed. Use ./setup.sh what will install whatever is missing as long as you are on a supported operating system. Please note that setup.sh is called from every script designed to run + +- Run a local instance of the Cirrus server by using the ./run_local.sh script + +- Use the following scripts to run locally or in your cloud instance: + - Start_SignallingServer.sh - Start only the Signalling (STUN) server + - Start_TURNServer.sh - Start only the TURN server + - Start_WithTURN_SignallingServer.sh - Start a TURN server and the Cirrus server together +- The Start_Common.sh file contains shared functions for other Start_.sh scripts and it is not supposed to run alone + +- Please note that scripts intended to run need to be executable: $ chmod +x *.sh will do that job. +- The local/cloud Start_*.sh shell scripts can be invoked with the --help command line option to see how those can be configured. The following options can be supplied: --publicip, --turn, --stun. Please read the --help diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_Common.sh b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_Common.sh new file mode 100644 index 0000000000000000000000000000000000000000..dec23a9f06194b9a144bc73c3fe654fbd83c8c02 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_Common.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +function print_usage { + echo " + Usage: + ${0} [--help] [--publicip ] [--turn ] [--stun ] [cirrus options...] + Where: + --help will print this message and stop this script. + --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 Cirrus server and the default IP address of the TURN server + --turn defines what TURN server to be used, syntax: --turn 127.0.0.1:19303 + default value: as above, IP address downloaded from https://api.ipify.org; in case if download failure it is set to 127.0.0.1 + --stun defined what STUN server to be used, syntax: --stun stun.l.google.com:19302 + default value as above + Other options: stored and passed to the Cirrus server. All parameters printed once the script values are set. + Command line options might be omitted to run with defaults and it is a good practice to omit specific ones when just starting the TURN or the STUN server alone, not the whole set of scripts. + " + exit 1 +} + +function print_parameters { + echo "" + echo "${0} is running with the following parameters:" + echo "--------------------------------------" + if [[ -n "${stunserver}" ]]; then echo "STUN server : ${stunserver}" ; fi + if [[ -n "${turnserver}" ]]; then echo "TURN server : ${turnserver}" ; fi + echo "Public IP address : ${publicip}" + echo "Cirrus server command line arguments: ${cirruscmd}" + echo "" +} + +function set_start_default_values { + # publicip and cirruscmd are always needed + publicip=$(curl -s https://api.ipify.org > /dev/null) + if [[ -z $publicip ]]; then + publicip="127.0.0.1" + fi + cirruscmd="" + + if [ "$1" = "y" ]; then + turnserver="${publicip}:19303" + fi + + if [ "$2" = "y" ]; then + stunserver="stun.l.google.com:19302" + fi +} + +function use_args { + while(($#)) ; do + case "$1" in + --stun ) stunserver="$2"; shift 2;; + --turn ) turnserver="$2"; shift 2;; + --publicip ) publicip="$2"; turnserver="${publicip}:19303"; shift 2;; + --help ) print_usage;; + * ) echo "Unknown command, adding to cirrus command line: $1"; cirruscmd+=" $1"; shift;; + esac + done +} + +function call_setup_sh { + bash "setup.sh" +} diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_SignallingServer.sh b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_SignallingServer.sh new file mode 100644 index 0000000000000000000000000000000000000000..c610bbb7c55f56f6a1994328a483da31eb19b4f5 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_SignallingServer.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +source Start_Common.sh + +set_start_default_values "n" "y" # Only STUN server defaults +use_args "$@" +call_setup_sh +print_parameters + +peerconnectionoptions="{\"iceServers\":[{\"urls\":[\"stun:${stunserver}\"]}]}" + +process="node" +arguments="cirrus --peerConnectionOptions=\"${peerconnectionoptions}\" --publicIp=${publicip}" +# Add arguments passed to script to arguments for executable +arguments+=" ${cirruscmd}" + +pushd ../.. +echo "Running: $process $arguments" +sudo $process $arguments +popd diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_TURNServer.sh b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_TURNServer.sh new file mode 100644 index 0000000000000000000000000000000000000000..ec2a0abcd7cd09fe3ba25468052837ec60dd8fcd --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_TURNServer.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +source Start_Common.sh + +set_start_default_values "y" "n" # TURN server defaults only +use_args "$@" +call_setup_sh +print_parameters + +localip=$(hostname -I | awk '{print $1}') +echo "Private IP: $localip" + +turnport="${turnserver##*:}" +echo "TURN port: ${turnport}" +echo "" + +pushd "$( dirname "${BASH_SOURCE[0]}" )" +bash Install_CoTurn.sh + +# Hmm, plain text +turnusername="PixelStreamingUser" +turnpassword="AnotherTURNintheroad" +realm="PixelStreaming" +process="turnserver" +arguments="-p ${turnport} -r $realm -X $publicip -E $localip -L $localip --no-cli --no-tls --no-dtls --pidfile /var/run/turnserver.pid -f -a -v -n -u ${turnusername}:${turnpassword}" + +# Add arguments passed to script to arguments for executable +arguments+=" ${cirruscmd}" + +pushd ../.. +echo "Running: $process $arguments" +# pause +sudo $process $arguments & +popd + +popd diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_WithTURN_SignallingServer.sh b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_WithTURN_SignallingServer.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ac28b66933afd9b9399e143e754580de1aae4c3 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/Start_WithTURN_SignallingServer.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +source Start_Common.sh + +set_start_default_values "y" "y" # Set both TURN and STUN server defaults +use_args "$@" +call_setup_sh +print_parameters + +pushd "$( dirname "${BASH_SOURCE[0]}" )" + +bash Start_TURNServer.sh --turn "${turnserver}" + +peerconnectionoptions="{\"iceServers\":[{\"urls\":[\"stun:$stunserver\",\"turn:$turnserver\"],\"username\":\"PixelStreamingUser\",\"credential\":\"AnotherTURNintheroad\"}]}" + +process="node" +arguments="cirrus --peerConnectionOptions=\"$peerconnectionoptions\" --publicIp=$publicip" +# Add arguments passed to script to arguments for executable +arguments+=" ${cirruscmd}" + +pushd ../.. +echo "Running: $process $arguments" +sudo $process $arguments +popd + +popd diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/run_local.sh b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/run_local.sh new file mode 100644 index 0000000000000000000000000000000000000000..92b71bef1bb6437739402b37968908bdf995ddbc --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/run_local.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +pushd "$( dirname "${BASH_SOURCE[0]}" )" +bash setup.sh +pushd ../.. +sudo node cirrus.js +popd +popd diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/setup.sh b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a6448e0c8f4f7f26ce36d4307930cdf97c31650 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/bash/setup.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# Copyright Epic Games, Inc. All Rights Reserved. + +# 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 + +declare -A Packages +num_rows=6 +num_cols=8 + +# Versions are from current working release versions +# No version for turnserver at the moment, see below why: +# https://github.com/coturn/coturn/issues/680 +# https://github.com/coturn/coturn/issues/843 +# +# Structure for installation preparation; please note | in "how to install" -> installer will split the command +# Need install Package name Version min/any how to get version how to install +Packages[1,1]="y" +Packages[1,2]="TURN server" +Packages[1,3]="" +Packages[1,4]="any" +Packages[1,5]="turnserver" +Packages[1,6]="sudo apt-get install -y coturn" +Packages[2,1]="y" +Packages[2,2]="node" +Packages[2,3]="v10.19.0" +Packages[2,4]="min" +Packages[2,5]="node --version" +Packages[2,6]="curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash - && sudo apt-get install -y nodejs" +Packages[3,1]="y" +Packages[3,2]="npm" +Packages[3,3]="8.1.2" +Packages[3,4]="min" +Packages[3,5]="npm --version" +Packages[3,6]="sudo npm install -g npm | sudo npm cache clean -f | sudo npm install -g npm@latest" +Packages[4,1]="y" +Packages[4,2]="express fw" +Packages[4,3]="4.17.1" +Packages[4,4]="min" +Packages[4,5]="sudo npm show express version" +Packages[4,6]="sudo npm install express -f" +Packages[5,1]="y" +Packages[5,2]="STUN server" +Packages[5,3]="0.0.1" +Packages[5,4]="min" +Packages[5,5]="sudo npm show cirrus-webserver version" +Packages[5,6]="sudo npm install cirrus-webserver -f" +Packages[6,1]="y" +Packages[6,2]="JSON jq" +Packages[6,3]="1.6" +Packages[6,4]="min" +Packages[6,5]="jq --version" +Packages[6,6]="sudo apt-get install -y jq" +Packages[7,1]="y" +Packages[7,2]="vulkan-utils" +Packages[7,3]="1.2.131" +Packages[7,4]="min" +Packages[7,5]="sudo apt show vulkan-utils 2>/dev/null | grep Version" +Packages[7,6]="sudo apt-get install -y vulkan-utils" +Packages[8,1]="y" +Packages[8,2]="pulseaudio" +Packages[8,3]="13.99" +Packages[8,4]="min" +Packages[8,5]="pulseaudio --version" +Packages[8,6]="sudo apt-get install -y pulseaudio" + +# Install npm packages at the correct place +pushd ../.. 2&>1 + +# Check what to install +for ((i=1;i<=num_cols;i++)) do + printf "Checking for %-12s ..." "${Packages[$i,2]}" + if [ "${Packages[$i,4]}" = "any" ]; then + printf " any version ... " + IsInstalled=$(command -v "${Packages[$i,5]}") + if [ -z "$IsInstalled" ]; then + printf " not found marked for installation\n" + else + printf " found no install needed %s\n" "${IsInstalled}" + Packages[$i,1]="n" + fi + elif [ "${Packages[$i,4]}" = "min" ]; then + printf " minimum version: %-15s" "${Packages[$i,3]}" + Wanted=$(echo "${Packages[$i,3]}" | sed -E 's/[^0-9.]//g') + Installed=$(eval "${Packages[$i,5]}" 2>/dev/null) + if [ -z "${Installed}" ]; then + printf "not found an installed version\n" + else + printf "found version: %-20s" "${Installed}" + Current=$(echo "${Installed}" | sed -E 's/[^0-9.]//g') + if [ "${Current}" == "${Wanted}" ]; then + Packages[$i,1]="n" + printf " no install needed\n" + else + Newer=$(printf "%s\n%s" "${Wanted}" "${Current}" | sort -r | head -n 1) + if [ "${Current}" != "${Newer}" ]; then + printf " old, marked for installation\n" + else + printf " new, no installation\n" + Packages[$i,1]="n" + fi + fi + fi + else + printf "Code error, please check Packages setup for %s %s\n" "${Packages[$i,2]}" + exit + fi +done + +# Do the installation +for ((i=1;i<=num_cols;i++)) do + if [ "${Packages[$i,1]}" != "n" ]; then + if [[ "${Packages[$i,6]}" == :* ]]; then + printf "Will not install %s because %s" "${Packages[$i,2]}" "${Packages[$i,6]}" + else + printf "Executing command: %s" "${Packages[$i,6]}" + eval "${Packages[$i,6]}" + fi + fi +done + +# Reverse ../.. location +popd diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/README.txt b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..b051d2faeb7a2b9e8d479ddd8ef492fe92642a61 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/README.txt @@ -0,0 +1,13 @@ +How to use files in this directory: +- Files with .ps1 extension can be run with PowerShell[.exe] in Windows. Powershell needs to be started as Administrator to run setup.ps1 so it can run installation / installation check steps +- Make sure that all of your dependencies are installed. Use .\setup.ps1 what will install whatever is missing as long as you are on a supported operating system + +- Run a local instance of the Cirrus server by using the .\run_local.ps1 script + +- Use the following scripts to run locally or in your cloud instance: + - Start_SignallingServer.ps1 - Start only the Signalling (STUN) server + - Start_TURNServer.ps1 - Start only the TURN server + - Start_WithTURN_SignallingServer.ps1 - Start a TURN server and the Cirrus server together +- The Start_Common.ps1 file contains shared functions for other Start_*.ps1 scripts and it is not supposed to run alone + +- The local/cloud Start_*.ps1 powershell scripts can be invoked with the --help command line option to see how those can be configured. The following options can be supplied: --publicip, --turn, --stun. Please read the --help diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_Common.ps1 b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_Common.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..b9bc0b77d414795c8de495e5066f092a30c136af --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_Common.ps1 @@ -0,0 +1,75 @@ +# Copyright 1998-2021 Epic Games, Inc. All Rights Reserved. + +# Do setup as a common task, it is smart and will not reinstall if not required. +. "$PSScriptRoot\setup.ps1" + +$global:ScriptName = $MyInvocation.MyCommand.Name +$global:PublicIP = $null +$global:StunServer = $null +$global:TurnServer = $null +$global:CirrusCmd = $null + +function print_usage { + echo " + Usage (in MS Windows Power Shell): + $global:ScriptName [--help] [--publicip ] [--turn ] [--stun ] [cirrus options...] + Where: + --help will print this message and stop this script. + --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 Cirrus server and the default IP address of the TURN server + --turn defines what TURN server to be used, syntax: --turn 127.0.0.1:19303 + default value: as above, IP address downloaded from https://api.ipify.org; in case if download failure it is set to 127.0.0.1 + --stun defined what STUN server to be used, syntax: --stun stun.l.google.com:19302 + default value as above + Other options: stored and passed to the Cirrus server. All parameters printed once the script values are set. + Command line options might be omitted to run with defaults and it is a good practice to omit specific ones when just starting the TURN or the STUN server alone, not the whole set of scripts. + " + exit 1 +} + +function print_parameters { + echo "" + echo "$scriptname is running with the following parameters:" + echo "--------------------------------------" + if ($global:StunServer -ne $null) { echo "STUN server : $global:StunServer" } + if ($global:TurnServer -ne $null) { echo "TURN server : $global:TurnServer" } + echo "Public IP address : $global:PublicIP" + echo "Cirrus server command line arguments: $global:CirrusCmd" + echo "" +} + +function set_start_default_values($SetTurnServerVar, $SetStunServerVar) { + # publicip and cirruscmd are always needed + $global:publicip = Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing + if ($global:PublicIP -ne $null -Or $global:PublicIP.length -eq 0) { + $global:PublicIP = "127.0.0.1" + } + $global:cirruscmd = "" + + if ($SetTurnServerVar -eq "y") { + $global:TurnServer = $global:PublicIP + ":19303" + } + if ($SetStunServerVar -eq "y") { + $global:StunServer = "stun.l.google.com:19302" + } +} + +function use_args($arg) { + $CmdArgs = $arg -split (" ") + while($CmdArgs.count -gt 0) { + $Cmd, $CmdArgs = $CmdArgs + if ($Cmd -eq "--stun") { + $global:StunServer, $CmdArgs = $CmdArgs + } elseif ($Cmd -eq "--turn") { + $global:TurnServer, $CmdArgs = $CmdArgs + } elseif ($Cmd -eq "--publicip") { + $global:PublicIP, $CmdArgs = $CmdArgs + $global:TurnServer = $global:publicip + ":19303" + } elseif ($Cmd -eq "--help") { + print_usage + } else { + echo "Unknown command, adding to cirrus command line: $Cmd" + $global:CirrusCmd += " $Cmd" + } + } +} diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_SignallingServer.ps1 b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_SignallingServer.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..480809c69b26721915f4f79d80a302ba739cdd87 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_SignallingServer.ps1 @@ -0,0 +1,19 @@ +# Copyright 1998-2021 Epic Games, Inc. All Rights Reserved. + +. "$PSScriptRoot\Start_Common.ps1" + +set_start_default_values "n" "y" # Set both TURN and STUN server defaults +use_args($args) +print_parameters + +$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + $global:StunServer + "\""]}] }" + +$ProcessExe = "node.exe" +$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""", "--publicIp=$global:PublicIp") +# Add arguments passed to script to Arguments for executable +$Arguments += $global:CirrusCmd + +Push-Location $PSScriptRoot\..\..\ +Write-Output "Running: $ProcessExe $Arguments" +Start-Process -FilePath $ProcessExe -ArgumentList "$Arguments" -Wait -NoNewWindow +Pop-Location diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_TURNServer.ps1 b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_TURNServer.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..2fe66239cca4a93483cd643b498ef8966fbc6eff --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_TURNServer.ps1 @@ -0,0 +1,37 @@ +# Copyright 1998-2021 Epic Games, Inc. All Rights Reserved. + +. "$PSScriptRoot\Start_Common.ps1" + +set_start_default_values "y" "n" # Set both TURN and STUN server defaults +use_args($args) +print_parameters +#$LocalIp = Invoke-WebRequest -Uri "http://169.254.169.254/latest/meta-data/local-ipv4" +$LocalIP = hostname.exe +Write-Output "Private IP: $LocalIp" + +$TurnPort="19303" +$Pos = $global:TurnServer.LastIndexOf(":") +if ($Pos -ne -1) { + $TurnPort = $global:TurnServer.Substring($Pos+ 1) +} +echo "TURN port: ${turnport}" +echo "" + +Push-Location $PSScriptRoot + +$TurnUsername = "PixelStreamingUser" +$TurnPassword = "AnotherTURNintheroad" +$Realm = "PixelStreaming" +$ProcessExe = "turnserver.exe" +$Arguments = "-p $TurnPort -r $Realm -X $PublicIP -E $LocalIP -L $LocalIP --no-cli --no-tls --no-dtls --pidfile `"C:\coturn.pid`" -f -a -v -n -u $TurnUsername`:$TurnPassword" + +# Add arguments passed to script to Arguments for executable +$Arguments += $args + +Push-Location $PSScriptRoot\coturn\ +Write-Output "Running: $ProcessExe $Arguments" +# pause +Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -NoNewWindow +Pop-Location + +Pop-Location \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_WithTURN_SignallingServer.ps1 b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_WithTURN_SignallingServer.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..57c92f91735e8f863fe30cade5898d2d535219be --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/Start_WithTURN_SignallingServer.ps1 @@ -0,0 +1,25 @@ +# Copyright 1998-2021 Epic Games, Inc. All Rights Reserved. + +. "$PSScriptRoot\Start_Common.ps1" + +set_start_default_values "y" "y" # Set both TURN and STUN server defaults +use_args($args) +print_parameters + +Push-Location $PSScriptRoot + +Start-Process -FilePath "PowerShell" -ArgumentList ".\Start_TURNServer.ps1 --turn $global:TurnServer" -WorkingDirectory "$PSScriptRoot" + +$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + $global:StunServer + "\"",\""turn:" + $global:TurnServer + "\""], \""username\"": \""PixelStreamingUser\"", \""credential\"": \""AnotherTURNintheroad\""}] }" + +$ProcessExe = "node.exe" +$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""", "--publicIp=$global:PublicIp") +# Add arguments passed to script to Arguments for executable +$Arguments += $args + +Push-Location $PSScriptRoot\..\..\ +Write-Output "Running: $ProcessExe $Arguments" +Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -Wait -NoNewWindow +Pop-Location + +Pop-Location \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/run_local.bat b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/run_local.bat new file mode 100644 index 0000000000000000000000000000000000000000..90a046a601a3f00c90f2bd9ad841412e4ceb5b29 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/run_local.bat @@ -0,0 +1,22 @@ +:: Copyright Epic Games, Inc. All Rights Reserved. +@echo off +if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b) + +pushd "%~dp0" + +title Cirrus + +pushd ..\.. + +::Install required deps +call powershell -command "%~dp0\setup.ps1" + +::Run node server +::If running with frontend web server and accessing outside of localhost pass in --publicIp= +node cirrus %* + +popd + +popd + +pause diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/setup.ps1 b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/setup.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..eac6259b0cdb184cb94ec7b949b8a5d182e8906a --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/platform_scripts/cmd/setup.ps1 @@ -0,0 +1,97 @@ +# Copyright Epic Games, Inc. All Rights Reserved. + +# Unclear if we need this? +# Set-ExecutionPolicy Bypass -Scope Process -Force + +# Versions are from current working release versions +# +# Structure for installation preparation; please note | in "how to install" -> installer will split the command +# Need install Package name Version min/any how to get version how to install path to be added +$Packages = @(@("y", "chocolatey", "0.11.3", "min", "choco --version", "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | choco upgrade chocolatey"), + @("y", "node", "v17.0.1","min", "node --version", "choco install nodejs -y -x -f"), + @("y", "npm", "8.1.2", "min", "npm --version", "npm install -g npm -f") + ) + +# Install npm packages at the correct place +Push-Location $PSScriptRoot\..\..\ + +# Check what to install +foreach ($Item in $Packages) { + Write-Host "Checking for " $Item[1].padRight(12) " ..." -NoNewLine + if ($Item[3] -eq "any") { + Write-Host " any version ... " -NoNewLine + $IsInstalled = Get-Command $Item[4] -ErrorAction SilentlyContinue + if ($IsInstalled -eq $null) { + Write-Host " not found marked for installation" + } else { + Write-Host " found no install needed" + $Item[0] = "n" + } + } elseif ($item[3] -eq "min") { + Write-Host " minimum version: " $Item[2].padRight(12) -NoNewLine + $Wanted = $Item[2] -replace "[^0-9.]" + $Installed = Invoke-Expression -Command $Item[4] 2>&1 + if ($Installed -eq $null) { + Write-Host " not found an installed version" $Item[4] + } else { + Write-Host " found version: " $Installed.padRight(15) -NoNewLine + $Current = $Installed -replace "[^0-9.]" + if ([System.Version]$Current -lt [System.Version]$Wanted) { + Write-Host "old marked for installation" + } else { + $item[0] = "n" + Write-Host "no install needed" + } + } + } else { + Write-Host "Code error, please check Packages setup for " $Item[1] + exit + } +} + +# Do the installation +foreach ($Item in $Packages) { + if ($Item[0] -eq "n") { + continue; + } + if ($Item[5].Substring(0, 1) -eq ":") { + Write-Host "Will not install " $Item[1] " because " $Item[5] + } else { + $HasPipe = $Item[5].indexOf("|") + if ($HasPipe) { + $Arr = $Item[5].Split("|"); + foreach($InstallExe in $Arr) { + $InstallExe = $InstallExe.trim() + Invoke-Expression $InstallExe + } + } else { + Invoke-Expression -Command $Item[5] + } + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + } +} + +# Install Cirrus +npm install + +# Reverse ..\.. location +Pop-Location + +# Put us in the cmd scripts folder +Push-Location $PSScriptRoot + +# Install CoTURN +Write-Host "Checking for Coturn..." -NoNewLine +if (-not(Test-Path -Path coturn/turnserver.exe -PathType Leaf)) { + Write-Host " ...installing... " -NoNewLine + curl -o ./turnserver.zip https://github.com/mcottontensor/coturn/releases/download/v4.5.2-windows/turnserver.zip + Expand-Archive -Path ./turnserver.zip -DestinationPath ./coturn + Remove-Item -Path ./turnserver.zip + Write-Host " ...done. " +} +else { + Write-Host " ...found." +} + +# Reverse location +Pop-Location diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/app.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/app.js new file mode 100644 index 0000000000000000000000000000000000000000..573af5db3d92ae72008b1269c7f2f36375a4f3ef --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/app.js @@ -0,0 +1,1918 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +// Window events for a gamepad connecting +let haveEvents = 'GamepadEvent' in window; +let haveWebkitEvents = 'WebKitGamepadEvent' in window; +let controllers = {}; +let rAF = window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || + window.requestAnimationFrame; +let kbEvent = document.createEvent("KeyboardEvent"); +let initMethod = typeof kbEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; + +let webRtcPlayerObj = null; +let print_stats = false; +let print_inputs = false; +let connect_on_load = false; + +let is_reconnection = false; +let ws; +const WS_OPEN_STATE = 1; + +let qualityControlOwnershipCheckBox; +let matchViewportResolution; +// TODO: Remove this - workaround because of bug causing UE to crash when switching resolutions too quickly +let lastTimeResized = new Date().getTime(); +let resizeTimeout; + +let onDataChannelConnected; +let responseEventListeners = new Map(); + +let freezeFrameOverlay = null; +let shouldShowPlayOverlay = true; +// A freeze frame is a still JPEG image shown instead of the video. +let freezeFrame = { + receiving: false, + size: 0, + jpeg: undefined, + height: 0, + width: 0, + valid: false +}; + +// Optionally detect if the user is not interacting (AFK) and disconnect them. +let afk = { + enabled: false, // Set to true to enable the AFK system. + warnTimeout: 120, // The time to elapse before warning the user they are inactive. + closeTimeout: 10, // The time after the warning when we disconnect the user. + + active: false, // Whether the AFK system is currently looking for inactivity. + overlay: undefined, // The UI overlay warning the user that they are inactive. + warnTimer: undefined, // The timer which waits to show the inactivity warning overlay. + countdown: 0, // The inactivity warning overlay has a countdown to show time until disconnect. + countdownTimer: undefined, // The timer used to tick the seconds shown on the inactivity warning overlay. +} + +// If the user focuses on a UE4 input widget then we show them a button to open +// the on-screen keyboard. JavaScript security means we can only show the +// on-screen keyboard in response to a user interaction. +let editTextButton = undefined; + +// A hidden input text box which is used only for focusing and opening the +// on-screen keyboard. +let hiddenInput = undefined; + +let t0 = Date.now(); + +function log(str) { + console.log(`${Math.floor(Date.now() - t0)}: ` + str); +} + +function scanGamepads() { + let gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []); + for (let i = 0; i < gamepads.length; i++) { + if (gamepads[i] && (gamepads[i].index in controllers)) { + controllers[gamepads[i].index].currentState = gamepads[i]; + } + } +} + + +function updateStatus() { + scanGamepads(); + // Iterate over multiple controllers in the case the mutiple gamepads are connected + for (j in controllers) { + let controller = controllers[j]; + let currentState = controller.currentState; + let prevState = controller.prevState; + // Iterate over buttons + for (let i = 0; i < currentState.buttons.length; i++) { + let currButton = currentState.buttons[i]; + let prevButton = prevState.buttons[i]; + // Button 6 is actually the left trigger, send it to UE as an analog axis + // Button 7 is actually the right trigger, send it to UE as an analog axis + // The rest are normal buttons. Treat as such + if (currButton.pressed && !prevButton.pressed) { + // New press + if (i == 6) { + emitControllerAxisMove(j, 5, currButton.value); + } else if (i == 7) { + emitControllerAxisMove(j, 6, currButton.value); + } else { + emitControllerButtonPressed(j, i, 0); + } + } else if (!currButton.pressed && prevButton.pressed) { + // release + if (i == 6) { + emitControllerAxisMove(j, 5, 0); + } else if (i == 7) { + emitControllerAxisMove(j, 6, 0); + } else { + emitControllerButtonReleased(j, i); + } + } else if (currButton.pressed && prevButton.pressed) { + // repeat press / hold + if (i == 6) { + emitControllerAxisMove(j, 5, currButton.value); + } else if (i == 7) { + emitControllerAxisMove(j, 6, currButton.value); + } else { + emitControllerButtonPressed(j, i, 1); + } + } + // Last case is button isn't currently pressed and wasn't pressed before. This doesn't need an else block + } + // Iterate over gamepad axes + for (let i = 0; i < currentState.axes.length; i += 2) { + let x = parseFloat(currentState.axes[i].toFixed(4)); + // https://w3c.github.io/gamepad/#remapping Gamepad broweser side standard mapping has positive down, negative up. This is downright disgusting. So we fix it. + let y = -parseFloat(currentState.axes[i + 1].toFixed(4)); + if (i === 0) { + // left stick + // axis 1 = left horizontal + emitControllerAxisMove(j, 1, x); + // axis 2 = left vertical + emitControllerAxisMove(j, 2, y); + } else if (i === 2) { + // right stick + // axis 3 = right horizontal + emitControllerAxisMove(j, 3, x); + // axis 4 = right vertical + emitControllerAxisMove(j, 4, y); + } + } + controllers[j].prevState = currentState; + } + rAF(updateStatus); +} + +function emitControllerButtonPressed(controllerIndex, buttonIndex, isRepeat) { + Data = new DataView(new ArrayBuffer(4)); + Data.setUint8(0, MessageType.GamepadButtonPressed); + Data.setUint8(1, controllerIndex); + Data.setUint8(2, buttonIndex); + Data.setUint8(3, isRepeat); +} + +function emitControllerButtonReleased(controllerIndex, buttonIndex) { + Data = new DataView(new ArrayBuffer(3)); + Data.setUint8(0, MessageType.GamepadButtonReleased); + Data.setUint8(1, controllerIndex); + Data.setUint8(2, buttonIndex); +} + +function emitControllerAxisMove(controllerIndex, axisIndex, analogValue) { + Data = new DataView(new ArrayBuffer(11)); + Data.setUint8(0, MessageType.GamepadAnalog); + Data.setUint8(1, controllerIndex); + Data.setUint8(2, axisIndex); + Data.setFloat64(3, analogValue, true); + sendInputData(Data.buffer); +} + +function gamepadConnectHandler(e) { + console.log("Gamepad connect handler"); + gamepad = e.gamepad; + controllers[gamepad.index] = {}; + controllers[gamepad.index].currentState = gamepad; + controllers[gamepad.index].prevState = gamepad; + console.log("gamepad: " + gamepad.id + " connected"); + rAF(updateStatus); +} + +function gamepadDisconnectHandler(e) { + console.log("Gamepad disconnect handler"); + console.log("gamepad: " + e.gamepad.id + " disconnected"); + delete controllers[e.gamepad.index]; +} + +function setupHtmlEvents() { + //Window events + window.addEventListener('resize', resizePlayerStyle, true); + window.addEventListener('orientationchange', onOrientationChange); + + //Gamepad events + if (haveEvents) { + window.addEventListener("gamepadconnected", gamepadConnectHandler); + window.addEventListener("gamepaddisconnected", gamepadDisconnectHandler); + } else if (haveWebkitEvents) { + window.addEventListener("webkitgamepadconnected", gamepadConnectHandler); + window.addEventListener("webkitgamepaddisconnected", gamepadDisconnectHandler); + } + + //HTML elements controls + let overlayButton = document.getElementById('overlayButton'); + overlayButton.addEventListener('click', onExpandOverlay_Click); + + let resizeCheckBox = document.getElementById('enlarge-display-to-fill-window-tgl'); + if (resizeCheckBox !== null) { + resizeCheckBox.onchange = function(event) { + resizePlayerStyle(); + }; + } + + qualityControlOwnershipCheckBox = document.getElementById('quality-control-ownership-tgl'); + if (qualityControlOwnershipCheckBox !== null) { + qualityControlOwnershipCheckBox.onchange = function(event) { + requestQualityControl(); + }; + } + + let encoderParamsSubmit = document.getElementById('encoder-params-submit'); + if (encoderParamsSubmit !== null) { + encoderParamsSubmit.onclick = function(event) { + let rateControl = document.getElementById('encoder-rate-control').value; + let targetBitrate = document.getElementById('encoder-target-bitrate-text').value * 1000; + let maxBitrate = document.getElementById('encoder-max-bitrate-text').value * 1000; + let minQP = document.getElementById('encoder-min-qp-text').value; + let maxQP = document.getElementById('encoder-max-qp-text').value; + let fillerData = document.getElementById('encoder-filler-data-tgl').checked ? 1 : 0; + let multipass = document.getElementById('encoder-multipass').value; + + emitUIInteraction({ Console: 'PixelStreaming.Encoder.RateControl ' + rateControl }); + emitUIInteraction({ Console: 'PixelStreaming.Encoder.TargetBitrate ' + targetBitrate > 0 ? targetBitrate : -1 }); + emitUIInteraction({ Console: 'PixelStreaming.Encoder.MaxBitrateVBR ' + maxBitrate > 0 ? maxBitrate : -1 }); + emitUIInteraction({ Console: 'PixelStreaming.Encoder.MinQP ' + minQP }); + emitUIInteraction({ Console: 'PixelStreaming.Encoder.MaxQP ' + maxQP }); + emitUIInteraction({ Console: 'PixelStreaming.Encoder.EnableFillerData ' + fillerData }); + emitUIInteraction({ Console: 'PixelStreaming.Encoder.Multipass ' + multipass }); + }; + } + + let webrtcParamsSubmit = document.getElementById('webrtc-params-submit'); + if (webrtcParamsSubmit !== null) { + webrtcParamsSubmit.onclick = function(event) { + let degradationPref = document.getElementById('webrtc-degradation-pref').value; + let maxFPS = document.getElementById('webrtc-max-fps-text').value; + let minBitrate = document.getElementById('webrtc-min-bitrate-text').value * 1000; + let maxBitrate = document.getElementById('webrtc-max-bitrate-text').value * 1000; + let lowQP = document.getElementById('webrtc-low-qp-text').value; + let highQP = document.getElementById('webrtc-high-qp-text').value; + + emitUIInteraction({ Console: 'PixelStreaming.WebRTC.DegradationPreference ' + degradationPref }); + emitUIInteraction({ Console: 'PixelStreaming.WebRTC.MaxFps ' + maxFPS }); + emitUIInteraction({ Console: 'PixelStreaming.WebRTC.MinBitrate ' + minBitrate }); + emitUIInteraction({ Console: 'PixelStreaming.WebRTC.MaxBitrate ' + maxBitrate }); + emitUIInteraction({ Console: 'PixelStreaming.WebRTC.LowQpThreshold ' + lowQP }); + emitUIInteraction({ Console: 'PixelStreaming.WebRTC.HighQpThreshold ' + highQP }); + }; + } + + let showFPSButton = document.getElementById('show-fps-button'); + if (showFPSButton !== null) { + showFPSButton.onclick = function (event) { + let consoleDescriptor = { + Console: 'stat fps' + }; + emitUIInteraction(consoleDescriptor); + }; + } + + let matchViewportResolutionCheckBox = document.getElementById('match-viewport-res-tgl'); + if (matchViewportResolutionCheckBox !== null) { + matchViewportResolutionCheckBox.onchange = function (event) { + matchViewportResolution = matchViewportResolutionCheckBox.checked; + }; + } + + let statsCheckBox = document.getElementById('show-stats-tgl'); + if (statsCheckBox !== null) { + statsCheckBox.onchange = function(event) { + let stats = document.getElementById('statsContainer'); + stats.style.display = event.target.checked ? "block" : "none"; + }; + } + + let kickButton = document.getElementById('kick-other-players-button'); + if (kickButton) { + kickButton.onclick = function (event) { + console.log(`-> SS: kick`); + ws.send(JSON.stringify({ + type: 'kick' + })); + }; + } + + let latencyButton = document.getElementById('test-latency-button'); + if (latencyButton) { + latencyButton.onclick = () => { + sendStartLatencyTest(); + }; + } +} + +function sendStartLatencyTest() { + // We need WebRTC to be active to do a latency test. + if (!webRtcPlayerObj) { + return; + } + + let onTestStarted = function(StartTimeMs) { + let descriptor = { + StartTime: StartTimeMs + }; + emitDescriptor(MessageType.LatencyTest, descriptor); + }; + + webRtcPlayerObj.startLatencyTest(onTestStarted); +} + +function setOverlay(htmlClass, htmlElement, onClickFunction) { + let videoPlayOverlay = document.getElementById('videoPlayOverlay'); + if (!videoPlayOverlay) { + let playerDiv = document.getElementById('player'); + videoPlayOverlay = document.createElement('div'); + videoPlayOverlay.id = 'videoPlayOverlay'; + playerDiv.appendChild(videoPlayOverlay); + } + + // Remove existing html child elements so we can add the new one + while (videoPlayOverlay.lastChild) { + videoPlayOverlay.removeChild(videoPlayOverlay.lastChild); + } + + if (htmlElement) + videoPlayOverlay.appendChild(htmlElement); + + if (onClickFunction) { + videoPlayOverlay.addEventListener('click', function onOverlayClick(event) { + onClickFunction(event); + videoPlayOverlay.removeEventListener('click', onOverlayClick); + }); + } + + // Remove existing html classes so we can set the new one + let cl = videoPlayOverlay.classList; + for (let i = cl.length - 1; i >= 0; i--) { + cl.remove(cl[i]); + } + + videoPlayOverlay.classList.add(htmlClass); +} + +function showConnectOverlay() { + let startText = document.createElement('div'); + startText.id = 'playButton'; + startText.innerHTML = 'Click to start'; + + setOverlay('clickableState', startText, event => { + connect(); + startAfkWarningTimer(); + }); +} + +function showTextOverlay(text) { + let textOverlay = document.createElement('div'); + textOverlay.id = 'messageOverlay'; + textOverlay.innerHTML = text ? text : ''; + setOverlay('textDisplayState', textOverlay); +} + +function playVideoStream() { + if (webRtcPlayerObj && webRtcPlayerObj.video) { + + webRtcPlayerObj.video.play().catch(function(onRejectedReason){ + console.error(onRejectedReason); + console.log("Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay.") + showPlayOverlay(); + }); + + requestInitialSettings(); + requestQualityControl(); + showFreezeFrameOverlay(); + hideOverlay(); + } else { + console.error("Could not player video stream because webRtcPlayerObj.video was not valid.") + } +} + +function showPlayOverlay() { + let img = document.createElement('img'); + img.id = 'playButton'; + img.src = '/images/Play.png'; + img.alt = 'Start Streaming'; + setOverlay('clickableState', img, event => { + playVideoStream(); + }); + shouldShowPlayOverlay = false; +} + +function updateAfkOverlayText() { + afk.overlay.innerHTML = '
No activity detected
Disconnecting in ' + afk.countdown + ' seconds
Click to continue
'; +} + +function showAfkOverlay() { + // Pause the timer while the user is looking at the inactivity warning overlay. + stopAfkWarningTimer(); + + // Show the inactivity warning overlay. + afk.overlay = document.createElement('div'); + afk.overlay.id = 'afkOverlay'; + setOverlay('clickableState', afk.overlay, event => { + // The user clicked so start the timer again and carry on. + hideOverlay(); + clearInterval(afk.countdownTimer); + startAfkWarningTimer(); + }); + + afk.countdown = afk.closeTimeout; + updateAfkOverlayText(); + + if (inputOptions.controlScheme == ControlSchemeType.LockedMouse) { + document.exitPointerLock(); + } + + afk.countdownTimer = setInterval(function() { + afk.countdown--; + if (afk.countdown == 0) { + // The user failed to click so disconnect them. + hideOverlay(); + ws.close(); + } else { + // Update the countdown message. + updateAfkOverlayText(); + } + }, 1000); +} + +function hideOverlay() { + setOverlay('hiddenState'); +} + +// Start a timer which when elapsed will warn the user they are inactive. +function startAfkWarningTimer() { + afk.active = afk.enabled; + resetAfkWarningTimer(); +} + +// Stop the timer which when elapsed will warn the user they are inactive. +function stopAfkWarningTimer() { + afk.active = false; +} + +// If the user interacts then reset the warning timer. +function resetAfkWarningTimer() { + if (afk.active) { + clearTimeout(afk.warnTimer); + afk.warnTimer = setTimeout(function () { + showAfkOverlay(); + }, afk.warnTimeout * 1000); + } +} + +function createWebRtcOffer() { + if (webRtcPlayerObj) { + console.log('Creating offer'); + showTextOverlay('Starting connection to server, please wait'); + webRtcPlayerObj.createOffer(); + } else { + console.log('WebRTC player not setup, cannot create offer'); + showTextOverlay('Unable to setup video'); + } +} + +function sendInputData(data) { + if (webRtcPlayerObj) { + resetAfkWarningTimer(); + webRtcPlayerObj.send(data); + } +} + +function addResponseEventListener(name, listener) { + responseEventListeners.set(name, listener); +} + +function removeResponseEventListener(name) { + responseEventListeners.remove(name); +} + +// Must be kept in sync with PixelStreamingProtocol::EToPlayerMsg C++ enum. +const ToClientMessageType = { + QualityControlOwnership: 0, + Response: 1, + Command: 2, + FreezeFrame: 3, + UnfreezeFrame: 4, + VideoEncoderAvgQP: 5, + LatencyTest: 6, + InitialSettings: 7 +}; + +let VideoEncoderQP = "N/A"; + +function setupWebRtcPlayer(htmlElement, config) { + webRtcPlayerObj = new webRtcPlayer(config); + htmlElement.appendChild(webRtcPlayerObj.video); + htmlElement.appendChild(freezeFrameOverlay); + + webRtcPlayerObj.onWebRtcOffer = function(offer) { + if (ws && ws.readyState === WS_OPEN_STATE) { + let offerStr = JSON.stringify(offer); + console.log(`-> SS: offer:\n${offerStr}`); + ws.send(offerStr); + } + }; + + webRtcPlayerObj.onWebRtcCandidate = function(candidate) { + if (ws && ws.readyState === WS_OPEN_STATE) { + console.log(`-> SS: iceCandidate\n${JSON.stringify(candidate, undefined, 4)}`); + ws.send(JSON.stringify({ + type: 'iceCandidate', + candidate: candidate + })); + } + }; + + webRtcPlayerObj.onVideoInitialised = function() { + if (ws && ws.readyState === WS_OPEN_STATE) { + if (shouldShowPlayOverlay) { + showPlayOverlay(); + resizePlayerStyle(); + } + else { + resizePlayerStyle(); + playVideoStream(); + } + } + }; + + webRtcPlayerObj.onDataChannelConnected = function() { + if (ws && ws.readyState === WS_OPEN_STATE) { + showTextOverlay('WebRTC connected, waiting for video'); + + if (webRtcPlayerObj.video && webRtcPlayerObj.video.srcObject && webRtcPlayerObj.onVideoInitialised) { + webRtcPlayerObj.onVideoInitialised(); + } + } + }; + + function showFreezeFrame() { + let base64 = btoa(freezeFrame.jpeg.reduce((data, byte) => data + String.fromCharCode(byte), '')); + let freezeFrameImage = document.getElementById("freezeFrameOverlay").childNodes[0]; + freezeFrameImage.src = 'data:image/jpeg;base64,' + base64; + freezeFrameImage.onload = function() { + freezeFrame.height = freezeFrameImage.naturalHeight; + freezeFrame.width = freezeFrameImage.naturalWidth; + resizeFreezeFrameOverlay(); + if (shouldShowPlayOverlay) { + showPlayOverlay(); + resizePlayerStyle(); + } else { + showFreezeFrameOverlay(); + } + webRtcPlayerObj.setVideoEnabled(false); + }; + } + + function processFreezeFrameMessage(view) { + // Reset freeze frame if we got a freeze frame message and we are not "receiving" yet. + if (!freezeFrame.receiving) { + freezeFrame.receiving = true; + freezeFrame.valid = false; + freezeFrame.size = 0; + freezeFrame.jpeg = undefined; + } + + // Extract total size of freeze frame (across all chunks) + freezeFrame.size = (new DataView(view.slice(1, 5).buffer)).getInt32(0, true); + + // Get the jpeg part of the payload + let jpegBytes = view.slice(1 + 4); + + // Append to existing jpeg that holds the freeze frame + if (freezeFrame.jpeg) { + let jpeg = new Uint8Array(freezeFrame.jpeg.length + jpegBytes.length); + jpeg.set(freezeFrame.jpeg, 0); + jpeg.set(jpegBytes, freezeFrame.jpeg.length); + freezeFrame.jpeg = jpeg; + } + // No existing freeze frame jpeg, make one + else { + freezeFrame.jpeg = jpegBytes; + freezeFrame.receiving = true; + console.log(`received first chunk of freeze frame: ${freezeFrame.jpeg.length}/${freezeFrame.size}`); + } + + // Uncomment for debug + //console.log(`Received freeze frame chunk: ${freezeFrame.jpeg.length}/${freezeFrame.size}`); + + // Finished receiving freeze frame, we can show it now + if (freezeFrame.jpeg.length === freezeFrame.size) { + freezeFrame.receiving = false; + freezeFrame.valid = true; + console.log(`received complete freeze frame ${freezeFrame.size}`); + showFreezeFrame(); + } + // We received more data than the freeze frame payload message indicate (this is an error) + else if (freezeFrame.jpeg.length > freezeFrame.size) { + console.error(`received bigger freeze frame than advertised: ${freezeFrame.jpeg.length}/${freezeFrame.size}`); + freezeFrame.jpeg = undefined; + freezeFrame.receiving = false; + } + } + + webRtcPlayerObj.onDataChannelMessage = function(data) { + let view = new Uint8Array(data); + + if (view[0] === ToClientMessageType.QualityControlOwnership) { + let ownership = view[1] === 0 ? false : true; + console.log("Received quality controller message, will control quality: " + ownership); + // If we own the quality control, we can't relenquish it. We only loose + // quality control when another peer asks for it + if (qualityControlOwnershipCheckBox !== null) { + qualityControlOwnershipCheckBox.disabled = ownership; + qualityControlOwnershipCheckBox.checked = ownership; + } + } else if (view[0] === ToClientMessageType.Response) { + let response = new TextDecoder("utf-16").decode(data.slice(1)); + for (let listener of responseEventListeners.values()) { + listener(response); + } + } else if (view[0] === ToClientMessageType.Command) { + let commandAsString = new TextDecoder("utf-16").decode(data.slice(1)); + console.log(commandAsString); + let command = JSON.parse(commandAsString); + if (command.command === 'onScreenKeyboard') { + showOnScreenKeyboard(command); + } + } else if (view[0] === ToClientMessageType.FreezeFrame) { + processFreezeFrameMessage(view); + } else if (view[0] === ToClientMessageType.UnfreezeFrame) { + invalidateFreezeFrameOverlay(); + } else if (view[0] === ToClientMessageType.VideoEncoderAvgQP) { + VideoEncoderQP = new TextDecoder("utf-16").decode(data.slice(1)); + //console.log(`received VideoEncoderAvgQP ${VideoEncoderQP}`); + } else if (view[0] == ToClientMessageType.LatencyTest) { + let latencyTimingsAsString = new TextDecoder("utf-16").decode(data.slice(1)); + console.log("Got latency timings from UE.") + console.log(latencyTimingsAsString); + let latencyTimingsFromUE = JSON.parse(latencyTimingsAsString); + if (webRtcPlayerObj) { + webRtcPlayerObj.latencyTestTimings.SetUETimings(latencyTimingsFromUE); + } + } else if (view[0] == ToClientMessageType.InitialSettings) { + let settingsString = new TextDecoder("utf-16").decode(data.slice(1)); + let settingsJSON = JSON.parse(settingsString); + + // reminder bitrates are sent in bps but displayed in kbps + + if (settingsJSON.Encoder) { + document.getElementById('encoder-rate-control').value = settingsJSON.Encoder.RateControl; + document.getElementById('encoder-target-bitrate-text').value = settingsJSON.Encoder.TargetBitrate > 0 ? settingsJSON.Encoder.TargetBitrate / 1000 : settingsJSON.Encoder.TargetBitrate; + document.getElementById('encoder-max-bitrate-text').value = settingsJSON.Encoder.MaxBitrate > 0 ? settingsJSON.Encoder.MaxBitrate / 1000 : settingsJSON.Encoder.MaxBitrate; + document.getElementById('encoder-min-qp-text').value = settingsJSON.Encoder.MinQP; + document.getElementById('encoder-max-qp-text').value = settingsJSON.Encoder.MaxQP; + document.getElementById('encoder-filler-data-tgl').checked = settingsJSON.Encoder.FillerData == 1; + document.getElementById('encoder-multipass').value = settingsJSON.Encoder.MultiPass; + } + if (settingsJSON.WebRTC) { + document.getElementById('webrtc-degradation-pref').value = settingsJSON.WebRTC.DegradationPref; + document.getElementById("webrtc-max-fps-text").value = settingsJSON.WebRTC.MaxFPS; + document.getElementById("webrtc-min-bitrate-text").value = settingsJSON.WebRTC.MinBitrate / 1000; + document.getElementById("webrtc-max-bitrate-text").value = settingsJSON.WebRTC.MaxBitrate / 1000; + document.getElementById("webrtc-low-qp-text").value = settingsJSON.WebRTC.LowQP; + document.getElementById("webrtc-high-qp-text").value = settingsJSON.WebRTC.HighQP; + } + } else { + console.error(`unrecognized data received, packet ID ${view[0]}`); + } + }; + + registerInputs(webRtcPlayerObj.video); + + // On a touch device we will need special ways to show the on-screen keyboard. + if ('ontouchstart' in document.documentElement) { + createOnScreenKeyboardHelpers(htmlElement); + } + + createWebRtcOffer(); + + return webRtcPlayerObj.video; +} + +function onWebRtcAnswer(webRTCData) { + webRtcPlayerObj.receiveAnswer(webRTCData); + + let printInterval = 5 * 60 * 1000; /*Print every 5 minutes*/ + let nextPrintDuration = printInterval; + + webRtcPlayerObj.onAggregatedStats = (aggregatedStats) => { + let numberFormat = new Intl.NumberFormat(window.navigator.language, { + maximumFractionDigits: 0 + }); + let timeFormat = new Intl.NumberFormat(window.navigator.language, { + maximumFractionDigits: 0, + minimumIntegerDigits: 2 + }); + + // Calculate duration of run + let runTime = (aggregatedStats.timestamp - aggregatedStats.timestampStart) / 1000; + let timeValues = []; + let timeDurations = [60, 60]; + for (let timeIndex = 0; timeIndex < timeDurations.length; timeIndex++) { + timeValues.push(runTime % timeDurations[timeIndex]); + runTime = runTime / timeDurations[timeIndex]; + } + timeValues.push(runTime); + + let runTimeSeconds = timeValues[0]; + let runTimeMinutes = Math.floor(timeValues[1]); + let runTimeHours = Math.floor([timeValues[2]]); + + receivedBytesMeasurement = 'B'; + receivedBytes = aggregatedStats.hasOwnProperty('bytesReceived') ? aggregatedStats.bytesReceived : 0; + let dataMeasurements = ['kB', 'MB', 'GB']; + for (let index = 0; index < dataMeasurements.length; index++) { + if (receivedBytes < 100 * 1000) + break; + receivedBytes = receivedBytes / 1000; + receivedBytesMeasurement = dataMeasurements[index]; + } + + let qualityStatus = document.getElementById("qualityStatus"); + + // "blinks" quality status element for 1 sec by making it transparent, speed = number of blinks + let blinkQualityStatus = function(speed) { + let iter = speed; + let opacity = 1; // [0..1] + let tickId = setInterval( + function() { + opacity -= 0.1; + // map `opacity` to [-0.5..0.5] range, decrement by 0.2 per step and take `abs` to make it blink: 1 -> 0 -> 1 + qualityStatus.style = `opacity: ${Math.abs((opacity - 0.5) * 2)}`; + if (opacity <= 0.1) { + if (--iter == 0) { + clearInterval(tickId); + } else { // next blink + opacity = 1; + } + } + }, + 100 / speed // msecs + ); + }; + + const orangeQP = 26; + const redQP = 35; + + let statsText = ''; + + let color = "lime"; + if (VideoEncoderQP > redQP) { + color = "red"; + blinkQualityStatus(2); + statsText += `
Bad network connection
`; + } else if (VideoEncoderQP > orangeQP) { + color = "orange"; + blinkQualityStatus(1); + statsText += `
Spotty network connection
`; + } + + qualityStatus.className = `${color}Status`; + + statsText += `
Duration: ${timeFormat.format(runTimeHours)}:${timeFormat.format(runTimeMinutes)}:${timeFormat.format(runTimeSeconds)}
`; + statsText += `
Video Resolution: ${ + aggregatedStats.hasOwnProperty('frameWidth') && aggregatedStats.frameWidth && aggregatedStats.hasOwnProperty('frameHeight') && aggregatedStats.frameHeight ? + aggregatedStats.frameWidth + 'x' + aggregatedStats.frameHeight : 'Chrome only' + }
`; + statsText += `
Received (${receivedBytesMeasurement}): ${numberFormat.format(receivedBytes)}
`; + statsText += `
Frames Decoded: ${aggregatedStats.hasOwnProperty('framesDecoded') ? numberFormat.format(aggregatedStats.framesDecoded) : 'Chrome only'}
`; + statsText += `
Packets Lost: ${aggregatedStats.hasOwnProperty('packetsLost') ? numberFormat.format(aggregatedStats.packetsLost) : 'Chrome only'}
`; + statsText += `
Bitrate (kbps): ${aggregatedStats.hasOwnProperty('bitrate') ? numberFormat.format(aggregatedStats.bitrate) : 'Chrome only'}
`; + statsText += `
Framerate: ${aggregatedStats.hasOwnProperty('framerate') ? numberFormat.format(aggregatedStats.framerate) : 'Chrome only'}
`; + statsText += `
Frames dropped: ${aggregatedStats.hasOwnProperty('framesDropped') ? numberFormat.format(aggregatedStats.framesDropped) : 'Chrome only'}
`; + statsText += `
Net RTT (ms): ${aggregatedStats.hasOwnProperty('currentRoundTripTime') ? numberFormat.format(aggregatedStats.currentRoundTripTime * 1000) : 'Can\'t calculate'}
`; + statsText += `
Browser receive to composite (ms): ${aggregatedStats.hasOwnProperty('receiveToCompositeMs') ? numberFormat.format(aggregatedStats.receiveToCompositeMs) : 'Chrome only'}
`; + statsText += `
Video Quantization Parameter: ${VideoEncoderQP}
`; + + let statsDiv = document.getElementById("stats"); + statsDiv.innerHTML = statsText; + + if (print_stats) { + if (aggregatedStats.timestampStart) { + if ((aggregatedStats.timestamp - aggregatedStats.timestampStart) > nextPrintDuration) { + if (ws && ws.readyState === WS_OPEN_STATE) { + console.log(`-> SS: stats\n${JSON.stringify(aggregatedStats)}`); + ws.send(JSON.stringify({ + type: 'stats', + data: aggregatedStats + })); + } + nextPrintDuration += printInterval; + } + } + } + }; + + webRtcPlayerObj.aggregateStats(1 * 1000 /*Check every 1 second*/ ); + + webRtcPlayerObj.latencyTestTimings.OnAllLatencyTimingsReady = function(timings) { + + if (!timings.BrowserReceiptTimeMs) { + return; + } + + let latencyExcludingDecode = timings.BrowserReceiptTimeMs - timings.TestStartTimeMs; + let uePixelStreamLatency = timings.UEPreEncodeTimeMs == 0 || timings.UEPreCaptureTimeMs == 0 ? "???" : timings.UEPostEncodeTimeMs - timings.UEPreCaptureTimeMs; + let captureLatency = timings.UEPostCaptureTimeMs - timings.UEPreCaptureTimeMs; + let encodeLatency = timings.UEPostEncodeTimeMs - timings.UEPreEncodeTimeMs; + let ueLatency = timings.UETransmissionTimeMs - timings.UEReceiptTimeMs; + let networkLatency = latencyExcludingDecode - ueLatency; + let browserSendLatency = latencyExcludingDecode - networkLatency - ueLatency; + + //these ones depend on FrameDisplayDeltaTimeMs + let endToEndLatency = null; + let browserSideLatency = null; + + if (timings.FrameDisplayDeltaTimeMs && timings.BrowserReceiptTimeMs) { + endToEndLatency = timings.FrameDisplayDeltaTimeMs + latencyExcludingDecode; + browserSideLatency = endToEndLatency - networkLatency - ueLatency; + } + + let latencyStatsInnerHTML = ''; + latencyStatsInnerHTML += `
Net latency RTT (ms): ${networkLatency}
`; + latencyStatsInnerHTML += `
UE Capture+Encode (ms): ${uePixelStreamLatency}
`; + latencyStatsInnerHTML += `
UE Capture (ms): ${captureLatency}
`; + latencyStatsInnerHTML += `
UE Encode (ms): ${encodeLatency}
`; + latencyStatsInnerHTML += `
Total UE latency (ms): ${ueLatency}
`; + latencyStatsInnerHTML += `
Browser send latency (ms): ${browserSendLatency}
` + latencyStatsInnerHTML += timings.FrameDisplayDeltaTimeMs && timings.BrowserReceiptTimeMs ? `
Browser receive latency (ms): ${timings.FrameDisplayDeltaTimeMs}
` : ""; + latencyStatsInnerHTML += browserSideLatency ? `
Total browser latency (ms): ${browserSideLatency}
` : ""; + latencyStatsInnerHTML += `
Total latency (excluding browser) (ms): ${latencyExcludingDecode}
`; + latencyStatsInnerHTML += endToEndLatency ? `
Total latency (ms): ${endToEndLatency}
` : ""; + document.getElementById("LatencyStats").innerHTML = latencyStatsInnerHTML; + } +} + +function onWebRtcIce(iceCandidate) { + if (webRtcPlayerObj) + webRtcPlayerObj.handleCandidateFromServer(iceCandidate); +} + +let styleWidth; +let styleHeight; +let styleTop; +let styleLeft; +let styleCursor = 'default'; +let styleAdditional; + +const ControlSchemeType = { + // A mouse can lock inside the WebRTC player so the user can simply move the + // mouse to control the orientation of the camera. The user presses the + // Escape key to unlock the mouse. + LockedMouse: 0, + + // A mouse can hover over the WebRTC player so the user needs to click and + // drag to control the orientation of the camera. + HoveringMouse: 1 +}; + +let inputOptions = { + // The control scheme controls the behaviour of the mouse when it interacts + // with the WebRTC player. + controlScheme: ControlSchemeType.LockedMouse, + + // Browser keys are those which are typically used by the browser UI. We + // usually want to suppress these to allow, for example, UE4 to show shader + // complexity with the F5 key without the web page refreshing. + suppressBrowserKeys: true, + + // UE4 has a faketouches option which fakes a single finger touch when the + // user drags with their mouse. We may perform the reverse; a single finger + // touch may be converted into a mouse drag UE4 side. This allows a + // non-touch application to be controlled partially via a touch device. + fakeMouseWithTouches: false +}; + +function resizePlayerStyleToFillWindow(playerElement) { + let videoElement = playerElement.getElementsByTagName("VIDEO"); + + // Fill the player display in window, keeping picture's aspect ratio. + let windowAspectRatio = window.innerHeight / window.innerWidth; + let playerAspectRatio = playerElement.clientHeight / playerElement.clientWidth; + // We want to keep the video ratio correct for the video stream + let videoAspectRatio = videoElement.videoHeight / videoElement.videoWidth; + if (isNaN(videoAspectRatio)) { + //Video is not initialised yet so set playerElement to size of window + styleWidth = window.innerWidth; + styleHeight = window.innerHeight; + styleTop = 0; + styleLeft = 0; + playerElement.style = "top: " + styleTop + "px; left: " + styleLeft + "px; width: " + styleWidth + "px; height: " + styleHeight + "px; cursor: " + styleCursor + "; " + styleAdditional; + } else if (windowAspectRatio < playerAspectRatio) { + // Window height is the constraining factor so to keep aspect ratio change width appropriately + styleWidth = Math.floor(window.innerHeight / videoAspectRatio); + styleHeight = window.innerHeight; + styleTop = 0; + styleLeft = Math.floor((window.innerWidth - styleWidth) * 0.5); + //Video is now 100% of the playerElement, so set the playerElement style + playerElement.style = "top: " + styleTop + "px; left: " + styleLeft + "px; width: " + styleWidth + "px; height: " + styleHeight + "px; cursor: " + styleCursor + "; " + styleAdditional; + } else { + // Window width is the constraining factor so to keep aspect ratio change height appropriately + styleWidth = window.innerWidth; + styleHeight = Math.floor(window.innerWidth * videoAspectRatio); + styleTop = Math.floor((window.innerHeight - styleHeight) * 0.5); + styleLeft = 0; + //Video is now 100% of the playerElement, so set the playerElement style + playerElement.style = "top: " + styleTop + "px; left: " + styleLeft + "px; width: " + styleWidth + "px; height: " + styleHeight + "px; cursor: " + styleCursor + "; " + styleAdditional; + } +} + +function resizePlayerStyleToActualSize(playerElement) { + let videoElement = playerElement.getElementsByTagName("VIDEO"); + + if (videoElement.length > 0) { + // Display image in its actual size + styleWidth = videoElement[0].videoWidth; + styleHeight = videoElement[0].videoHeight; + let Top = Math.floor((window.innerHeight - styleHeight) * 0.5); + let Left = Math.floor((window.innerWidth - styleWidth) * 0.5); + styleTop = (Top > 0) ? Top : 0; + styleLeft = (Left > 0) ? Left : 0; + //Video is now 100% of the playerElement, so set the playerElement style + playerElement.style = "top: " + styleTop + "px; left: " + styleLeft + "px; width: " + styleWidth + "px; height: " + styleHeight + "px; cursor: " + styleCursor + "; " + styleAdditional; + } +} + +function resizePlayerStyleToArbitrarySize(playerElement) { + let videoElement = playerElement.getElementsByTagName("VIDEO"); + //Video is now 100% of the playerElement, so set the playerElement style + playerElement.style = "top: 0px; left: 0px; width: " + styleWidth + "px; height: " + styleHeight + "px; cursor: " + styleCursor + "; " + styleAdditional; +} + +function setupFreezeFrameOverlay() { + freezeFrameOverlay = document.createElement('div'); + freezeFrameOverlay.id = 'freezeFrameOverlay'; + freezeFrameOverlay.style.display = 'none'; + freezeFrameOverlay.style.pointerEvents = 'none'; + freezeFrameOverlay.style.position = 'absolute'; + freezeFrameOverlay.style.zIndex = '20'; + + let freezeFrameImage = document.createElement('img'); + freezeFrameImage.style.position = 'absolute'; + freezeFrameOverlay.appendChild(freezeFrameImage); +} + +function showFreezeFrameOverlay() { + if (freezeFrame.valid) { + freezeFrameOverlay.classList.add("freezeframeBackground"); + freezeFrameOverlay.style.display = 'block'; + } +} + +function invalidateFreezeFrameOverlay() { + freezeFrameOverlay.style.display = 'none'; + freezeFrame.valid = false; + freezeFrameOverlay.classList.remove("freezeframeBackground"); + + if (webRtcPlayerObj) { + webRtcPlayerObj.setVideoEnabled(true); + } +} + +function resizeFreezeFrameOverlay() { + if (freezeFrame.width !== 0 && freezeFrame.height !== 0) { + let displayWidth = 0; + let displayHeight = 0; + let displayTop = 0; + let displayLeft = 0; + let checkBox = document.getElementById('enlarge-display-to-fill-window-tgl'); + let playerElement = document.getElementById('player'); + if (checkBox !== null && checkBox.checked) { + // We are fitting video to screen, we care about the screen (window) size + let windowAspectRatio = window.innerWidth / window.innerHeight; + let videoAspectRatio = freezeFrame.width / freezeFrame.height; + if (windowAspectRatio < videoAspectRatio) { + displayWidth = window.innerWidth; + displayHeight = Math.floor(window.innerWidth / videoAspectRatio); + displayTop = Math.floor((window.innerHeight - displayHeight) * 0.5); + displayLeft = 0; + } else { + displayWidth = Math.floor(window.innerHeight * videoAspectRatio); + displayHeight = window.innerHeight; + displayTop = 0; + displayLeft = Math.floor((window.innerWidth - displayWidth) * 0.5); + } + } else { + // Video is coming in at native resolution, we care more about the player size + let playerAspectRatio = playerElement.offsetWidth / playerElement.offsetHeight; + let videoAspectRatio = freezeFrame.width / freezeFrame.height; + if (playerAspectRatio < videoAspectRatio) { + displayWidth = playerElement.offsetWidth; + displayHeight = Math.floor(playerElement.offsetWidth / videoAspectRatio); + displayTop = Math.floor((playerElement.offsetHeight - displayHeight) * 0.5); + displayLeft = 0; + } else { + displayWidth = Math.floor(playerElement.offsetHeight * videoAspectRatio); + displayHeight = playerElement.offsetHeight; + displayTop = 0; + displayLeft = Math.floor((playerElement.offsetWidth - displayWidth) * 0.5); + } + } + let freezeFrameImage = document.getElementById("freezeFrameOverlay").childNodes[0]; + freezeFrameOverlay.style.width = playerElement.offsetWidth + 'px'; + freezeFrameOverlay.style.height = playerElement.offsetHeight + 'px'; + freezeFrameOverlay.style.left = 0 + 'px'; + freezeFrameOverlay.style.top = 0 + 'px'; + + freezeFrameImage.style.width = displayWidth + 'px'; + freezeFrameImage.style.height = displayHeight + 'px'; + freezeFrameImage.style.left = displayLeft + 'px'; + freezeFrameImage.style.top = displayTop + 'px'; + } +} + +function resizePlayerStyle(event) { + let playerElement = document.getElementById('player'); + + if (!playerElement) + return; + + updateVideoStreamSize(); + + if (playerElement.classList.contains('fixed-size')) { + setupMouseAndFreezeFrame(playerElement) + return; + } + + + let checkBox = document.getElementById('enlarge-display-to-fill-window-tgl'); + let windowSmallerThanPlayer = window.innerWidth < playerElement.videoWidth || window.innerHeight < playerElement.videoHeight; + if (checkBox !== null) { + if (checkBox.checked || windowSmallerThanPlayer) { + resizePlayerStyleToFillWindow(playerElement); + } else { + resizePlayerStyleToActualSize(playerElement); + } + } else { + resizePlayerStyleToArbitrarySize(playerElement); + } + + setupMouseAndFreezeFrame(playerElement) +} + +function setupMouseAndFreezeFrame(playerElement) { + // Calculating and normalizing positions depends on the width and height of + // the player. + playerElementClientRect = playerElement.getBoundingClientRect(); + setupNormalizeAndQuantize(); + resizeFreezeFrameOverlay(); +} + +function updateVideoStreamSize() { + if (!matchViewportResolution) { + return; + } + + let now = new Date().getTime(); + if (now - lastTimeResized > 1000) { + let playerElement = document.getElementById('player'); + if (!playerElement) + return; + + let descriptor = { + Console: 'setres ' + playerElement.clientWidth + 'x' + playerElement.clientHeight + }; + emitUIInteraction(descriptor); + console.log(descriptor); + lastTimeResized = new Date().getTime(); + } else { + console.log('Resizing too often - skipping'); + clearTimeout(resizeTimeout); + resizeTimeout = setTimeout(updateVideoStreamSize, 1000); + } +} + +// Fix for bug in iOS where windowsize is not correct at instance or orientation change +// https://github.com/dimsemenov/PhotoSwipe/issues/1315 +let _orientationChangeTimeout; + +function onOrientationChange(event) { + clearTimeout(_orientationChangeTimeout); + _orientationChangeTimeout = setTimeout(function() { + resizePlayerStyle(); + }, 500); +} + +// Must be kept in sync with PixelStreamingProtocol::EToUE4Msg C++ enum. +const MessageType = { + + /**********************************************************************/ + + /* + * Control Messages. Range = 0..49. + */ + IFrameRequest: 0, + RequestQualityControl: 1, + MaxFpsRequest: 2, + AverageBitrateRequest: 3, + StartStreaming: 4, + StopStreaming: 5, + LatencyTest: 6, + RequestInitialSettings: 7, + + /**********************************************************************/ + + /* + * Input Messages. Range = 50..89. + */ + + // Generic Input Messages. Range = 50..59. + UIInteraction: 50, + Command: 51, + + // Keyboard Input Message. Range = 60..69. + KeyDown: 60, + KeyUp: 61, + KeyPress: 62, + + // Mouse Input Messages. Range = 70..79. + MouseEnter: 70, + MouseLeave: 71, + MouseDown: 72, + MouseUp: 73, + MouseMove: 74, + MouseWheel: 75, + + // Touch Input Messages. Range = 80..89. + TouchStart: 80, + TouchEnd: 81, + TouchMove: 82, + + // Gamepad Input Messages. Range = 90..99 + GamepadButtonPressed: 90, + GamepadButtonReleased: 91, + GamepadAnalog: 92 + + /**************************************************************************/ +}; + +// A generic message has a type and a descriptor. +function emitDescriptor(messageType, descriptor) { + // Convert the dscriptor object into a JSON string. + let descriptorAsString = JSON.stringify(descriptor); + + // Add the UTF-16 JSON string to the array byte buffer, going two bytes at + // a time. + let data = new DataView(new ArrayBuffer(1 + 2 + 2 * descriptorAsString.length)); + let byteIdx = 0; + data.setUint8(byteIdx, messageType); + byteIdx++; + data.setUint16(byteIdx, descriptorAsString.length, true); + byteIdx += 2; + for (i = 0; i < descriptorAsString.length; i++) { + data.setUint16(byteIdx, descriptorAsString.charCodeAt(i), true); + byteIdx += 2; + } + sendInputData(data.buffer); +} + +// A UI interation will occur when the user presses a button powered by +// JavaScript as opposed to pressing a button which is part of the pixel +// streamed UI from the UE4 client. +function emitUIInteraction(descriptor) { + emitDescriptor(MessageType.UIInteraction, descriptor); +} + +// A build-in command can be sent to UE4 client. The commands are defined by a +// JSON descriptor and will be executed automatically. +// The currently supported commands are: +// +// 1. A command to run any console command: +// "{ ConsoleCommand: }" +// +// 2. A command to change the resolution to the given width and height. +// "{ Resolution.Width: , Resolution.Height: } }" +// +function emitCommand(descriptor) { + emitDescriptor(MessageType.Command, descriptor); +} + +function requestInitialSettings() { + sendInputData(new Uint8Array([MessageType.RequestInitialSettings]).buffer); +} + +function requestQualityControl() { + sendInputData(new Uint8Array([MessageType.RequestQualityControl]).buffer); +} + +let playerElementClientRect = undefined; +let normalizeAndQuantizeUnsigned = undefined; +let normalizeAndQuantizeSigned = undefined; + +function setupNormalizeAndQuantize() { + let playerElement = document.getElementById('player'); + let videoElement = playerElement.getElementsByTagName("video"); + + if (playerElement && videoElement.length > 0) { + let playerAspectRatio = playerElement.clientHeight / playerElement.clientWidth; + let videoAspectRatio = videoElement[0].videoHeight / videoElement[0].videoWidth; + + // Unsigned XY positions are the ratio (0.0..1.0) along a viewport axis, + // quantized into an uint16 (0..65536). + // Signed XY deltas are the ratio (-1.0..1.0) along a viewport axis, + // quantized into an int16 (-32767..32767). + // This allows the browser viewport and client viewport to have a different + // size. + // Hack: Currently we set an out-of-range position to an extreme (65535) + // as we can't yet accurately detect mouse enter and leave events + // precisely inside a video with an aspect ratio which causes mattes. + if (playerAspectRatio > videoAspectRatio) { + if (print_inputs) { + console.log('Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio'); + } + let ratio = playerAspectRatio / videoAspectRatio; + // Unsigned. + normalizeAndQuantizeUnsigned = (x, y) => { + let normalizedX = x / playerElement.clientWidth; + let normalizedY = ratio * (y / playerElement.clientHeight - 0.5) + 0.5; + if (normalizedX < 0.0 || normalizedX > 1.0 || normalizedY < 0.0 || normalizedY > 1.0) { + return { + inRange: false, + x: 65535, + y: 65535 + }; + } else { + return { + inRange: true, + x: normalizedX * 65536, + y: normalizedY * 65536 + }; + } + }; + unquantizeAndDenormalizeUnsigned = (x, y) => { + let normalizedX = x / 65536; + let normalizedY = (y / 65536 - 0.5) / ratio + 0.5; + return { + x: normalizedX * playerElement.clientWidth, + y: normalizedY * playerElement.clientHeight + }; + }; + // Signed. + normalizeAndQuantizeSigned = (x, y) => { + let normalizedX = x / (0.5 * playerElement.clientWidth); + let normalizedY = (ratio * y) / (0.5 * playerElement.clientHeight); + return { + x: normalizedX * 32767, + y: normalizedY * 32767 + }; + }; + } else { + if (print_inputs) { + console.log('Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio'); + } + let ratio = videoAspectRatio / playerAspectRatio; + // Unsigned. + normalizeAndQuantizeUnsigned = (x, y) => { + let normalizedX = ratio * (x / playerElement.clientWidth - 0.5) + 0.5; + let normalizedY = y / playerElement.clientHeight; + if (normalizedX < 0.0 || normalizedX > 1.0 || normalizedY < 0.0 || normalizedY > 1.0) { + return { + inRange: false, + x: 65535, + y: 65535 + }; + } else { + return { + inRange: true, + x: normalizedX * 65536, + y: normalizedY * 65536 + }; + } + }; + unquantizeAndDenormalizeUnsigned = (x, y) => { + let normalizedX = (x / 65536 - 0.5) / ratio + 0.5; + let normalizedY = y / 65536; + return { + x: normalizedX * playerElement.clientWidth, + y: normalizedY * playerElement.clientHeight + }; + }; + // Signed. + normalizeAndQuantizeSigned = (x, y) => { + let normalizedX = (ratio * x) / (0.5 * playerElement.clientWidth); + let normalizedY = y / (0.5 * playerElement.clientHeight); + return { + x: normalizedX * 32767, + y: normalizedY * 32767 + }; + }; + } + } +} + +function emitMouseMove(x, y, deltaX, deltaY) { + if (print_inputs) { + console.log(`x: ${x}, y:${y}, dX: ${deltaX}, dY: ${deltaY}`); + } + let coord = normalizeAndQuantizeUnsigned(x, y); + let delta = normalizeAndQuantizeSigned(deltaX, deltaY); + let Data = new DataView(new ArrayBuffer(9)); + Data.setUint8(0, MessageType.MouseMove); + Data.setUint16(1, coord.x, true); + Data.setUint16(3, coord.y, true); + Data.setInt16(5, delta.x, true); + Data.setInt16(7, delta.y, true); + sendInputData(Data.buffer); +} + +function emitMouseDown(button, x, y) { + if (print_inputs) { + console.log(`mouse button ${button} down at (${x}, ${y})`); + } + let coord = normalizeAndQuantizeUnsigned(x, y); + let Data = new DataView(new ArrayBuffer(6)); + Data.setUint8(0, MessageType.MouseDown); + Data.setUint8(1, button); + Data.setUint16(2, coord.x, true); + Data.setUint16(4, coord.y, true); + sendInputData(Data.buffer); +} + +function emitMouseUp(button, x, y) { + if (print_inputs) { + console.log(`mouse button ${button} up at (${x}, ${y})`); + } + let coord = normalizeAndQuantizeUnsigned(x, y); + let Data = new DataView(new ArrayBuffer(6)); + Data.setUint8(0, MessageType.MouseUp); + Data.setUint8(1, button); + Data.setUint16(2, coord.x, true); + Data.setUint16(4, coord.y, true); + sendInputData(Data.buffer); +} + +function emitMouseWheel(delta, x, y) { + if (print_inputs) { + console.log(`mouse wheel with delta ${delta} at (${x}, ${y})`); + } + let coord = normalizeAndQuantizeUnsigned(x, y); + let Data = new DataView(new ArrayBuffer(7)); + Data.setUint8(0, MessageType.MouseWheel); + Data.setInt16(1, delta, true); + Data.setUint16(3, coord.x, true); + Data.setUint16(5, coord.y, true); + sendInputData(Data.buffer); +} + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button +const MouseButton = { + MainButton: 0, // Left button. + AuxiliaryButton: 1, // Wheel button. + SecondaryButton: 2, // Right button. + FourthButton: 3, // Browser Back button. + FifthButton: 4 // Browser Forward button. +}; + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons +const MouseButtonsMask = { + PrimaryButton: 1, // Left button. + SecondaryButton: 2, // Right button. + AuxiliaryButton: 4, // Wheel button. + FourthButton: 8, // Browser Back button. + FifthButton: 16 // Browser Forward button. +}; + +// If the user has any mouse buttons pressed then release them. +function releaseMouseButtons(buttons, x, y) { + if (buttons & MouseButtonsMask.PrimaryButton) { + emitMouseUp(MouseButton.MainButton, x, y); + } + if (buttons & MouseButtonsMask.SecondaryButton) { + emitMouseUp(MouseButton.SecondaryButton, x, y); + } + if (buttons & MouseButtonsMask.AuxiliaryButton) { + emitMouseUp(MouseButton.AuxiliaryButton, x, y); + } + if (buttons & MouseButtonsMask.FourthButton) { + emitMouseUp(MouseButton.FourthButton, x, y); + } + if (buttons & MouseButtonsMask.FifthButton) { + emitMouseUp(MouseButton.FifthButton, x, y); + } +} + +// If the user has any mouse buttons pressed then press them again. +function pressMouseButtons(buttons, x, y) { + if (buttons & MouseButtonsMask.PrimaryButton) { + emitMouseDown(MouseButton.MainButton, x, y); + } + if (buttons & MouseButtonsMask.SecondaryButton) { + emitMouseDown(MouseButton.SecondaryButton, x, y); + } + if (buttons & MouseButtonsMask.AuxiliaryButton) { + emitMouseDown(MouseButton.AuxiliaryButton, x, y); + } + if (buttons & MouseButtonsMask.FourthButton) { + emitMouseDown(MouseButton.FourthButton, x, y); + } + if (buttons & MouseButtonsMask.FifthButton) { + emitMouseDown(MouseButton.FifthButton, x, y); + } +} + +function registerInputs(playerElement) { + if (!playerElement) + return; + + registerMouseEnterAndLeaveEvents(playerElement); + registerTouchEvents(playerElement); +} + +function createOnScreenKeyboardHelpers(htmlElement) { + if (document.getElementById('hiddenInput') === null) { + hiddenInput = document.createElement('input'); + hiddenInput.id = 'hiddenInput'; + hiddenInput.maxLength = 0; + htmlElement.appendChild(hiddenInput); + } + + if (document.getElementById('editTextButton') === null) { + editTextButton = document.createElement('button'); + editTextButton.id = 'editTextButton'; + editTextButton.innerHTML = 'edit text'; + htmlElement.appendChild(editTextButton); + + // Hide the 'edit text' button. + editTextButton.classList.add('hiddenState'); + + editTextButton.addEventListener('click', function() { + // Show the on-screen keyboard. + hiddenInput.focus(); + }); + } +} + +function showOnScreenKeyboard(command) { + if (command.showOnScreenKeyboard) { + // Show the 'edit text' button. + editTextButton.classList.remove('hiddenState'); + // Place the 'edit text' button near the UE4 input widget. + let pos = unquantizeAndDenormalizeUnsigned(command.x, command.y); + editTextButton.style.top = pos.y.toString() + 'px'; + editTextButton.style.left = (pos.x - 40).toString() + 'px'; + } else { + // Hide the 'edit text' button. + editTextButton.classList.add('hiddenState'); + // Hide the on-screen keyboard. + hiddenInput.blur(); + } +} + +function registerMouseEnterAndLeaveEvents(playerElement) { + playerElement.onmouseenter = function(e) { + if (print_inputs) { + console.log('mouse enter'); + } + let Data = new DataView(new ArrayBuffer(1)); + Data.setUint8(0, MessageType.MouseEnter); + sendInputData(Data.buffer); + playerElement.pressMouseButtons(e); + }; + + playerElement.onmouseleave = function(e) { + if (print_inputs) { + console.log('mouse leave'); + } + let Data = new DataView(new ArrayBuffer(1)); + Data.setUint8(0, MessageType.MouseLeave); + sendInputData(Data.buffer); + playerElement.releaseMouseButtons(e); + }; +} + +// A locked mouse works by the user clicking in the browser player and the +// cursor disappears and is locked. The user moves the cursor and the camera +// moves, for example. The user presses escape to free the mouse. +function registerLockedMouseEvents(playerElement) { + let x = playerElement.width / 2; + let y = playerElement.height / 2; + + playerElement.requestPointerLock = playerElement.requestPointerLock || playerElement.mozRequestPointerLock; + document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock; + + playerElement.onclick = function() { + playerElement.requestPointerLock(); + }; + + // Respond to lock state change events + document.addEventListener('pointerlockchange', lockStateChange, false); + document.addEventListener('mozpointerlockchange', lockStateChange, false); + + function lockStateChange() { + if (document.pointerLockElement === playerElement || + document.mozPointerLockElement === playerElement) { + console.log('Pointer locked'); + document.addEventListener("mousemove", updatePosition, false); + } else { + console.log('The pointer lock status is now unlocked'); + document.removeEventListener("mousemove", updatePosition, false); + } + } + + function updatePosition(e) { + x += e.movementX; + y += e.movementY; + if (x > styleWidth) { + x -= styleWidth; + } + if (y > styleHeight) { + y -= styleHeight; + } + if (x < 0) { + x = styleWidth + x; + } + if (y < 0) { + y = styleHeight - y; + } + emitMouseMove(x, y, e.movementX, e.movementY); + } + + playerElement.onmousedown = function(e) { + emitMouseDown(e.button, x, y); + }; + + playerElement.onmouseup = function(e) { + emitMouseUp(e.button, x, y); + }; + + playerElement.onmousewheel = function(e) { + emitMouseWheel(e.wheelDelta, x, y); + }; + + playerElement.pressMouseButtons = function(e) { + pressMouseButtons(e.buttons, x, y); + }; + + playerElement.releaseMouseButtons = function(e) { + releaseMouseButtons(e.buttons, x, y); + }; +} + +// A hovering mouse works by the user clicking the mouse button when they want +// the cursor to have an effect over the video. Otherwise the cursor just +// passes over the browser. +function registerHoveringMouseEvents(playerElement) { + styleCursor = 'none'; // We will rely on UE4 client's software cursor. + //styleCursor = 'default'; // Showing cursor + + playerElement.onmousemove = function(e) { + emitMouseMove(e.offsetX, e.offsetY, e.movementX, e.movementY); + e.preventDefault(); + }; + + playerElement.onmousedown = function(e) { + emitMouseDown(e.button, e.offsetX, e.offsetY); + e.preventDefault(); + }; + + playerElement.onmouseup = function(e) { + emitMouseUp(e.button, e.offsetX, e.offsetY); + e.preventDefault(); + }; + + // When the context menu is shown then it is safest to release the button + // which was pressed when the event happened. This will guarantee we will + // get at least one mouse up corresponding to a mouse down event. Otherwise + // the mouse can get stuck. + // https://github.com/facebook/react/issues/5531 + playerElement.oncontextmenu = function(e) { + emitMouseUp(e.button, e.offsetX, e.offsetY); + e.preventDefault(); + }; + + if ('onmousewheel' in playerElement) { + playerElement.onmousewheel = function(e) { + emitMouseWheel(e.wheelDelta, e.offsetX, e.offsetY); + e.preventDefault(); + }; + } else { + playerElement.addEventListener('DOMMouseScroll', function(e) { + emitMouseWheel(e.detail * -120, e.offsetX, e.offsetY); + e.preventDefault(); + }, false); + } + + playerElement.pressMouseButtons = function(e) { + pressMouseButtons(e.buttons, e.offsetX, e.offsetY); + }; + + playerElement.releaseMouseButtons = function(e) { + releaseMouseButtons(e.buttons, e.offsetX, e.offsetY); + }; +} + +function registerTouchEvents(playerElement) { + + // We need to assign a unique identifier to each finger. + // We do this by mapping each Touch object to the identifier. + let fingers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]; + let fingerIds = {}; + + function rememberTouch(touch) { + let finger = fingers.pop(); + if (finger === undefined) { + console.log('exhausted touch indentifiers'); + } + fingerIds[touch.identifier] = finger; + } + + function forgetTouch(touch) { + fingers.push(fingerIds[touch.identifier]); + delete fingerIds[touch.identifier]; + } + + function emitTouchData(type, touches) { + let data = new DataView(new ArrayBuffer(2 + 7 * touches.length)); + data.setUint8(0, type); + data.setUint8(1, touches.length); + let byte = 2; + for (let t = 0; t < touches.length; t++) { + let touch = touches[t]; + let x = touch.clientX - playerElement.offsetLeft; + let y = touch.clientY - playerElement.offsetTop; + if (print_inputs) { + console.log(`F${fingerIds[touch.identifier]}=(${x}, ${y})`); + } + let coord = normalizeAndQuantizeUnsigned(x, y); + data.setUint16(byte, coord.x, true); + byte += 2; + data.setUint16(byte, coord.y, true); + byte += 2; + data.setUint8(byte, fingerIds[touch.identifier], true); + byte += 1; + data.setUint8(byte, 255 * touch.force, true); // force is between 0.0 and 1.0 so quantize into byte. + byte += 1; + data.setUint8(byte, coord.inRange ? 1 : 0, true); // mark the touch as in the player or not + byte += 1; + } + + sendInputData(data.buffer); + } + + if (inputOptions.fakeMouseWithTouches) { + + let finger = undefined; + + playerElement.ontouchstart = function(e) { + if (finger === undefined) { + let firstTouch = e.changedTouches[0]; + finger = { + id: firstTouch.identifier, + x: firstTouch.clientX - playerElementClientRect.left, + y: firstTouch.clientY - playerElementClientRect.top + }; + // Hack: Mouse events require an enter and leave so we just + // enter and leave manually with each touch as this event + // is not fired with a touch device. + playerElement.onmouseenter(e); + emitMouseDown(MouseButton.MainButton, finger.x, finger.y); + } + e.preventDefault(); + }; + + playerElement.ontouchend = function(e) { + for (let t = 0; t < e.changedTouches.length; t++) { + let touch = e.changedTouches[t]; + if (touch.identifier === finger.id) { + let x = touch.clientX - playerElementClientRect.left; + let y = touch.clientY - playerElementClientRect.top; + emitMouseUp(MouseButton.MainButton, x, y); + // Hack: Manual mouse leave event. + playerElement.onmouseleave(e); + finger = undefined; + break; + } + } + e.preventDefault(); + }; + + playerElement.ontouchmove = function(e) { + for (let t = 0; t < e.touches.length; t++) { + let touch = e.touches[t]; + if (touch.identifier === finger.id) { + let x = touch.clientX - playerElementClientRect.left; + let y = touch.clientY - playerElementClientRect.top; + emitMouseMove(x, y, x - finger.x, y - finger.y); + finger.x = x; + finger.y = y; + break; + } + } + e.preventDefault(); + }; + } else { + playerElement.ontouchstart = function(e) { + // Assign a unique identifier to each touch. + for (let t = 0; t < e.changedTouches.length; t++) { + rememberTouch(e.changedTouches[t]); + } + + if (print_inputs) { + console.log('touch start'); + } + emitTouchData(MessageType.TouchStart, e.changedTouches); + e.preventDefault(); + }; + + playerElement.ontouchend = function(e) { + if (print_inputs) { + console.log('touch end'); + } + emitTouchData(MessageType.TouchEnd, e.changedTouches); + + // Re-cycle unique identifiers previously assigned to each touch. + for (let t = 0; t < e.changedTouches.length; t++) { + forgetTouch(e.changedTouches[t]); + } + e.preventDefault(); + }; + + playerElement.ontouchmove = function(e) { + if (print_inputs) { + console.log('touch move'); + } + emitTouchData(MessageType.TouchMove, e.touches); + e.preventDefault(); + }; + } +} + +// Browser keys do not have a charCode so we only need to test keyCode. +function isKeyCodeBrowserKey(keyCode) { + // Function keys or tab key. + return keyCode >= 112 && keyCode <= 123 || keyCode === 9; +} + +// Must be kept in sync with JavaScriptKeyCodeToFKey C++ array. The index of the +// entry in the array is the special key code given below. +const SpecialKeyCodes = { + BackSpace: 8, + Shift: 16, + Control: 17, + Alt: 18, + RightShift: 253, + RightControl: 254, + RightAlt: 255 +}; + +// We want to be able to differentiate between left and right versions of some +// keys. +function getKeyCode(e) { + if (e.keyCode === SpecialKeyCodes.Shift && e.code === 'ShiftRight') return SpecialKeyCodes.RightShift; + else if (e.keyCode === SpecialKeyCodes.Control && e.code === 'ControlRight') return SpecialKeyCodes.RightControl; + else if (e.keyCode === SpecialKeyCodes.Alt && e.code === 'AltRight') return SpecialKeyCodes.RightAlt; + else return e.keyCode; +} + +function registerKeyboardEvents() { + document.onkeydown = function(e) { + if (print_inputs) { + console.log(`key down ${e.keyCode}, repeat = ${e.repeat}`); + } + sendInputData(new Uint8Array([MessageType.KeyDown, getKeyCode(e), e.repeat]).buffer); + // Backspace is not considered a keypress in JavaScript but we need it + // to be so characters may be deleted in a UE4 text entry field. + if (e.keyCode === SpecialKeyCodes.BackSpace) { + document.onkeypress({ + charCode: SpecialKeyCodes.BackSpace + }); + } + if (inputOptions.suppressBrowserKeys && isKeyCodeBrowserKey(e.keyCode)) { + e.preventDefault(); + } + }; + + document.onkeyup = function(e) { + if (print_inputs) { + console.log(`key up ${e.keyCode}`); + } + sendInputData(new Uint8Array([MessageType.KeyUp, getKeyCode(e)]).buffer); + if (inputOptions.suppressBrowserKeys && isKeyCodeBrowserKey(e.keyCode)) { + e.preventDefault(); + } + }; + + document.onkeypress = function(e) { + if (print_inputs) { + console.log(`key press ${e.charCode}`); + } + let data = new DataView(new ArrayBuffer(3)); + data.setUint8(0, MessageType.KeyPress); + data.setUint16(1, e.charCode, true); + sendInputData(data.buffer); + }; +} + +function onExpandOverlay_Click( /* e */ ) { + let overlay = document.getElementById('overlay'); + overlay.classList.toggle("overlay-shown"); +} + +function start() { + // update "quality status" to "disconnected" state + let qualityStatus = document.getElementById("qualityStatus"); + if (qualityStatus) { + qualityStatus.className = "grey-status"; + } + + + let statsDiv = document.getElementById("stats"); + if (statsDiv) { + statsDiv.innerHTML = 'Not connected'; + } + + if (!connect_on_load || is_reconnection) { + showConnectOverlay(); + invalidateFreezeFrameOverlay(); + shouldShowPlayOverlay = true; + resizePlayerStyle(); + } else { + connect(); + } + + updateKickButton(0); +} + +function updateKickButton(playersCount) { + let kickButton = document.getElementById('kick-other-players-button'); + if (kickButton) + kickButton.value = `Kick (${playersCount})`; +} + +function connect() { + "use strict"; + + window.WebSocket = window.WebSocket || window.MozWebSocket; + + if (!window.WebSocket) { + alert('Your browser doesn\'t support WebSocket'); + return; + } + + ws = new WebSocket(window.location.href.replace('http://', 'ws://').replace('https://', 'wss://')); + + ws.onmessage = function(event) { + console.log(`<- SS: ${event.data}`); + let msg = JSON.parse(event.data); + if (msg.type === 'config') { + onConfig(msg); + } else if (msg.type === 'playerCount') { + updateKickButton(msg.count - 1); + } else if (msg.type === 'answer') { + onWebRtcAnswer(msg); + } else if (msg.type === 'iceCandidate') { + onWebRtcIce(msg.candidate); + } else { + console.log(`invalid SS message type: ${msg.type}`); + } + }; + + ws.onerror = function(event) { + console.log(`WS error: ${JSON.stringify(event)}`); + }; + + ws.onclose = function(event) { + console.log(`WS closed: ${JSON.stringify(event.code)} - ${event.reason}`); + ws = undefined; + is_reconnection = true; + + // destroy `webRtcPlayerObj` if any + let playerDiv = document.getElementById('player'); + if (webRtcPlayerObj) { + playerDiv.removeChild(webRtcPlayerObj.video); + webRtcPlayerObj.close(); + webRtcPlayerObj = undefined; + } + + showTextOverlay(`Disconnected: ${event.reason}`); + let reclickToStart = setTimeout(start, 4000); + }; +} + +// Config data received from WebRTC sender via the Cirrus web server +function onConfig(config) { + let playerDiv = document.getElementById('player'); + let playerElement = setupWebRtcPlayer(playerDiv, config); + resizePlayerStyle(); + + switch (inputOptions.controlScheme) { + case ControlSchemeType.HoveringMouse: + registerHoveringMouseEvents(playerElement); + break; + case ControlSchemeType.LockedMouse: + registerLockedMouseEvents(playerElement); + break; + default: + console.log(`ERROR: Unknown control scheme ${inputOptions.controlScheme}`); + registerLockedMouseEvents(playerElement); + break; + } +} + +function load() { + setupHtmlEvents(); + setupFreezeFrameOverlay(); + registerKeyboardEvents(); + start(); +} \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/stressTest.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/stressTest.js new file mode 100644 index 0000000000000000000000000000000000000000..710d40774ebd7675cc1cf59d5f2980b11d191b88 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/stressTest.js @@ -0,0 +1,165 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +// This is the entrypoint to the stress test, all setup happens here +function stressTest() { + + + // This stress test creates a number of Pixel Streaming pages on the same page + // using iframes and then tries to auto-connect them. + + // The purpose of the stress test is to automate testing a large number of peers + // connecting and disconnecting regularly from a single Unreal Engine streaming instance. + + let self = this; + this.play = true; + this.maxPeers = 5; + this.totalStreams = 0; + this.streamCreationIntervalMs = 200; + this.streamDeletionIntervalMs = 2000; + this.pixelStreamingFrames = []; + this.creationIntervalHandle = null; + this.deletionIntervalHandle = null; + + // Create a container to put the "Pixel Streaming" pages in. + let streamsContainer = document.getElementById("streamsContainer"); + + function startStressTest() { + setupNumPeersSlider(); + startStreamCreation(); + startStreamDeletion(); + setupPlayPause(); + + document.getElementById("creationIntervalInput").addEventListener("change", function(){ + self.streamCreationIntervalMs = document.getElementById("creationIntervalInput").value * 1000.0; + startStreamCreation(); + }); + + document.getElementById("deletionIntervalInput").addEventListener("change", function(){ + self.streamDeletionIntervalMs = document.getElementById("deletionIntervalInput").value * 1000.0; + startStreamDeletion(); + }); + } + + function startStreamCreation() { + + if(self.creationIntervalHandle) { + clearInterval(self.creationIntervalHandle); + } + + // Create iframes of Pixel Streaming as a given interval (up to the max nPeers) + self.creationIntervalHandle = setInterval(function(){ + + if(self.play) { + let curNPeers = self.pixelStreamingFrames.length; + if(curNPeers >= self.maxPeers) { + return; + } + + // Make a random amount of peers between 0 and up to max peers. + let maxPeersToCreate = self.maxPeers - curNPeers; + let nPeersToCreate = Math.ceil(Math.random() * maxPeersToCreate); + + for(let i = 0; i < nPeersToCreate; i++) { + let frame = createPixelStreamingFrame(); + let n = self.pixelStreamingFrames.length; + frame.id = "PixelStreamingFrame_" + (n + 1); + streamsContainer.append(frame); + self.pixelStreamingFrames.push(frame); + self.totalStreams += 1; + updateTotalStreams(); + } + } + }, self.streamCreationIntervalMs); + } + + function startStreamDeletion() { + + if(self.deletionIntervalHandle) { + clearInterval(self.deletionIntervalHandle); + } + + self.deletionIntervalHandle = setInterval(function(){ + if(self.play) { + let curNPeers = self.pixelStreamingFrames.length; + if(curNPeers == 0) { + return; + } + + // Delete a random amount of peers up to current number of peers + let nPeersToDelete = Math.ceil(Math.random() * curNPeers); + + for(let i = 0; i < nPeersToDelete; i++) { + let frame = self.pixelStreamingFrames.shift(); + frame.parentNode.removeChild(frame); + } + } + }, self.streamDeletionIntervalMs); + + } + + function updateTotalStreams() { + let nStreamsLabel = document.getElementById("nStreamsLabel"); + nStreamsLabel.innerHTML = self.totalStreams; + } + + + function setupPlayPause() { + let playPauseBtn = document.getElementById("playPause"); + playPauseBtn.addEventListener("click", () => { + if(self.play) { + self.play = false; + playPauseBtn.innerHTML = "Play" + } else { + self.play = true; + playPauseBtn.innerHTML = "Pause" + } + }); + } + + function setupNumPeersSlider() { + // Tie number of peers to the slider + let nPeersSlider = document.getElementById("nPeersSlider"); + nPeersSlider.value = self.maxPeers; + + let nPeersLabel = document.getElementById("nPeerLabel"); + nPeersLabel.innerHTML = self.maxPeers; + + // When the slide changes update the nPeers variable + nPeersSlider.addEventListener("change", function(){ + self.maxPeers = nPeersSlider.value; + nPeersLabel.innerHTML = nPeersSlider.value; + }); + } + + function createPixelStreamingFrame() { + // Create an iframe that holds the Pixel Streaming page + let streamIFrame = document.createElement("iframe"); + streamIFrame.src = "player.html"; + streamIFrame.onload = function(){ + + let pixelStreamingJS = streamIFrame.contentWindow; + + // Don't show the play button + pixelStreamingJS.connect_on_load = true; + pixelStreamingJS.shouldShowPlayOverlay = false; + + // Create a hook for when webRTCPlayer is setup + let existingSetupPlayerFunc = pixelStreamingJS.setupWebRtcPlayer; + let newSetupPlayerFunc = function(htmlElement, config){ + config.startVideoMuted = true; + config.autoPlayAudio = false; + let webrtcPlayer = existingSetupPlayerFunc(htmlElement, config); + return webrtcPlayer; + } + pixelStreamingJS.setupWebRtcPlayer = newSetupPlayerFunc; + + + pixelStreamingJS.connect(); + } + return streamIFrame; + } + + // Start here + startStressTest(); + +} diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/webRtcPlayer.js b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/webRtcPlayer.js new file mode 100644 index 0000000000000000000000000000000000000000..af7a1e288f0fc780e1587b821b7e09f3a1184885 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/scripts/webRtcPlayer.js @@ -0,0 +1,533 @@ +// Copyright Epic Games, Inc. All Rights Reserved. +// universal module definition - read https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(["./adapter"], factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(require("./adapter")); + } else { + // Browser globals (root is window) + root.webRtcPlayer = factory(root.adapter); + } +}(this, function (adapter) { + + function webRtcPlayer(parOptions) { + parOptions = typeof parOptions !== 'undefined' ? parOptions : {}; + + var self = this; + + //********************** + //Config setup + //********************** + this.cfg = typeof parOptions.peerConnectionOptions !== 'undefined' ? parOptions.peerConnectionOptions : {}; + this.cfg.sdpSemantics = 'unified-plan'; + // this.cfg.rtcAudioJitterBufferMaxPackets = 10; + // this.cfg.rtcAudioJitterBufferFastAccelerate = true; + // this.cfg.rtcAudioJitterBufferMinDelayMs = 0; + + // If this is true in Chrome 89+ SDP is sent that is incompatible with UE Pixel Streaming 4.26 and below. + // However 4.27 Pixel Streaming does not need this set to false as it supports `offerExtmapAllowMixed`. + // tdlr; uncomment this line for older versions of Pixel Streaming that need Chrome 89+. + this.cfg.offerExtmapAllowMixed = false; + + //********************** + //Variables + //********************** + this.pcClient = null; + this.dcClient = null; + this.tnClient = null; + + this.sdpConstraints = { + offerToReceiveAudio: 1, //Note: if you don't need audio you can get improved latency by turning this off. + offerToReceiveVideo: 1, + voiceActivityDetection: false + }; + + // See https://www.w3.org/TR/webrtc/#dom-rtcdatachannelinit for values (this is needed for Firefox to be consistent with Chrome.) + this.dataChannelOptions = {ordered: true}; + + // This is useful if the video/audio needs to autoplay (without user input) as browsers do not allow autoplay non-muted of sound sources without user interaction. + this.startVideoMuted = typeof parOptions.startVideoMuted !== 'undefined' ? parOptions.startVideoMuted : false; + this.autoPlayAudio = typeof parOptions.autoPlayAudio !== 'undefined' ? parOptions.autoPlayAudio : true; + + // To enable mic in browser use SSL/localhost and have ?useMic in the query string. + const urlParams = new URLSearchParams(window.location.search); + this.useMic = urlParams.has('useMic'); + if(!this.useMic) + { + console.log("Microphone access is not enabled. Pass ?useMic in the url to enable it."); + } + + // When ?useMic check for SSL or localhost + let isLocalhostConnection = location.hostname === "localhost" || location.hostname === "127.0.0.1"; + let isHttpsConnection = location.protocol === 'https:'; + if(this.useMic && !isLocalhostConnection && !isHttpsConnection) + { + this.useMic = false; + console.error("Microphone access in the browser will not work if you are not on HTTPS or localhost. Disabling mic access."); + console.error("For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'"); + } + + // Latency tester + this.latencyTestTimings = + { + TestStartTimeMs: null, + UEReceiptTimeMs: null, + UEPreCaptureTimeMs: null, + UEPostCaptureTimeMs: null, + UEPreEncodeTimeMs: null, + UEPostEncodeTimeMs: null, + UETransmissionTimeMs: null, + BrowserReceiptTimeMs: null, + FrameDisplayDeltaTimeMs: null, + Reset: function() + { + this.TestStartTimeMs = null; + this.UEReceiptTimeMs = null; + this.UEPreCaptureTimeMs = null; + this.UEPostCaptureTimeMs = null; + this.UEPreEncodeTimeMs = null; + this.UEPostEncodeTimeMs = null; + this.UETransmissionTimeMs = null; + this.BrowserReceiptTimeMs = null; + this.FrameDisplayDeltaTimeMs = null; + }, + SetUETimings: function(UETimings) + { + this.UEReceiptTimeMs = UETimings.ReceiptTimeMs; + this.UEPreCaptureTimeMs = UETimings.PreCaptureTimeMs; + this.UEPostCaptureTimeMs = UETimings.PostCaptureTimeMs; + this.UEPreEncodeTimeMs = UETimings.PreEncodeTimeMs; + this.UEPostEncodeTimeMs = UETimings.PostEncodeTimeMs; + this.UETransmissionTimeMs = UETimings.TransmissionTimeMs; + this.BrowserReceiptTimeMs = Date.now(); + this.OnAllLatencyTimingsReady(this); + }, + SetFrameDisplayDeltaTime: function(DeltaTimeMs) + { + if(this.FrameDisplayDeltaTimeMs == null) + { + this.FrameDisplayDeltaTimeMs = Math.round(DeltaTimeMs); + this.OnAllLatencyTimingsReady(this); + } + }, + OnAllLatencyTimingsReady: function(Timings){} + } + + //********************** + //Functions + //********************** + + //Create Video element and expose that as a parameter + this.createWebRtcVideo = function() { + var video = document.createElement('video'); + + video.id = "streamingVideo"; + video.playsInline = true; + video.disablepictureinpicture = true; + video.muted = self.startVideoMuted;; + + video.addEventListener('loadedmetadata', function(e){ + if(self.onVideoInitialised){ + self.onVideoInitialised(); + } + }, true); + + // Check if request video frame callback is supported + if ('requestVideoFrameCallback' in HTMLVideoElement.prototype) { + // The API is supported! + + const onVideoFrameReady = (now, metadata) => { + + if(metadata.receiveTime && metadata.expectedDisplayTime) + { + const receiveToCompositeMs = metadata.presentationTime - metadata.receiveTime; + self.aggregatedStats.receiveToCompositeMs = receiveToCompositeMs; + } + + + // Re-register the callback to be notified about the next frame. + video.requestVideoFrameCallback(onVideoFrameReady); + }; + + // Initially register the callback to be notified about the first frame. + video.requestVideoFrameCallback(onVideoFrameReady); + } + + return video; + } + + this.video = this.createWebRtcVideo(); + + onsignalingstatechange = function(state) { + console.info('signaling state change:', state) + }; + + oniceconnectionstatechange = function(state) { + console.info('ice connection state change:', state) + }; + + onicegatheringstatechange = function(state) { + console.info('ice gathering state change:', state) + }; + + handleOnTrack = function(e) { + console.log('handleOnTrack', e.streams); + + if (e.track) + { + console.log('Got track - ' + e.track.kind + ' id=' + e.track.id + ' readyState=' + e.track.readyState); + } + + if(e.track.kind == "audio") + { + handleOnAudioTrack(e.streams[0]); + return; + } + else(e.track.kind == "video" && self.video.srcObject !== e.streams[0]) + { + self.video.srcObject = e.streams[0]; + console.log('Set video source from video track ontrack.'); + return; + } + + }; + + handleOnAudioTrack = function(audioMediaStream) + { + // do nothing the video has the same media stream as the audio track we have here (they are linked) + if(self.video.srcObject == audioMediaStream) + { + return; + } + // video element has some other media stream that is not associated with this audio track + else if(self.video.srcObject && self.video.srcObject !== audioMediaStream) + { + // create a new audio element + let audioElem = document.createElement("Audio"); + audioElem.srcObject = audioMediaStream; + + // there is no way to autoplay audio (even muted), so we defer audio until first click + if(!self.autoPlayAudio) { + + let clickToPlayAudio = function() { + audioElem.play(); + self.video.removeEventListener("click", clickToPlayAudio); + }; + + self.video.addEventListener("click", clickToPlayAudio); + } + // we assume the user has clicked somewhere on the page and autoplaying audio will work + else { + audioElem.play(); + } + console.log('Created new audio element to play seperate audio stream.'); + } + + } + + setupDataChannel = function(pc, label, options) { + try { + let datachannel = pc.createDataChannel(label, options); + console.log(`Created datachannel (${label})`) + + // Inform browser we would like binary data as an ArrayBuffer (FF chooses Blob by default!) + datachannel.binaryType = "arraybuffer"; + + datachannel.onopen = function (e) { + console.log(`data channel (${label}) connect`) + if(self.onDataChannelConnected){ + self.onDataChannelConnected(); + } + } + + datachannel.onclose = function (e) { + console.log(`data channel (${label}) closed`) + } + + datachannel.onmessage = function (e) { + //console.log(`Got message (${label})`, e.data) + if (self.onDataChannelMessage) + self.onDataChannelMessage(e.data); + } + + return datachannel; + } catch (e) { + console.warn('No data channel', e); + return null; + } + } + + onicecandidate = function (e) { + console.log('ICE candidate', e) + if (e.candidate && e.candidate.candidate) { + self.onWebRtcCandidate(e.candidate); + } + }; + + handleCreateOffer = function (pc) { + pc.createOffer(self.sdpConstraints).then(function (offer) { + + // Munging is where we modifying the sdp string to set parameters that are not exposed to the browser's WebRTC API + mungeSDPOffer(offer); + + // Set our munged SDP on the local peer connection so it is "set" and will be send across + pc.setLocalDescription(offer); + if (self.onWebRtcOffer) { + self.onWebRtcOffer(offer); + } + }, + function () { console.warn("Couldn't create offer") }); + } + + mungeSDPOffer = function (offer) { + + // turn off video-timing sdp sent from browser + //offer.sdp = offer.sdp.replace("http://www.webrtc.org/experiments/rtp-hdrext/playout-delay", ""); + + // this indicate we support stereo (Chrome needs this) + offer.sdp = offer.sdp.replace('useinbandfec=1', 'useinbandfec=1;stereo=1;sprop-maxcapturerate=48000'); + + } + + setupPeerConnection = function (pc) { + if (pc.SetBitrate) + console.log("Hurray! there's RTCPeerConnection.SetBitrate function"); + + //Setup peerConnection events + pc.onsignalingstatechange = onsignalingstatechange; + pc.oniceconnectionstatechange = oniceconnectionstatechange; + pc.onicegatheringstatechange = onicegatheringstatechange; + + pc.ontrack = handleOnTrack; + pc.onicecandidate = onicecandidate; + }; + + generateAggregatedStatsFunction = function(){ + if(!self.aggregatedStats) + self.aggregatedStats = {}; + + return function(stats){ + //console.log('Printing Stats'); + + let newStat = {}; + + stats.forEach(stat => { +// console.log(JSON.stringify(stat, undefined, 4)); + if (stat.type == 'inbound-rtp' + && !stat.isRemote + && (stat.mediaType == 'video' || stat.id.toLowerCase().includes('video'))) { + + newStat.timestamp = stat.timestamp; + newStat.bytesReceived = stat.bytesReceived; + newStat.framesDecoded = stat.framesDecoded; + newStat.packetsLost = stat.packetsLost; + newStat.bytesReceivedStart = self.aggregatedStats && self.aggregatedStats.bytesReceivedStart ? self.aggregatedStats.bytesReceivedStart : stat.bytesReceived; + newStat.framesDecodedStart = self.aggregatedStats && self.aggregatedStats.framesDecodedStart ? self.aggregatedStats.framesDecodedStart : stat.framesDecoded; + newStat.timestampStart = self.aggregatedStats && self.aggregatedStats.timestampStart ? self.aggregatedStats.timestampStart : stat.timestamp; + + if(self.aggregatedStats && self.aggregatedStats.timestamp){ + if(self.aggregatedStats.bytesReceived){ + // bitrate = bits received since last time / number of ms since last time + //This is automatically in kbits (where k=1000) since time is in ms and stat we want is in seconds (so a '* 1000' then a '/ 1000' would negate each other) + newStat.bitrate = 8 * (newStat.bytesReceived - self.aggregatedStats.bytesReceived) / (newStat.timestamp - self.aggregatedStats.timestamp); + newStat.bitrate = Math.floor(newStat.bitrate); + newStat.lowBitrate = self.aggregatedStats.lowBitrate && self.aggregatedStats.lowBitrate < newStat.bitrate ? self.aggregatedStats.lowBitrate : newStat.bitrate + newStat.highBitrate = self.aggregatedStats.highBitrate && self.aggregatedStats.highBitrate > newStat.bitrate ? self.aggregatedStats.highBitrate : newStat.bitrate + } + + if(self.aggregatedStats.bytesReceivedStart){ + newStat.avgBitrate = 8 * (newStat.bytesReceived - self.aggregatedStats.bytesReceivedStart) / (newStat.timestamp - self.aggregatedStats.timestampStart); + newStat.avgBitrate = Math.floor(newStat.avgBitrate); + } + + if(self.aggregatedStats.framesDecoded){ + // framerate = frames decoded since last time / number of seconds since last time + newStat.framerate = (newStat.framesDecoded - self.aggregatedStats.framesDecoded) / ((newStat.timestamp - self.aggregatedStats.timestamp) / 1000); + newStat.framerate = Math.floor(newStat.framerate); + newStat.lowFramerate = self.aggregatedStats.lowFramerate && self.aggregatedStats.lowFramerate < newStat.framerate ? self.aggregatedStats.lowFramerate : newStat.framerate + newStat.highFramerate = self.aggregatedStats.highFramerate && self.aggregatedStats.highFramerate > newStat.framerate ? self.aggregatedStats.highFramerate : newStat.framerate + } + + if(self.aggregatedStats.framesDecodedStart){ + newStat.avgframerate = (newStat.framesDecoded - self.aggregatedStats.framesDecodedStart) / ((newStat.timestamp - self.aggregatedStats.timestampStart) / 1000); + newStat.avgframerate = Math.floor(newStat.avgframerate); + } + } + } + + //Read video track stats + if(stat.type == 'track' && (stat.trackIdentifier == 'video_label' || stat.kind == 'video')) { + newStat.framesDropped = stat.framesDropped; + newStat.framesReceived = stat.framesReceived; + newStat.framesDroppedPercentage = stat.framesDropped / stat.framesReceived * 100; + newStat.frameHeight = stat.frameHeight; + newStat.frameWidth = stat.frameWidth; + newStat.frameHeightStart = self.aggregatedStats && self.aggregatedStats.frameHeightStart ? self.aggregatedStats.frameHeightStart : stat.frameHeight; + newStat.frameWidthStart = self.aggregatedStats && self.aggregatedStats.frameWidthStart ? self.aggregatedStats.frameWidthStart : stat.frameWidth; + } + + if(stat.type =='candidate-pair' && stat.hasOwnProperty('currentRoundTripTime') && stat.currentRoundTripTime != 0){ + newStat.currentRoundTripTime = stat.currentRoundTripTime; + } + }); + + + if(self.aggregatedStats.receiveToCompositeMs) + { + newStat.receiveToCompositeMs = self.aggregatedStats.receiveToCompositeMs; + self.latencyTestTimings.SetFrameDisplayDeltaTime(self.aggregatedStats.receiveToCompositeMs); + } + + self.aggregatedStats = newStat; + + if(self.onAggregatedStats) + self.onAggregatedStats(newStat) + } + }; + + setupTracksToSendAsync = async function(pc){ + + // Setup a transceiver for getting UE video + pc.addTransceiver("video", { direction: "recvonly" }); + + // Setup a transceiver for sending mic audio to UE and receiving audio from UE + if(!self.useMic) + { + pc.addTransceiver("audio", { direction: "recvonly" }); + } + else + { + let audioSendOptions = self.useMic ? + { + autoGainControl: false, + channelCount: 1, + echoCancellation: false, + latency: 0, + noiseSuppression: false, + sampleRate: 16000, + volume: 1.0 + } : false; + + // Note using mic on android chrome requires SSL or chrome://flags/ "unsafely-treat-insecure-origin-as-secure" + const stream = await navigator.mediaDevices.getUserMedia({video: false, audio: audioSendOptions}); + if(stream) + { + for (const track of stream.getTracks()) { + if(track.kind && track.kind == "audio") + { + pc.addTransceiver(track, { direction: "sendrecv" }); + } + } + } + else + { + pc.addTransceiver("audio", { direction: "recvonly" }); + } + } + }; + + + //********************** + //Public functions + //********************** + + this.setVideoEnabled = function(enabled) { + self.video.srcObject.getTracks().forEach(track => track.enabled = enabled); + } + + this.startLatencyTest = function(onTestStarted) { + // Can't start latency test without a video element + if(!self.video) + { + return; + } + + self.latencyTestTimings.Reset(); + self.latencyTestTimings.TestStartTimeMs = Date.now(); + onTestStarted(self.latencyTestTimings.TestStartTimeMs); + } + + //This is called when revceiving new ice candidates individually instead of part of the offer + //This is currently not used but would be called externally from this class + this.handleCandidateFromServer = function(iceCandidate) { + console.log("ICE candidate: ", iceCandidate); + let candidate = new RTCIceCandidate(iceCandidate); + self.pcClient.addIceCandidate(candidate).then(_=>{ + console.log('ICE candidate successfully added'); + }); + }; + + //Called externaly to create an offer for the server + this.createOffer = function() { + if(self.pcClient){ + console.log("Closing existing PeerConnection") + self.pcClient.close(); + self.pcClient = null; + } + self.pcClient = new RTCPeerConnection(self.cfg); + + setupTracksToSendAsync(self.pcClient).finally(function() + { + setupPeerConnection(self.pcClient); + self.dcClient = setupDataChannel(self.pcClient, 'cirrus', self.dataChannelOptions); + handleCreateOffer(self.pcClient); + }); + + }; + + //Called externaly when an answer is received from the server + this.receiveAnswer = function(answer) { + console.log('Received answer:'); + console.log(answer); + var answerDesc = new RTCSessionDescription(answer); + self.pcClient.setRemoteDescription(answerDesc); + + let receivers = self.pcClient.getReceivers(); + for(let receiver of receivers) + { + receiver.playoutDelayHint = 0; + } + }; + + this.close = function(){ + if(self.pcClient){ + console.log("Closing existing peerClient") + self.pcClient.close(); + self.pcClient = null; + } + if(self.aggregateStatsIntervalId) + clearInterval(self.aggregateStatsIntervalId); + } + + //Sends data across the datachannel + this.send = function(data){ + if(self.dcClient && self.dcClient.readyState == 'open'){ + //console.log('Sending data on dataconnection', self.dcClient) + self.dcClient.send(data); + } + }; + + this.getStats = function(onStats){ + if(self.pcClient && onStats){ + self.pcClient.getStats(null).then((stats) => { + onStats(stats); + }); + } + } + + this.aggregateStats = function(checkInterval){ + let calcAggregatedStats = generateAggregatedStatsFunction(); + let printAggregatedStats = () => { self.getStats(calcAggregatedStats); } + self.aggregateStatsIntervalId = setInterval(printAggregatedStats, checkInterval); + } + }; + + return webRtcPlayer; + +})); diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Bootstrap.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Bootstrap.tps new file mode 100644 index 0000000000000000000000000000000000000000..80b368ff757515739e67f11409ccbb11e976b10b --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Bootstrap.tps @@ -0,0 +1,13 @@ + + + bootstrap v3.x, v4.x + /Samples/PixelStreaming/WebServers/ + This is a requirement to using Bootstrap, providing better UI elements for the client web pages created for demoing pixelstreaming + https://github.com/twitter/bootstrap/blob/master/LICENSE + + Licensees + Git + P4 + + /Engine/Source/ThirdParty/Licenses/Bootstrap_License.txt + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Express.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Express.tps new file mode 100644 index 0000000000000000000000000000000000000000..3577ae51e68a6722e3a3ce1e78826cde343ad1f3 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Express.tps @@ -0,0 +1,13 @@ + + + Express v4.16.2 + /Samples/PixelStreaming/WebServers/ + Express is a web framework for Node.js. + https://github.com/expressjs/express/blob/master/LICENSE + + Licensees + Git + P4 + + /Engine/Plugins/Experimental/PixelStreaming/Source/Express_License.txt + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/FontAwesome.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/FontAwesome.tps new file mode 100644 index 0000000000000000000000000000000000000000..dd188c2a922fe9240ab2db1ea2eb2a210a70f50d --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/FontAwesome.tps @@ -0,0 +1,11 @@ + + + FontAwesome Free v5.1 + /Samples/PixelStreaming/WebServers/ + Provides a consistent icon style to use in the sites for demoing pixelstreaming. + https://github.com/FortAwesome/Font-Awesome/blob/master/LICENSE.txt + + P4 + + None + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Helmet.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Helmet.tps new file mode 100644 index 0000000000000000000000000000000000000000..4a1575b8782b8f89df71a973d30d75227c4c6201 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Helmet.tps @@ -0,0 +1,13 @@ + + + Helmet v.3.21.3 + /Samples/PixelStreaming/WebServers/SignallingWebServer + Helmet helps you secure your Express apps by setting various HTTP headers. + https://github.com/helmetjs/helmet/blob/v3.21.3/LICENSE + + Licensees + Git + P4 + + NONE (but keep license with code) + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/JQuery.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/JQuery.tps new file mode 100644 index 0000000000000000000000000000000000000000..3822fad4d822575d4aa9da8e1a5b4c87de23f635 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/JQuery.tps @@ -0,0 +1,13 @@ + + + JQuery + /Samples/PixelStreaming/WebServers/ + This is a requirement to using Bootstrap, providing access to the DOM in the browser for easier and more advanced client side interactions and UI. Used for Project Cirrus. + https://github.com/jquery/jquery/blob/master/LICENSE.txt; https://js.foundation/pdf/ip-policy.pdf + + Licensees + Git + P4 + + /Engine/Source/ThirdParty/Licenses/JQuery_License.txt + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Popper.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Popper.tps new file mode 100644 index 0000000000000000000000000000000000000000..ade4df6c0b6ed5b1ddc891bb530d9adfdae58d2d --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/Popper.tps @@ -0,0 +1,13 @@ + + + Popper.js v1.14.3 + /Samples/PixelStreaming/WebServers/ + A requirement to using Bootstrap. + https://github.com/FezVrasta/popper.js/blob/master/LICENSE.md + + Licensees + Git + P4 + + /Engine/Source/ThirdParty/Licenses/Popper.js_License.txt + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/bcrypt-js.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/bcrypt-js.tps new file mode 100644 index 0000000000000000000000000000000000000000..5b2c5481d1fff971be1452603b4422c04a59372e --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/bcrypt-js.tps @@ -0,0 +1,11 @@ + + + Bcrypt.js + /Samples/PixelStreaming/WebServers/SignallingWebServer/ + This is used to verify passwords match the ones stored using the bcrypt algorithm. The passwords are always stored using bcrypt and so we never know the unencrypted password. This allows us to implement a authentication system on the web server so that only people we give accounts to can access the web server. This use is only for prototype stage, production will use the Epic unreal account system + https://github.com/dcodeIO/bcrypt.js/blob/master/LICENSE + + P4 + + /UE4/Main/Engine/Source/ThirdParty/Licenses + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/expression-session.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/expression-session.tps new file mode 100644 index 0000000000000000000000000000000000000000..0d88bc486e6fc23c93a8cafbcdc5e620ea4e93d4 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/expression-session.tps @@ -0,0 +1,13 @@ + + + express-session v1.15.6 + /Samples/PixelStreaming/WebServers/ + Used to create session id's used to remember a person who has logged into a server across page loads so that they don't have to log in every time the reload or navigate to a different page hosted on a webserver + https://github.com/expressjs/session/blob/master/LICENSE + + Licensees + Git + P4 + + /Engine/Source/ThirdParty/Licenses/express-session_license.txt + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/passport-local.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/passport-local.tps new file mode 100644 index 0000000000000000000000000000000000000000..896a3d62cb67de466dfc8f92ed0cf0f85b21ea84 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/passport-local.tps @@ -0,0 +1,13 @@ + + + passport-local v1.0.0 + /Samples/PixelStreaming/WebServers/ + This is a implementation for the Passport middleware that allows you to store user credentials locally on the machine (passwords are stored with bcrypt and not reversible) to be used to authenticate users on a node.js webserver. This use is only for prototype stage, production will use the Epic unreal account system. + https://github.com/jaredhanson/passport-local/blob/master/LICENSE + + Licensees + Git + P4 + + /Engine/Source/ThirdParty/Licenses/passport-local_license.txt + \ No newline at end of file diff --git a/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/passport.tps b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/passport.tps new file mode 100644 index 0000000000000000000000000000000000000000..c6d8e55a09433475401bdd83be411c43e1daf9f2 --- /dev/null +++ b/WindowsNoEditor/Samples/PixelStreaming/WebServers/SignallingWebServer/tps/passport.tps @@ -0,0 +1,13 @@ + + + passport v0.4.0 + /Samples/PixelStreaming/WebServers/ + Is the authentication middleware that adds the ability to securely log in a user to the webserver. This is a generic framework that you add specific implementation frameworks (separate TPS's will be provided for these) to to provide authentication on a node.js webserver. + https://github.com/jaredhanson/passport/blob/master/LICENSE + + Licensees + Git + P4 + + /Engine/Source/ThirdParty/Licenses/passport_license.txt + \ No newline at end of file