From 10a638aecc8162846c09d488db39b3e5e5e5e298 Mon Sep 17 00:00:00 2001 From: Daniel Holden Date: Tue, 9 May 2023 11:18:49 +1000 Subject: [PATCH 1/3] extend the handleOnConfig from the PS library so we are able to include an engine version. The engine version is then used to determine if we need to send our WebRTC offer from the frontend or from the UE instance --- examples/typescript/src/index.ts | 33 +++++++++++++++++++++++++------ examples/typescript/tsconfig.json | 2 +- library/package-lock.json | 21 ++++++++++---------- library/package.json | 2 +- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/examples/typescript/src/index.ts b/examples/typescript/src/index.ts index e2337471..90128ce4 100644 --- a/examples/typescript/src/index.ts +++ b/examples/typescript/src/index.ts @@ -1,4 +1,4 @@ -import {Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle} from "@tensorworks/libspsfrontend"; +import { Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle, MessageRecv, Flags } from "@tensorworks/libspsfrontend"; // Apply default styling from Epic Games Pixel Streaming Frontend export const PixelStreamingApplicationStyles = new PixelStreamingApplicationStyle(); @@ -7,24 +7,45 @@ PixelStreamingApplicationStyles.applyStyleSheet(); // websocket url env declare var WEBSOCKET_URL: string; +// Extend the MessageRecv to allow the engine version to exist as part of our config message from the signalling server +class MessageExtendedConfig extends MessageRecv { + peerConnectionOptions: RTCConfiguration; + engineVersion: string +}; + +// Extend PixelStreaming to use our custom extended config that includes the engine version +class ScalablePixelStreaming extends PixelStreaming { + // Create a new method that retains original functionality + public handleOnConfig(messageExtendedConfig: MessageExtendedConfig) { + this._webRtcController.handleOnConfigMessage(messageExtendedConfig) + } +}; + document.body.onload = function () { - // Create a config object. - // Note: This config is extremely important, SPS only supports the browser sending the offer. + // Create a config object. We default to sending the WebRTC offer from the browser as true const config = new Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true } }); // make usage of WEBSOCKET_URL if it is not empty let webSocketAddress = WEBSOCKET_URL; - if(webSocketAddress != ""){ + if (webSocketAddress != "") { config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress) } // Create stream and spsApplication instances that implement the Epic Games Pixel Streaming Frontend PixelStreaming and Application types - const stream = new PixelStreaming(config); + const stream = new ScalablePixelStreaming(config); + + // Override the onConfig so we can determine if we need to send the WebRTC offer based on the engine version + // If the engine version is 4.27 or not defined, the browser should send the offer. This is what the Scalable Pixel Streaming signalling server will be expecting. + stream.webSocketController.onConfig = (messageExtendedConfig: MessageExtendedConfig) => { + stream.config.setFlagEnabled(Flags.BrowserSendOffer, (messageExtendedConfig.engineVersion == "4.27" || messageExtendedConfig.engineVersion == "")); + stream.handleOnConfig(messageExtendedConfig); + } + + // Create and append our application const spsApplication = new SPSApplication({ stream, onColorModeChanged: (isLightMode) => PixelStreamingApplicationStyles.setColorMode(isLightMode) /* Light/Dark mode support. */ }); - document.body.appendChild(spsApplication.rootElement); } \ No newline at end of file diff --git a/examples/typescript/tsconfig.json b/examples/typescript/tsconfig.json index 32cb2238..c9623293 100644 --- a/examples/typescript/tsconfig.json +++ b/examples/typescript/tsconfig.json @@ -4,7 +4,7 @@ "noImplicitAny": true, "module": "es6", "esModuleInterop": true, - "target": "es5", + "target": "ES6", "moduleResolution": "node", "sourceMap": false, "allowJs": true, diff --git a/library/package-lock.json b/library/package-lock.json index 68e57307..5f7088d4 100644 --- a/library/package-lock.json +++ b/library/package-lock.json @@ -1,16 +1,16 @@ { "name": "@tensorworks/libspsfrontend", - "version": "0.3.2", + "version": "0.3.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@tensorworks/libspsfrontend", - "version": "0.3.2", + "version": "0.3.3", "license": "MIT", "dependencies": { "@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.1", - "@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.0" + "@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.1" }, "devDependencies": { "css-loader": "^6.7.3", @@ -53,16 +53,17 @@ } }, "node_modules/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.0.tgz", - "integrity": "sha512-WwIUMMMxRDbo+LTt/t3b24qNhTX4d4TuWoj4Ynw37fX8SHLFvJ++9U0ByP3bRxyw9scRBNTVtCZ/6kZIzJV2fQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.1.tgz", + "integrity": "sha512-GXwB4/LS2fcVyfTAHe6Ma90+Z+oxNIIiwowe0S5ItgsGn2DPo1KwhDw7AbIsbqgtJDntKoofuzrtcdU6lG4RNw==", + "license": "MIT", "dependencies": { "jss": "^10.9.2", "jss-plugin-camel-case": "^10.9.2", "jss-plugin-global": "^10.9.2" }, "peerDependencies": { - "@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.0" + "@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.1" } }, "node_modules/@jridgewell/gen-mapping": { @@ -4333,9 +4334,9 @@ } }, "@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.0.tgz", - "integrity": "sha512-WwIUMMMxRDbo+LTt/t3b24qNhTX4d4TuWoj4Ynw37fX8SHLFvJ++9U0ByP3bRxyw9scRBNTVtCZ/6kZIzJV2fQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.1.tgz", + "integrity": "sha512-GXwB4/LS2fcVyfTAHe6Ma90+Z+oxNIIiwowe0S5ItgsGn2DPo1KwhDw7AbIsbqgtJDntKoofuzrtcdU6lG4RNw==", "requires": { "jss": "^10.9.2", "jss-plugin-camel-case": "^10.9.2", diff --git a/library/package.json b/library/package.json index ac3cd55d..3b8c76f9 100644 --- a/library/package.json +++ b/library/package.json @@ -15,7 +15,7 @@ "license": "MIT", "dependencies": { "@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.1", - "@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.0" + "@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.1" }, "devDependencies": { "css-loader": "^6.7.3", From 1bf90ba6fac236a9cbd2f15b8f15b0446ea52305 Mon Sep 17 00:00:00 2001 From: Daniel Holden Date: Tue, 9 May 2023 15:27:02 +1000 Subject: [PATCH 2/3] send offers from the frontend when using ue 5.0 as well --- examples/typescript/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typescript/src/index.ts b/examples/typescript/src/index.ts index 90128ce4..b9d0e4d1 100644 --- a/examples/typescript/src/index.ts +++ b/examples/typescript/src/index.ts @@ -38,7 +38,7 @@ document.body.onload = function () { // Override the onConfig so we can determine if we need to send the WebRTC offer based on the engine version // If the engine version is 4.27 or not defined, the browser should send the offer. This is what the Scalable Pixel Streaming signalling server will be expecting. stream.webSocketController.onConfig = (messageExtendedConfig: MessageExtendedConfig) => { - stream.config.setFlagEnabled(Flags.BrowserSendOffer, (messageExtendedConfig.engineVersion == "4.27" || messageExtendedConfig.engineVersion == "")); + stream.config.setFlagEnabled(Flags.BrowserSendOffer, (messageExtendedConfig.engineVersion == "4.27" || messageExtendedConfig.engineVersion == "5.0" || messageExtendedConfig.engineVersion == "")); stream.handleOnConfig(messageExtendedConfig); } From 8815bae2f9772e79e0ef459702a57715e369efa9 Mon Sep 17 00:00:00 2001 From: Daniel Holden Date: Tue, 9 May 2023 15:53:45 +1000 Subject: [PATCH 3/3] remove 5.0 as a version that sends offers from the frontend --- examples/typescript/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typescript/src/index.ts b/examples/typescript/src/index.ts index b9d0e4d1..90128ce4 100644 --- a/examples/typescript/src/index.ts +++ b/examples/typescript/src/index.ts @@ -38,7 +38,7 @@ document.body.onload = function () { // Override the onConfig so we can determine if we need to send the WebRTC offer based on the engine version // If the engine version is 4.27 or not defined, the browser should send the offer. This is what the Scalable Pixel Streaming signalling server will be expecting. stream.webSocketController.onConfig = (messageExtendedConfig: MessageExtendedConfig) => { - stream.config.setFlagEnabled(Flags.BrowserSendOffer, (messageExtendedConfig.engineVersion == "4.27" || messageExtendedConfig.engineVersion == "5.0" || messageExtendedConfig.engineVersion == "")); + stream.config.setFlagEnabled(Flags.BrowserSendOffer, (messageExtendedConfig.engineVersion == "4.27" || messageExtendedConfig.engineVersion == "")); stream.handleOnConfig(messageExtendedConfig); }