Skip to content

Commit bd8d18e

Browse files
Merge pull request #37 from ScalablePixelStreaming/v0.3.4
merge v0.3.4 into main ready for release
2 parents 0fac50c + 60a74ca commit bd8d18e

File tree

5 files changed

+46
-23
lines changed

5 files changed

+46
-23
lines changed

examples/typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tensorworks/spstypescriptexample",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "The typescript example for consuming the Scalable Pixel Streaming Frontend",
55
"main": "./src/index.ts",
66
"scripts": {
@@ -38,4 +38,4 @@
3838
"webpack-dev-server": "^4.11.1",
3939
"wepack-cli": "^0.0.1-security"
4040
}
41-
}
41+
}

examples/typescript/src/index.ts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle} from "@tensorworks/libspsfrontend";
1+
import { Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle, MessageRecv, Flags } from "@tensorworks/libspsfrontend";
22

33
// Apply default styling from Epic Games Pixel Streaming Frontend
44
export const PixelStreamingApplicationStyles = new PixelStreamingApplicationStyle();
@@ -7,24 +7,46 @@ PixelStreamingApplicationStyles.applyStyleSheet();
77
// websocket url env
88
declare var WEBSOCKET_URL: string;
99

10+
// Extend the MessageRecv to allow the engine version to exist as part of our config message from the signalling server
11+
class MessageExtendedConfig extends MessageRecv {
12+
peerConnectionOptions: RTCConfiguration;
13+
engineVersion: string;
14+
platform: string;
15+
frontendToSendOffer: boolean;
16+
};
17+
18+
// Extend PixelStreaming to use our custom extended config that includes the engine version
19+
class ScalablePixelStreaming extends PixelStreaming {
20+
// Create a new method that retains original functionality
21+
public handleOnConfig(messageExtendedConfig: MessageExtendedConfig) {
22+
this._webRtcController.handleOnConfigMessage(messageExtendedConfig);
23+
}
24+
};
25+
1026
document.body.onload = function () {
1127

12-
// Create a config object.
13-
// Note: This config is extremely important, SPS only supports the browser sending the offer.
14-
const config = new Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true } });
28+
// Create a config object. We default to sending the WebRTC offer from the browser as true, TimeoutIfIdle to true, AutoConnect to false and MaxReconnectAttempts to 0
29+
const config = new Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true, AutoConnect: false, MaxReconnectAttempts: 0 } });
1530

1631
// make usage of WEBSOCKET_URL if it is not empty
1732
let webSocketAddress = WEBSOCKET_URL;
18-
if(webSocketAddress != ""){
19-
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress)
33+
if (webSocketAddress != "") {
34+
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress);
2035
}
2136

2237
// Create stream and spsApplication instances that implement the Epic Games Pixel Streaming Frontend PixelStreaming and Application types
23-
const stream = new PixelStreaming(config);
38+
const stream = new ScalablePixelStreaming(config);
39+
40+
// Override the onConfig so we can determine if we need to send the WebRTC offer based on what is sent from the signalling server
41+
stream.webSocketController.onConfig = (messageExtendedConfig: MessageExtendedConfig) => {
42+
stream.config.setFlagEnabled(Flags.BrowserSendOffer, messageExtendedConfig.frontendToSendOffer);
43+
stream.handleOnConfig(messageExtendedConfig);
44+
}
45+
46+
// Create and append our application
2447
const spsApplication = new SPSApplication({
2548
stream,
2649
onColorModeChanged: (isLightMode) => PixelStreamingApplicationStyles.setColorMode(isLightMode) /* Light/Dark mode support. */
2750
});
28-
2951
document.body.appendChild(spsApplication.rootElement);
3052
}

examples/typescript/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"noImplicitAny": true,
55
"module": "es6",
66
"esModuleInterop": true,
7-
"target": "es5",
7+
"target": "ES6",
88
"moduleResolution": "node",
99
"sourceMap": false,
1010
"allowJs": true,

library/package-lock.json

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tensorworks/libspsfrontend",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "The Scalable Pixel Streaming Frontend Library consuming Epic Games' Pixel Streaming Frontend",
55
"main": "dist/libspsfrontend.min.js",
66
"module": "dist/libspsfrontend.esm.js",
@@ -15,7 +15,7 @@
1515
"license": "MIT",
1616
"dependencies": {
1717
"@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.1",
18-
"@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.0"
18+
"@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.1"
1919
},
2020
"devDependencies": {
2121
"css-loader": "^6.7.3",

0 commit comments

Comments
 (0)